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 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"
81 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
87 #ifdef XCOFF_DEBUGGING_INFO
92 #define ASM_STABS_OP ".stabs"
96 #define ASM_STABN_OP ".stabn"
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 /* Nonzero means if the type has methods, only output debugging
129 information if methods are actually written to the asm file. This
130 optimization only works if the debugger can detect the special C++
133 #define MINIMAL_DEBUG 1
135 #ifdef NO_DOLLAR_IN_LABEL
136 #ifdef NO_DOT_IN_LABEL
138 #define MINIMAL_DEBUG 0
142 /* Typical USG systems don't have stab.h, and they also have
143 no use for DBX-format debugging info. */
145 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
147 static int flag_minimal_debug
= MINIMAL_DEBUG
;
149 /* Nonzero if we have actually used any of the GDB extensions
150 to the debugging format. The idea is that we use them for the
151 first time only if there's a strong reason, but once we have done that,
152 we use them whenever convenient. */
154 static int have_used_extensions
= 0;
156 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
157 for the N_SO filename stabs label. */
159 static int source_label_number
= 1;
161 #ifdef DEBUG_SYMS_TEXT
162 #define FORCE_TEXT text_section ();
167 /* If there is a system stab.h, use it. Otherwise, use our own. */
168 /* ??? This is supposed to describe the target's stab format, so using
169 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
170 when cross compiling. */
171 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
172 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
176 /* This is a GNU extension we need to reference in this file. */
183 #define STAB_CODE_TYPE enum __stab_debug_code
185 #define STAB_CODE_TYPE int
188 /* 1 if PARM is passed to this function in memory. */
190 #define PARM_PASSED_IN_MEMORY(PARM) \
191 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
193 /* A C expression for the integer offset value of an automatic variable
194 (N_LSYM) having address X (an RTX). */
195 #ifndef DEBUGGER_AUTO_OFFSET
196 #define DEBUGGER_AUTO_OFFSET(X) \
197 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
200 /* A C expression for the integer offset value of an argument (N_PSYM)
201 having address X (an RTX). The nominal offset is OFFSET. */
202 #ifndef DEBUGGER_ARG_OFFSET
203 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
206 /* Stream for writing to assembler file. */
208 static FILE *asmfile
;
210 /* Last source file name mentioned in a NOTE insn. */
212 static const char *lastfile
;
214 /* Current working directory. */
216 static const char *cwd
;
218 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
220 /* Structure recording information about a C data type.
221 The status element says whether we have yet output
222 the definition of the type. TYPE_XREF says we have
223 output it as a cross-reference only.
224 The file_number and type_number elements are used if DBX_USE_BINCL
229 enum typestatus status
;
236 /* Vector recording information about C data types.
237 When we first notice a data type (a tree node),
238 we assign it a number using next_type_number.
239 That is its index in this vector. */
241 struct typeinfo
*typevec
;
243 /* Number of elements of space allocated in `typevec'. */
245 static int typevec_len
;
247 /* In dbx output, each type gets a unique number.
248 This is the number for the next type output.
249 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
251 static int next_type_number
;
255 /* When using N_BINCL in dbx output, each type number is actually a
256 pair of the file number and the type number within the file.
257 This is a stack of input files. */
261 struct dbx_file
*next
;
263 int next_type_number
;
266 /* This is the top of the stack. */
268 static struct dbx_file
*current_file
;
270 /* This is the next file number to use. */
272 static int next_file_number
;
274 #endif /* DBX_USE_BINCL */
276 /* In dbx output, we must assign symbol-blocks id numbers
277 in the order in which their beginnings are encountered.
278 We output debugging info that refers to the beginning and
279 end of the ranges of code in each block
280 with assembler labels LBBn and LBEn, where n is the block number.
281 The labels are generated in final, which assigns numbers to the
282 blocks in the same way. */
284 static int next_block_number
;
286 /* These variables are for dbxout_symbol to communicate to
287 dbxout_finish_symbol.
288 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
289 current_sym_value and current_sym_addr are two ways to address the
290 value to store in the symtab entry.
291 current_sym_addr if nonzero represents the value as an rtx.
292 If that is zero, current_sym_value is used. This is used
293 when the value is an offset (such as for auto variables,
294 register variables and parms). */
296 static STAB_CODE_TYPE current_sym_code
;
297 static int current_sym_value
;
298 static rtx current_sym_addr
;
300 /* Number of chars of symbol-description generated so far for the
301 current symbol. Used by CHARS and CONTIN. */
303 static int current_sym_nchars
;
305 /* Report having output N chars of the current symbol-description. */
307 #define CHARS(N) (current_sym_nchars += (N))
309 /* Break the current symbol-description, generating a continuation,
310 if it has become long. */
312 #ifndef DBX_CONTIN_LENGTH
313 #define DBX_CONTIN_LENGTH 80
316 #if DBX_CONTIN_LENGTH > 0
318 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
323 #if defined(ASM_OUTPUT_SECTION_NAME)
324 static void dbxout_function_end
PARAMS ((void));
326 static void dbxout_typedefs
PARAMS ((tree
));
327 static void dbxout_type_index
PARAMS ((tree
));
328 #if DBX_CONTIN_LENGTH > 0
329 static void dbxout_continue
PARAMS ((void));
331 static void dbxout_type_fields
PARAMS ((tree
));
332 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
333 static void dbxout_type_methods
PARAMS ((tree
));
334 static void dbxout_range_type
PARAMS ((tree
));
335 static void dbxout_type
PARAMS ((tree
, int, int));
336 static void print_int_cst_octal
PARAMS ((tree
));
337 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
338 static void dbxout_type_name
PARAMS ((tree
));
339 static void dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
340 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
341 static void dbxout_prepare_symbol
PARAMS ((tree
));
342 static void dbxout_finish_symbol
PARAMS ((tree
));
343 static void dbxout_block
PARAMS ((tree
, int, tree
));
344 static void dbxout_really_begin_function
PARAMS ((tree
));
346 #if defined(ASM_OUTPUT_SECTION_NAME)
348 dbxout_function_end ()
350 static int scope_labelno
= 0;
351 char lscope_label_name
[100];
352 /* Convert Ltext into the appropriate format for local labels in case
353 the system doesn't insert underscores in front of user generated
355 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
356 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
359 /* By convention, GCC will mark the end of a function with an N_FUN
360 symbol and an empty string. */
361 fprintf (asmfile
, "%s \"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
362 assemble_name (asmfile
, lscope_label_name
);
363 fputc ('-', asmfile
);
364 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
365 fprintf (asmfile
, "\n");
367 #endif /* ! NO_DBX_FUNCTION_END */
369 /* At the beginning of compilation, start writing the symbol table.
370 Initialize `typevec' and output the standard data types of C. */
373 dbxout_init (asm_file
, input_file_name
, syms
)
375 const char *input_file_name
;
378 char ltext_label_name
[100];
383 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
385 /* Convert Ltext into the appropriate format for local labels in case
386 the system doesn't insert underscores in front of user generated
388 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
390 /* Put the current working directory in an N_SO symbol. */
391 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
392 but GDB always does. */
393 if (use_gnu_debug_info_extensions
)
396 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
398 char *wdslash
= xmalloc (strlen (cwd
) + sizeof (FILE_NAME_JOINER
));
399 sprintf (wdslash
, "%s%s", cwd
, FILE_NAME_JOINER
);
404 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
405 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
406 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
407 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
408 output_quoted_string (asmfile
, cwd
);
409 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
410 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
414 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
415 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
416 would give us an N_SOL, and we want an N_SO. */
417 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
418 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
419 /* We include outputting `Ltext:' here,
420 because that gives you a way to override it. */
421 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
422 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
423 output_quoted_string (asmfile
, input_file_name
);
424 fprintf (asmfile
, ",%d,0,0,%s\n",
425 N_SO
, <ext_label_name
[1]);
427 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
428 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
430 /* Possibly output something to inform GDB that this compilation was by
431 GCC. It's easier for GDB to parse it when after the N_SO's. This
432 is used in Solaris 2. */
433 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
434 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile
);
437 lastfile
= input_file_name
;
439 next_type_number
= 1;
440 next_block_number
= 2;
443 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
444 current_file
->next
= NULL
;
445 current_file
->file_number
= 0;
446 current_file
->next_type_number
= 1;
447 next_file_number
= 1;
450 /* Make sure that types `int' and `char' have numbers 1 and 2.
451 Definitions of other integer types will refer to those numbers.
452 (Actually it should no longer matter what their numbers are.
453 Also, if any types with tags have been defined, dbxout_symbol
454 will output them first, so the numbers won't be 1 and 2. That
455 happens in C++. So it's a good thing it should no longer matter). */
457 #ifdef DBX_OUTPUT_STANDARD_TYPES
458 DBX_OUTPUT_STANDARD_TYPES (syms
);
460 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
461 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
464 /* Get all permanent types that have typedef names,
465 and output them all, except for those already output. */
467 dbxout_typedefs (syms
);
469 ggc_add_string_root ((char **) &lastfile
, 1);
472 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
473 in the reverse order from that which is found in SYMS. */
476 dbxout_typedefs (syms
)
481 dbxout_typedefs (TREE_CHAIN (syms
));
482 if (TREE_CODE (syms
) == TYPE_DECL
)
484 tree type
= TREE_TYPE (syms
);
486 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
487 && TYPE_SIZE (type
) != NULL_TREE
488 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
489 dbxout_symbol (TYPE_NAME (type
), 0);
494 /* Change to reading from a new source file. Generate a N_BINCL stab. */
497 dbxout_start_new_source_file (filename
)
498 const char *filename ATTRIBUTE_UNUSED
;
501 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
503 n
->next
= current_file
;
504 n
->file_number
= next_file_number
++;
505 n
->next_type_number
= 1;
507 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
508 output_quoted_string (asmfile
, filename
);
509 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
513 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
516 dbxout_resume_previous_source_file ()
519 struct dbx_file
*next
;
521 fprintf (asmfile
, "%s %d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
522 next
= current_file
->next
;
528 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
531 dbxout_source_file (file
, filename
)
533 const char *filename
;
535 char ltext_label_name
[100];
537 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
539 #ifdef DBX_OUTPUT_SOURCE_FILENAME
540 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
542 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
543 source_label_number
);
544 fprintf (file
, "%s ", ASM_STABS_OP
);
545 output_quoted_string (file
, filename
);
546 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
547 if (current_function_decl
!= NULL_TREE
548 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
549 ; /* Don't change section amid function. */
552 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
553 source_label_number
++;
559 /* Output a line number symbol entry into output stream FILE,
560 for source file FILENAME and line number LINENO. */
563 dbxout_source_line (file
, filename
, lineno
)
565 const char *filename
;
568 dbxout_source_file (file
, filename
);
570 #ifdef ASM_OUTPUT_SOURCE_LINE
571 ASM_OUTPUT_SOURCE_LINE (file
, lineno
);
573 fprintf (file
, "\t%s %d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
577 /* At the end of compilation, finish writing the symbol table.
578 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
582 dbxout_finish (file
, filename
)
583 FILE *file ATTRIBUTE_UNUSED
;
584 const char *filename ATTRIBUTE_UNUSED
;
586 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
587 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file
, filename
);
588 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
591 /* Output the index of a type. */
594 dbxout_type_index (type
)
597 #ifndef DBX_USE_BINCL
598 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
601 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
602 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
607 #if DBX_CONTIN_LENGTH > 0
608 /* Continue a symbol-description that gets too big.
609 End one symbol table entry with a double-backslash
610 and start a new one, eventually producing something like
611 .stabs "start......\\",code,0,value
612 .stabs "...rest",code,0,value */
617 #ifdef DBX_CONTIN_CHAR
618 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
620 fprintf (asmfile
, "\\\\");
622 dbxout_finish_symbol (NULL_TREE
);
623 fprintf (asmfile
, "%s \"", ASM_STABS_OP
);
624 current_sym_nchars
= 0;
626 #endif /* DBX_CONTIN_LENGTH > 0 */
628 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
629 This must be a separate function because anonymous unions require
633 dbxout_type_fields (type
)
637 /* Output the name, type, position (in bits), size (in bits) of each
639 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
641 /* Omit here local type decls until we know how to support them. */
642 if (TREE_CODE (tem
) == TYPE_DECL
)
644 /* Omit fields whose position or size are variable. */
645 else if (TREE_CODE (tem
) == FIELD_DECL
646 && (TREE_CODE (DECL_FIELD_BITPOS (tem
)) != INTEGER_CST
647 || TREE_CODE (DECL_SIZE (tem
)) != INTEGER_CST
))
649 /* Omit here the nameless fields that are used to skip bits. */
650 else if (DECL_IGNORED_P (tem
))
652 else if (TREE_CODE (tem
) != CONST_DECL
)
654 /* Continue the line if necessary,
655 but not before the first field. */
656 if (tem
!= TYPE_FIELDS (type
))
661 if (use_gnu_debug_info_extensions
662 && flag_minimal_debug
663 && TREE_CODE (tem
) == FIELD_DECL
664 && DECL_VIRTUAL_P (tem
)
665 && DECL_ASSEMBLER_NAME (tem
))
667 have_used_extensions
= 1;
668 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem
)));
669 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
)), asmfile
);
670 dbxout_type (DECL_FCONTEXT (tem
), 0, 0);
671 fprintf (asmfile
, ":");
672 dbxout_type (TREE_TYPE (tem
), 0, 0);
673 fputc (',', asmfile
);
674 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
675 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
676 fputc (';', asmfile
);
682 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
683 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
687 fprintf (asmfile
, ":");
691 if (use_gnu_debug_info_extensions
692 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
693 || TREE_CODE (tem
) != FIELD_DECL
))
695 have_used_extensions
= 1;
697 putc ((TREE_PRIVATE (tem
) ? '0'
698 : TREE_PROTECTED (tem
) ? '1' : '2'),
703 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
704 && DECL_BIT_FIELD_TYPE (tem
))
705 ? DECL_BIT_FIELD_TYPE (tem
)
706 : TREE_TYPE (tem
), 0, 0);
708 if (TREE_CODE (tem
) == VAR_DECL
)
710 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
713 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
));
714 have_used_extensions
= 1;
715 fprintf (asmfile
, ":%s;", name
);
716 CHARS (strlen (name
));
720 /* If TEM is non-static, GDB won't understand it. */
721 fprintf (asmfile
, ",0,0;");
724 else if (TREE_CODE (DECL_FIELD_BITPOS (tem
)) == INTEGER_CST
)
726 fputc (',', asmfile
);
727 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
728 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
729 fputc (',', asmfile
);
730 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
731 TREE_INT_CST_LOW (DECL_SIZE (tem
)));
732 fputc (';', asmfile
);
739 /* Subroutine of `dbxout_type_methods'. Output debug info about the
740 method described DECL. DEBUG_NAME is an encoding of the method's
741 type signature. ??? We may be able to do without DEBUG_NAME altogether
745 dbxout_type_method_1 (decl
, debug_name
)
747 const char *debug_name
;
751 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
753 else /* it's a METHOD_TYPE. */
755 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
756 /* A for normal functions.
757 B for `const' member functions.
758 C for `volatile' member functions.
759 D for `const volatile' member functions. */
760 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
762 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
765 if (DECL_VINDEX (decl
))
771 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
772 TREE_PRIVATE (decl
) ? '0' : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
773 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
774 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
775 if (DECL_VINDEX (decl
))
777 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
778 TREE_INT_CST_LOW (DECL_VINDEX (decl
)));
779 fputc (';', asmfile
);
780 dbxout_type (DECL_CONTEXT (decl
), 0, 0);
781 fprintf (asmfile
, ";");
786 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
790 dbxout_type_methods (type
)
793 /* C++: put out the method names and their parameter lists */
794 tree methods
= TYPE_METHODS (type
);
796 register tree fndecl
;
798 char formatted_type_identifier_length
[16];
799 register int type_identifier_length
;
801 if (methods
== NULL_TREE
)
804 type_encoding
= DECL_NAME (TYPE_NAME (type
));
807 /* C++: Template classes break some assumptions made by this code about
808 the class names, constructor names, and encodings for assembler
809 label names. For now, disable output of dbx info for them. */
811 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
812 /* This should use index. (mrs) */
813 while (*ptr
&& *ptr
!= '<') ptr
++;
824 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
826 sprintf(formatted_type_identifier_length
, "%d", type_identifier_length
);
828 if (TREE_CODE (methods
) != TREE_VEC
)
830 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
831 fndecl
= TREE_VEC_ELT (methods
, 0);
833 fndecl
= TREE_VEC_ELT (methods
, 1);
837 tree name
= DECL_NAME (fndecl
);
840 /* Group together all the methods for the same operation.
841 These differ in the types of the arguments. */
842 for (last
= NULL_TREE
;
843 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
844 fndecl
= TREE_CHAIN (fndecl
))
845 /* Output the name of the field (after overloading), as
846 well as the name of the field before overloading, along
847 with its parameter list */
849 /* This is the "mangled" name of the method.
850 It encodes the argument types. */
851 const char *debug_name
=
852 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
853 int show_arg_types
= 0;
859 if (DECL_IGNORED_P (fndecl
))
862 if (flag_minimal_debug
)
866 /* We can't optimize a method which uses an anonymous
867 class, because the debugger will not be able to
868 associate the arbitrary class name with the actual
870 #ifndef NO_DOLLAR_IN_LABEL
875 if (strchr (debug_name
, marker
))
877 /* Detect ordinary methods because their mangled names
878 start with the operation name. */
879 else if (!strncmp (IDENTIFIER_POINTER (name
), debug_name
,
880 IDENTIFIER_LENGTH (name
)))
882 debug_name
+= IDENTIFIER_LENGTH (name
);
883 if (debug_name
[0] == '_' && debug_name
[1] == '_')
885 const char *method_name
= debug_name
+ 2;
886 const char *length_ptr
=
887 formatted_type_identifier_length
;
888 /* Get past const and volatile qualifiers. */
889 while (*method_name
== 'C' || *method_name
== 'V')
891 /* Skip digits for length of type_encoding. */
892 while (*method_name
== *length_ptr
&& *length_ptr
)
893 length_ptr
++, method_name
++;
894 if (! strncmp (method_name
,
895 IDENTIFIER_POINTER (type_encoding
),
896 type_identifier_length
))
897 method_name
+= type_identifier_length
;
898 debug_name
= method_name
;
901 /* Detect constructors by their style of name mangling. */
902 else if (debug_name
[0] == '_' && debug_name
[1] == '_')
904 const char *ctor_name
= debug_name
+ 2;
905 const char *length_ptr
= formatted_type_identifier_length
;
906 while (*ctor_name
== 'C' || *ctor_name
== 'V')
908 /* Skip digits for length of type_encoding. */
909 while (*ctor_name
== *length_ptr
&& *length_ptr
)
910 length_ptr
++, ctor_name
++;
911 if (!strncmp (IDENTIFIER_POINTER (type_encoding
), ctor_name
,
912 type_identifier_length
))
913 debug_name
= ctor_name
+ type_identifier_length
;
915 /* The other alternative is a destructor. */
919 /* Output the operation name just once, for the first method
923 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
924 CHARS (IDENTIFIER_LENGTH (name
) + 2);
929 dbxout_type (TREE_TYPE (fndecl
), 0, show_arg_types
);
931 dbxout_type_method_1 (fndecl
, debug_name
);
941 /* Emit a "range" type specification, which has the form:
942 "r<index type>;<lower bound>;<upper bound>;".
943 TYPE is an INTEGER_TYPE. */
946 dbxout_range_type (type
)
949 fprintf (asmfile
, "r");
950 if (TREE_TYPE (type
))
951 dbxout_type (TREE_TYPE (type
), 0, 0);
952 else if (TREE_CODE (type
) != INTEGER_TYPE
)
953 dbxout_type (type
, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
956 /* Traditionally, we made sure 'int' was type 1, and builtin types
957 were defined to be sub-ranges of int. Unfortunately, this
958 does not allow us to distinguish true sub-ranges from integer
959 types. So, instead we define integer (non-sub-range) types as
960 sub-ranges of themselves. This matters for Chill. If this isn't
961 a subrange type, then we want to define it in terms of itself.
962 However, in C, this may be an anonymous integer type, and we don't
963 want to emit debug info referring to it. Just calling
964 dbxout_type_index won't work anyways, because the type hasn't been
965 defined yet. We make this work for both cases by checked to see
966 whether this is a defined type, referring to it if it is, and using
968 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
969 dbxout_type_index (type
);
971 dbxout_type_index (integer_type_node
);
973 if (TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
)
975 fputc (';', asmfile
);
976 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
977 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type
)));
980 fprintf (asmfile
, ";0");
981 if (TYPE_MAX_VALUE (type
)
982 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
)
984 fputc (';', asmfile
);
985 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
986 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type
)));
987 fputc (';', asmfile
);
990 fprintf (asmfile
, ";-1;");
993 /* Output a reference to a type. If the type has not yet been
994 described in the dbx output, output its definition now.
995 For a type already defined, just refer to its definition
996 using the type number.
998 If FULL is nonzero, and the type has been described only with
999 a forward-reference, output the definition now.
1000 If FULL is zero in this case, just refer to the forward-reference
1001 using the number previously allocated.
1003 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1004 types for a METHOD_TYPE. */
1007 dbxout_type (type
, full
, show_arg_types
)
1013 static int anonymous_type_number
= 0;
1015 /* If there was an input error and we don't really have a type,
1016 avoid crashing and write something that is at least valid
1017 by assuming `int'. */
1018 if (type
== error_mark_node
)
1019 type
= integer_type_node
;
1022 /* Try to find the "main variant" with the same name but not const
1023 or volatile. (Since stabs does not distinguish const and volatile,
1024 there is no need to make them separate types. But types with
1025 different names are usefully distinguished.) */
1027 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
1028 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
1029 && TYPE_NAME (tem
) == TYPE_NAME (type
))
1034 if (TYPE_NAME (type
)
1035 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1036 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1040 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1042 /* Type has no dbx number assigned. Assign next available number. */
1043 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1045 /* Make sure type vector is long enough to record about this type. */
1047 if (next_type_number
== typevec_len
)
1050 = (struct typeinfo
*) xrealloc (typevec
,
1051 typevec_len
* 2 * sizeof typevec
[0]);
1052 bzero ((char *) (typevec
+ typevec_len
),
1053 typevec_len
* sizeof typevec
[0]);
1057 #ifdef DBX_USE_BINCL
1058 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1059 = current_file
->file_number
;
1060 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1061 = current_file
->next_type_number
++;
1065 /* Output the number of this type, to refer to it. */
1066 dbxout_type_index (type
);
1068 #ifdef DBX_TYPE_DEFINED
1069 if (DBX_TYPE_DEFINED (type
))
1073 /* If this type's definition has been output or is now being output,
1076 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1081 /* If we have already had a cross reference,
1082 and either that's all we want or that's the best we could do,
1083 don't repeat the cross reference.
1084 Sun dbx crashes if we do. */
1085 if (! full
|| TYPE_SIZE (type
) == 0
1086 /* No way in DBX fmt to describe a variable size. */
1087 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1095 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1096 leave the type-number completely undefined rather than output
1097 a cross-reference. If we have already used GNU debug info extensions,
1098 then it is OK to output a cross reference. This is necessary to get
1099 proper C++ debug output. */
1100 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1101 || TREE_CODE (type
) == QUAL_UNION_TYPE
1102 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1103 && ! use_gnu_debug_info_extensions
)
1104 /* We must use the same test here as we use twice below when deciding
1105 whether to emit a cross-reference. */
1106 if ((TYPE_NAME (type
) != 0
1107 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1108 && DECL_IGNORED_P (TYPE_NAME (type
)))
1110 || TYPE_SIZE (type
) == 0
1111 /* No way in DBX fmt to describe a variable size. */
1112 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1114 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1119 /* Output a definition now. */
1121 fprintf (asmfile
, "=");
1124 /* Mark it as defined, so that if it is self-referent
1125 we will not get into an infinite recursion of definitions. */
1127 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1129 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1130 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1132 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0, 0);
1136 switch (TREE_CODE (type
))
1140 /* For a void type, just define it as itself; ie, "5=5".
1141 This makes us consider it defined
1142 without saying what it is. The debugger will make it
1143 a void type when the reference is seen, and nothing will
1144 ever override that default. */
1145 dbxout_type_index (type
);
1149 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1151 /* Output the type `char' as a subrange of itself!
1152 I don't understand this definition, just copied it
1153 from the output of pcc.
1154 This used to use `r2' explicitly and we used to
1155 take care to make sure that `char' was type number 2. */
1156 fprintf (asmfile
, "r");
1157 dbxout_type_index (type
);
1158 fprintf (asmfile
, ";0;127;");
1161 /* If this is a subtype of another integer type, always prefer to
1162 write it as a subtype. */
1163 else if (TREE_TYPE (type
) != 0
1164 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_CST
)
1165 dbxout_range_type (type
);
1169 /* If the size is non-standard, say what it is if we can use
1172 if (use_gnu_debug_info_extensions
1173 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1174 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1176 /* If we can use GDB extensions and the size is wider than a
1177 long (the size used by GDB to read them) or we may have
1178 trouble writing the bounds the usual way, write them in
1179 octal. Note the test is for the *target's* size of "long",
1180 not that of the host. The host test is just to make sure we
1181 can write it out in case the host wide int is narrower than the
1184 /* For unsigned types, we use octal if they are the same size or
1185 larger. This is because we print the bounds as signed decimal,
1186 and hence they can't span same size unsigned types. */
1188 if (use_gnu_debug_info_extensions
1189 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1190 || (TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
)
1191 && TREE_UNSIGNED (type
))
1192 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1193 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1194 && TREE_UNSIGNED (type
))))
1196 fprintf (asmfile
, "r");
1197 dbxout_type_index (type
);
1198 fprintf (asmfile
, ";");
1199 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1200 fprintf (asmfile
, ";");
1201 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1202 fprintf (asmfile
, ";");
1206 /* Output other integer types as subranges of `int'. */
1207 dbxout_range_type (type
);
1214 /* This used to say `r1' and we used to take care
1215 to make sure that `int' was type number 1. */
1216 fprintf (asmfile
, "r");
1217 dbxout_type_index (integer_type_node
);
1218 fputc (';', asmfile
);
1219 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1220 fputs (";0;", asmfile
);
1225 if (use_gnu_debug_info_extensions
)
1227 fputs ("@s", asmfile
);
1228 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1229 BITS_PER_UNIT
* int_size_in_bytes (type
));
1230 fputs (";-20;", asmfile
);
1234 /* Output the type `char' as a subrange of itself.
1235 That is what pcc seems to do. */
1236 fprintf (asmfile
, "r");
1237 dbxout_type_index (char_type_node
);
1238 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1244 if (use_gnu_debug_info_extensions
)
1246 fputs ("@s", asmfile
);
1247 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1248 BITS_PER_UNIT
* int_size_in_bytes (type
));
1249 fputs (";-16;", asmfile
);
1251 else /* Define as enumeral type (False, True) */
1252 fprintf (asmfile
, "eFalse:0,True:1,;");
1257 putc ('d', asmfile
);
1259 dbxout_type (TREE_TYPE (type
), 0, 0);
1263 /* Differs from the REAL_TYPE by its new data type number */
1265 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1267 fprintf (asmfile
, "r");
1268 dbxout_type_index (type
);
1269 fputc (';', asmfile
);
1270 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1271 int_size_in_bytes (TREE_TYPE (type
)));
1272 fputs (";0;", asmfile
);
1273 CHARS (12); /* The number is probably incorrect here. */
1277 /* Output a complex integer type as a structure,
1278 pending some other way to do it. */
1279 fputc ('s', asmfile
);
1280 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1282 fprintf (asmfile
, "real:");
1284 dbxout_type (TREE_TYPE (type
), 0, 0);
1285 fprintf (asmfile
, ",%d,%d;",
1286 0, TYPE_PRECISION (TREE_TYPE (type
)));
1288 fprintf (asmfile
, "imag:");
1290 dbxout_type (TREE_TYPE (type
), 0, 0);
1291 fprintf (asmfile
, ",%d,%d;;",
1292 TYPE_PRECISION (TREE_TYPE (type
)),
1293 TYPE_PRECISION (TREE_TYPE (type
)));
1299 if (use_gnu_debug_info_extensions
)
1301 have_used_extensions
= 1;
1302 fputs ("@s", asmfile
);
1303 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1304 BITS_PER_UNIT
* int_size_in_bytes (type
));
1305 fputc (';', asmfile
);
1306 /* Check if a bitstring type, which in Chill is
1307 different from a [power]set. */
1308 if (TYPE_STRING_FLAG (type
))
1309 fprintf (asmfile
, "@S;");
1311 putc ('S', asmfile
);
1313 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1317 /* Make arrays of packed bits look like bitstrings for chill. */
1318 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1320 have_used_extensions
= 1;
1321 fputs ("@s", asmfile
);
1322 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1323 BITS_PER_UNIT
* int_size_in_bytes (type
));
1324 fputc (';', asmfile
);
1325 fprintf (asmfile
, "@S;");
1326 putc ('S', asmfile
);
1328 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1331 /* Output "a" followed by a range type definition
1332 for the index type of the array
1333 followed by a reference to the target-type.
1334 ar1;0;N;M for a C array of type M and size N+1. */
1335 /* Check if a character string type, which in Chill is
1336 different from an array of characters. */
1337 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1339 have_used_extensions
= 1;
1340 fprintf (asmfile
, "@S;");
1342 tem
= TYPE_DOMAIN (type
);
1345 fprintf (asmfile
, "ar");
1346 dbxout_type_index (integer_type_node
);
1347 fprintf (asmfile
, ";0;-1;");
1351 fprintf (asmfile
, "a");
1352 dbxout_range_type (tem
);
1355 dbxout_type (TREE_TYPE (type
), 0, 0);
1360 case QUAL_UNION_TYPE
:
1362 int i
, n_baseclasses
= 0;
1364 if (TYPE_BINFO (type
) != 0
1365 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1366 && TYPE_BINFO_BASETYPES (type
) != 0)
1367 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1369 /* Output a structure type. We must use the same test here as we
1370 use in the DBX_NO_XREFS case above. */
1371 if ((TYPE_NAME (type
) != 0
1372 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1373 && DECL_IGNORED_P (TYPE_NAME (type
)))
1375 || TYPE_SIZE (type
) == 0
1376 /* No way in DBX fmt to describe a variable size. */
1377 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1379 /* If the type is just a cross reference, output one
1380 and mark the type as partially described.
1381 If it later becomes defined, we will output
1382 its real definition.
1383 If the type has a name, don't nest its definition within
1384 another type's definition; instead, output an xref
1385 and let the definition come when the name is defined. */
1386 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1388 #if 0 /* This assertion is legitimately false in C++. */
1389 /* We shouldn't be outputting a reference to a type before its
1390 definition unless the type has a tag name.
1391 A typedef name without a tag name should be impossible. */
1392 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1395 if (TYPE_NAME (type
) != 0)
1396 dbxout_type_name (type
);
1398 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1399 fprintf (asmfile
, ":");
1400 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1404 /* Identify record or union, and print its size. */
1405 fputc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1406 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1407 int_size_in_bytes (type
));
1409 if (use_gnu_debug_info_extensions
)
1413 have_used_extensions
= 1;
1414 fprintf (asmfile
, "!%d,", n_baseclasses
);
1418 for (i
= 0; i
< n_baseclasses
; i
++)
1420 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1421 if (use_gnu_debug_info_extensions
)
1423 have_used_extensions
= 1;
1424 putc (TREE_VIA_VIRTUAL (child
) ? '1'
1427 putc (TREE_VIA_PUBLIC (child
) ? '2'
1430 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1431 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1432 fputc (',', asmfile
);
1434 dbxout_type (BINFO_TYPE (child
), 0, 0);
1435 putc (';', asmfile
);
1439 /* Print out the base class information with fields
1440 which have the same names at the types they hold. */
1441 dbxout_type_name (BINFO_TYPE (child
));
1442 putc (':', asmfile
);
1443 dbxout_type (BINFO_TYPE (child
), full
, 0);
1444 fputc (',', asmfile
);
1445 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1446 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1447 fputc (',', asmfile
);
1448 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1449 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child
)))) * BITS_PER_UNIT
);
1450 fputc (';', asmfile
);
1458 /* Write out the field declarations. */
1459 dbxout_type_fields (type
);
1460 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1462 have_used_extensions
= 1;
1463 dbxout_type_methods (type
);
1465 putc (';', asmfile
);
1467 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1468 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1469 && TYPE_VFIELD (type
))
1471 have_used_extensions
= 1;
1473 /* Tell GDB+ that it may keep reading. */
1474 putc ('~', asmfile
);
1476 /* We need to write out info about what field this class
1477 uses as its "main" vtable pointer field, because if this
1478 field is inherited from a base class, GDB cannot necessarily
1479 figure out which field it's using in time. */
1480 if (TYPE_VFIELD (type
))
1482 putc ('%', asmfile
);
1483 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0, 0);
1485 putc (';', asmfile
);
1491 /* We must use the same test here as we use in the DBX_NO_XREFS case
1492 above. We simplify it a bit since an enum will never have a variable
1494 if ((TYPE_NAME (type
) != 0
1495 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1496 && DECL_IGNORED_P (TYPE_NAME (type
)))
1498 || TYPE_SIZE (type
) == 0)
1500 fprintf (asmfile
, "xe");
1502 dbxout_type_name (type
);
1503 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1504 fprintf (asmfile
, ":");
1507 #ifdef DBX_OUTPUT_ENUM
1508 DBX_OUTPUT_ENUM (asmfile
, type
);
1510 if (use_gnu_debug_info_extensions
1511 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1512 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1513 putc ('e', asmfile
);
1515 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1517 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1518 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1519 fprintf (asmfile
, HOST_WIDE_INT_PRINT_UNSIGNED
,
1520 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1521 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1522 && TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1523 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1524 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1526 print_int_cst_octal (TREE_VALUE (tem
));
1527 fprintf (asmfile
, ",");
1528 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)));
1529 if (TREE_CHAIN (tem
) != 0)
1534 putc (';', asmfile
);
1540 putc ('*', asmfile
);
1542 dbxout_type (TREE_TYPE (type
), 0, 0);
1546 if (use_gnu_debug_info_extensions
)
1548 have_used_extensions
= 1;
1549 putc ('#', asmfile
);
1551 if (flag_minimal_debug
&& !show_arg_types
)
1553 /* Normally, just output the return type.
1554 The argument types are encoded in the method name. */
1555 putc ('#', asmfile
);
1557 dbxout_type (TREE_TYPE (type
), 0, 0);
1558 putc (';', asmfile
);
1563 /* When outputting destructors, we need to write
1564 the argument types out longhand. */
1565 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0, 0);
1566 putc (',', asmfile
);
1568 dbxout_type (TREE_TYPE (type
), 0, 0);
1569 dbxout_args (TYPE_ARG_TYPES (type
));
1570 putc (';', asmfile
);
1576 /* Treat it as a function type. */
1577 dbxout_type (TREE_TYPE (type
), 0, 0);
1582 if (use_gnu_debug_info_extensions
)
1584 have_used_extensions
= 1;
1585 putc ('@', asmfile
);
1587 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0, 0);
1588 putc (',', asmfile
);
1590 dbxout_type (TREE_TYPE (type
), 0, 0);
1594 /* Should print as an int, because it is really
1596 dbxout_type (integer_type_node
, 0, 0);
1600 case REFERENCE_TYPE
:
1601 if (use_gnu_debug_info_extensions
)
1602 have_used_extensions
= 1;
1603 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1605 dbxout_type (TREE_TYPE (type
), 0, 0);
1609 putc ('f', asmfile
);
1611 dbxout_type (TREE_TYPE (type
), 0, 0);
1619 /* Print the value of integer constant C, in octal,
1620 handling double precision. */
1623 print_int_cst_octal (c
)
1626 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1627 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1628 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1629 int width
= TYPE_PRECISION (TREE_TYPE (c
));
1631 /* GDB wants constants with no extra leading "1" bits, so
1632 we need to remove any sign-extension that might be
1634 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1636 else if (width
> HOST_BITS_PER_WIDE_INT
)
1637 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1638 else if (width
== HOST_BITS_PER_WIDE_INT
)
1641 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1643 fprintf (asmfile
, "0");
1647 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1648 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1652 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1653 unsigned HOST_WIDE_INT middle
1654 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1655 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1656 unsigned HOST_WIDE_INT end
1657 = low
& (((unsigned HOST_WIDE_INT
) 1
1658 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1661 fprintf (asmfile
, "%o%01o", (int)beg
, (int)middle
);
1662 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1667 print_octal (value
, digits
)
1668 unsigned HOST_WIDE_INT value
;
1673 for (i
= digits
- 1; i
>= 0; i
--)
1674 fprintf (asmfile
, "%01o", (int)((value
>> (3 * i
)) & 7));
1677 /* Output the name of type TYPE, with no punctuation.
1678 Such names can be set up either by typedef declarations
1679 or by struct, enum and union tags. */
1682 dbxout_type_name (type
)
1686 if (TYPE_NAME (type
) == 0)
1688 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1690 t
= TYPE_NAME (type
);
1692 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1694 t
= DECL_NAME (TYPE_NAME (type
));
1699 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1700 CHARS (IDENTIFIER_LENGTH (t
));
1703 /* Output a .stabs for the symbol defined by DECL,
1704 which must be a ..._DECL node in the normal namespace.
1705 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1706 LOCAL is nonzero if the scope is less than the entire file. */
1709 dbxout_symbol (decl
, local
)
1711 int local ATTRIBUTE_UNUSED
;
1713 tree type
= TREE_TYPE (decl
);
1714 tree context
= NULL_TREE
;
1716 /* Cast avoids warning in old compilers. */
1717 current_sym_code
= (STAB_CODE_TYPE
) 0;
1718 current_sym_value
= 0;
1719 current_sym_addr
= 0;
1721 /* Ignore nameless syms, but don't ignore type tags. */
1723 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1724 || DECL_IGNORED_P (decl
))
1727 dbxout_prepare_symbol (decl
);
1729 /* The output will always start with the symbol name,
1730 so always count that in the length-output-so-far. */
1732 if (DECL_NAME (decl
) != 0)
1733 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1735 switch (TREE_CODE (decl
))
1738 /* Enum values are defined by defining the enum type. */
1742 if (DECL_RTL (decl
) == 0)
1744 if (DECL_EXTERNAL (decl
))
1746 /* Don't mention a nested function under its parent. */
1747 context
= decl_function_context (decl
);
1748 if (context
== current_function_decl
)
1750 if (GET_CODE (DECL_RTL (decl
)) != MEM
1751 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1755 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
1756 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1757 TREE_PUBLIC (decl
) ? 'F' : 'f');
1759 current_sym_code
= N_FUN
;
1760 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1762 if (TREE_TYPE (type
))
1763 dbxout_type (TREE_TYPE (type
), 0, 0);
1765 dbxout_type (void_type_node
, 0, 0);
1767 /* For a nested function, when that function is compiled,
1768 mention the containing function name
1769 as well as (since dbx wants it) our own assembler-name. */
1771 fprintf (asmfile
, ",%s,%s",
1772 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1773 IDENTIFIER_POINTER (DECL_NAME (context
)));
1775 dbxout_finish_symbol (decl
);
1780 /* This seems all wrong. Outputting most kinds of types gives no name
1781 at all. A true definition gives no name; a cross-ref for a
1782 structure can give the tag name, but not a type name.
1783 It seems that no typedef name is defined by outputting a type. */
1785 /* If this typedef name was defined by outputting the type,
1786 don't duplicate it. */
1787 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1788 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1791 /* Don't output the same typedef twice.
1792 And don't output what language-specific stuff doesn't want output. */
1793 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1802 if (DECL_NAME (decl
))
1804 /* Nonzero means we must output a tag as well as a typedef. */
1807 /* Handle the case of a C++ structure or union
1808 where the TYPE_NAME is a TYPE_DECL
1809 which gives both a typedef name and a tag. */
1810 /* dbx requires the tag first and the typedef second. */
1811 if ((TREE_CODE (type
) == RECORD_TYPE
1812 || TREE_CODE (type
) == UNION_TYPE
1813 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1814 && TYPE_NAME (type
) == decl
1815 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1816 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1817 /* Distinguish the implicit typedefs of C++
1818 from explicit ones that might be found in C. */
1819 && DECL_ARTIFICIAL (decl
))
1821 tree name
= TYPE_NAME (type
);
1822 if (TREE_CODE (name
) == TYPE_DECL
)
1823 name
= DECL_NAME (name
);
1825 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1826 current_sym_value
= 0;
1827 current_sym_addr
= 0;
1828 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1830 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1831 IDENTIFIER_POINTER (name
));
1832 dbxout_type (type
, 1, 0);
1833 dbxout_finish_symbol (NULL_TREE
);
1836 /* Output typedef name. */
1837 fprintf (asmfile
, "%s \"%s:", ASM_STABS_OP
,
1838 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1840 /* Short cut way to output a tag also. */
1841 if ((TREE_CODE (type
) == RECORD_TYPE
1842 || TREE_CODE (type
) == UNION_TYPE
1843 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1844 && TYPE_NAME (type
) == decl
1845 /* Distinguish the implicit typedefs of C++
1846 from explicit ones that might be found in C. */
1847 && DECL_ARTIFICIAL (decl
))
1849 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1851 putc ('T', asmfile
);
1852 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1854 #if 0 /* Now we generate the tag for this case up above. */
1860 putc ('t', asmfile
);
1861 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1863 dbxout_type (type
, 1, 0);
1864 dbxout_finish_symbol (decl
);
1868 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1869 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1871 if (tag_needed
&& TYPE_NAME (type
) != 0
1872 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1873 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1874 && TYPE_SIZE (type
) != 0
1875 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1877 /* For a TYPE_DECL with no name, but the type has a name,
1879 This is what represents `struct foo' with no typedef. */
1880 /* In C++, the name of a type is the corresponding typedef.
1881 In C, it is an IDENTIFIER_NODE. */
1882 tree name
= TYPE_NAME (type
);
1883 if (TREE_CODE (name
) == TYPE_DECL
)
1884 name
= DECL_NAME (name
);
1886 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1887 current_sym_value
= 0;
1888 current_sym_addr
= 0;
1889 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1891 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1892 IDENTIFIER_POINTER (name
));
1893 dbxout_type (type
, 1, 0);
1894 dbxout_finish_symbol (NULL_TREE
);
1898 /* If an enum type has no name, it cannot be referred to,
1899 but we must output it anyway, since the enumeration constants
1900 can be referred to. */
1901 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1903 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1904 current_sym_value
= 0;
1905 current_sym_addr
= 0;
1906 current_sym_nchars
= 2;
1908 /* Some debuggers fail when given NULL names, so give this a
1909 harmless name of ` '. */
1910 fprintf (asmfile
, "%s \" :T", ASM_STABS_OP
);
1911 dbxout_type (type
, 1, 0);
1912 dbxout_finish_symbol (NULL_TREE
);
1915 /* Prevent duplicate output of a typedef. */
1916 TREE_ASM_WRITTEN (decl
) = 1;
1921 /* Parm decls go in their own separate chains
1922 and are output by dbxout_reg_parms and dbxout_parms. */
1926 /* Named return value, treat like a VAR_DECL. */
1928 if (DECL_RTL (decl
) == 0)
1930 /* Don't mention a variable that is external.
1931 Let the file that defines it describe it. */
1932 if (DECL_EXTERNAL (decl
))
1935 /* If the variable is really a constant
1936 and not written in memory, inform the debugger. */
1937 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
1938 && DECL_INITIAL (decl
) != 0
1939 && ! TREE_ASM_WRITTEN (decl
)
1940 && (DECL_FIELD_CONTEXT (decl
) == NULL_TREE
1941 || TREE_CODE (DECL_FIELD_CONTEXT (decl
)) == BLOCK
))
1943 if (TREE_PUBLIC (decl
) == 0)
1945 /* The sun4 assembler does not grok this. */
1946 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
1947 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
1948 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
1950 HOST_WIDE_INT ival
= TREE_INT_CST_LOW (DECL_INITIAL (decl
));
1951 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1952 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
1954 fprintf (asmfile
, "%s \"%s:c=i", ASM_STABS_OP
, name
);
1956 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
1957 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
1961 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
1963 /* don't know how to do this yet. */
1967 /* else it is something we handle like a normal variable. */
1970 DECL_RTL (decl
) = eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
);
1971 #ifdef LEAF_REG_REMAP
1972 if (current_function_uses_only_leaf_regs
)
1973 leaf_renumber_regs_insn (DECL_RTL (decl
));
1976 dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
1984 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1985 Add SUFFIX to its name, if SUFFIX is not 0.
1986 Describe the variable as residing in HOME
1987 (usually HOME is DECL_RTL (DECL), but not always). */
1990 dbxout_symbol_location (decl
, type
, suffix
, home
)
1998 /* Don't mention a variable at all
1999 if it was completely optimized into nothingness.
2001 If the decl was from an inline function, then its rtl
2002 is not identically the rtl that was used in this
2003 particular compilation. */
2004 if (GET_CODE (home
) == REG
)
2006 regno
= REGNO (home
);
2007 if (regno
>= FIRST_PSEUDO_REGISTER
)
2010 else if (GET_CODE (home
) == SUBREG
)
2014 while (GET_CODE (value
) == SUBREG
)
2016 offset
+= SUBREG_WORD (value
);
2017 value
= SUBREG_REG (value
);
2019 if (GET_CODE (value
) == REG
)
2021 regno
= REGNO (value
);
2022 if (regno
>= FIRST_PSEUDO_REGISTER
)
2026 alter_subreg (home
);
2029 /* The kind-of-variable letter depends on where
2030 the variable is and on the scope of its name:
2031 G and N_GSYM for static storage and global scope,
2032 S for static storage and file scope,
2033 V for static storage and local scope,
2034 for those two, use N_LCSYM if data is in bss segment,
2035 N_STSYM if in data segment, N_FUN otherwise.
2036 (We used N_FUN originally, then changed to N_STSYM
2037 to please GDB. However, it seems that confused ld.
2038 Now GDB has been fixed to like N_FUN, says Kingdon.)
2039 no letter at all, and N_LSYM, for auto variable,
2040 r and N_RSYM for register variable. */
2042 if (GET_CODE (home
) == MEM
2043 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2045 if (TREE_PUBLIC (decl
))
2048 current_sym_code
= N_GSYM
;
2052 current_sym_addr
= XEXP (home
, 0);
2054 letter
= decl_function_context (decl
) ? 'V' : 'S';
2056 /* This should be the same condition as in assemble_variable, but
2057 we don't have access to dont_output_data here. So, instead,
2058 we rely on the fact that error_mark_node initializers always
2059 end up in bss for C++ and never end up in bss for C. */
2060 if (DECL_INITIAL (decl
) == 0
2061 || (!strcmp (lang_identify (), "cplusplus")
2062 && DECL_INITIAL (decl
) == error_mark_node
))
2063 current_sym_code
= N_LCSYM
;
2064 else if (DECL_IN_TEXT_SECTION (decl
))
2065 /* This is not quite right, but it's the closest
2066 of all the codes that Unix defines. */
2067 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2070 /* Ultrix `as' seems to need this. */
2071 #ifdef DBX_STATIC_STAB_DATA_SECTION
2074 current_sym_code
= N_STSYM
;
2078 else if (regno
>= 0)
2081 current_sym_code
= N_RSYM
;
2082 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2084 else if (GET_CODE (home
) == MEM
2085 && (GET_CODE (XEXP (home
, 0)) == MEM
2086 || (GET_CODE (XEXP (home
, 0)) == REG
2087 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2088 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2089 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2090 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2093 /* If the value is indirect by memory or by a register
2094 that isn't the frame pointer
2095 then it means the object is variable-sized and address through
2096 that register or stack slot. DBX has no way to represent this
2097 so all we can do is output the variable as a pointer.
2098 If it's not a parameter, ignore it.
2099 (VAR_DECLs like this can be made by integrate.c.) */
2101 if (GET_CODE (XEXP (home
, 0)) == REG
)
2104 current_sym_code
= N_RSYM
;
2105 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2109 current_sym_code
= N_LSYM
;
2110 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2111 We want the value of that CONST_INT. */
2113 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2116 /* Effectively do build_pointer_type, but don't cache this type,
2117 since it might be temporary whereas the type it points to
2118 might have been saved for inlining. */
2119 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2120 type
= make_node (POINTER_TYPE
);
2121 TREE_TYPE (type
) = TREE_TYPE (decl
);
2123 else if (GET_CODE (home
) == MEM
2124 && GET_CODE (XEXP (home
, 0)) == REG
)
2126 current_sym_code
= N_LSYM
;
2127 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2129 else if (GET_CODE (home
) == MEM
2130 && GET_CODE (XEXP (home
, 0)) == PLUS
2131 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2133 current_sym_code
= N_LSYM
;
2134 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2135 We want the value of that CONST_INT. */
2136 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2138 else if (GET_CODE (home
) == MEM
2139 && GET_CODE (XEXP (home
, 0)) == CONST
)
2141 /* Handle an obscure case which can arise when optimizing and
2142 when there are few available registers. (This is *always*
2143 the case for i386/i486 targets). The RTL looks like
2144 (MEM (CONST ...)) even though this variable is a local `auto'
2145 or a local `register' variable. In effect, what has happened
2146 is that the reload pass has seen that all assignments and
2147 references for one such a local variable can be replaced by
2148 equivalent assignments and references to some static storage
2149 variable, thereby avoiding the need for a register. In such
2150 cases we're forced to lie to debuggers and tell them that
2151 this variable was itself `static'. */
2152 current_sym_code
= N_LCSYM
;
2154 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2156 else if (GET_CODE (home
) == CONCAT
)
2158 tree subtype
= TREE_TYPE (type
);
2160 /* If the variable's storage is in two parts,
2161 output each as a separate stab with a modified name. */
2162 if (WORDS_BIG_ENDIAN
)
2163 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2165 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2167 /* Cast avoids warning in old compilers. */
2168 current_sym_code
= (STAB_CODE_TYPE
) 0;
2169 current_sym_value
= 0;
2170 current_sym_addr
= 0;
2171 dbxout_prepare_symbol (decl
);
2173 if (WORDS_BIG_ENDIAN
)
2174 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2176 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2180 /* Address might be a MEM, when DECL is a variable-sized object.
2181 Or it might be const0_rtx, meaning previous passes
2182 want us to ignore this variable. */
2185 /* Ok, start a symtab entry and output the variable name. */
2188 #ifdef DBX_STATIC_BLOCK_START
2189 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2192 dbxout_symbol_name (decl
, suffix
, letter
);
2193 dbxout_type (type
, 0, 0);
2194 dbxout_finish_symbol (decl
);
2196 #ifdef DBX_STATIC_BLOCK_END
2197 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2201 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2202 Then output LETTER to indicate the kind of location the symbol has. */
2205 dbxout_symbol_name (decl
, suffix
, letter
)
2210 /* One slight hitch: if this is a VAR_DECL which is a static
2211 class member, we must put out the mangled name instead of the
2212 DECL_NAME. Note also that static member (variable) names DO NOT begin
2213 with underscores in .stabs directives. */
2214 const char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2217 fprintf (asmfile
, "%s \"%s%s:", ASM_STABS_OP
, name
,
2218 (suffix
? suffix
: ""));
2220 if (letter
) putc (letter
, asmfile
);
2224 dbxout_prepare_symbol (decl
)
2225 tree decl ATTRIBUTE_UNUSED
;
2228 const char *filename
= DECL_SOURCE_FILE (decl
);
2230 dbxout_source_file (asmfile
, filename
);
2235 dbxout_finish_symbol (sym
)
2238 #ifdef DBX_FINISH_SYMBOL
2239 DBX_FINISH_SYMBOL (sym
);
2242 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2243 line
= DECL_SOURCE_LINE (sym
);
2245 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2246 if (current_sym_addr
)
2247 output_addr_const (asmfile
, current_sym_addr
);
2249 fprintf (asmfile
, "%d", current_sym_value
);
2250 putc ('\n', asmfile
);
2254 /* Output definitions of all the decls in a chain. */
2262 dbxout_symbol (syms
, 1);
2263 syms
= TREE_CHAIN (syms
);
2267 /* The following two functions output definitions of function parameters.
2268 Each parameter gets a definition locating it in the parameter list.
2269 Each parameter that is a register variable gets a second definition
2270 locating it in the register.
2272 Printing or argument lists in gdb uses the definitions that
2273 locate in the parameter list. But reference to the variable in
2274 expressions uses preferentially the definition as a register. */
2276 /* Output definitions, referring to storage in the parmlist,
2277 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2280 dbxout_parms (parms
)
2283 for (; parms
; parms
= TREE_CHAIN (parms
))
2284 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2286 dbxout_prepare_symbol (parms
);
2288 /* Perform any necessary register eliminations on the parameter's rtl,
2289 so that the debugging output will be accurate. */
2290 DECL_INCOMING_RTL (parms
)
2291 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2292 DECL_RTL (parms
) = eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
);
2293 #ifdef LEAF_REG_REMAP
2294 if (current_function_uses_only_leaf_regs
)
2296 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2297 leaf_renumber_regs_insn (DECL_RTL (parms
));
2301 if (PARM_PASSED_IN_MEMORY (parms
))
2303 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2305 /* ??? Here we assume that the parm address is indexed
2306 off the frame pointer or arg pointer.
2307 If that is not true, we produce meaningless results,
2308 but do not crash. */
2309 if (GET_CODE (addr
) == PLUS
2310 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2311 current_sym_value
= INTVAL (XEXP (addr
, 1));
2313 current_sym_value
= 0;
2315 current_sym_code
= N_PSYM
;
2316 current_sym_addr
= 0;
2319 if (DECL_NAME (parms
))
2321 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2323 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2324 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2325 DBX_MEMPARM_STABS_LETTER
);
2329 current_sym_nchars
= 8;
2330 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2331 DBX_MEMPARM_STABS_LETTER
);
2334 /* It is quite tempting to use:
2336 dbxout_type (TREE_TYPE (parms), 0, 0);
2338 as the next statement, rather than using DECL_ARG_TYPE(), so
2339 that gcc reports the actual type of the parameter, rather
2340 than the promoted type. This certainly makes GDB's life
2341 easier, at least for some ports. The change is a bad idea
2342 however, since GDB expects to be able access the type without
2343 performing any conversions. So for example, if we were
2344 passing a float to an unprototyped function, gcc will store a
2345 double on the stack, but if we emit a stab saying the type is a
2346 float, then gdb will only read in a single value, and this will
2347 produce an erropneous value. */
2348 dbxout_type (DECL_ARG_TYPE (parms
), 0, 0);
2349 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2350 dbxout_finish_symbol (parms
);
2352 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2355 char regparm_letter
;
2357 /* Parm passed in registers and lives in registers or nowhere. */
2359 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2360 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2361 current_sym_addr
= 0;
2363 /* If parm lives in a register, use that register;
2364 pretend the parm was passed there. It would be more consistent
2365 to describe the register where the parm was passed,
2366 but in practice that register usually holds something else.
2368 If we use DECL_RTL, then we must use the declared type of
2369 the variable, not the type that it arrived in. */
2370 if (REGNO (DECL_RTL (parms
)) >= 0
2371 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2373 best_rtl
= DECL_RTL (parms
);
2374 parm_type
= TREE_TYPE (parms
);
2376 /* If the parm lives nowhere, use the register where it was
2377 passed. It is also better to use the declared type here. */
2380 best_rtl
= DECL_INCOMING_RTL (parms
);
2381 parm_type
= TREE_TYPE (parms
);
2383 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2386 if (DECL_NAME (parms
))
2388 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2389 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2390 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2395 current_sym_nchars
= 8;
2396 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2400 dbxout_type (parm_type
, 0, 0);
2401 dbxout_finish_symbol (parms
);
2403 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2404 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2405 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2406 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2407 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2408 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2412 /* Parm was passed via invisible reference.
2413 That is, its address was passed in a register.
2414 Output it as if it lived in that register.
2415 The debugger will know from the type
2416 that it was actually passed by invisible reference. */
2418 char regparm_letter
;
2419 /* Parm passed in registers and lives in registers or nowhere. */
2421 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2422 if (use_gnu_debug_info_extensions
)
2423 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2425 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2427 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2428 If it is an unallocated pseudo-reg, then use the register where
2429 it was passed instead. */
2430 if (REGNO (XEXP (DECL_RTL (parms
), 0)) >= 0
2431 && REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2432 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2434 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2436 current_sym_addr
= 0;
2439 if (DECL_NAME (parms
))
2441 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2443 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2444 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2449 current_sym_nchars
= 8;
2450 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2454 dbxout_type (TREE_TYPE (parms
), 0, 0);
2455 dbxout_finish_symbol (parms
);
2457 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2458 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2459 /* ??? A constant address for a parm can happen
2460 when the reg it lives in is equiv to a constant in memory.
2461 Should make this not happen, after 2.4. */
2462 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2464 /* Parm was passed in registers but lives on the stack. */
2465 int aux_sym_value
= 0;
2467 current_sym_code
= N_PSYM
;
2468 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2469 in which case we want the value of that CONST_INT,
2470 or (MEM (REG ...)) or (MEM (MEM ...)),
2471 in which case we use a value of zero. */
2472 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2473 current_sym_value
= 0;
2474 else if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2476 /* Remember the location on the stack the parm is moved to */
2478 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2479 current_sym_value
= 0;
2483 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2485 current_sym_addr
= 0;
2487 /* Make a big endian correction if the mode of the type of the
2488 parameter is not the same as the mode of the rtl. */
2489 if (BYTES_BIG_ENDIAN
2490 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2491 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2493 current_sym_value
+= UNITS_PER_WORD
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2497 if (DECL_NAME (parms
))
2500 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2502 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2503 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2504 DBX_MEMPARM_STABS_LETTER
);
2508 current_sym_nchars
= 8;
2509 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2510 DBX_MEMPARM_STABS_LETTER
);
2514 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2515 XEXP (DECL_RTL (parms
), 0));
2516 dbxout_type (TREE_TYPE (parms
), 0, 0);
2517 dbxout_finish_symbol (parms
);
2518 if (aux_sym_value
!= 0)
2520 /* Generate an entry for the stack location */
2522 fprintf (asmfile
, "%s \"%s:", ASM_STABS_OP
,
2523 IDENTIFIER_POINTER (DECL_NAME (parms
)));
2524 current_sym_value
= aux_sym_value
;
2525 current_sym_code
= N_LSYM
;
2526 dbxout_type (build_reference_type (TREE_TYPE (parms
)), 0, 0);
2527 dbxout_finish_symbol (parms
);
2533 /* Output definitions for the places where parms live during the function,
2534 when different from where they were passed, when the parms were passed
2537 It is not useful to do this for parms passed in registers
2538 that live during the function in different registers, because it is
2539 impossible to look in the passed register for the passed value,
2540 so we use the within-the-function register to begin with.
2542 PARMS is a chain of PARM_DECL nodes. */
2545 dbxout_reg_parms (parms
)
2548 for (; parms
; parms
= TREE_CHAIN (parms
))
2549 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2551 dbxout_prepare_symbol (parms
);
2553 /* Report parms that live in registers during the function
2554 but were passed in memory. */
2555 if (GET_CODE (DECL_RTL (parms
)) == REG
2556 && REGNO (DECL_RTL (parms
)) >= 0
2557 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2558 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2559 0, DECL_RTL (parms
));
2560 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2561 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2562 0, DECL_RTL (parms
));
2563 /* Report parms that live in memory but not where they were passed. */
2564 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2565 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2566 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2567 0, DECL_RTL (parms
));
2571 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2572 output definitions of those names, in raw form */
2580 putc (',', asmfile
);
2581 dbxout_type (TREE_VALUE (args
), 0, 0);
2583 args
= TREE_CHAIN (args
);
2587 /* Given a chain of ..._TYPE nodes,
2588 find those which have typedef names and output those names.
2589 This is to ensure those types get output. */
2592 dbxout_types (types
)
2593 register tree types
;
2597 if (TYPE_NAME (types
)
2598 && TREE_CODE (TYPE_NAME (types
)) == TYPE_DECL
2599 && ! TREE_ASM_WRITTEN (TYPE_NAME (types
)))
2600 dbxout_symbol (TYPE_NAME (types
), 1);
2601 types
= TREE_CHAIN (types
);
2605 /* Output everything about a symbol block (a BLOCK node
2606 that represents a scope level),
2607 including recursive output of contained blocks.
2609 BLOCK is the BLOCK node.
2610 DEPTH is its depth within containing symbol blocks.
2611 ARGS is usually zero; but for the outermost block of the
2612 body of a function, it is a chain of PARM_DECLs for the function parameters.
2613 We output definitions of all the register parms
2614 as if they were local variables of that block.
2616 If -g1 was used, we count blocks just the same, but output nothing
2617 except for the outermost block.
2619 Actually, BLOCK may be several blocks chained together.
2620 We handle them all in sequence. */
2623 dbxout_block (block
, depth
, args
)
2624 register tree block
;
2632 /* Ignore blocks never expanded or otherwise marked as real. */
2633 if (TREE_USED (block
))
2635 #ifndef DBX_LBRAC_FIRST
2636 /* In dbx format, the syms of a block come before the N_LBRAC. */
2637 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2638 dbxout_syms (BLOCK_VARS (block
));
2640 dbxout_reg_parms (args
);
2643 /* Now output an N_LBRAC symbol to represent the beginning of
2644 the block. Use the block's tree-walk order to generate
2645 the assembler symbols LBBn and LBEn
2646 that final will define around the code in this block. */
2647 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2650 blocknum
= next_block_number
++;
2651 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2653 if (BLOCK_HANDLER_BLOCK (block
))
2655 /* A catch block. Must precede N_LBRAC. */
2656 tree decl
= BLOCK_VARS (block
);
2659 #ifdef DBX_OUTPUT_CATCH
2660 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2662 fprintf (asmfile
, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2663 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2664 assemble_name (asmfile
, buf
);
2665 fprintf (asmfile
, "\n");
2667 decl
= TREE_CHAIN (decl
);
2671 #ifdef DBX_OUTPUT_LBRAC
2672 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2674 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2675 assemble_name (asmfile
, buf
);
2676 #if DBX_BLOCKS_FUNCTION_RELATIVE
2677 fputc ('-', asmfile
);
2678 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2680 fprintf (asmfile
, "\n");
2684 /* Count blocks the same way regardless of debug_info_level. */
2685 next_block_number
++;
2687 #ifdef DBX_LBRAC_FIRST
2688 /* On some weird machines, the syms of a block
2689 come after the N_LBRAC. */
2690 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2691 dbxout_syms (BLOCK_VARS (block
));
2693 dbxout_reg_parms (args
);
2696 /* Output the subblocks. */
2697 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2699 /* Refer to the marker for the end of the block. */
2700 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2703 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2704 #ifdef DBX_OUTPUT_RBRAC
2705 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2707 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2708 assemble_name (asmfile
, buf
);
2709 #if DBX_BLOCKS_FUNCTION_RELATIVE
2710 fputc ('-', asmfile
);
2711 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2713 fprintf (asmfile
, "\n");
2717 block
= BLOCK_CHAIN (block
);
2721 /* Output the information about a function and its arguments and result.
2722 Usually this follows the function's code,
2723 but on some systems, it comes before. */
2726 dbxout_really_begin_function (decl
)
2729 dbxout_symbol (decl
, 0);
2730 dbxout_parms (DECL_ARGUMENTS (decl
));
2731 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2732 dbxout_symbol (DECL_RESULT (decl
), 1);
2735 /* Called at beginning of output of function definition. */
2738 dbxout_begin_function (decl
)
2739 tree decl ATTRIBUTE_UNUSED
;
2741 #ifdef DBX_FUNCTION_FIRST
2742 dbxout_really_begin_function (decl
);
2746 /* Output dbx data for a function definition.
2747 This includes a definition of the function name itself (a symbol),
2748 definitions of the parameters (locating them in the parameter list)
2749 and then output the block that makes up the function's body
2750 (including all the auto variables of the function). */
2753 dbxout_function (decl
)
2756 #ifndef DBX_FUNCTION_FIRST
2757 dbxout_really_begin_function (decl
);
2759 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
2760 #ifdef DBX_OUTPUT_FUNCTION_END
2761 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
2763 #if defined(ASM_OUTPUT_SECTION_NAME)
2764 if (use_gnu_debug_info_extensions
2765 #if defined(NO_DBX_FUNCTION_END)
2766 && ! NO_DBX_FUNCTION_END
2769 dbxout_function_end ();
2772 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */