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. */
86 #ifdef XCOFF_DEBUGGING_INFO
91 #define ASM_STABS_OP "\t.stabs\t"
95 #define ASM_STABN_OP "\t.stabn\t"
98 #ifndef DBX_TYPE_DECL_STABS_CODE
99 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
102 #ifndef DBX_STATIC_CONST_VAR_CODE
103 #define DBX_STATIC_CONST_VAR_CODE N_FUN
106 #ifndef DBX_REGPARM_STABS_CODE
107 #define DBX_REGPARM_STABS_CODE N_RSYM
110 #ifndef DBX_REGPARM_STABS_LETTER
111 #define DBX_REGPARM_STABS_LETTER 'P'
114 /* This is used for parameters passed by invisible reference in a register. */
115 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
116 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
119 #ifndef DBX_MEMPARM_STABS_LETTER
120 #define DBX_MEMPARM_STABS_LETTER 'p'
123 #ifndef FILE_NAME_JOINER
124 #define FILE_NAME_JOINER "/"
127 /* GDB needs to know that the stabs were generated by GCC. We emit an
128 N_OPT stab at the beginning of the source file to indicate this.
129 The string is historical, and different on a very few targets. */
130 #ifndef STABS_GCC_MARKER
131 #define STABS_GCC_MARKER "gcc2_compiled."
134 /* Typical USG systems don't have stab.h, and they also have
135 no use for DBX-format debugging info. */
137 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
139 /* Nonzero if we have actually used any of the GDB extensions
140 to the debugging format. The idea is that we use them for the
141 first time only if there's a strong reason, but once we have done that,
142 we use them whenever convenient. */
144 static int have_used_extensions
= 0;
146 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
147 for the N_SO filename stabs label. */
149 static int source_label_number
= 1;
151 #ifdef DEBUG_SYMS_TEXT
152 #define FORCE_TEXT text_section ();
159 #define STAB_CODE_TYPE enum __stab_debug_code
161 /* 1 if PARM is passed to this function in memory. */
163 #define PARM_PASSED_IN_MEMORY(PARM) \
164 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
166 /* A C expression for the integer offset value of an automatic variable
167 (N_LSYM) having address X (an RTX). */
168 #ifndef DEBUGGER_AUTO_OFFSET
169 #define DEBUGGER_AUTO_OFFSET(X) \
170 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
173 /* A C expression for the integer offset value of an argument (N_PSYM)
174 having address X (an RTX). The nominal offset is OFFSET. */
175 #ifndef DEBUGGER_ARG_OFFSET
176 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
179 /* Stream for writing to assembler file. */
181 static FILE *asmfile
;
183 /* Last source file name mentioned in a NOTE insn. */
185 static const char *lastfile
;
187 /* Current working directory. */
189 static const char *cwd
;
191 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
193 /* Structure recording information about a C data type.
194 The status element says whether we have yet output
195 the definition of the type. TYPE_XREF says we have
196 output it as a cross-reference only.
197 The file_number and type_number elements are used if DBX_USE_BINCL
202 enum typestatus status
;
209 /* Vector recording information about C data types.
210 When we first notice a data type (a tree node),
211 we assign it a number using next_type_number.
212 That is its index in this vector. */
214 struct typeinfo
*typevec
;
216 /* Number of elements of space allocated in `typevec'. */
218 static int typevec_len
;
220 /* In dbx output, each type gets a unique number.
221 This is the number for the next type output.
222 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
224 static int next_type_number
;
228 /* When using N_BINCL in dbx output, each type number is actually a
229 pair of the file number and the type number within the file.
230 This is a stack of input files. */
234 struct dbx_file
*next
;
236 int next_type_number
;
239 /* This is the top of the stack. */
241 static struct dbx_file
*current_file
;
243 /* This is the next file number to use. */
245 static int next_file_number
;
247 #endif /* DBX_USE_BINCL */
249 /* These variables are for dbxout_symbol to communicate to
250 dbxout_finish_symbol.
251 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
252 current_sym_value and current_sym_addr are two ways to address the
253 value to store in the symtab entry.
254 current_sym_addr if nonzero represents the value as an rtx.
255 If that is zero, current_sym_value is used. This is used
256 when the value is an offset (such as for auto variables,
257 register variables and parms). */
259 static STAB_CODE_TYPE current_sym_code
;
260 static int current_sym_value
;
261 static rtx current_sym_addr
;
263 /* Number of chars of symbol-description generated so far for the
264 current symbol. Used by CHARS and CONTIN. */
266 static int current_sym_nchars
;
268 /* Report having output N chars of the current symbol-description. */
270 #define CHARS(N) (current_sym_nchars += (N))
272 /* Break the current symbol-description, generating a continuation,
273 if it has become long. */
275 #ifndef DBX_CONTIN_LENGTH
276 #define DBX_CONTIN_LENGTH 80
279 #if DBX_CONTIN_LENGTH > 0
281 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
283 #define CONTIN do { } while (0)
286 #if defined(ASM_OUTPUT_SECTION_NAME)
287 static void dbxout_function_end
PARAMS ((void));
289 static void dbxout_typedefs
PARAMS ((tree
));
290 static void dbxout_type_index
PARAMS ((tree
));
291 #if DBX_CONTIN_LENGTH > 0
292 static void dbxout_continue
PARAMS ((void));
294 static void dbxout_type_fields
PARAMS ((tree
));
295 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
296 static void dbxout_type_methods
PARAMS ((tree
));
297 static void dbxout_range_type
PARAMS ((tree
));
298 static void dbxout_type
PARAMS ((tree
, int));
299 static void print_int_cst_octal
PARAMS ((tree
));
300 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
301 static void dbxout_type_name
PARAMS ((tree
));
302 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
303 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
304 static void dbxout_prepare_symbol
PARAMS ((tree
));
305 static void dbxout_finish_symbol
PARAMS ((tree
));
306 static void dbxout_block
PARAMS ((tree
, int, tree
));
307 static void dbxout_really_begin_function
PARAMS ((tree
));
309 #if defined(ASM_OUTPUT_SECTION_NAME)
311 dbxout_function_end ()
313 static int scope_labelno
= 0;
314 char lscope_label_name
[100];
315 /* Convert Ltext into the appropriate format for local labels in case
316 the system doesn't insert underscores in front of user generated
318 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
319 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
322 /* By convention, GCC will mark the end of a function with an N_FUN
323 symbol and an empty string. */
324 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
325 assemble_name (asmfile
, lscope_label_name
);
326 fputc ('-', asmfile
);
327 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
328 fprintf (asmfile
, "\n");
330 #endif /* ! NO_DBX_FUNCTION_END */
332 /* At the beginning of compilation, start writing the symbol table.
333 Initialize `typevec' and output the standard data types of C. */
336 dbxout_init (asm_file
, input_file_name
, syms
)
338 const char *input_file_name
;
341 char ltext_label_name
[100];
346 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
348 /* Convert Ltext into the appropriate format for local labels in case
349 the system doesn't insert underscores in front of user generated
351 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
353 /* Put the current working directory in an N_SO symbol. */
354 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
355 but GDB always does. */
356 if (use_gnu_debug_info_extensions
)
359 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
360 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
363 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
364 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
365 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
366 fprintf (asmfile
, "%s", ASM_STABS_OP
);
367 output_quoted_string (asmfile
, cwd
);
368 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
369 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
373 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
374 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
375 would give us an N_SOL, and we want an N_SO. */
376 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
377 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
378 /* We include outputting `Ltext:' here,
379 because that gives you a way to override it. */
380 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
381 fprintf (asmfile
, "%s", ASM_STABS_OP
);
382 output_quoted_string (asmfile
, input_file_name
);
383 fprintf (asmfile
, ",%d,0,0,%s\n",
384 N_SO
, <ext_label_name
[1]);
386 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
387 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
389 #ifdef DBX_OUTPUT_GCC_MARKER
390 DBX_OUTPUT_GCC_MARKER (asmfile
);
392 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
393 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
394 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
397 lastfile
= input_file_name
;
399 next_type_number
= 1;
402 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
403 current_file
->next
= NULL
;
404 current_file
->file_number
= 0;
405 current_file
->next_type_number
= 1;
406 next_file_number
= 1;
409 /* Make sure that types `int' and `char' have numbers 1 and 2.
410 Definitions of other integer types will refer to those numbers.
411 (Actually it should no longer matter what their numbers are.
412 Also, if any types with tags have been defined, dbxout_symbol
413 will output them first, so the numbers won't be 1 and 2. That
414 happens in C++. So it's a good thing it should no longer matter). */
416 #ifdef DBX_OUTPUT_STANDARD_TYPES
417 DBX_OUTPUT_STANDARD_TYPES (syms
);
419 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
420 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
423 /* Get all permanent types that have typedef names,
424 and output them all, except for those already output. */
426 dbxout_typedefs (syms
);
429 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
430 in the reverse order from that which is found in SYMS. */
433 dbxout_typedefs (syms
)
438 dbxout_typedefs (TREE_CHAIN (syms
));
439 if (TREE_CODE (syms
) == TYPE_DECL
)
441 tree type
= TREE_TYPE (syms
);
443 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
444 && COMPLETE_TYPE_P (type
)
445 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
446 dbxout_symbol (TYPE_NAME (type
), 0);
451 /* Change to reading from a new source file. Generate a N_BINCL stab. */
454 dbxout_start_new_source_file (filename
)
455 const char *filename ATTRIBUTE_UNUSED
;
458 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
460 n
->next
= current_file
;
461 n
->file_number
= next_file_number
++;
462 n
->next_type_number
= 1;
464 fprintf (asmfile
, "%s", ASM_STABS_OP
);
465 output_quoted_string (asmfile
, filename
);
466 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
470 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
473 dbxout_resume_previous_source_file ()
476 struct dbx_file
*next
;
478 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
479 next
= current_file
->next
;
485 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
488 dbxout_source_file (file
, filename
)
490 const char *filename
;
492 char ltext_label_name
[100];
494 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
496 #ifdef DBX_OUTPUT_SOURCE_FILENAME
497 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
499 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
500 source_label_number
);
501 fprintf (file
, "%s", ASM_STABS_OP
);
502 output_quoted_string (file
, filename
);
503 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
504 if (current_function_decl
!= NULL_TREE
505 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
506 ; /* Don't change section amid function. */
509 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
510 source_label_number
++;
516 /* Output a line number symbol entry into output stream FILE,
517 for source file FILENAME and line number LINENO. */
520 dbxout_source_line (file
, filename
, lineno
)
522 const char *filename
;
525 dbxout_source_file (file
, filename
);
527 #ifdef ASM_OUTPUT_SOURCE_LINE
528 ASM_OUTPUT_SOURCE_LINE (file
, lineno
);
530 fprintf (file
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
534 /* At the end of compilation, finish writing the symbol table.
535 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
539 dbxout_finish (file
, filename
)
540 FILE *file ATTRIBUTE_UNUSED
;
541 const char *filename ATTRIBUTE_UNUSED
;
543 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
544 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file
, filename
);
545 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
548 /* Output the index of a type. */
551 dbxout_type_index (type
)
554 #ifndef DBX_USE_BINCL
555 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
558 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
559 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
564 #if DBX_CONTIN_LENGTH > 0
565 /* Continue a symbol-description that gets too big.
566 End one symbol table entry with a double-backslash
567 and start a new one, eventually producing something like
568 .stabs "start......\\",code,0,value
569 .stabs "...rest",code,0,value */
574 #ifdef DBX_CONTIN_CHAR
575 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
577 fprintf (asmfile
, "\\\\");
579 dbxout_finish_symbol (NULL_TREE
);
580 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
581 current_sym_nchars
= 0;
583 #endif /* DBX_CONTIN_LENGTH > 0 */
585 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
586 This must be a separate function because anonymous unions require
590 dbxout_type_fields (type
)
595 /* Output the name, type, position (in bits), size (in bits) of each
596 field that we can support. */
597 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
599 /* Omit here local type decls until we know how to support them. */
600 if (TREE_CODE (tem
) == TYPE_DECL
601 /* Omit fields whose position or size are variable or too large to
603 || (TREE_CODE (tem
) == FIELD_DECL
604 && (! host_integerp (bit_position (tem
), 0)
606 || ! host_integerp (DECL_SIZE (tem
), 1)))
607 /* Omit here the nameless fields that are used to skip bits. */
608 || DECL_IGNORED_P (tem
))
611 else if (TREE_CODE (tem
) != CONST_DECL
)
613 /* Continue the line if necessary,
614 but not before the first field. */
615 if (tem
!= TYPE_FIELDS (type
))
620 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
621 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
625 fprintf (asmfile
, ":");
629 if (use_gnu_debug_info_extensions
630 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
631 || TREE_CODE (tem
) != FIELD_DECL
))
633 have_used_extensions
= 1;
635 putc ((TREE_PRIVATE (tem
) ? '0'
636 : TREE_PROTECTED (tem
) ? '1' : '2'),
641 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
642 && DECL_BIT_FIELD_TYPE (tem
))
643 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
645 if (TREE_CODE (tem
) == VAR_DECL
)
647 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
650 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
));
651 have_used_extensions
= 1;
652 fprintf (asmfile
, ":%s;", name
);
653 CHARS (strlen (name
));
656 /* If TEM is non-static, GDB won't understand it. */
657 fprintf (asmfile
, ",0,0;");
661 fputc (',', asmfile
);
662 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
663 int_bit_position (tem
));
664 fputc (',', asmfile
);
665 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
666 tree_low_cst (DECL_SIZE (tem
), 1));
667 fputc (';', asmfile
);
674 /* Subroutine of `dbxout_type_methods'. Output debug info about the
675 method described DECL. DEBUG_NAME is an encoding of the method's
676 type signature. ??? We may be able to do without DEBUG_NAME altogether
680 dbxout_type_method_1 (decl
, debug_name
)
682 const char *debug_name
;
686 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
688 else /* it's a METHOD_TYPE. */
690 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
691 /* A for normal functions.
692 B for `const' member functions.
693 C for `volatile' member functions.
694 D for `const volatile' member functions. */
695 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
697 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
700 if (DECL_VINDEX (decl
))
706 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
707 TREE_PRIVATE (decl
) ? '0'
708 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
709 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
710 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
712 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
714 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
715 tree_low_cst (DECL_VINDEX (decl
), 0));
716 fputc (';', asmfile
);
717 dbxout_type (DECL_CONTEXT (decl
), 0);
718 fprintf (asmfile
, ";");
723 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
727 dbxout_type_methods (type
)
730 /* C++: put out the method names and their parameter lists */
731 tree methods
= TYPE_METHODS (type
);
733 register tree fndecl
;
735 char formatted_type_identifier_length
[16];
736 register int type_identifier_length
;
738 if (methods
== NULL_TREE
)
741 type_encoding
= DECL_NAME (TYPE_NAME (type
));
744 /* C++: Template classes break some assumptions made by this code about
745 the class names, constructor names, and encodings for assembler
746 label names. For now, disable output of dbx info for them. */
748 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
749 /* This should use index. (mrs) */
750 while (*ptr
&& *ptr
!= '<') ptr
++;
761 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
763 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
765 if (TREE_CODE (methods
) != TREE_VEC
)
767 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
768 fndecl
= TREE_VEC_ELT (methods
, 0);
770 fndecl
= TREE_VEC_ELT (methods
, 1);
776 /* Group together all the methods for the same operation.
777 These differ in the types of the arguments. */
778 for (last
= NULL_TREE
;
779 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
780 fndecl
= TREE_CHAIN (fndecl
))
781 /* Output the name of the field (after overloading), as
782 well as the name of the field before overloading, along
783 with its parameter list */
785 /* This is the "mangled" name of the method.
786 It encodes the argument types. */
787 const char *debug_name
;
789 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
790 include TEMPLATE_DECLs.) The debugger doesn't know what
791 to do with such entities anyhow. */
792 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
796 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
802 /* Also ignore abstract methods; those are only interesting to
803 the DWARF backends. */
804 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
807 /* Redundantly output the plain name, since that's what gdb
811 tree name
= DECL_NAME (fndecl
);
812 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
813 CHARS (IDENTIFIER_LENGTH (name
) + 2);
817 dbxout_type (TREE_TYPE (fndecl
), 0);
819 dbxout_type_method_1 (fndecl
, debug_name
);
829 /* Emit a "range" type specification, which has the form:
830 "r<index type>;<lower bound>;<upper bound>;".
831 TYPE is an INTEGER_TYPE. */
834 dbxout_range_type (type
)
837 fprintf (asmfile
, "r");
838 if (TREE_TYPE (type
))
839 dbxout_type (TREE_TYPE (type
), 0);
840 else if (TREE_CODE (type
) != INTEGER_TYPE
)
841 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
844 /* Traditionally, we made sure 'int' was type 1, and builtin types
845 were defined to be sub-ranges of int. Unfortunately, this
846 does not allow us to distinguish true sub-ranges from integer
847 types. So, instead we define integer (non-sub-range) types as
848 sub-ranges of themselves. This matters for Chill. If this isn't
849 a subrange type, then we want to define it in terms of itself.
850 However, in C, this may be an anonymous integer type, and we don't
851 want to emit debug info referring to it. Just calling
852 dbxout_type_index won't work anyways, because the type hasn't been
853 defined yet. We make this work for both cases by checked to see
854 whether this is a defined type, referring to it if it is, and using
856 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
857 dbxout_type_index (type
);
859 dbxout_type_index (integer_type_node
);
862 if (TYPE_MIN_VALUE (type
) != 0
863 && host_integerp (TYPE_MIN_VALUE (type
), 0))
865 fputc (';', asmfile
);
866 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
867 tree_low_cst (TYPE_MIN_VALUE (type
), 0));
870 fprintf (asmfile
, ";0");
872 if (TYPE_MAX_VALUE (type
) != 0
873 && host_integerp (TYPE_MAX_VALUE (type
), 0))
875 fputc (';', asmfile
);
876 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
877 tree_low_cst (TYPE_MAX_VALUE (type
), 0));
878 fputc (';', asmfile
);
881 fprintf (asmfile
, ";-1;");
884 /* Output a reference to a type. If the type has not yet been
885 described in the dbx output, output its definition now.
886 For a type already defined, just refer to its definition
887 using the type number.
889 If FULL is nonzero, and the type has been described only with
890 a forward-reference, output the definition now.
891 If FULL is zero in this case, just refer to the forward-reference
892 using the number previously allocated. */
895 dbxout_type (type
, full
)
900 static int anonymous_type_number
= 0;
902 if (TREE_CODE (type
) == VECTOR_TYPE
)
903 type
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
905 /* If there was an input error and we don't really have a type,
906 avoid crashing and write something that is at least valid
907 by assuming `int'. */
908 if (type
== error_mark_node
)
909 type
= integer_type_node
;
912 /* Try to find the "main variant" with the same name but not const
913 or volatile. (Since stabs does not distinguish const and volatile,
914 there is no need to make them separate types. But types with
915 different names are usefully distinguished.) */
917 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
918 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
919 && TYPE_NAME (tem
) == TYPE_NAME (type
))
925 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
926 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
930 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
932 /* Type has no dbx number assigned. Assign next available number. */
933 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
935 /* Make sure type vector is long enough to record about this type. */
937 if (next_type_number
== typevec_len
)
940 = (struct typeinfo
*) xrealloc (typevec
,
941 typevec_len
* 2 * sizeof typevec
[0]);
942 memset ((char *) (typevec
+ typevec_len
), 0,
943 typevec_len
* sizeof typevec
[0]);
948 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
949 = current_file
->file_number
;
950 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
951 = current_file
->next_type_number
++;
955 /* Output the number of this type, to refer to it. */
956 dbxout_type_index (type
);
958 #ifdef DBX_TYPE_DEFINED
959 if (DBX_TYPE_DEFINED (type
))
963 /* If this type's definition has been output or is now being output,
966 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
971 /* If we have already had a cross reference,
972 and either that's all we want or that's the best we could do,
973 don't repeat the cross reference.
974 Sun dbx crashes if we do. */
975 if (! full
|| !COMPLETE_TYPE_P (type
)
976 /* No way in DBX fmt to describe a variable size. */
977 || ! host_integerp (TYPE_SIZE (type
), 1))
985 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
986 leave the type-number completely undefined rather than output
987 a cross-reference. If we have already used GNU debug info extensions,
988 then it is OK to output a cross reference. This is necessary to get
989 proper C++ debug output. */
990 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
991 || TREE_CODE (type
) == QUAL_UNION_TYPE
992 || TREE_CODE (type
) == ENUMERAL_TYPE
)
993 && ! use_gnu_debug_info_extensions
)
994 /* We must use the same test here as we use twice below when deciding
995 whether to emit a cross-reference. */
996 if ((TYPE_NAME (type
) != 0
997 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
998 && DECL_IGNORED_P (TYPE_NAME (type
)))
1000 || !COMPLETE_TYPE_P (type
)
1001 /* No way in DBX fmt to describe a variable size. */
1002 || ! host_integerp (TYPE_SIZE (type
), 1))
1004 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1009 /* Output a definition now. */
1011 fprintf (asmfile
, "=");
1014 /* Mark it as defined, so that if it is self-referent
1015 we will not get into an infinite recursion of definitions. */
1017 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1019 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1020 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1022 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1026 switch (TREE_CODE (type
))
1030 /* For a void type, just define it as itself; ie, "5=5".
1031 This makes us consider it defined
1032 without saying what it is. The debugger will make it
1033 a void type when the reference is seen, and nothing will
1034 ever override that default. */
1035 dbxout_type_index (type
);
1039 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1041 /* Output the type `char' as a subrange of itself!
1042 I don't understand this definition, just copied it
1043 from the output of pcc.
1044 This used to use `r2' explicitly and we used to
1045 take care to make sure that `char' was type number 2. */
1046 fprintf (asmfile
, "r");
1047 dbxout_type_index (type
);
1048 fprintf (asmfile
, ";0;127;");
1051 /* If this is a subtype of another integer type, always prefer to
1052 write it as a subtype. */
1053 else if (TREE_TYPE (type
) != 0
1054 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1055 dbxout_range_type (type
);
1059 /* If the size is non-standard, say what it is if we can use
1062 if (use_gnu_debug_info_extensions
1063 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1064 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1066 /* If we can use GDB extensions and the size is wider than a
1067 long (the size used by GDB to read them) or we may have
1068 trouble writing the bounds the usual way, write them in
1069 octal. Note the test is for the *target's* size of "long",
1070 not that of the host. The host test is just to make sure we
1071 can write it out in case the host wide int is narrower than the
1074 /* For unsigned types, we use octal if they are the same size or
1075 larger. This is because we print the bounds as signed decimal,
1076 and hence they can't span same size unsigned types. */
1078 if (use_gnu_debug_info_extensions
1079 && TYPE_MIN_VALUE (type
) != 0
1080 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1081 && TYPE_MAX_VALUE (type
) != 0
1082 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1083 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1084 || ((TYPE_PRECISION (type
)
1085 == TYPE_PRECISION (integer_type_node
))
1086 && TREE_UNSIGNED (type
))
1087 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1088 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1089 && TREE_UNSIGNED (type
))))
1091 fprintf (asmfile
, "r");
1092 dbxout_type_index (type
);
1093 fprintf (asmfile
, ";");
1094 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1095 fprintf (asmfile
, ";");
1096 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1097 fprintf (asmfile
, ";");
1101 /* Output other integer types as subranges of `int'. */
1102 dbxout_range_type (type
);
1109 /* This used to say `r1' and we used to take care
1110 to make sure that `int' was type number 1. */
1111 fprintf (asmfile
, "r");
1112 dbxout_type_index (integer_type_node
);
1113 fputc (';', asmfile
);
1114 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1115 fputs (";0;", asmfile
);
1120 if (use_gnu_debug_info_extensions
)
1122 fputs ("@s", asmfile
);
1123 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1124 BITS_PER_UNIT
* int_size_in_bytes (type
));
1125 fputs (";-20;", asmfile
);
1129 /* Output the type `char' as a subrange of itself.
1130 That is what pcc seems to do. */
1131 fprintf (asmfile
, "r");
1132 dbxout_type_index (char_type_node
);
1133 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1139 if (use_gnu_debug_info_extensions
)
1141 fputs ("@s", asmfile
);
1142 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1143 BITS_PER_UNIT
* int_size_in_bytes (type
));
1144 fputs (";-16;", asmfile
);
1146 else /* Define as enumeral type (False, True) */
1147 fprintf (asmfile
, "eFalse:0,True:1,;");
1152 putc ('d', asmfile
);
1154 dbxout_type (TREE_TYPE (type
), 0);
1158 /* Differs from the REAL_TYPE by its new data type number */
1160 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1162 fprintf (asmfile
, "r");
1163 dbxout_type_index (type
);
1164 fputc (';', asmfile
);
1165 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1166 2 * int_size_in_bytes (TREE_TYPE (type
)));
1167 fputs (";0;", asmfile
);
1168 CHARS (12); /* The number is probably incorrect here. */
1172 /* Output a complex integer type as a structure,
1173 pending some other way to do it. */
1174 fputc ('s', asmfile
);
1175 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1177 fprintf (asmfile
, "real:");
1179 dbxout_type (TREE_TYPE (type
), 0);
1180 fprintf (asmfile
, ",%d,%d;",
1181 0, TYPE_PRECISION (TREE_TYPE (type
)));
1183 fprintf (asmfile
, "imag:");
1185 dbxout_type (TREE_TYPE (type
), 0);
1186 fprintf (asmfile
, ",%d,%d;;",
1187 TYPE_PRECISION (TREE_TYPE (type
)),
1188 TYPE_PRECISION (TREE_TYPE (type
)));
1194 if (use_gnu_debug_info_extensions
)
1196 have_used_extensions
= 1;
1197 fputs ("@s", asmfile
);
1198 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1199 BITS_PER_UNIT
* int_size_in_bytes (type
));
1200 fputc (';', asmfile
);
1201 /* Check if a bitstring type, which in Chill is
1202 different from a [power]set. */
1203 if (TYPE_STRING_FLAG (type
))
1204 fprintf (asmfile
, "@S;");
1206 putc ('S', asmfile
);
1208 dbxout_type (TYPE_DOMAIN (type
), 0);
1212 /* Make arrays of packed bits look like bitstrings for chill. */
1213 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1215 have_used_extensions
= 1;
1216 fputs ("@s", asmfile
);
1217 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1218 BITS_PER_UNIT
* int_size_in_bytes (type
));
1219 fputc (';', asmfile
);
1220 fprintf (asmfile
, "@S;");
1221 putc ('S', asmfile
);
1223 dbxout_type (TYPE_DOMAIN (type
), 0);
1226 /* Output "a" followed by a range type definition
1227 for the index type of the array
1228 followed by a reference to the target-type.
1229 ar1;0;N;M for a C array of type M and size N+1. */
1230 /* Check if a character string type, which in Chill is
1231 different from an array of characters. */
1232 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1234 have_used_extensions
= 1;
1235 fprintf (asmfile
, "@S;");
1237 tem
= TYPE_DOMAIN (type
);
1240 fprintf (asmfile
, "ar");
1241 dbxout_type_index (integer_type_node
);
1242 fprintf (asmfile
, ";0;-1;");
1246 fprintf (asmfile
, "a");
1247 dbxout_range_type (tem
);
1250 dbxout_type (TREE_TYPE (type
), 0);
1255 case QUAL_UNION_TYPE
:
1257 int i
, n_baseclasses
= 0;
1259 if (TYPE_BINFO (type
) != 0
1260 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1261 && TYPE_BINFO_BASETYPES (type
) != 0)
1262 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1264 /* Output a structure type. We must use the same test here as we
1265 use in the DBX_NO_XREFS case above. */
1266 if ((TYPE_NAME (type
) != 0
1267 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1268 && DECL_IGNORED_P (TYPE_NAME (type
)))
1270 || !COMPLETE_TYPE_P (type
)
1271 /* No way in DBX fmt to describe a variable size. */
1272 || ! host_integerp (TYPE_SIZE (type
), 1))
1274 /* If the type is just a cross reference, output one
1275 and mark the type as partially described.
1276 If it later becomes defined, we will output
1277 its real definition.
1278 If the type has a name, don't nest its definition within
1279 another type's definition; instead, output an xref
1280 and let the definition come when the name is defined. */
1281 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1283 #if 0 /* This assertion is legitimately false in C++. */
1284 /* We shouldn't be outputting a reference to a type before its
1285 definition unless the type has a tag name.
1286 A typedef name without a tag name should be impossible. */
1287 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1290 if (TYPE_NAME (type
) != 0)
1291 dbxout_type_name (type
);
1293 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1294 fprintf (asmfile
, ":");
1295 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1299 /* Identify record or union, and print its size. */
1300 fputc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1301 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1302 int_size_in_bytes (type
));
1304 if (use_gnu_debug_info_extensions
)
1308 have_used_extensions
= 1;
1309 fprintf (asmfile
, "!%d,", n_baseclasses
);
1313 for (i
= 0; i
< n_baseclasses
; i
++)
1315 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1317 if (use_gnu_debug_info_extensions
)
1319 have_used_extensions
= 1;
1320 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1321 putc (TREE_VIA_PUBLIC (child
) ? '2' : '0', asmfile
);
1322 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1323 (tree_low_cst (BINFO_OFFSET (child
), 0)
1325 fputc (',', asmfile
);
1327 dbxout_type (BINFO_TYPE (child
), 0);
1328 putc (';', asmfile
);
1332 /* Print out the base class information with fields
1333 which have the same names at the types they hold. */
1334 dbxout_type_name (BINFO_TYPE (child
));
1335 putc (':', asmfile
);
1336 dbxout_type (BINFO_TYPE (child
), full
);
1337 fputc (',', asmfile
);
1338 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1339 tree_low_cst (BINFO_OFFSET (child
), 0)
1341 fputc (',', asmfile
);
1342 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1343 (tree_low_cst (DECL_SIZE (TYPE_NAME
1344 (BINFO_TYPE (child
))), 0)
1346 fputc (';', asmfile
);
1354 /* Write out the field declarations. */
1355 dbxout_type_fields (type
);
1356 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1358 have_used_extensions
= 1;
1359 dbxout_type_methods (type
);
1362 putc (';', asmfile
);
1364 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1365 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1366 && TYPE_VFIELD (type
))
1368 have_used_extensions
= 1;
1370 /* Tell GDB+ that it may keep reading. */
1371 putc ('~', asmfile
);
1373 /* We need to write out info about what field this class
1374 uses as its "main" vtable pointer field, because if this
1375 field is inherited from a base class, GDB cannot necessarily
1376 figure out which field it's using in time. */
1377 if (TYPE_VFIELD (type
))
1379 putc ('%', asmfile
);
1380 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1382 putc (';', asmfile
);
1388 /* We must use the same test here as we use in the DBX_NO_XREFS case
1389 above. We simplify it a bit since an enum will never have a variable
1391 if ((TYPE_NAME (type
) != 0
1392 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1393 && DECL_IGNORED_P (TYPE_NAME (type
)))
1395 || !COMPLETE_TYPE_P (type
))
1397 fprintf (asmfile
, "xe");
1399 dbxout_type_name (type
);
1400 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1401 fprintf (asmfile
, ":");
1404 #ifdef DBX_OUTPUT_ENUM
1405 DBX_OUTPUT_ENUM (asmfile
, type
);
1407 if (use_gnu_debug_info_extensions
1408 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1409 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1410 putc ('e', asmfile
);
1412 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1414 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1415 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1416 fprintf (asmfile
, HOST_WIDE_INT_PRINT_UNSIGNED
,
1417 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1418 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1419 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1420 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1421 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1423 print_int_cst_octal (TREE_VALUE (tem
));
1424 fprintf (asmfile
, ",");
1425 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)));
1426 if (TREE_CHAIN (tem
) != 0)
1431 putc (';', asmfile
);
1437 putc ('*', asmfile
);
1439 dbxout_type (TREE_TYPE (type
), 0);
1443 if (use_gnu_debug_info_extensions
)
1445 have_used_extensions
= 1;
1446 putc ('#', asmfile
);
1449 /* Write the argument types out longhand. */
1450 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1451 putc (',', asmfile
);
1453 dbxout_type (TREE_TYPE (type
), 0);
1454 dbxout_args (TYPE_ARG_TYPES (type
));
1455 putc (';', asmfile
);
1460 /* Treat it as a function type. */
1461 dbxout_type (TREE_TYPE (type
), 0);
1466 if (use_gnu_debug_info_extensions
)
1468 have_used_extensions
= 1;
1469 putc ('@', asmfile
);
1471 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1472 putc (',', asmfile
);
1474 dbxout_type (TREE_TYPE (type
), 0);
1478 /* Should print as an int, because it is really
1480 dbxout_type (integer_type_node
, 0);
1484 case REFERENCE_TYPE
:
1485 if (use_gnu_debug_info_extensions
)
1486 have_used_extensions
= 1;
1487 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1489 dbxout_type (TREE_TYPE (type
), 0);
1493 putc ('f', asmfile
);
1495 dbxout_type (TREE_TYPE (type
), 0);
1503 /* Print the value of integer constant C, in octal,
1504 handling double precision. */
1507 print_int_cst_octal (c
)
1510 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1511 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1512 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1513 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1515 /* GDB wants constants with no extra leading "1" bits, so
1516 we need to remove any sign-extension that might be
1518 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1520 else if (width
> HOST_BITS_PER_WIDE_INT
)
1521 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1522 else if (width
== HOST_BITS_PER_WIDE_INT
)
1525 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1527 fprintf (asmfile
, "0");
1531 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1532 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1536 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1537 unsigned HOST_WIDE_INT middle
1538 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1539 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1540 unsigned HOST_WIDE_INT end
1541 = low
& (((unsigned HOST_WIDE_INT
) 1
1542 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1545 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1546 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1551 print_octal (value
, digits
)
1552 unsigned HOST_WIDE_INT value
;
1557 for (i
= digits
- 1; i
>= 0; i
--)
1558 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1561 /* Output the name of type TYPE, with no punctuation.
1562 Such names can be set up either by typedef declarations
1563 or by struct, enum and union tags. */
1566 dbxout_type_name (type
)
1570 if (TYPE_NAME (type
) == 0)
1572 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1574 t
= TYPE_NAME (type
);
1576 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1578 t
= DECL_NAME (TYPE_NAME (type
));
1583 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1584 CHARS (IDENTIFIER_LENGTH (t
));
1587 /* Output a .stabs for the symbol defined by DECL,
1588 which must be a ..._DECL node in the normal namespace.
1589 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1590 LOCAL is nonzero if the scope is less than the entire file.
1591 Return 1 if a stabs might have been emitted. */
1594 dbxout_symbol (decl
, local
)
1596 int local ATTRIBUTE_UNUSED
;
1598 tree type
= TREE_TYPE (decl
);
1599 tree context
= NULL_TREE
;
1602 /* Cast avoids warning in old compilers. */
1603 current_sym_code
= (STAB_CODE_TYPE
) 0;
1604 current_sym_value
= 0;
1605 current_sym_addr
= 0;
1607 /* Ignore nameless syms, but don't ignore type tags. */
1609 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1610 || DECL_IGNORED_P (decl
))
1613 dbxout_prepare_symbol (decl
);
1615 /* The output will always start with the symbol name,
1616 so always count that in the length-output-so-far. */
1618 if (DECL_NAME (decl
) != 0)
1619 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1621 switch (TREE_CODE (decl
))
1624 /* Enum values are defined by defining the enum type. */
1628 if (DECL_RTL (decl
) == 0)
1630 if (DECL_EXTERNAL (decl
))
1632 /* Don't mention a nested function under its parent. */
1633 context
= decl_function_context (decl
);
1634 if (context
== current_function_decl
)
1636 if (GET_CODE (DECL_RTL (decl
)) != MEM
1637 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1641 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
1642 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1643 TREE_PUBLIC (decl
) ? 'F' : 'f');
1646 current_sym_code
= N_FUN
;
1647 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1649 if (TREE_TYPE (type
))
1650 dbxout_type (TREE_TYPE (type
), 0);
1652 dbxout_type (void_type_node
, 0);
1654 /* For a nested function, when that function is compiled,
1655 mention the containing function name
1656 as well as (since dbx wants it) our own assembler-name. */
1658 fprintf (asmfile
, ",%s,%s",
1659 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1660 IDENTIFIER_POINTER (DECL_NAME (context
)));
1662 dbxout_finish_symbol (decl
);
1667 /* This seems all wrong. Outputting most kinds of types gives no name
1668 at all. A true definition gives no name; a cross-ref for a
1669 structure can give the tag name, but not a type name.
1670 It seems that no typedef name is defined by outputting a type. */
1672 /* If this typedef name was defined by outputting the type,
1673 don't duplicate it. */
1674 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1675 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1678 /* Don't output the same typedef twice.
1679 And don't output what language-specific stuff doesn't want output. */
1680 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1689 if (DECL_NAME (decl
))
1691 /* Nonzero means we must output a tag as well as a typedef. */
1694 /* Handle the case of a C++ structure or union
1695 where the TYPE_NAME is a TYPE_DECL
1696 which gives both a typedef name and a tag. */
1697 /* dbx requires the tag first and the typedef second. */
1698 if ((TREE_CODE (type
) == RECORD_TYPE
1699 || TREE_CODE (type
) == UNION_TYPE
1700 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1701 && TYPE_NAME (type
) == decl
1702 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1703 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1704 /* Distinguish the implicit typedefs of C++
1705 from explicit ones that might be found in C. */
1706 && DECL_ARTIFICIAL (decl
)
1707 /* Do not generate a tag for records of variable size,
1708 since this type can not be properly described in the
1709 DBX format, and it confuses some tools such as objdump. */
1710 && host_integerp (TYPE_SIZE (type
), 1))
1712 tree name
= TYPE_NAME (type
);
1713 if (TREE_CODE (name
) == TYPE_DECL
)
1714 name
= DECL_NAME (name
);
1716 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1717 current_sym_value
= 0;
1718 current_sym_addr
= 0;
1719 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1721 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1722 IDENTIFIER_POINTER (name
));
1723 dbxout_type (type
, 1);
1724 dbxout_finish_symbol (NULL_TREE
);
1727 /* Output typedef name. */
1728 fprintf (asmfile
, "%s\"%s:", ASM_STABS_OP
,
1729 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1731 /* Short cut way to output a tag also. */
1732 if ((TREE_CODE (type
) == RECORD_TYPE
1733 || TREE_CODE (type
) == UNION_TYPE
1734 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1735 && TYPE_NAME (type
) == decl
1736 /* Distinguish the implicit typedefs of C++
1737 from explicit ones that might be found in C. */
1738 && DECL_ARTIFICIAL (decl
))
1740 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1742 putc ('T', asmfile
);
1743 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1745 #if 0 /* Now we generate the tag for this case up above. */
1751 putc ('t', asmfile
);
1752 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1754 dbxout_type (type
, 1);
1755 dbxout_finish_symbol (decl
);
1759 /* Don't output a tag if this is an incomplete type. This prevents
1760 the sun4 Sun OS 4.x dbx from crashing. */
1762 if (tag_needed
&& TYPE_NAME (type
) != 0
1763 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1764 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1765 && COMPLETE_TYPE_P (type
)
1766 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1768 /* For a TYPE_DECL with no name, but the type has a name,
1770 This is what represents `struct foo' with no typedef. */
1771 /* In C++, the name of a type is the corresponding typedef.
1772 In C, it is an IDENTIFIER_NODE. */
1773 tree name
= TYPE_NAME (type
);
1774 if (TREE_CODE (name
) == TYPE_DECL
)
1775 name
= DECL_NAME (name
);
1777 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1778 current_sym_value
= 0;
1779 current_sym_addr
= 0;
1780 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1782 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1783 IDENTIFIER_POINTER (name
));
1784 dbxout_type (type
, 1);
1785 dbxout_finish_symbol (NULL_TREE
);
1789 /* If an enum type has no name, it cannot be referred to,
1790 but we must output it anyway, since the enumeration constants
1791 can be referred to. */
1792 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1794 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1795 current_sym_value
= 0;
1796 current_sym_addr
= 0;
1797 current_sym_nchars
= 2;
1799 /* Some debuggers fail when given NULL names, so give this a
1800 harmless name of ` '. */
1801 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
1802 dbxout_type (type
, 1);
1803 dbxout_finish_symbol (NULL_TREE
);
1806 /* Prevent duplicate output of a typedef. */
1807 TREE_ASM_WRITTEN (decl
) = 1;
1812 /* Parm decls go in their own separate chains
1813 and are output by dbxout_reg_parms and dbxout_parms. */
1817 /* Named return value, treat like a VAR_DECL. */
1819 if (! DECL_RTL_SET_P (decl
))
1821 /* Don't mention a variable that is external.
1822 Let the file that defines it describe it. */
1823 if (DECL_EXTERNAL (decl
))
1826 /* If the variable is really a constant
1827 and not written in memory, inform the debugger. */
1828 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
1829 && DECL_INITIAL (decl
) != 0
1830 && host_integerp (DECL_INITIAL (decl
), 0)
1831 && ! TREE_ASM_WRITTEN (decl
)
1832 && (DECL_CONTEXT (decl
) == NULL_TREE
1833 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
1835 if (TREE_PUBLIC (decl
) == 0)
1837 /* The sun4 assembler does not grok this. */
1838 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
1840 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
1841 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
1843 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
1844 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1845 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
1847 fprintf (asmfile
, "%s\"%s:c=i", ASM_STABS_OP
, name
);
1849 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
1850 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
1854 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
1856 /* don't know how to do this yet. */
1860 /* else it is something we handle like a normal variable. */
1863 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
1864 #ifdef LEAF_REG_REMAP
1865 if (current_function_uses_only_leaf_regs
)
1866 leaf_renumber_regs_insn (DECL_RTL (decl
));
1869 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
1878 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1879 Add SUFFIX to its name, if SUFFIX is not 0.
1880 Describe the variable as residing in HOME
1881 (usually HOME is DECL_RTL (DECL), but not always).
1882 Returns 1 if the stab was really emitted. */
1885 dbxout_symbol_location (decl
, type
, suffix
, home
)
1893 /* Don't mention a variable at all
1894 if it was completely optimized into nothingness.
1896 If the decl was from an inline function, then its rtl
1897 is not identically the rtl that was used in this
1898 particular compilation. */
1899 if (GET_CODE (home
) == REG
)
1901 regno
= REGNO (home
);
1902 if (regno
>= FIRST_PSEUDO_REGISTER
)
1905 else if (GET_CODE (home
) == SUBREG
)
1909 while (GET_CODE (value
) == SUBREG
)
1910 value
= SUBREG_REG (value
);
1911 if (GET_CODE (value
) == REG
)
1913 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
1916 regno
= REGNO (alter_subreg (home
));
1919 /* The kind-of-variable letter depends on where
1920 the variable is and on the scope of its name:
1921 G and N_GSYM for static storage and global scope,
1922 S for static storage and file scope,
1923 V for static storage and local scope,
1924 for those two, use N_LCSYM if data is in bss segment,
1925 N_STSYM if in data segment, N_FUN otherwise.
1926 (We used N_FUN originally, then changed to N_STSYM
1927 to please GDB. However, it seems that confused ld.
1928 Now GDB has been fixed to like N_FUN, says Kingdon.)
1929 no letter at all, and N_LSYM, for auto variable,
1930 r and N_RSYM for register variable. */
1932 if (GET_CODE (home
) == MEM
1933 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
1935 if (TREE_PUBLIC (decl
))
1938 current_sym_code
= N_GSYM
;
1942 current_sym_addr
= XEXP (home
, 0);
1944 letter
= decl_function_context (decl
) ? 'V' : 'S';
1946 /* This should be the same condition as in assemble_variable, but
1947 we don't have access to dont_output_data here. So, instead,
1948 we rely on the fact that error_mark_node initializers always
1949 end up in bss for C++ and never end up in bss for C. */
1950 if (DECL_INITIAL (decl
) == 0
1951 || (!strcmp (lang_identify (), "cplusplus")
1952 && DECL_INITIAL (decl
) == error_mark_node
))
1953 current_sym_code
= N_LCSYM
;
1954 else if (DECL_IN_TEXT_SECTION (decl
))
1955 /* This is not quite right, but it's the closest
1956 of all the codes that Unix defines. */
1957 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
1960 /* Ultrix `as' seems to need this. */
1961 #ifdef DBX_STATIC_STAB_DATA_SECTION
1964 current_sym_code
= N_STSYM
;
1968 else if (regno
>= 0)
1971 current_sym_code
= N_RSYM
;
1972 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
1974 else if (GET_CODE (home
) == MEM
1975 && (GET_CODE (XEXP (home
, 0)) == MEM
1976 || (GET_CODE (XEXP (home
, 0)) == REG
1977 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
1978 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
1979 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
1980 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
1983 /* If the value is indirect by memory or by a register
1984 that isn't the frame pointer
1985 then it means the object is variable-sized and address through
1986 that register or stack slot. DBX has no way to represent this
1987 so all we can do is output the variable as a pointer.
1988 If it's not a parameter, ignore it.
1989 (VAR_DECLs like this can be made by integrate.c.) */
1991 if (GET_CODE (XEXP (home
, 0)) == REG
)
1994 current_sym_code
= N_RSYM
;
1995 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
1999 current_sym_code
= N_LSYM
;
2000 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2001 We want the value of that CONST_INT. */
2003 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2006 /* Effectively do build_pointer_type, but don't cache this type,
2007 since it might be temporary whereas the type it points to
2008 might have been saved for inlining. */
2009 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2010 type
= make_node (POINTER_TYPE
);
2011 TREE_TYPE (type
) = TREE_TYPE (decl
);
2013 else if (GET_CODE (home
) == MEM
2014 && GET_CODE (XEXP (home
, 0)) == REG
)
2016 current_sym_code
= N_LSYM
;
2017 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2019 else if (GET_CODE (home
) == MEM
2020 && GET_CODE (XEXP (home
, 0)) == PLUS
2021 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2023 current_sym_code
= N_LSYM
;
2024 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2025 We want the value of that CONST_INT. */
2026 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2028 else if (GET_CODE (home
) == MEM
2029 && GET_CODE (XEXP (home
, 0)) == CONST
)
2031 /* Handle an obscure case which can arise when optimizing and
2032 when there are few available registers. (This is *always*
2033 the case for i386/i486 targets). The RTL looks like
2034 (MEM (CONST ...)) even though this variable is a local `auto'
2035 or a local `register' variable. In effect, what has happened
2036 is that the reload pass has seen that all assignments and
2037 references for one such a local variable can be replaced by
2038 equivalent assignments and references to some static storage
2039 variable, thereby avoiding the need for a register. In such
2040 cases we're forced to lie to debuggers and tell them that
2041 this variable was itself `static'. */
2042 current_sym_code
= N_LCSYM
;
2044 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2046 else if (GET_CODE (home
) == CONCAT
)
2050 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2051 for example), then there is no easy way to figure out
2052 what SUBTYPE should be. So, we give up. */
2053 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2056 subtype
= TREE_TYPE (type
);
2058 /* If the variable's storage is in two parts,
2059 output each as a separate stab with a modified name. */
2060 if (WORDS_BIG_ENDIAN
)
2061 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2063 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2065 /* Cast avoids warning in old compilers. */
2066 current_sym_code
= (STAB_CODE_TYPE
) 0;
2067 current_sym_value
= 0;
2068 current_sym_addr
= 0;
2069 dbxout_prepare_symbol (decl
);
2071 if (WORDS_BIG_ENDIAN
)
2072 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2074 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2078 /* Address might be a MEM, when DECL is a variable-sized object.
2079 Or it might be const0_rtx, meaning previous passes
2080 want us to ignore this variable. */
2083 /* Ok, start a symtab entry and output the variable name. */
2086 #ifdef DBX_STATIC_BLOCK_START
2087 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2090 dbxout_symbol_name (decl
, suffix
, letter
);
2091 dbxout_type (type
, 0);
2092 dbxout_finish_symbol (decl
);
2094 #ifdef DBX_STATIC_BLOCK_END
2095 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2100 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2101 Then output LETTER to indicate the kind of location the symbol has. */
2104 dbxout_symbol_name (decl
, suffix
, letter
)
2111 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2112 /* One slight hitch: if this is a VAR_DECL which is a static
2113 class member, we must put out the mangled name instead of the
2114 DECL_NAME. Note also that static member (variable) names DO NOT begin
2115 with underscores in .stabs directives. */
2116 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2118 /* ...but if we're function-local, we don't want to include the junk
2119 added by ASM_FORMAT_PRIVATE_NAME. */
2120 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2124 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2125 (suffix
? suffix
: ""));
2127 if (letter
) putc (letter
, asmfile
);
2131 dbxout_prepare_symbol (decl
)
2132 tree decl ATTRIBUTE_UNUSED
;
2135 const char *filename
= DECL_SOURCE_FILE (decl
);
2137 dbxout_source_file (asmfile
, filename
);
2142 dbxout_finish_symbol (sym
)
2145 #ifdef DBX_FINISH_SYMBOL
2146 DBX_FINISH_SYMBOL (sym
);
2149 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2150 line
= DECL_SOURCE_LINE (sym
);
2152 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2153 if (current_sym_addr
)
2154 output_addr_const (asmfile
, current_sym_addr
);
2156 fprintf (asmfile
, "%d", current_sym_value
);
2157 putc ('\n', asmfile
);
2161 /* Output definitions of all the decls in a chain. Return non-zero if
2162 anything was output */
2171 result
+= dbxout_symbol (syms
, 1);
2172 syms
= TREE_CHAIN (syms
);
2177 /* The following two functions output definitions of function parameters.
2178 Each parameter gets a definition locating it in the parameter list.
2179 Each parameter that is a register variable gets a second definition
2180 locating it in the register.
2182 Printing or argument lists in gdb uses the definitions that
2183 locate in the parameter list. But reference to the variable in
2184 expressions uses preferentially the definition as a register. */
2186 /* Output definitions, referring to storage in the parmlist,
2187 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2190 dbxout_parms (parms
)
2193 for (; parms
; parms
= TREE_CHAIN (parms
))
2194 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2196 dbxout_prepare_symbol (parms
);
2198 /* Perform any necessary register eliminations on the parameter's rtl,
2199 so that the debugging output will be accurate. */
2200 DECL_INCOMING_RTL (parms
)
2201 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2202 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2203 #ifdef LEAF_REG_REMAP
2204 if (current_function_uses_only_leaf_regs
)
2206 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2207 leaf_renumber_regs_insn (DECL_RTL (parms
));
2211 if (PARM_PASSED_IN_MEMORY (parms
))
2213 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2215 /* ??? Here we assume that the parm address is indexed
2216 off the frame pointer or arg pointer.
2217 If that is not true, we produce meaningless results,
2218 but do not crash. */
2219 if (GET_CODE (addr
) == PLUS
2220 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2221 current_sym_value
= INTVAL (XEXP (addr
, 1));
2223 current_sym_value
= 0;
2225 current_sym_code
= N_PSYM
;
2226 current_sym_addr
= 0;
2229 if (DECL_NAME (parms
))
2231 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2233 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2234 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2235 DBX_MEMPARM_STABS_LETTER
);
2239 current_sym_nchars
= 8;
2240 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2241 DBX_MEMPARM_STABS_LETTER
);
2244 /* It is quite tempting to use:
2246 dbxout_type (TREE_TYPE (parms), 0);
2248 as the next statement, rather than using DECL_ARG_TYPE(), so
2249 that gcc reports the actual type of the parameter, rather
2250 than the promoted type. This certainly makes GDB's life
2251 easier, at least for some ports. The change is a bad idea
2252 however, since GDB expects to be able access the type without
2253 performing any conversions. So for example, if we were
2254 passing a float to an unprototyped function, gcc will store a
2255 double on the stack, but if we emit a stab saying the type is a
2256 float, then gdb will only read in a single value, and this will
2257 produce an erropneous value. */
2258 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2259 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2260 dbxout_finish_symbol (parms
);
2262 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2265 char regparm_letter
;
2267 /* Parm passed in registers and lives in registers or nowhere. */
2269 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2270 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2271 current_sym_addr
= 0;
2273 /* If parm lives in a register, use that register;
2274 pretend the parm was passed there. It would be more consistent
2275 to describe the register where the parm was passed,
2276 but in practice that register usually holds something else.
2278 If we use DECL_RTL, then we must use the declared type of
2279 the variable, not the type that it arrived in. */
2280 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2282 best_rtl
= DECL_RTL (parms
);
2283 parm_type
= TREE_TYPE (parms
);
2285 /* If the parm lives nowhere, use the register where it was
2286 passed. It is also better to use the declared type here. */
2289 best_rtl
= DECL_INCOMING_RTL (parms
);
2290 parm_type
= TREE_TYPE (parms
);
2292 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2295 if (DECL_NAME (parms
))
2297 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2298 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2299 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2304 current_sym_nchars
= 8;
2305 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2309 dbxout_type (parm_type
, 0);
2310 dbxout_finish_symbol (parms
);
2312 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2313 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2314 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2315 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2316 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2317 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2321 /* Parm was passed via invisible reference.
2322 That is, its address was passed in a register.
2323 Output it as if it lived in that register.
2324 The debugger will know from the type
2325 that it was actually passed by invisible reference. */
2327 char regparm_letter
;
2328 /* Parm passed in registers and lives in registers or nowhere. */
2330 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2331 if (use_gnu_debug_info_extensions
)
2332 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2334 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2336 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2337 If it is an unallocated pseudo-reg, then use the register where
2338 it was passed instead. */
2339 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2340 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2342 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2344 current_sym_addr
= 0;
2347 if (DECL_NAME (parms
))
2349 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2351 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2352 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2357 current_sym_nchars
= 8;
2358 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2362 dbxout_type (TREE_TYPE (parms
), 0);
2363 dbxout_finish_symbol (parms
);
2365 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2366 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2368 /* Parm was passed via invisible reference, with the reference
2369 living on the stack. DECL_RTL looks like
2370 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2371 could look like (MEM (MEM (REG))). */
2372 const char *decl_name
= (DECL_NAME (parms
)
2373 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2375 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2376 current_sym_value
= 0;
2379 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2380 current_sym_addr
= 0;
2383 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2384 dbxout_type (TREE_TYPE (parms
), 0);
2385 dbxout_finish_symbol (parms
);
2387 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2388 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2389 /* ??? A constant address for a parm can happen
2390 when the reg it lives in is equiv to a constant in memory.
2391 Should make this not happen, after 2.4. */
2392 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2394 /* Parm was passed in registers but lives on the stack. */
2396 current_sym_code
= N_PSYM
;
2397 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2398 in which case we want the value of that CONST_INT,
2400 in which case we use a value of zero. */
2401 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2402 current_sym_value
= 0;
2405 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2407 current_sym_addr
= 0;
2409 /* Make a big endian correction if the mode of the type of the
2410 parameter is not the same as the mode of the rtl. */
2411 if (BYTES_BIG_ENDIAN
2412 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2413 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2415 current_sym_value
+=
2416 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2417 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2421 if (DECL_NAME (parms
))
2424 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2426 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2427 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2428 DBX_MEMPARM_STABS_LETTER
);
2432 current_sym_nchars
= 8;
2433 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2434 DBX_MEMPARM_STABS_LETTER
);
2438 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2439 XEXP (DECL_RTL (parms
), 0));
2440 dbxout_type (TREE_TYPE (parms
), 0);
2441 dbxout_finish_symbol (parms
);
2446 /* Output definitions for the places where parms live during the function,
2447 when different from where they were passed, when the parms were passed
2450 It is not useful to do this for parms passed in registers
2451 that live during the function in different registers, because it is
2452 impossible to look in the passed register for the passed value,
2453 so we use the within-the-function register to begin with.
2455 PARMS is a chain of PARM_DECL nodes. */
2458 dbxout_reg_parms (parms
)
2461 for (; parms
; parms
= TREE_CHAIN (parms
))
2462 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2464 dbxout_prepare_symbol (parms
);
2466 /* Report parms that live in registers during the function
2467 but were passed in memory. */
2468 if (GET_CODE (DECL_RTL (parms
)) == REG
2469 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2470 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2471 0, DECL_RTL (parms
));
2472 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2473 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2474 0, DECL_RTL (parms
));
2475 /* Report parms that live in memory but not where they were passed. */
2476 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2477 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2478 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2479 0, DECL_RTL (parms
));
2483 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2484 output definitions of those names, in raw form */
2492 putc (',', asmfile
);
2493 dbxout_type (TREE_VALUE (args
), 0);
2495 args
= TREE_CHAIN (args
);
2499 /* Given a chain of ..._TYPE nodes,
2500 find those which have typedef names and output those names.
2501 This is to ensure those types get output. */
2504 dbxout_types (types
)
2505 register tree types
;
2509 if (TYPE_NAME (types
)
2510 && TREE_CODE (TYPE_NAME (types
)) == TYPE_DECL
2511 && ! TREE_ASM_WRITTEN (TYPE_NAME (types
)))
2512 dbxout_symbol (TYPE_NAME (types
), 1);
2513 types
= TREE_CHAIN (types
);
2517 /* Output everything about a symbol block (a BLOCK node
2518 that represents a scope level),
2519 including recursive output of contained blocks.
2521 BLOCK is the BLOCK node.
2522 DEPTH is its depth within containing symbol blocks.
2523 ARGS is usually zero; but for the outermost block of the
2524 body of a function, it is a chain of PARM_DECLs for the function parameters.
2525 We output definitions of all the register parms
2526 as if they were local variables of that block.
2528 If -g1 was used, we count blocks just the same, but output nothing
2529 except for the outermost block.
2531 Actually, BLOCK may be several blocks chained together.
2532 We handle them all in sequence. */
2535 dbxout_block (block
, depth
, args
)
2536 register tree block
;
2542 #if DBX_BLOCKS_FUNCTION_RELATIVE
2543 const char *begin_label
;
2544 if (current_function_func_begin_label
!= NULL_TREE
)
2545 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2547 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2552 /* Ignore blocks never expanded or otherwise marked as real. */
2553 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2557 #ifdef DBX_LBRAC_FIRST
2560 /* In dbx format, the syms of a block come before the N_LBRAC.
2561 If nothing is output, we don't need the N_LBRAC, either. */
2563 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2564 did_output
= dbxout_syms (BLOCK_VARS (block
));
2566 dbxout_reg_parms (args
);
2569 /* Now output an N_LBRAC symbol to represent the beginning of
2570 the block. Use the block's tree-walk order to generate
2571 the assembler symbols LBBn and LBEn
2572 that final will define around the code in this block. */
2573 if (depth
> 0 && did_output
)
2576 blocknum
= BLOCK_NUMBER (block
);
2577 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2579 if (BLOCK_HANDLER_BLOCK (block
))
2581 /* A catch block. Must precede N_LBRAC. */
2582 tree decl
= BLOCK_VARS (block
);
2585 #ifdef DBX_OUTPUT_CATCH
2586 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2588 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2589 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2590 assemble_name (asmfile
, buf
);
2591 fprintf (asmfile
, "\n");
2593 decl
= TREE_CHAIN (decl
);
2597 #ifdef DBX_OUTPUT_LBRAC
2598 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2600 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2601 assemble_name (asmfile
, buf
);
2602 #if DBX_BLOCKS_FUNCTION_RELATIVE
2603 fputc ('-', asmfile
);
2604 assemble_name (asmfile
, begin_label
);
2606 fprintf (asmfile
, "\n");
2610 #ifdef DBX_LBRAC_FIRST
2611 /* On some weird machines, the syms of a block
2612 come after the N_LBRAC. */
2613 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2614 dbxout_syms (BLOCK_VARS (block
));
2616 dbxout_reg_parms (args
);
2619 /* Output the subblocks. */
2620 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2622 /* Refer to the marker for the end of the block. */
2623 if (depth
> 0 && did_output
)
2626 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2627 #ifdef DBX_OUTPUT_RBRAC
2628 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2630 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2631 assemble_name (asmfile
, buf
);
2632 #if DBX_BLOCKS_FUNCTION_RELATIVE
2633 fputc ('-', asmfile
);
2634 assemble_name (asmfile
, begin_label
);
2636 fprintf (asmfile
, "\n");
2640 block
= BLOCK_CHAIN (block
);
2644 /* Output the information about a function and its arguments and result.
2645 Usually this follows the function's code,
2646 but on some systems, it comes before. */
2649 dbxout_really_begin_function (decl
)
2652 dbxout_symbol (decl
, 0);
2653 dbxout_parms (DECL_ARGUMENTS (decl
));
2654 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2655 dbxout_symbol (DECL_RESULT (decl
), 1);
2658 /* Called at beginning of output of function definition. */
2661 dbxout_begin_function (decl
)
2662 tree decl ATTRIBUTE_UNUSED
;
2664 #ifdef DBX_FUNCTION_FIRST
2665 dbxout_really_begin_function (decl
);
2669 /* Output dbx data for a function definition.
2670 This includes a definition of the function name itself (a symbol),
2671 definitions of the parameters (locating them in the parameter list)
2672 and then output the block that makes up the function's body
2673 (including all the auto variables of the function). */
2676 dbxout_function (decl
)
2679 #ifndef DBX_FUNCTION_FIRST
2680 dbxout_really_begin_function (decl
);
2682 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
2683 #ifdef DBX_OUTPUT_FUNCTION_END
2684 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
2686 #if defined(ASM_OUTPUT_SECTION_NAME)
2687 if (use_gnu_debug_info_extensions
2688 #if defined(NO_DBX_FUNCTION_END)
2689 && ! NO_DBX_FUNCTION_END
2692 dbxout_function_end ();
2695 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */