1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
78 #include "insn-config.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
87 #ifdef XCOFF_DEBUGGING_INFO
92 #define ASM_STABS_OP "\t.stabs\t"
96 #define ASM_STABN_OP "\t.stabn\t"
99 #ifndef DBX_TYPE_DECL_STABS_CODE
100 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
103 #ifndef DBX_STATIC_CONST_VAR_CODE
104 #define DBX_STATIC_CONST_VAR_CODE N_FUN
107 #ifndef DBX_REGPARM_STABS_CODE
108 #define DBX_REGPARM_STABS_CODE N_RSYM
111 #ifndef DBX_REGPARM_STABS_LETTER
112 #define DBX_REGPARM_STABS_LETTER 'P'
115 /* This is used for parameters passed by invisible reference in a register. */
116 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
117 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
120 #ifndef DBX_MEMPARM_STABS_LETTER
121 #define DBX_MEMPARM_STABS_LETTER 'p'
124 #ifndef FILE_NAME_JOINER
125 #define FILE_NAME_JOINER "/"
128 /* GDB needs to know that the stabs were generated by GCC. We emit an
129 N_OPT stab at the beginning of the source file to indicate this.
130 The string is historical, and different on a very few targets. */
131 #ifndef STABS_GCC_MARKER
132 #define STABS_GCC_MARKER "gcc2_compiled."
135 /* Typical USG systems don't have stab.h, and they also have
136 no use for DBX-format debugging info. */
138 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
140 /* Nonzero if we have actually used any of the GDB extensions
141 to the debugging format. The idea is that we use them for the
142 first time only if there's a strong reason, but once we have done that,
143 we use them whenever convenient. */
145 static int have_used_extensions
= 0;
147 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
148 for the N_SO filename stabs label. */
150 static int source_label_number
= 1;
152 #ifdef DEBUG_SYMS_TEXT
153 #define FORCE_TEXT text_section ();
160 #define STAB_CODE_TYPE enum __stab_debug_code
162 /* 1 if PARM is passed to this function in memory. */
164 #define PARM_PASSED_IN_MEMORY(PARM) \
165 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
167 /* A C expression for the integer offset value of an automatic variable
168 (N_LSYM) having address X (an RTX). */
169 #ifndef DEBUGGER_AUTO_OFFSET
170 #define DEBUGGER_AUTO_OFFSET(X) \
171 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
174 /* A C expression for the integer offset value of an argument (N_PSYM)
175 having address X (an RTX). The nominal offset is OFFSET. */
176 #ifndef DEBUGGER_ARG_OFFSET
177 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
180 /* Stream for writing to assembler file. */
182 static FILE *asmfile
;
184 /* Last source file name mentioned in a NOTE insn. */
186 static const char *lastfile
;
188 /* Current working directory. */
190 static const char *cwd
;
192 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
194 /* Structure recording information about a C data type.
195 The status element says whether we have yet output
196 the definition of the type. TYPE_XREF says we have
197 output it as a cross-reference only.
198 The file_number and type_number elements are used if DBX_USE_BINCL
203 enum typestatus status
;
210 /* Vector recording information about C data types.
211 When we first notice a data type (a tree node),
212 we assign it a number using next_type_number.
213 That is its index in this vector. */
215 struct typeinfo
*typevec
;
217 /* Number of elements of space allocated in `typevec'. */
219 static int typevec_len
;
221 /* In dbx output, each type gets a unique number.
222 This is the number for the next type output.
223 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
225 static int next_type_number
;
229 /* When using N_BINCL in dbx output, each type number is actually a
230 pair of the file number and the type number within the file.
231 This is a stack of input files. */
235 struct dbx_file
*next
;
237 int next_type_number
;
240 /* This is the top of the stack. */
242 static struct dbx_file
*current_file
;
244 /* This is the next file number to use. */
246 static int next_file_number
;
248 #endif /* DBX_USE_BINCL */
250 /* These variables are for dbxout_symbol to communicate to
251 dbxout_finish_symbol.
252 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
253 current_sym_value and current_sym_addr are two ways to address the
254 value to store in the symtab entry.
255 current_sym_addr if nonzero represents the value as an rtx.
256 If that is zero, current_sym_value is used. This is used
257 when the value is an offset (such as for auto variables,
258 register variables and parms). */
260 static STAB_CODE_TYPE current_sym_code
;
261 static int current_sym_value
;
262 static rtx current_sym_addr
;
264 /* Number of chars of symbol-description generated so far for the
265 current symbol. Used by CHARS and CONTIN. */
267 static int current_sym_nchars
;
269 /* Report having output N chars of the current symbol-description. */
271 #define CHARS(N) (current_sym_nchars += (N))
273 /* Break the current symbol-description, generating a continuation,
274 if it has become long. */
276 #ifndef DBX_CONTIN_LENGTH
277 #define DBX_CONTIN_LENGTH 80
280 #if DBX_CONTIN_LENGTH > 0
282 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
284 #define CONTIN do { } while (0)
287 static void dbxout_init
PARAMS ((FILE *, const char *));
288 static void dbxout_finish
PARAMS ((FILE *, const char *));
289 static void dbxout_start_source_file
PARAMS ((unsigned, const char *));
290 static void dbxout_end_source_file
PARAMS ((unsigned));
291 #if defined(ASM_OUTPUT_SECTION_NAME)
292 static void dbxout_function_end
PARAMS ((void));
294 static void dbxout_typedefs
PARAMS ((tree
));
295 static void dbxout_type_index
PARAMS ((tree
));
296 #if DBX_CONTIN_LENGTH > 0
297 static void dbxout_continue
PARAMS ((void));
299 static void dbxout_type_fields
PARAMS ((tree
));
300 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
301 static void dbxout_type_methods
PARAMS ((tree
));
302 static void dbxout_range_type
PARAMS ((tree
));
303 static void dbxout_type
PARAMS ((tree
, int));
304 static void print_int_cst_octal
PARAMS ((tree
));
305 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
306 static void dbxout_type_name
PARAMS ((tree
));
307 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
308 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
309 static void dbxout_prepare_symbol
PARAMS ((tree
));
310 static void dbxout_finish_symbol
PARAMS ((tree
));
311 static void dbxout_block
PARAMS ((tree
, int, tree
));
312 static void dbxout_really_begin_function
PARAMS ((tree
));
314 /* The debug hooks structure. */
315 struct gcc_debug_hooks dbx_debug_hooks
=
319 debug_nothing_int_charstar
,
320 debug_nothing_int_charstar
,
321 dbxout_start_source_file
,
322 dbxout_end_source_file
325 #if defined(ASM_OUTPUT_SECTION_NAME)
327 dbxout_function_end ()
329 static int scope_labelno
= 0;
330 char lscope_label_name
[100];
331 /* Convert Ltext into the appropriate format for local labels in case
332 the system doesn't insert underscores in front of user generated
334 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
335 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
338 /* By convention, GCC will mark the end of a function with an N_FUN
339 symbol and an empty string. */
340 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
341 assemble_name (asmfile
, lscope_label_name
);
342 fputc ('-', asmfile
);
343 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
344 fprintf (asmfile
, "\n");
346 #endif /* ! NO_DBX_FUNCTION_END */
348 /* At the beginning of compilation, start writing the symbol table.
349 Initialize `typevec' and output the standard data types of C. */
352 dbxout_init (asm_file
, input_file_name
)
354 const char *input_file_name
;
356 char ltext_label_name
[100];
357 tree syms
= getdecls ();
362 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
364 /* Convert Ltext into the appropriate format for local labels in case
365 the system doesn't insert underscores in front of user generated
367 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
369 /* Put the current working directory in an N_SO symbol. */
370 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
371 but GDB always does. */
372 if (use_gnu_debug_info_extensions
)
375 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
376 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
379 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
380 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
381 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
382 fprintf (asmfile
, "%s", ASM_STABS_OP
);
383 output_quoted_string (asmfile
, cwd
);
384 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
385 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
389 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
390 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
391 would give us an N_SOL, and we want an N_SO. */
392 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
393 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
394 /* We include outputting `Ltext:' here,
395 because that gives you a way to override it. */
396 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
397 fprintf (asmfile
, "%s", ASM_STABS_OP
);
398 output_quoted_string (asmfile
, input_file_name
);
399 fprintf (asmfile
, ",%d,0,0,%s\n",
400 N_SO
, <ext_label_name
[1]);
402 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
403 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
405 #ifdef DBX_OUTPUT_GCC_MARKER
406 DBX_OUTPUT_GCC_MARKER (asmfile
);
408 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
409 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
410 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
413 lastfile
= input_file_name
;
415 next_type_number
= 1;
418 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
419 current_file
->next
= NULL
;
420 current_file
->file_number
= 0;
421 current_file
->next_type_number
= 1;
422 next_file_number
= 1;
425 /* Make sure that types `int' and `char' have numbers 1 and 2.
426 Definitions of other integer types will refer to those numbers.
427 (Actually it should no longer matter what their numbers are.
428 Also, if any types with tags have been defined, dbxout_symbol
429 will output them first, so the numbers won't be 1 and 2. That
430 happens in C++. So it's a good thing it should no longer matter). */
432 #ifdef DBX_OUTPUT_STANDARD_TYPES
433 DBX_OUTPUT_STANDARD_TYPES (syms
);
435 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
436 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
439 /* Get all permanent types that have typedef names,
440 and output them all, except for those already output. */
442 dbxout_typedefs (syms
);
445 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
446 in the reverse order from that which is found in SYMS. */
449 dbxout_typedefs (syms
)
454 dbxout_typedefs (TREE_CHAIN (syms
));
455 if (TREE_CODE (syms
) == TYPE_DECL
)
457 tree type
= TREE_TYPE (syms
);
459 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
460 && COMPLETE_TYPE_P (type
)
461 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
462 dbxout_symbol (TYPE_NAME (type
), 0);
467 /* Change to reading from a new source file. Generate a N_BINCL stab. */
470 dbxout_start_source_file (line
, filename
)
471 unsigned int line ATTRIBUTE_UNUSED
;
472 const char *filename ATTRIBUTE_UNUSED
;
475 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
477 n
->next
= current_file
;
478 n
->file_number
= next_file_number
++;
479 n
->next_type_number
= 1;
481 fprintf (asmfile
, "%s", ASM_STABS_OP
);
482 output_quoted_string (asmfile
, filename
);
483 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
487 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
490 dbxout_end_source_file (line
)
491 unsigned int line ATTRIBUTE_UNUSED
;
494 struct dbx_file
*next
;
496 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
497 next
= current_file
->next
;
503 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
506 dbxout_source_file (file
, filename
)
508 const char *filename
;
510 char ltext_label_name
[100];
512 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
514 #ifdef DBX_OUTPUT_SOURCE_FILENAME
515 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
517 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
518 source_label_number
);
519 fprintf (file
, "%s", ASM_STABS_OP
);
520 output_quoted_string (file
, filename
);
521 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
522 if (current_function_decl
!= NULL_TREE
523 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
524 ; /* Don't change section amid function. */
527 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
528 source_label_number
++;
534 /* Output a line number symbol entry into output stream FILE,
535 for source file FILENAME and line number LINENO. */
538 dbxout_source_line (file
, filename
, lineno
)
540 const char *filename
;
543 dbxout_source_file (file
, filename
);
545 #ifdef ASM_OUTPUT_SOURCE_LINE
546 ASM_OUTPUT_SOURCE_LINE (file
, lineno
);
548 fprintf (file
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
552 /* At the end of compilation, finish writing the symbol table.
553 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
557 dbxout_finish (file
, filename
)
558 FILE *file ATTRIBUTE_UNUSED
;
559 const char *filename ATTRIBUTE_UNUSED
;
561 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
562 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file
, filename
);
563 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
566 /* Output the index of a type. */
569 dbxout_type_index (type
)
572 #ifndef DBX_USE_BINCL
573 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
576 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
577 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
582 #if DBX_CONTIN_LENGTH > 0
583 /* Continue a symbol-description that gets too big.
584 End one symbol table entry with a double-backslash
585 and start a new one, eventually producing something like
586 .stabs "start......\\",code,0,value
587 .stabs "...rest",code,0,value */
592 #ifdef DBX_CONTIN_CHAR
593 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
595 fprintf (asmfile
, "\\\\");
597 dbxout_finish_symbol (NULL_TREE
);
598 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
599 current_sym_nchars
= 0;
601 #endif /* DBX_CONTIN_LENGTH > 0 */
603 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
604 This must be a separate function because anonymous unions require
608 dbxout_type_fields (type
)
613 /* Output the name, type, position (in bits), size (in bits) of each
614 field that we can support. */
615 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
617 /* Omit here local type decls until we know how to support them. */
618 if (TREE_CODE (tem
) == TYPE_DECL
619 /* Omit fields whose position or size are variable or too large to
621 || (TREE_CODE (tem
) == FIELD_DECL
622 && (! host_integerp (bit_position (tem
), 0)
624 || ! host_integerp (DECL_SIZE (tem
), 1)))
625 /* Omit here the nameless fields that are used to skip bits. */
626 || DECL_IGNORED_P (tem
))
629 else if (TREE_CODE (tem
) != CONST_DECL
)
631 /* Continue the line if necessary,
632 but not before the first field. */
633 if (tem
!= TYPE_FIELDS (type
))
638 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
639 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
643 fprintf (asmfile
, ":");
647 if (use_gnu_debug_info_extensions
648 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
649 || TREE_CODE (tem
) != FIELD_DECL
))
651 have_used_extensions
= 1;
653 putc ((TREE_PRIVATE (tem
) ? '0'
654 : TREE_PROTECTED (tem
) ? '1' : '2'),
659 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
660 && DECL_BIT_FIELD_TYPE (tem
))
661 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
663 if (TREE_CODE (tem
) == VAR_DECL
)
665 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
668 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
));
669 have_used_extensions
= 1;
670 fprintf (asmfile
, ":%s;", name
);
671 CHARS (strlen (name
));
674 /* If TEM is non-static, GDB won't understand it. */
675 fprintf (asmfile
, ",0,0;");
679 fputc (',', asmfile
);
680 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
681 int_bit_position (tem
));
682 fputc (',', asmfile
);
683 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
684 tree_low_cst (DECL_SIZE (tem
), 1));
685 fputc (';', asmfile
);
692 /* Subroutine of `dbxout_type_methods'. Output debug info about the
693 method described DECL. DEBUG_NAME is an encoding of the method's
694 type signature. ??? We may be able to do without DEBUG_NAME altogether
698 dbxout_type_method_1 (decl
, debug_name
)
700 const char *debug_name
;
704 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
706 else /* it's a METHOD_TYPE. */
708 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
709 /* A for normal functions.
710 B for `const' member functions.
711 C for `volatile' member functions.
712 D for `const volatile' member functions. */
713 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
715 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
718 if (DECL_VINDEX (decl
))
724 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
725 TREE_PRIVATE (decl
) ? '0'
726 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
727 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
728 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
730 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
732 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
733 tree_low_cst (DECL_VINDEX (decl
), 0));
734 fputc (';', asmfile
);
735 dbxout_type (DECL_CONTEXT (decl
), 0);
736 fprintf (asmfile
, ";");
741 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
745 dbxout_type_methods (type
)
748 /* C++: put out the method names and their parameter lists */
749 tree methods
= TYPE_METHODS (type
);
751 register tree fndecl
;
753 char formatted_type_identifier_length
[16];
754 register int type_identifier_length
;
756 if (methods
== NULL_TREE
)
759 type_encoding
= DECL_NAME (TYPE_NAME (type
));
762 /* C++: Template classes break some assumptions made by this code about
763 the class names, constructor names, and encodings for assembler
764 label names. For now, disable output of dbx info for them. */
766 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
767 /* This should use index. (mrs) */
768 while (*ptr
&& *ptr
!= '<') ptr
++;
779 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
781 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
783 if (TREE_CODE (methods
) != TREE_VEC
)
785 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
786 fndecl
= TREE_VEC_ELT (methods
, 0);
788 fndecl
= TREE_VEC_ELT (methods
, 1);
794 /* Group together all the methods for the same operation.
795 These differ in the types of the arguments. */
796 for (last
= NULL_TREE
;
797 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
798 fndecl
= TREE_CHAIN (fndecl
))
799 /* Output the name of the field (after overloading), as
800 well as the name of the field before overloading, along
801 with its parameter list */
803 /* This is the "mangled" name of the method.
804 It encodes the argument types. */
805 const char *debug_name
;
807 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
808 include TEMPLATE_DECLs.) The debugger doesn't know what
809 to do with such entities anyhow. */
810 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
814 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
820 /* Also ignore abstract methods; those are only interesting to
821 the DWARF backends. */
822 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
825 /* Redundantly output the plain name, since that's what gdb
829 tree name
= DECL_NAME (fndecl
);
830 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
831 CHARS (IDENTIFIER_LENGTH (name
) + 2);
835 dbxout_type (TREE_TYPE (fndecl
), 0);
837 dbxout_type_method_1 (fndecl
, debug_name
);
847 /* Emit a "range" type specification, which has the form:
848 "r<index type>;<lower bound>;<upper bound>;".
849 TYPE is an INTEGER_TYPE. */
852 dbxout_range_type (type
)
855 fprintf (asmfile
, "r");
856 if (TREE_TYPE (type
))
857 dbxout_type (TREE_TYPE (type
), 0);
858 else if (TREE_CODE (type
) != INTEGER_TYPE
)
859 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
862 /* Traditionally, we made sure 'int' was type 1, and builtin types
863 were defined to be sub-ranges of int. Unfortunately, this
864 does not allow us to distinguish true sub-ranges from integer
865 types. So, instead we define integer (non-sub-range) types as
866 sub-ranges of themselves. This matters for Chill. If this isn't
867 a subrange type, then we want to define it in terms of itself.
868 However, in C, this may be an anonymous integer type, and we don't
869 want to emit debug info referring to it. Just calling
870 dbxout_type_index won't work anyways, because the type hasn't been
871 defined yet. We make this work for both cases by checked to see
872 whether this is a defined type, referring to it if it is, and using
874 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
875 dbxout_type_index (type
);
877 dbxout_type_index (integer_type_node
);
880 if (TYPE_MIN_VALUE (type
) != 0
881 && host_integerp (TYPE_MIN_VALUE (type
), 0))
883 fputc (';', asmfile
);
884 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
885 tree_low_cst (TYPE_MIN_VALUE (type
), 0));
888 fprintf (asmfile
, ";0");
890 if (TYPE_MAX_VALUE (type
) != 0
891 && host_integerp (TYPE_MAX_VALUE (type
), 0))
893 fputc (';', asmfile
);
894 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
895 tree_low_cst (TYPE_MAX_VALUE (type
), 0));
896 fputc (';', asmfile
);
899 fprintf (asmfile
, ";-1;");
902 /* Output a reference to a type. If the type has not yet been
903 described in the dbx output, output its definition now.
904 For a type already defined, just refer to its definition
905 using the type number.
907 If FULL is nonzero, and the type has been described only with
908 a forward-reference, output the definition now.
909 If FULL is zero in this case, just refer to the forward-reference
910 using the number previously allocated. */
913 dbxout_type (type
, full
)
918 static int anonymous_type_number
= 0;
920 if (TREE_CODE (type
) == VECTOR_TYPE
)
921 type
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
923 /* If there was an input error and we don't really have a type,
924 avoid crashing and write something that is at least valid
925 by assuming `int'. */
926 if (type
== error_mark_node
)
927 type
= integer_type_node
;
930 /* Try to find the "main variant" with the same name but not const
931 or volatile. (Since stabs does not distinguish const and volatile,
932 there is no need to make them separate types. But types with
933 different names are usefully distinguished.) */
935 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
936 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
937 && TYPE_NAME (tem
) == TYPE_NAME (type
))
943 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
944 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
948 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
950 /* Type has no dbx number assigned. Assign next available number. */
951 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
953 /* Make sure type vector is long enough to record about this type. */
955 if (next_type_number
== typevec_len
)
958 = (struct typeinfo
*) xrealloc (typevec
,
959 typevec_len
* 2 * sizeof typevec
[0]);
960 memset ((char *) (typevec
+ typevec_len
), 0,
961 typevec_len
* sizeof typevec
[0]);
966 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
967 = current_file
->file_number
;
968 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
969 = current_file
->next_type_number
++;
973 /* Output the number of this type, to refer to it. */
974 dbxout_type_index (type
);
976 #ifdef DBX_TYPE_DEFINED
977 if (DBX_TYPE_DEFINED (type
))
981 /* If this type's definition has been output or is now being output,
984 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
989 /* If we have already had a cross reference,
990 and either that's all we want or that's the best we could do,
991 don't repeat the cross reference.
992 Sun dbx crashes if we do. */
993 if (! full
|| !COMPLETE_TYPE_P (type
)
994 /* No way in DBX fmt to describe a variable size. */
995 || ! host_integerp (TYPE_SIZE (type
), 1))
1003 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1004 leave the type-number completely undefined rather than output
1005 a cross-reference. If we have already used GNU debug info extensions,
1006 then it is OK to output a cross reference. This is necessary to get
1007 proper C++ debug output. */
1008 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1009 || TREE_CODE (type
) == QUAL_UNION_TYPE
1010 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1011 && ! use_gnu_debug_info_extensions
)
1012 /* We must use the same test here as we use twice below when deciding
1013 whether to emit a cross-reference. */
1014 if ((TYPE_NAME (type
) != 0
1015 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1016 && DECL_IGNORED_P (TYPE_NAME (type
)))
1018 || !COMPLETE_TYPE_P (type
)
1019 /* No way in DBX fmt to describe a variable size. */
1020 || ! host_integerp (TYPE_SIZE (type
), 1))
1022 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1027 /* Output a definition now. */
1029 fprintf (asmfile
, "=");
1032 /* Mark it as defined, so that if it is self-referent
1033 we will not get into an infinite recursion of definitions. */
1035 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1037 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1038 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1040 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1044 switch (TREE_CODE (type
))
1048 /* For a void type, just define it as itself; ie, "5=5".
1049 This makes us consider it defined
1050 without saying what it is. The debugger will make it
1051 a void type when the reference is seen, and nothing will
1052 ever override that default. */
1053 dbxout_type_index (type
);
1057 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1059 /* Output the type `char' as a subrange of itself!
1060 I don't understand this definition, just copied it
1061 from the output of pcc.
1062 This used to use `r2' explicitly and we used to
1063 take care to make sure that `char' was type number 2. */
1064 fprintf (asmfile
, "r");
1065 dbxout_type_index (type
);
1066 fprintf (asmfile
, ";0;127;");
1069 /* If this is a subtype of another integer type, always prefer to
1070 write it as a subtype. */
1071 else if (TREE_TYPE (type
) != 0
1072 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1073 dbxout_range_type (type
);
1077 /* If the size is non-standard, say what it is if we can use
1080 if (use_gnu_debug_info_extensions
1081 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1082 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1084 /* If we can use GDB extensions and the size is wider than a
1085 long (the size used by GDB to read them) or we may have
1086 trouble writing the bounds the usual way, write them in
1087 octal. Note the test is for the *target's* size of "long",
1088 not that of the host. The host test is just to make sure we
1089 can write it out in case the host wide int is narrower than the
1092 /* For unsigned types, we use octal if they are the same size or
1093 larger. This is because we print the bounds as signed decimal,
1094 and hence they can't span same size unsigned types. */
1096 if (use_gnu_debug_info_extensions
1097 && TYPE_MIN_VALUE (type
) != 0
1098 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1099 && TYPE_MAX_VALUE (type
) != 0
1100 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1101 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1102 || ((TYPE_PRECISION (type
)
1103 == TYPE_PRECISION (integer_type_node
))
1104 && TREE_UNSIGNED (type
))
1105 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1106 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1107 && TREE_UNSIGNED (type
))))
1109 fprintf (asmfile
, "r");
1110 dbxout_type_index (type
);
1111 fprintf (asmfile
, ";");
1112 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1113 fprintf (asmfile
, ";");
1114 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1115 fprintf (asmfile
, ";");
1119 /* Output other integer types as subranges of `int'. */
1120 dbxout_range_type (type
);
1127 /* This used to say `r1' and we used to take care
1128 to make sure that `int' was type number 1. */
1129 fprintf (asmfile
, "r");
1130 dbxout_type_index (integer_type_node
);
1131 fputc (';', asmfile
);
1132 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1133 fputs (";0;", asmfile
);
1138 if (use_gnu_debug_info_extensions
)
1140 fputs ("@s", asmfile
);
1141 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1142 BITS_PER_UNIT
* int_size_in_bytes (type
));
1143 fputs (";-20;", asmfile
);
1147 /* Output the type `char' as a subrange of itself.
1148 That is what pcc seems to do. */
1149 fprintf (asmfile
, "r");
1150 dbxout_type_index (char_type_node
);
1151 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1157 if (use_gnu_debug_info_extensions
)
1159 fputs ("@s", asmfile
);
1160 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1161 BITS_PER_UNIT
* int_size_in_bytes (type
));
1162 fputs (";-16;", asmfile
);
1164 else /* Define as enumeral type (False, True) */
1165 fprintf (asmfile
, "eFalse:0,True:1,;");
1170 putc ('d', asmfile
);
1172 dbxout_type (TREE_TYPE (type
), 0);
1176 /* Differs from the REAL_TYPE by its new data type number */
1178 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1180 fprintf (asmfile
, "r");
1181 dbxout_type_index (type
);
1182 fputc (';', asmfile
);
1183 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1184 2 * int_size_in_bytes (TREE_TYPE (type
)));
1185 fputs (";0;", asmfile
);
1186 CHARS (12); /* The number is probably incorrect here. */
1190 /* Output a complex integer type as a structure,
1191 pending some other way to do it. */
1192 fputc ('s', asmfile
);
1193 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1195 fprintf (asmfile
, "real:");
1197 dbxout_type (TREE_TYPE (type
), 0);
1198 fprintf (asmfile
, ",%d,%d;",
1199 0, TYPE_PRECISION (TREE_TYPE (type
)));
1201 fprintf (asmfile
, "imag:");
1203 dbxout_type (TREE_TYPE (type
), 0);
1204 fprintf (asmfile
, ",%d,%d;;",
1205 TYPE_PRECISION (TREE_TYPE (type
)),
1206 TYPE_PRECISION (TREE_TYPE (type
)));
1212 if (use_gnu_debug_info_extensions
)
1214 have_used_extensions
= 1;
1215 fputs ("@s", asmfile
);
1216 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1217 BITS_PER_UNIT
* int_size_in_bytes (type
));
1218 fputc (';', asmfile
);
1219 /* Check if a bitstring type, which in Chill is
1220 different from a [power]set. */
1221 if (TYPE_STRING_FLAG (type
))
1222 fprintf (asmfile
, "@S;");
1224 putc ('S', asmfile
);
1226 dbxout_type (TYPE_DOMAIN (type
), 0);
1230 /* Make arrays of packed bits look like bitstrings for chill. */
1231 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1233 have_used_extensions
= 1;
1234 fputs ("@s", asmfile
);
1235 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1236 BITS_PER_UNIT
* int_size_in_bytes (type
));
1237 fputc (';', asmfile
);
1238 fprintf (asmfile
, "@S;");
1239 putc ('S', asmfile
);
1241 dbxout_type (TYPE_DOMAIN (type
), 0);
1244 /* Output "a" followed by a range type definition
1245 for the index type of the array
1246 followed by a reference to the target-type.
1247 ar1;0;N;M for a C array of type M and size N+1. */
1248 /* Check if a character string type, which in Chill is
1249 different from an array of characters. */
1250 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1252 have_used_extensions
= 1;
1253 fprintf (asmfile
, "@S;");
1255 tem
= TYPE_DOMAIN (type
);
1258 fprintf (asmfile
, "ar");
1259 dbxout_type_index (integer_type_node
);
1260 fprintf (asmfile
, ";0;-1;");
1264 fprintf (asmfile
, "a");
1265 dbxout_range_type (tem
);
1268 dbxout_type (TREE_TYPE (type
), 0);
1273 case QUAL_UNION_TYPE
:
1275 int i
, n_baseclasses
= 0;
1277 if (TYPE_BINFO (type
) != 0
1278 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1279 && TYPE_BINFO_BASETYPES (type
) != 0)
1280 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1282 /* Output a structure type. We must use the same test here as we
1283 use in the DBX_NO_XREFS case above. */
1284 if ((TYPE_NAME (type
) != 0
1285 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1286 && DECL_IGNORED_P (TYPE_NAME (type
)))
1288 || !COMPLETE_TYPE_P (type
)
1289 /* No way in DBX fmt to describe a variable size. */
1290 || ! host_integerp (TYPE_SIZE (type
), 1))
1292 /* If the type is just a cross reference, output one
1293 and mark the type as partially described.
1294 If it later becomes defined, we will output
1295 its real definition.
1296 If the type has a name, don't nest its definition within
1297 another type's definition; instead, output an xref
1298 and let the definition come when the name is defined. */
1299 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1301 #if 0 /* This assertion is legitimately false in C++. */
1302 /* We shouldn't be outputting a reference to a type before its
1303 definition unless the type has a tag name.
1304 A typedef name without a tag name should be impossible. */
1305 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1308 if (TYPE_NAME (type
) != 0)
1309 dbxout_type_name (type
);
1311 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1312 fprintf (asmfile
, ":");
1313 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1317 /* Identify record or union, and print its size. */
1318 fputc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1319 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1320 int_size_in_bytes (type
));
1322 if (use_gnu_debug_info_extensions
)
1326 have_used_extensions
= 1;
1327 fprintf (asmfile
, "!%d,", n_baseclasses
);
1331 for (i
= 0; i
< n_baseclasses
; i
++)
1333 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1335 if (use_gnu_debug_info_extensions
)
1337 have_used_extensions
= 1;
1338 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1339 putc (TREE_VIA_PUBLIC (child
) ? '2' : '0', asmfile
);
1340 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1341 (tree_low_cst (BINFO_OFFSET (child
), 0)
1343 fputc (',', asmfile
);
1345 dbxout_type (BINFO_TYPE (child
), 0);
1346 putc (';', asmfile
);
1350 /* Print out the base class information with fields
1351 which have the same names at the types they hold. */
1352 dbxout_type_name (BINFO_TYPE (child
));
1353 putc (':', asmfile
);
1354 dbxout_type (BINFO_TYPE (child
), full
);
1355 fputc (',', asmfile
);
1356 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1357 tree_low_cst (BINFO_OFFSET (child
), 0)
1359 fputc (',', asmfile
);
1360 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1361 (tree_low_cst (DECL_SIZE (TYPE_NAME
1362 (BINFO_TYPE (child
))), 0)
1364 fputc (';', asmfile
);
1372 /* Write out the field declarations. */
1373 dbxout_type_fields (type
);
1374 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1376 have_used_extensions
= 1;
1377 dbxout_type_methods (type
);
1380 putc (';', asmfile
);
1382 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1383 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1384 && TYPE_VFIELD (type
))
1386 have_used_extensions
= 1;
1388 /* Tell GDB+ that it may keep reading. */
1389 putc ('~', asmfile
);
1391 /* We need to write out info about what field this class
1392 uses as its "main" vtable pointer field, because if this
1393 field is inherited from a base class, GDB cannot necessarily
1394 figure out which field it's using in time. */
1395 if (TYPE_VFIELD (type
))
1397 putc ('%', asmfile
);
1398 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1400 putc (';', asmfile
);
1406 /* We must use the same test here as we use in the DBX_NO_XREFS case
1407 above. We simplify it a bit since an enum will never have a variable
1409 if ((TYPE_NAME (type
) != 0
1410 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1411 && DECL_IGNORED_P (TYPE_NAME (type
)))
1413 || !COMPLETE_TYPE_P (type
))
1415 fprintf (asmfile
, "xe");
1417 dbxout_type_name (type
);
1418 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1419 fprintf (asmfile
, ":");
1422 #ifdef DBX_OUTPUT_ENUM
1423 DBX_OUTPUT_ENUM (asmfile
, type
);
1425 if (use_gnu_debug_info_extensions
1426 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1427 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1428 putc ('e', asmfile
);
1430 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1432 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1433 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1434 fprintf (asmfile
, HOST_WIDE_INT_PRINT_UNSIGNED
,
1435 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1436 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1437 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1438 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1439 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1441 print_int_cst_octal (TREE_VALUE (tem
));
1442 fprintf (asmfile
, ",");
1443 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)));
1444 if (TREE_CHAIN (tem
) != 0)
1449 putc (';', asmfile
);
1455 putc ('*', asmfile
);
1457 dbxout_type (TREE_TYPE (type
), 0);
1461 if (use_gnu_debug_info_extensions
)
1463 have_used_extensions
= 1;
1464 putc ('#', asmfile
);
1467 /* Write the argument types out longhand. */
1468 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1469 putc (',', asmfile
);
1471 dbxout_type (TREE_TYPE (type
), 0);
1472 dbxout_args (TYPE_ARG_TYPES (type
));
1473 putc (';', asmfile
);
1478 /* Treat it as a function type. */
1479 dbxout_type (TREE_TYPE (type
), 0);
1484 if (use_gnu_debug_info_extensions
)
1486 have_used_extensions
= 1;
1487 putc ('@', asmfile
);
1489 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1490 putc (',', asmfile
);
1492 dbxout_type (TREE_TYPE (type
), 0);
1496 /* Should print as an int, because it is really
1498 dbxout_type (integer_type_node
, 0);
1502 case REFERENCE_TYPE
:
1503 if (use_gnu_debug_info_extensions
)
1504 have_used_extensions
= 1;
1505 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1507 dbxout_type (TREE_TYPE (type
), 0);
1511 putc ('f', asmfile
);
1513 dbxout_type (TREE_TYPE (type
), 0);
1521 /* Print the value of integer constant C, in octal,
1522 handling double precision. */
1525 print_int_cst_octal (c
)
1528 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1529 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1530 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1531 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1533 /* GDB wants constants with no extra leading "1" bits, so
1534 we need to remove any sign-extension that might be
1536 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1538 else if (width
> HOST_BITS_PER_WIDE_INT
)
1539 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1540 else if (width
== HOST_BITS_PER_WIDE_INT
)
1543 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1545 fprintf (asmfile
, "0");
1549 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1550 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1554 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1555 unsigned HOST_WIDE_INT middle
1556 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1557 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1558 unsigned HOST_WIDE_INT end
1559 = low
& (((unsigned HOST_WIDE_INT
) 1
1560 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1563 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1564 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1569 print_octal (value
, digits
)
1570 unsigned HOST_WIDE_INT value
;
1575 for (i
= digits
- 1; i
>= 0; i
--)
1576 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1579 /* Output the name of type TYPE, with no punctuation.
1580 Such names can be set up either by typedef declarations
1581 or by struct, enum and union tags. */
1584 dbxout_type_name (type
)
1588 if (TYPE_NAME (type
) == 0)
1590 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1592 t
= TYPE_NAME (type
);
1594 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1596 t
= DECL_NAME (TYPE_NAME (type
));
1601 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1602 CHARS (IDENTIFIER_LENGTH (t
));
1605 /* Output a .stabs for the symbol defined by DECL,
1606 which must be a ..._DECL node in the normal namespace.
1607 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1608 LOCAL is nonzero if the scope is less than the entire file.
1609 Return 1 if a stabs might have been emitted. */
1612 dbxout_symbol (decl
, local
)
1614 int local ATTRIBUTE_UNUSED
;
1616 tree type
= TREE_TYPE (decl
);
1617 tree context
= NULL_TREE
;
1620 /* Cast avoids warning in old compilers. */
1621 current_sym_code
= (STAB_CODE_TYPE
) 0;
1622 current_sym_value
= 0;
1623 current_sym_addr
= 0;
1625 /* Ignore nameless syms, but don't ignore type tags. */
1627 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1628 || DECL_IGNORED_P (decl
))
1631 dbxout_prepare_symbol (decl
);
1633 /* The output will always start with the symbol name,
1634 so always count that in the length-output-so-far. */
1636 if (DECL_NAME (decl
) != 0)
1637 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1639 switch (TREE_CODE (decl
))
1642 /* Enum values are defined by defining the enum type. */
1646 if (DECL_RTL (decl
) == 0)
1648 if (DECL_EXTERNAL (decl
))
1650 /* Don't mention a nested function under its parent. */
1651 context
= decl_function_context (decl
);
1652 if (context
== current_function_decl
)
1654 if (GET_CODE (DECL_RTL (decl
)) != MEM
1655 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1659 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
1660 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1661 TREE_PUBLIC (decl
) ? 'F' : 'f');
1664 current_sym_code
= N_FUN
;
1665 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1667 if (TREE_TYPE (type
))
1668 dbxout_type (TREE_TYPE (type
), 0);
1670 dbxout_type (void_type_node
, 0);
1672 /* For a nested function, when that function is compiled,
1673 mention the containing function name
1674 as well as (since dbx wants it) our own assembler-name. */
1676 fprintf (asmfile
, ",%s,%s",
1677 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1678 IDENTIFIER_POINTER (DECL_NAME (context
)));
1680 dbxout_finish_symbol (decl
);
1685 /* This seems all wrong. Outputting most kinds of types gives no name
1686 at all. A true definition gives no name; a cross-ref for a
1687 structure can give the tag name, but not a type name.
1688 It seems that no typedef name is defined by outputting a type. */
1690 /* If this typedef name was defined by outputting the type,
1691 don't duplicate it. */
1692 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1693 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1696 /* Don't output the same typedef twice.
1697 And don't output what language-specific stuff doesn't want output. */
1698 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1707 if (DECL_NAME (decl
))
1709 /* Nonzero means we must output a tag as well as a typedef. */
1712 /* Handle the case of a C++ structure or union
1713 where the TYPE_NAME is a TYPE_DECL
1714 which gives both a typedef name and a tag. */
1715 /* dbx requires the tag first and the typedef second. */
1716 if ((TREE_CODE (type
) == RECORD_TYPE
1717 || TREE_CODE (type
) == UNION_TYPE
1718 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1719 && TYPE_NAME (type
) == decl
1720 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1721 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1722 /* Distinguish the implicit typedefs of C++
1723 from explicit ones that might be found in C. */
1724 && DECL_ARTIFICIAL (decl
)
1725 /* Do not generate a tag for records of variable size,
1726 since this type can not be properly described in the
1727 DBX format, and it confuses some tools such as objdump. */
1728 && host_integerp (TYPE_SIZE (type
), 1))
1730 tree name
= TYPE_NAME (type
);
1731 if (TREE_CODE (name
) == TYPE_DECL
)
1732 name
= DECL_NAME (name
);
1734 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1735 current_sym_value
= 0;
1736 current_sym_addr
= 0;
1737 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1739 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1740 IDENTIFIER_POINTER (name
));
1741 dbxout_type (type
, 1);
1742 dbxout_finish_symbol (NULL_TREE
);
1745 /* Output typedef name. */
1746 fprintf (asmfile
, "%s\"%s:", ASM_STABS_OP
,
1747 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1749 /* Short cut way to output a tag also. */
1750 if ((TREE_CODE (type
) == RECORD_TYPE
1751 || TREE_CODE (type
) == UNION_TYPE
1752 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1753 && TYPE_NAME (type
) == decl
1754 /* Distinguish the implicit typedefs of C++
1755 from explicit ones that might be found in C. */
1756 && DECL_ARTIFICIAL (decl
))
1758 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1760 putc ('T', asmfile
);
1761 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1763 #if 0 /* Now we generate the tag for this case up above. */
1769 putc ('t', asmfile
);
1770 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1772 dbxout_type (type
, 1);
1773 dbxout_finish_symbol (decl
);
1777 /* Don't output a tag if this is an incomplete type. This prevents
1778 the sun4 Sun OS 4.x dbx from crashing. */
1780 if (tag_needed
&& TYPE_NAME (type
) != 0
1781 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1782 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1783 && COMPLETE_TYPE_P (type
)
1784 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1786 /* For a TYPE_DECL with no name, but the type has a name,
1788 This is what represents `struct foo' with no typedef. */
1789 /* In C++, the name of a type is the corresponding typedef.
1790 In C, it is an IDENTIFIER_NODE. */
1791 tree name
= TYPE_NAME (type
);
1792 if (TREE_CODE (name
) == TYPE_DECL
)
1793 name
= DECL_NAME (name
);
1795 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1796 current_sym_value
= 0;
1797 current_sym_addr
= 0;
1798 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1800 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1801 IDENTIFIER_POINTER (name
));
1802 dbxout_type (type
, 1);
1803 dbxout_finish_symbol (NULL_TREE
);
1807 /* If an enum type has no name, it cannot be referred to,
1808 but we must output it anyway, since the enumeration constants
1809 can be referred to. */
1810 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1812 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1813 current_sym_value
= 0;
1814 current_sym_addr
= 0;
1815 current_sym_nchars
= 2;
1817 /* Some debuggers fail when given NULL names, so give this a
1818 harmless name of ` '. */
1819 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
1820 dbxout_type (type
, 1);
1821 dbxout_finish_symbol (NULL_TREE
);
1824 /* Prevent duplicate output of a typedef. */
1825 TREE_ASM_WRITTEN (decl
) = 1;
1830 /* Parm decls go in their own separate chains
1831 and are output by dbxout_reg_parms and dbxout_parms. */
1835 /* Named return value, treat like a VAR_DECL. */
1837 if (! DECL_RTL_SET_P (decl
))
1839 /* Don't mention a variable that is external.
1840 Let the file that defines it describe it. */
1841 if (DECL_EXTERNAL (decl
))
1844 /* If the variable is really a constant
1845 and not written in memory, inform the debugger. */
1846 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
1847 && DECL_INITIAL (decl
) != 0
1848 && host_integerp (DECL_INITIAL (decl
), 0)
1849 && ! TREE_ASM_WRITTEN (decl
)
1850 && (DECL_CONTEXT (decl
) == NULL_TREE
1851 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
1853 if (TREE_PUBLIC (decl
) == 0)
1855 /* The sun4 assembler does not grok this. */
1856 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
1858 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
1859 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
1861 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
1862 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1863 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
1865 fprintf (asmfile
, "%s\"%s:c=i", ASM_STABS_OP
, name
);
1867 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
1868 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
1872 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
1874 /* don't know how to do this yet. */
1878 /* else it is something we handle like a normal variable. */
1881 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
1882 #ifdef LEAF_REG_REMAP
1883 if (current_function_uses_only_leaf_regs
)
1884 leaf_renumber_regs_insn (DECL_RTL (decl
));
1887 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
1896 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1897 Add SUFFIX to its name, if SUFFIX is not 0.
1898 Describe the variable as residing in HOME
1899 (usually HOME is DECL_RTL (DECL), but not always).
1900 Returns 1 if the stab was really emitted. */
1903 dbxout_symbol_location (decl
, type
, suffix
, home
)
1911 /* Don't mention a variable at all
1912 if it was completely optimized into nothingness.
1914 If the decl was from an inline function, then its rtl
1915 is not identically the rtl that was used in this
1916 particular compilation. */
1917 if (GET_CODE (home
) == REG
)
1919 regno
= REGNO (home
);
1920 if (regno
>= FIRST_PSEUDO_REGISTER
)
1923 else if (GET_CODE (home
) == SUBREG
)
1927 while (GET_CODE (value
) == SUBREG
)
1928 value
= SUBREG_REG (value
);
1929 if (GET_CODE (value
) == REG
)
1931 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
1934 regno
= REGNO (alter_subreg (home
));
1937 /* The kind-of-variable letter depends on where
1938 the variable is and on the scope of its name:
1939 G and N_GSYM for static storage and global scope,
1940 S for static storage and file scope,
1941 V for static storage and local scope,
1942 for those two, use N_LCSYM if data is in bss segment,
1943 N_STSYM if in data segment, N_FUN otherwise.
1944 (We used N_FUN originally, then changed to N_STSYM
1945 to please GDB. However, it seems that confused ld.
1946 Now GDB has been fixed to like N_FUN, says Kingdon.)
1947 no letter at all, and N_LSYM, for auto variable,
1948 r and N_RSYM for register variable. */
1950 if (GET_CODE (home
) == MEM
1951 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
1953 if (TREE_PUBLIC (decl
))
1956 current_sym_code
= N_GSYM
;
1960 current_sym_addr
= XEXP (home
, 0);
1962 letter
= decl_function_context (decl
) ? 'V' : 'S';
1964 /* This should be the same condition as in assemble_variable, but
1965 we don't have access to dont_output_data here. So, instead,
1966 we rely on the fact that error_mark_node initializers always
1967 end up in bss for C++ and never end up in bss for C. */
1968 if (DECL_INITIAL (decl
) == 0
1969 || (!strcmp (lang_identify (), "cplusplus")
1970 && DECL_INITIAL (decl
) == error_mark_node
))
1971 current_sym_code
= N_LCSYM
;
1972 else if (DECL_IN_TEXT_SECTION (decl
))
1973 /* This is not quite right, but it's the closest
1974 of all the codes that Unix defines. */
1975 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
1978 /* Ultrix `as' seems to need this. */
1979 #ifdef DBX_STATIC_STAB_DATA_SECTION
1982 current_sym_code
= N_STSYM
;
1986 else if (regno
>= 0)
1989 current_sym_code
= N_RSYM
;
1990 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
1992 else if (GET_CODE (home
) == MEM
1993 && (GET_CODE (XEXP (home
, 0)) == MEM
1994 || (GET_CODE (XEXP (home
, 0)) == REG
1995 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
1996 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
1997 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
1998 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2001 /* If the value is indirect by memory or by a register
2002 that isn't the frame pointer
2003 then it means the object is variable-sized and address through
2004 that register or stack slot. DBX has no way to represent this
2005 so all we can do is output the variable as a pointer.
2006 If it's not a parameter, ignore it.
2007 (VAR_DECLs like this can be made by integrate.c.) */
2009 if (GET_CODE (XEXP (home
, 0)) == REG
)
2012 current_sym_code
= N_RSYM
;
2013 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2017 current_sym_code
= N_LSYM
;
2018 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2019 We want the value of that CONST_INT. */
2021 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2024 /* Effectively do build_pointer_type, but don't cache this type,
2025 since it might be temporary whereas the type it points to
2026 might have been saved for inlining. */
2027 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2028 type
= make_node (POINTER_TYPE
);
2029 TREE_TYPE (type
) = TREE_TYPE (decl
);
2031 else if (GET_CODE (home
) == MEM
2032 && GET_CODE (XEXP (home
, 0)) == REG
)
2034 current_sym_code
= N_LSYM
;
2035 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2037 else if (GET_CODE (home
) == MEM
2038 && GET_CODE (XEXP (home
, 0)) == PLUS
2039 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2041 current_sym_code
= N_LSYM
;
2042 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2043 We want the value of that CONST_INT. */
2044 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2046 else if (GET_CODE (home
) == MEM
2047 && GET_CODE (XEXP (home
, 0)) == CONST
)
2049 /* Handle an obscure case which can arise when optimizing and
2050 when there are few available registers. (This is *always*
2051 the case for i386/i486 targets). The RTL looks like
2052 (MEM (CONST ...)) even though this variable is a local `auto'
2053 or a local `register' variable. In effect, what has happened
2054 is that the reload pass has seen that all assignments and
2055 references for one such a local variable can be replaced by
2056 equivalent assignments and references to some static storage
2057 variable, thereby avoiding the need for a register. In such
2058 cases we're forced to lie to debuggers and tell them that
2059 this variable was itself `static'. */
2060 current_sym_code
= N_LCSYM
;
2062 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2064 else if (GET_CODE (home
) == CONCAT
)
2068 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2069 for example), then there is no easy way to figure out
2070 what SUBTYPE should be. So, we give up. */
2071 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2074 subtype
= TREE_TYPE (type
);
2076 /* If the variable's storage is in two parts,
2077 output each as a separate stab with a modified name. */
2078 if (WORDS_BIG_ENDIAN
)
2079 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2081 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2083 /* Cast avoids warning in old compilers. */
2084 current_sym_code
= (STAB_CODE_TYPE
) 0;
2085 current_sym_value
= 0;
2086 current_sym_addr
= 0;
2087 dbxout_prepare_symbol (decl
);
2089 if (WORDS_BIG_ENDIAN
)
2090 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2092 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2096 /* Address might be a MEM, when DECL is a variable-sized object.
2097 Or it might be const0_rtx, meaning previous passes
2098 want us to ignore this variable. */
2101 /* Ok, start a symtab entry and output the variable name. */
2104 #ifdef DBX_STATIC_BLOCK_START
2105 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2108 dbxout_symbol_name (decl
, suffix
, letter
);
2109 dbxout_type (type
, 0);
2110 dbxout_finish_symbol (decl
);
2112 #ifdef DBX_STATIC_BLOCK_END
2113 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2118 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2119 Then output LETTER to indicate the kind of location the symbol has. */
2122 dbxout_symbol_name (decl
, suffix
, letter
)
2129 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2130 /* One slight hitch: if this is a VAR_DECL which is a static
2131 class member, we must put out the mangled name instead of the
2132 DECL_NAME. Note also that static member (variable) names DO NOT begin
2133 with underscores in .stabs directives. */
2134 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2136 /* ...but if we're function-local, we don't want to include the junk
2137 added by ASM_FORMAT_PRIVATE_NAME. */
2138 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2142 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2143 (suffix
? suffix
: ""));
2145 if (letter
) putc (letter
, asmfile
);
2149 dbxout_prepare_symbol (decl
)
2150 tree decl ATTRIBUTE_UNUSED
;
2153 const char *filename
= DECL_SOURCE_FILE (decl
);
2155 dbxout_source_file (asmfile
, filename
);
2160 dbxout_finish_symbol (sym
)
2163 #ifdef DBX_FINISH_SYMBOL
2164 DBX_FINISH_SYMBOL (sym
);
2167 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2168 line
= DECL_SOURCE_LINE (sym
);
2170 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2171 if (current_sym_addr
)
2172 output_addr_const (asmfile
, current_sym_addr
);
2174 fprintf (asmfile
, "%d", current_sym_value
);
2175 putc ('\n', asmfile
);
2179 /* Output definitions of all the decls in a chain. Return non-zero if
2180 anything was output */
2189 result
+= dbxout_symbol (syms
, 1);
2190 syms
= TREE_CHAIN (syms
);
2195 /* The following two functions output definitions of function parameters.
2196 Each parameter gets a definition locating it in the parameter list.
2197 Each parameter that is a register variable gets a second definition
2198 locating it in the register.
2200 Printing or argument lists in gdb uses the definitions that
2201 locate in the parameter list. But reference to the variable in
2202 expressions uses preferentially the definition as a register. */
2204 /* Output definitions, referring to storage in the parmlist,
2205 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2208 dbxout_parms (parms
)
2211 for (; parms
; parms
= TREE_CHAIN (parms
))
2212 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2214 dbxout_prepare_symbol (parms
);
2216 /* Perform any necessary register eliminations on the parameter's rtl,
2217 so that the debugging output will be accurate. */
2218 DECL_INCOMING_RTL (parms
)
2219 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2220 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2221 #ifdef LEAF_REG_REMAP
2222 if (current_function_uses_only_leaf_regs
)
2224 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2225 leaf_renumber_regs_insn (DECL_RTL (parms
));
2229 if (PARM_PASSED_IN_MEMORY (parms
))
2231 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2233 /* ??? Here we assume that the parm address is indexed
2234 off the frame pointer or arg pointer.
2235 If that is not true, we produce meaningless results,
2236 but do not crash. */
2237 if (GET_CODE (addr
) == PLUS
2238 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2239 current_sym_value
= INTVAL (XEXP (addr
, 1));
2241 current_sym_value
= 0;
2243 current_sym_code
= N_PSYM
;
2244 current_sym_addr
= 0;
2247 if (DECL_NAME (parms
))
2249 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2251 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2252 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2253 DBX_MEMPARM_STABS_LETTER
);
2257 current_sym_nchars
= 8;
2258 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2259 DBX_MEMPARM_STABS_LETTER
);
2262 /* It is quite tempting to use:
2264 dbxout_type (TREE_TYPE (parms), 0);
2266 as the next statement, rather than using DECL_ARG_TYPE(), so
2267 that gcc reports the actual type of the parameter, rather
2268 than the promoted type. This certainly makes GDB's life
2269 easier, at least for some ports. The change is a bad idea
2270 however, since GDB expects to be able access the type without
2271 performing any conversions. So for example, if we were
2272 passing a float to an unprototyped function, gcc will store a
2273 double on the stack, but if we emit a stab saying the type is a
2274 float, then gdb will only read in a single value, and this will
2275 produce an erropneous value. */
2276 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2277 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2278 dbxout_finish_symbol (parms
);
2280 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2283 char regparm_letter
;
2285 /* Parm passed in registers and lives in registers or nowhere. */
2287 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2288 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2289 current_sym_addr
= 0;
2291 /* If parm lives in a register, use that register;
2292 pretend the parm was passed there. It would be more consistent
2293 to describe the register where the parm was passed,
2294 but in practice that register usually holds something else.
2296 If we use DECL_RTL, then we must use the declared type of
2297 the variable, not the type that it arrived in. */
2298 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2300 best_rtl
= DECL_RTL (parms
);
2301 parm_type
= TREE_TYPE (parms
);
2303 /* If the parm lives nowhere, use the register where it was
2304 passed. It is also better to use the declared type here. */
2307 best_rtl
= DECL_INCOMING_RTL (parms
);
2308 parm_type
= TREE_TYPE (parms
);
2310 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2313 if (DECL_NAME (parms
))
2315 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2316 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2317 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2322 current_sym_nchars
= 8;
2323 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2327 dbxout_type (parm_type
, 0);
2328 dbxout_finish_symbol (parms
);
2330 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2331 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2332 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2333 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2334 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2335 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2339 /* Parm was passed via invisible reference.
2340 That is, its address was passed in a register.
2341 Output it as if it lived in that register.
2342 The debugger will know from the type
2343 that it was actually passed by invisible reference. */
2345 char regparm_letter
;
2346 /* Parm passed in registers and lives in registers or nowhere. */
2348 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2349 if (use_gnu_debug_info_extensions
)
2350 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2352 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2354 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2355 If it is an unallocated pseudo-reg, then use the register where
2356 it was passed instead. */
2357 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2358 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2360 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2362 current_sym_addr
= 0;
2365 if (DECL_NAME (parms
))
2367 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2369 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2370 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2375 current_sym_nchars
= 8;
2376 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2380 dbxout_type (TREE_TYPE (parms
), 0);
2381 dbxout_finish_symbol (parms
);
2383 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2384 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2386 /* Parm was passed via invisible reference, with the reference
2387 living on the stack. DECL_RTL looks like
2388 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2389 could look like (MEM (MEM (REG))). */
2390 const char *decl_name
= (DECL_NAME (parms
)
2391 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2393 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2394 current_sym_value
= 0;
2397 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2398 current_sym_addr
= 0;
2401 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2402 dbxout_type (TREE_TYPE (parms
), 0);
2403 dbxout_finish_symbol (parms
);
2405 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2406 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2407 /* ??? A constant address for a parm can happen
2408 when the reg it lives in is equiv to a constant in memory.
2409 Should make this not happen, after 2.4. */
2410 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2412 /* Parm was passed in registers but lives on the stack. */
2414 current_sym_code
= N_PSYM
;
2415 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2416 in which case we want the value of that CONST_INT,
2418 in which case we use a value of zero. */
2419 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2420 current_sym_value
= 0;
2423 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2425 current_sym_addr
= 0;
2427 /* Make a big endian correction if the mode of the type of the
2428 parameter is not the same as the mode of the rtl. */
2429 if (BYTES_BIG_ENDIAN
2430 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2431 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2433 current_sym_value
+=
2434 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2435 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2439 if (DECL_NAME (parms
))
2442 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2444 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2445 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2446 DBX_MEMPARM_STABS_LETTER
);
2450 current_sym_nchars
= 8;
2451 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2452 DBX_MEMPARM_STABS_LETTER
);
2456 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2457 XEXP (DECL_RTL (parms
), 0));
2458 dbxout_type (TREE_TYPE (parms
), 0);
2459 dbxout_finish_symbol (parms
);
2464 /* Output definitions for the places where parms live during the function,
2465 when different from where they were passed, when the parms were passed
2468 It is not useful to do this for parms passed in registers
2469 that live during the function in different registers, because it is
2470 impossible to look in the passed register for the passed value,
2471 so we use the within-the-function register to begin with.
2473 PARMS is a chain of PARM_DECL nodes. */
2476 dbxout_reg_parms (parms
)
2479 for (; parms
; parms
= TREE_CHAIN (parms
))
2480 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2482 dbxout_prepare_symbol (parms
);
2484 /* Report parms that live in registers during the function
2485 but were passed in memory. */
2486 if (GET_CODE (DECL_RTL (parms
)) == REG
2487 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2488 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2489 0, DECL_RTL (parms
));
2490 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2491 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2492 0, DECL_RTL (parms
));
2493 /* Report parms that live in memory but not where they were passed. */
2494 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2495 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2496 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2497 0, DECL_RTL (parms
));
2501 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2502 output definitions of those names, in raw form */
2510 putc (',', asmfile
);
2511 dbxout_type (TREE_VALUE (args
), 0);
2513 args
= TREE_CHAIN (args
);
2517 /* Given a chain of ..._TYPE nodes,
2518 find those which have typedef names and output those names.
2519 This is to ensure those types get output. */
2522 dbxout_types (types
)
2523 register tree types
;
2527 if (TYPE_NAME (types
)
2528 && TREE_CODE (TYPE_NAME (types
)) == TYPE_DECL
2529 && ! TREE_ASM_WRITTEN (TYPE_NAME (types
)))
2530 dbxout_symbol (TYPE_NAME (types
), 1);
2531 types
= TREE_CHAIN (types
);
2535 /* Output everything about a symbol block (a BLOCK node
2536 that represents a scope level),
2537 including recursive output of contained blocks.
2539 BLOCK is the BLOCK node.
2540 DEPTH is its depth within containing symbol blocks.
2541 ARGS is usually zero; but for the outermost block of the
2542 body of a function, it is a chain of PARM_DECLs for the function parameters.
2543 We output definitions of all the register parms
2544 as if they were local variables of that block.
2546 If -g1 was used, we count blocks just the same, but output nothing
2547 except for the outermost block.
2549 Actually, BLOCK may be several blocks chained together.
2550 We handle them all in sequence. */
2553 dbxout_block (block
, depth
, args
)
2554 register tree block
;
2560 #if DBX_BLOCKS_FUNCTION_RELATIVE
2561 const char *begin_label
;
2562 if (current_function_func_begin_label
!= NULL_TREE
)
2563 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2565 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2570 /* Ignore blocks never expanded or otherwise marked as real. */
2571 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2575 #ifdef DBX_LBRAC_FIRST
2578 /* In dbx format, the syms of a block come before the N_LBRAC.
2579 If nothing is output, we don't need the N_LBRAC, either. */
2581 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2582 did_output
= 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 && did_output
)
2594 blocknum
= BLOCK_NUMBER (block
);
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
, begin_label
);
2624 fprintf (asmfile
, "\n");
2628 #ifdef DBX_LBRAC_FIRST
2629 /* On some weird machines, the syms of a block
2630 come after the N_LBRAC. */
2631 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2632 dbxout_syms (BLOCK_VARS (block
));
2634 dbxout_reg_parms (args
);
2637 /* Output the subblocks. */
2638 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2640 /* Refer to the marker for the end of the block. */
2641 if (depth
> 0 && did_output
)
2644 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2645 #ifdef DBX_OUTPUT_RBRAC
2646 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2648 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2649 assemble_name (asmfile
, buf
);
2650 #if DBX_BLOCKS_FUNCTION_RELATIVE
2651 fputc ('-', asmfile
);
2652 assemble_name (asmfile
, begin_label
);
2654 fprintf (asmfile
, "\n");
2658 block
= BLOCK_CHAIN (block
);
2662 /* Output the information about a function and its arguments and result.
2663 Usually this follows the function's code,
2664 but on some systems, it comes before. */
2667 dbxout_really_begin_function (decl
)
2670 dbxout_symbol (decl
, 0);
2671 dbxout_parms (DECL_ARGUMENTS (decl
));
2672 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2673 dbxout_symbol (DECL_RESULT (decl
), 1);
2676 /* Called at beginning of output of function definition. */
2679 dbxout_begin_function (decl
)
2680 tree decl ATTRIBUTE_UNUSED
;
2682 #ifdef DBX_FUNCTION_FIRST
2683 dbxout_really_begin_function (decl
);
2687 /* Output dbx data for a function definition.
2688 This includes a definition of the function name itself (a symbol),
2689 definitions of the parameters (locating them in the parameter list)
2690 and then output the block that makes up the function's body
2691 (including all the auto variables of the function). */
2694 dbxout_function (decl
)
2697 #ifndef DBX_FUNCTION_FIRST
2698 dbxout_really_begin_function (decl
);
2700 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
2701 #ifdef DBX_OUTPUT_FUNCTION_END
2702 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
2704 #if defined(ASM_OUTPUT_SECTION_NAME)
2705 if (use_gnu_debug_info_extensions
2706 #if defined(NO_DBX_FUNCTION_END)
2707 && ! NO_DBX_FUNCTION_END
2710 dbxout_function_end ();
2713 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */