1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* Output dbx-format symbol table data.
23 This consists of many symbol table entries, each of them
24 a .stabs assembler pseudo-op with four operands:
25 a "name" which is really a description of one symbol and its type,
26 a "code", which is a symbol defined in stab.h whose name starts with N_,
27 an unused operand always 0,
28 and a "value" which is an address or an offset.
29 The name is enclosed in doublequote characters.
31 Each function, variable, typedef, and structure tag
32 has a symbol table entry to define it.
33 The beginning and end of each level of name scoping within
34 a function are also marked by special symbol table entries.
36 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
37 and a data type number. The data type number may be followed by
38 "=" and a type definition; normally this will happen the first time
39 the type number is mentioned. The type definition may refer to
40 other types by number, and those type numbers may be followed
41 by "=" and nested definitions.
43 This can make the "name" quite long.
44 When a name is more than 80 characters, we split the .stabs pseudo-op
45 into two .stabs pseudo-ops, both sharing the same "code" and "value".
46 The first one is marked as continued with a double-backslash at the
49 The kind-of-symbol letter distinguished function names from global
50 variables from file-scope variables from parameters from auto
51 variables in memory from typedef names from register variables.
54 The "code" is mostly redundant with the kind-of-symbol letter
55 that goes in the "name", but not entirely: for symbols located
56 in static storage, the "code" says which segment the address is in,
57 which controls how it is relocated.
59 The "value" for a symbol in static storage
60 is the core address of the symbol (actually, the assembler
61 label for the symbol). For a symbol located in a stack slot
62 it is the stack offset; for one in a register, the register number.
63 For a typedef symbol, it is zero.
65 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
66 output while in the text section.
68 For more on data type definitions, see `dbxout_type'. */
77 #include "insn-config.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
85 #ifdef XCOFF_DEBUGGING_INFO
90 #define ASM_STABS_OP ".stabs"
94 #define ASM_STABN_OP ".stabn"
97 #ifndef DBX_TYPE_DECL_STABS_CODE
98 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
101 #ifndef DBX_STATIC_CONST_VAR_CODE
102 #define DBX_STATIC_CONST_VAR_CODE N_FUN
105 #ifndef DBX_REGPARM_STABS_CODE
106 #define DBX_REGPARM_STABS_CODE N_RSYM
109 #ifndef DBX_REGPARM_STABS_LETTER
110 #define DBX_REGPARM_STABS_LETTER 'P'
113 /* This is used for parameters passed by invisible reference in a register. */
114 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
115 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
118 #ifndef DBX_MEMPARM_STABS_LETTER
119 #define DBX_MEMPARM_STABS_LETTER 'p'
122 #ifndef FILE_NAME_JOINER
123 #define FILE_NAME_JOINER "/"
126 /* Nonzero means if the type has methods, only output debugging
127 information if methods are actually written to the asm file. This
128 optimization only works if the debugger can detect the special C++
131 #define MINIMAL_DEBUG 1
133 #ifdef NO_DOLLAR_IN_LABEL
134 #ifdef NO_DOT_IN_LABEL
136 #define MINIMAL_DEBUG 0
140 /* Typical USG systems don't have stab.h, and they also have
141 no use for DBX-format debugging info. */
143 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
145 static int flag_minimal_debug
= MINIMAL_DEBUG
;
147 /* Nonzero if we have actually used any of the GDB extensions
148 to the debugging format. The idea is that we use them for the
149 first time only if there's a strong reason, but once we have done that,
150 we use them whenever convenient. */
152 static int have_used_extensions
= 0;
154 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
155 for the N_SO filename stabs label. */
157 static int source_label_number
= 1;
159 #ifdef DEBUG_SYMS_TEXT
160 #define FORCE_TEXT text_section ();
165 /* If there is a system stab.h, use it. Otherwise, use our own. */
166 /* ??? This is supposed to describe the target's stab format, so using
167 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
168 when cross compiling. */
169 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
170 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
174 /* This is a GNU extension we need to reference in this file. */
181 #define STAB_CODE_TYPE enum __stab_debug_code
183 #define STAB_CODE_TYPE int
186 /* 1 if PARM is passed to this function in memory. */
188 #define PARM_PASSED_IN_MEMORY(PARM) \
189 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
191 /* A C expression for the integer offset value of an automatic variable
192 (N_LSYM) having address X (an RTX). */
193 #ifndef DEBUGGER_AUTO_OFFSET
194 #define DEBUGGER_AUTO_OFFSET(X) \
195 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
198 /* A C expression for the integer offset value of an argument (N_PSYM)
199 having address X (an RTX). The nominal offset is OFFSET. */
200 #ifndef DEBUGGER_ARG_OFFSET
201 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
204 /* Stream for writing to assembler file. */
206 static FILE *asmfile
;
208 /* Last source file name mentioned in a NOTE insn. */
210 static const char *lastfile
;
212 /* Current working directory. */
214 static const char *cwd
;
216 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
218 /* Structure recording information about a C data type.
219 The status element says whether we have yet output
220 the definition of the type. TYPE_XREF says we have
221 output it as a cross-reference only.
222 The file_number and type_number elements are used if DBX_USE_BINCL
227 enum typestatus status
;
234 /* Vector recording information about C data types.
235 When we first notice a data type (a tree node),
236 we assign it a number using next_type_number.
237 That is its index in this vector. */
239 struct typeinfo
*typevec
;
241 /* Number of elements of space allocated in `typevec'. */
243 static int typevec_len
;
245 /* In dbx output, each type gets a unique number.
246 This is the number for the next type output.
247 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
249 static int next_type_number
;
253 /* When using N_BINCL in dbx output, each type number is actually a
254 pair of the file number and the type number within the file.
255 This is a stack of input files. */
259 struct dbx_file
*next
;
261 int next_type_number
;
264 /* This is the top of the stack. */
266 static struct dbx_file
*current_file
;
268 /* This is the next file number to use. */
270 static int next_file_number
;
272 #endif /* DBX_USE_BINCL */
274 /* In dbx output, we must assign symbol-blocks id numbers
275 in the order in which their beginnings are encountered.
276 We output debugging info that refers to the beginning and
277 end of the ranges of code in each block
278 with assembler labels LBBn and LBEn, where n is the block number.
279 The labels are generated in final, which assigns numbers to the
280 blocks in the same way. */
282 static int next_block_number
;
284 /* These variables are for dbxout_symbol to communicate to
285 dbxout_finish_symbol.
286 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
287 current_sym_value and current_sym_addr are two ways to address the
288 value to store in the symtab entry.
289 current_sym_addr if nonzero represents the value as an rtx.
290 If that is zero, current_sym_value is used. This is used
291 when the value is an offset (such as for auto variables,
292 register variables and parms). */
294 static STAB_CODE_TYPE current_sym_code
;
295 static int current_sym_value
;
296 static rtx current_sym_addr
;
298 /* Number of chars of symbol-description generated so far for the
299 current symbol. Used by CHARS and CONTIN. */
301 static int current_sym_nchars
;
303 /* Report having output N chars of the current symbol-description. */
305 #define CHARS(N) (current_sym_nchars += (N))
307 /* Break the current symbol-description, generating a continuation,
308 if it has become long. */
310 #ifndef DBX_CONTIN_LENGTH
311 #define DBX_CONTIN_LENGTH 80
314 #if DBX_CONTIN_LENGTH > 0
316 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
321 #if defined(ASM_OUTPUT_SECTION_NAME)
322 static void dbxout_function_end
PROTO((void));
324 static void dbxout_typedefs
PROTO((tree
));
325 static void dbxout_type_index
PROTO((tree
));
326 #if DBX_CONTIN_LENGTH > 0
327 static void dbxout_continue
PROTO((void));
329 static void dbxout_type_fields
PROTO((tree
));
330 static void dbxout_type_method_1
PROTO((tree
, const char *));
331 static void dbxout_type_methods
PROTO((tree
));
332 static void dbxout_range_type
PROTO((tree
));
333 static void dbxout_type
PROTO((tree
, int, int));
334 static void print_int_cst_octal
PROTO((tree
));
335 static void print_octal
PROTO((unsigned HOST_WIDE_INT
, int));
336 static void dbxout_type_name
PROTO((tree
));
337 static void dbxout_symbol_location
PROTO((tree
, tree
, const char *, rtx
));
338 static void dbxout_symbol_name
PROTO((tree
, const char *, int));
339 static void dbxout_prepare_symbol
PROTO((tree
));
340 static void dbxout_finish_symbol
PROTO((tree
));
341 static void dbxout_block
PROTO((tree
, int, tree
));
342 static void dbxout_really_begin_function
PROTO((tree
));
344 #if defined(ASM_OUTPUT_SECTION_NAME)
346 dbxout_function_end ()
348 static int scope_labelno
= 0;
349 char lscope_label_name
[100];
350 /* Convert Ltext into the appropriate format for local labels in case
351 the system doesn't insert underscores in front of user generated
353 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
354 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
357 /* By convention, GCC will mark the end of a function with an N_FUN
358 symbol and an empty string. */
359 fprintf (asmfile
, "%s \"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
360 assemble_name (asmfile
, lscope_label_name
);
361 fputc ('-', asmfile
);
362 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
363 fprintf (asmfile
, "\n");
365 #endif /* ! NO_DBX_FUNCTION_END */
367 /* At the beginning of compilation, start writing the symbol table.
368 Initialize `typevec' and output the standard data types of C. */
371 dbxout_init (asm_file
, input_file_name
, syms
)
373 const char *input_file_name
;
376 char ltext_label_name
[100];
381 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
383 /* Convert Ltext into the appropriate format for local labels in case
384 the system doesn't insert underscores in front of user generated
386 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
388 /* Put the current working directory in an N_SO symbol. */
389 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
390 but GDB always does. */
391 if (use_gnu_debug_info_extensions
)
394 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
396 char *wdslash
= xmalloc (strlen (cwd
) + sizeof (FILE_NAME_JOINER
));
397 sprintf (wdslash
, "%s%s", cwd
, FILE_NAME_JOINER
);
402 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
403 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
404 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
405 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
406 output_quoted_string (asmfile
, cwd
);
407 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
408 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
412 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
413 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
414 would give us an N_SOL, and we want an N_SO. */
415 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
416 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
417 /* We include outputting `Ltext:' here,
418 because that gives you a way to override it. */
419 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
420 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
421 output_quoted_string (asmfile
, input_file_name
);
422 fprintf (asmfile
, ",%d,0,0,%s\n",
423 N_SO
, <ext_label_name
[1]);
425 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
426 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
428 /* Possibly output something to inform GDB that this compilation was by
429 GCC. It's easier for GDB to parse it when after the N_SO's. This
430 is used in Solaris 2. */
431 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
432 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile
);
435 lastfile
= input_file_name
;
437 next_type_number
= 1;
438 next_block_number
= 2;
441 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
442 current_file
->next
= NULL
;
443 current_file
->file_number
= 0;
444 current_file
->next_type_number
= 1;
445 next_file_number
= 1;
448 /* Make sure that types `int' and `char' have numbers 1 and 2.
449 Definitions of other integer types will refer to those numbers.
450 (Actually it should no longer matter what their numbers are.
451 Also, if any types with tags have been defined, dbxout_symbol
452 will output them first, so the numbers won't be 1 and 2. That
453 happens in C++. So it's a good thing it should no longer matter). */
455 #ifdef DBX_OUTPUT_STANDARD_TYPES
456 DBX_OUTPUT_STANDARD_TYPES (syms
);
458 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
459 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
462 /* Get all permanent types that have typedef names,
463 and output them all, except for those already output. */
465 dbxout_typedefs (syms
);
468 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
469 in the reverse order from that which is found in SYMS. */
472 dbxout_typedefs (syms
)
477 dbxout_typedefs (TREE_CHAIN (syms
));
478 if (TREE_CODE (syms
) == TYPE_DECL
)
480 tree type
= TREE_TYPE (syms
);
482 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
483 && TYPE_SIZE (type
) != NULL_TREE
484 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
485 dbxout_symbol (TYPE_NAME (type
), 0);
490 /* Change to reading from a new source file. Generate a N_BINCL stab. */
493 dbxout_start_new_source_file (filename
)
494 const char *filename ATTRIBUTE_UNUSED
;
497 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
499 n
->next
= current_file
;
500 n
->file_number
= next_file_number
++;
501 n
->next_type_number
= 1;
503 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
504 output_quoted_string (asmfile
, filename
);
505 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
509 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
512 dbxout_resume_previous_source_file ()
515 struct dbx_file
*next
;
517 fprintf (asmfile
, "%s %d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
518 next
= current_file
->next
;
524 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
527 dbxout_source_file (file
, filename
)
529 const char *filename
;
531 char ltext_label_name
[100];
533 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
535 #ifdef DBX_OUTPUT_SOURCE_FILENAME
536 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
538 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
539 source_label_number
);
540 fprintf (file
, "%s ", ASM_STABS_OP
);
541 output_quoted_string (file
, filename
);
542 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
543 if (current_function_decl
!= NULL_TREE
544 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
545 ; /* Don't change section amid function. */
548 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
549 source_label_number
++;
555 /* Output a line number symbol entry into output stream FILE,
556 for source file FILENAME and line number LINENO. */
559 dbxout_source_line (file
, filename
, lineno
)
561 const char *filename
;
564 dbxout_source_file (file
, filename
);
566 #ifdef ASM_OUTPUT_SOURCE_LINE
567 ASM_OUTPUT_SOURCE_LINE (file
, lineno
);
569 fprintf (file
, "\t%s %d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
573 /* At the end of compilation, finish writing the symbol table.
574 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
578 dbxout_finish (file
, filename
)
579 FILE *file ATTRIBUTE_UNUSED
;
580 const char *filename ATTRIBUTE_UNUSED
;
582 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
583 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file
, filename
);
584 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
587 /* Output the index of a type. */
590 dbxout_type_index (type
)
593 #ifndef DBX_USE_BINCL
594 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
597 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
598 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
603 #if DBX_CONTIN_LENGTH > 0
604 /* Continue a symbol-description that gets too big.
605 End one symbol table entry with a double-backslash
606 and start a new one, eventually producing something like
607 .stabs "start......\\",code,0,value
608 .stabs "...rest",code,0,value */
613 #ifdef DBX_CONTIN_CHAR
614 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
616 fprintf (asmfile
, "\\\\");
618 dbxout_finish_symbol (NULL_TREE
);
619 fprintf (asmfile
, "%s \"", ASM_STABS_OP
);
620 current_sym_nchars
= 0;
622 #endif /* DBX_CONTIN_LENGTH > 0 */
624 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
625 This must be a separate function because anonymous unions require
629 dbxout_type_fields (type
)
633 /* Output the name, type, position (in bits), size (in bits) of each
635 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
637 /* Omit here local type decls until we know how to support them. */
638 if (TREE_CODE (tem
) == TYPE_DECL
)
640 /* Omit fields whose position or size are variable. */
641 else if (TREE_CODE (tem
) == FIELD_DECL
642 && (TREE_CODE (DECL_FIELD_BITPOS (tem
)) != INTEGER_CST
643 || TREE_CODE (DECL_SIZE (tem
)) != INTEGER_CST
))
645 /* Omit here the nameless fields that are used to skip bits. */
646 else if (DECL_IGNORED_P (tem
))
648 else if (TREE_CODE (tem
) != CONST_DECL
)
650 /* Continue the line if necessary,
651 but not before the first field. */
652 if (tem
!= TYPE_FIELDS (type
))
657 if (use_gnu_debug_info_extensions
658 && flag_minimal_debug
659 && TREE_CODE (tem
) == FIELD_DECL
660 && DECL_VIRTUAL_P (tem
)
661 && DECL_ASSEMBLER_NAME (tem
))
663 have_used_extensions
= 1;
664 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem
)));
665 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
)), asmfile
);
666 dbxout_type (DECL_FCONTEXT (tem
), 0, 0);
667 fprintf (asmfile
, ":");
668 dbxout_type (TREE_TYPE (tem
), 0, 0);
669 fputc (',', asmfile
);
670 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
671 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
672 fputc (';', asmfile
);
678 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
679 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
683 fprintf (asmfile
, ":");
687 if (use_gnu_debug_info_extensions
688 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
689 || TREE_CODE (tem
) != FIELD_DECL
))
691 have_used_extensions
= 1;
693 putc ((TREE_PRIVATE (tem
) ? '0'
694 : TREE_PROTECTED (tem
) ? '1' : '2'),
699 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
700 && DECL_BIT_FIELD_TYPE (tem
))
701 ? DECL_BIT_FIELD_TYPE (tem
)
702 : TREE_TYPE (tem
), 0, 0);
704 if (TREE_CODE (tem
) == VAR_DECL
)
706 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
709 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
));
710 have_used_extensions
= 1;
711 fprintf (asmfile
, ":%s;", name
);
712 CHARS (strlen (name
));
716 /* If TEM is non-static, GDB won't understand it. */
717 fprintf (asmfile
, ",0,0;");
720 else if (TREE_CODE (DECL_FIELD_BITPOS (tem
)) == INTEGER_CST
)
722 fputc (',', asmfile
);
723 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
724 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
725 fputc (',', asmfile
);
726 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
727 TREE_INT_CST_LOW (DECL_SIZE (tem
)));
728 fputc (';', asmfile
);
735 /* Subroutine of `dbxout_type_methods'. Output debug info about the
736 method described DECL. DEBUG_NAME is an encoding of the method's
737 type signature. ??? We may be able to do without DEBUG_NAME altogether
741 dbxout_type_method_1 (decl
, debug_name
)
743 const char *debug_name
;
747 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
749 else /* it's a METHOD_TYPE. */
751 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
752 /* A for normal functions.
753 B for `const' member functions.
754 C for `volatile' member functions.
755 D for `const volatile' member functions. */
756 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
758 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
761 if (DECL_VINDEX (decl
))
767 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
768 TREE_PRIVATE (decl
) ? '0' : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
769 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
770 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
771 if (DECL_VINDEX (decl
))
773 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
774 TREE_INT_CST_LOW (DECL_VINDEX (decl
)));
775 fputc (';', asmfile
);
776 dbxout_type (DECL_CONTEXT (decl
), 0, 0);
777 fprintf (asmfile
, ";");
782 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
786 dbxout_type_methods (type
)
789 /* C++: put out the method names and their parameter lists */
790 tree methods
= TYPE_METHODS (type
);
792 register tree fndecl
;
794 char formatted_type_identifier_length
[16];
795 register int type_identifier_length
;
797 if (methods
== NULL_TREE
)
800 type_encoding
= DECL_NAME (TYPE_NAME (type
));
803 /* C++: Template classes break some assumptions made by this code about
804 the class names, constructor names, and encodings for assembler
805 label names. For now, disable output of dbx info for them. */
807 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
808 /* This should use index. (mrs) */
809 while (*ptr
&& *ptr
!= '<') ptr
++;
820 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
822 sprintf(formatted_type_identifier_length
, "%d", type_identifier_length
);
824 if (TREE_CODE (methods
) != TREE_VEC
)
826 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
827 fndecl
= TREE_VEC_ELT (methods
, 0);
829 fndecl
= TREE_VEC_ELT (methods
, 1);
833 tree name
= DECL_NAME (fndecl
);
836 /* Group together all the methods for the same operation.
837 These differ in the types of the arguments. */
838 for (last
= NULL_TREE
;
839 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
840 fndecl
= TREE_CHAIN (fndecl
))
841 /* Output the name of the field (after overloading), as
842 well as the name of the field before overloading, along
843 with its parameter list */
845 /* This is the "mangled" name of the method.
846 It encodes the argument types. */
847 const char *debug_name
=
848 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
849 int show_arg_types
= 0;
855 if (DECL_IGNORED_P (fndecl
))
858 if (flag_minimal_debug
)
862 /* We can't optimize a method which uses an anonymous
863 class, because the debugger will not be able to
864 associate the arbitrary class name with the actual
866 #ifndef NO_DOLLAR_IN_LABEL
871 if (strchr (debug_name
, marker
))
873 /* Detect ordinary methods because their mangled names
874 start with the operation name. */
875 else if (!strncmp (IDENTIFIER_POINTER (name
), debug_name
,
876 IDENTIFIER_LENGTH (name
)))
878 debug_name
+= IDENTIFIER_LENGTH (name
);
879 if (debug_name
[0] == '_' && debug_name
[1] == '_')
881 const char *method_name
= debug_name
+ 2;
882 const char *length_ptr
=
883 formatted_type_identifier_length
;
884 /* Get past const and volatile qualifiers. */
885 while (*method_name
== 'C' || *method_name
== 'V')
887 /* Skip digits for length of type_encoding. */
888 while (*method_name
== *length_ptr
&& *length_ptr
)
889 length_ptr
++, method_name
++;
890 if (! strncmp (method_name
,
891 IDENTIFIER_POINTER (type_encoding
),
892 type_identifier_length
))
893 method_name
+= type_identifier_length
;
894 debug_name
= method_name
;
897 /* Detect constructors by their style of name mangling. */
898 else if (debug_name
[0] == '_' && debug_name
[1] == '_')
900 const char *ctor_name
= debug_name
+ 2;
901 const char *length_ptr
= formatted_type_identifier_length
;
902 while (*ctor_name
== 'C' || *ctor_name
== 'V')
904 /* Skip digits for length of type_encoding. */
905 while (*ctor_name
== *length_ptr
&& *length_ptr
)
906 length_ptr
++, ctor_name
++;
907 if (!strncmp (IDENTIFIER_POINTER (type_encoding
), ctor_name
,
908 type_identifier_length
))
909 debug_name
= ctor_name
+ type_identifier_length
;
911 /* The other alternative is a destructor. */
915 /* Output the operation name just once, for the first method
919 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
920 CHARS (IDENTIFIER_LENGTH (name
) + 2);
925 dbxout_type (TREE_TYPE (fndecl
), 0, show_arg_types
);
927 dbxout_type_method_1 (fndecl
, debug_name
);
937 /* Emit a "range" type specification, which has the form:
938 "r<index type>;<lower bound>;<upper bound>;".
939 TYPE is an INTEGER_TYPE. */
942 dbxout_range_type (type
)
945 fprintf (asmfile
, "r");
946 if (TREE_TYPE (type
))
947 dbxout_type (TREE_TYPE (type
), 0, 0);
948 else if (TREE_CODE (type
) != INTEGER_TYPE
)
949 dbxout_type (type
, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
952 /* Traditionally, we made sure 'int' was type 1, and builtin types
953 were defined to be sub-ranges of int. Unfortunately, this
954 does not allow us to distinguish true sub-ranges from integer
955 types. So, instead we define integer (non-sub-range) types as
956 sub-ranges of themselves. This matters for Chill. If this isn't
957 a subrange type, then we want to define it in terms of itself.
958 However, in C, this may be an anonymous integer type, and we don't
959 want to emit debug info referring to it. Just calling
960 dbxout_type_index won't work anyways, because the type hasn't been
961 defined yet. We make this work for both cases by checked to see
962 whether this is a defined type, referring to it if it is, and using
964 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
965 dbxout_type_index (type
);
967 dbxout_type_index (integer_type_node
);
969 if (TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
)
971 fputc (';', asmfile
);
972 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
973 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type
)));
976 fprintf (asmfile
, ";0");
977 if (TYPE_MAX_VALUE (type
)
978 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
)
980 fputc (';', asmfile
);
981 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
982 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type
)));
983 fputc (';', asmfile
);
986 fprintf (asmfile
, ";-1;");
989 /* Output a reference to a type. If the type has not yet been
990 described in the dbx output, output its definition now.
991 For a type already defined, just refer to its definition
992 using the type number.
994 If FULL is nonzero, and the type has been described only with
995 a forward-reference, output the definition now.
996 If FULL is zero in this case, just refer to the forward-reference
997 using the number previously allocated.
999 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1000 types for a METHOD_TYPE. */
1003 dbxout_type (type
, full
, show_arg_types
)
1009 static int anonymous_type_number
= 0;
1011 /* If there was an input error and we don't really have a type,
1012 avoid crashing and write something that is at least valid
1013 by assuming `int'. */
1014 if (type
== error_mark_node
)
1015 type
= integer_type_node
;
1018 /* Try to find the "main variant" with the same name but not const
1019 or volatile. (Since stabs does not distinguish const and volatile,
1020 there is no need to make them separate types. But types with
1021 different names are usefully distinguished.) */
1023 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
1024 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
1025 && TYPE_NAME (tem
) == TYPE_NAME (type
))
1030 if (TYPE_NAME (type
)
1031 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1032 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1036 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1038 /* Type has no dbx number assigned. Assign next available number. */
1039 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1041 /* Make sure type vector is long enough to record about this type. */
1043 if (next_type_number
== typevec_len
)
1046 = (struct typeinfo
*) xrealloc (typevec
,
1047 typevec_len
* 2 * sizeof typevec
[0]);
1048 bzero ((char *) (typevec
+ typevec_len
),
1049 typevec_len
* sizeof typevec
[0]);
1053 #ifdef DBX_USE_BINCL
1054 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1055 = current_file
->file_number
;
1056 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1057 = current_file
->next_type_number
++;
1061 /* Output the number of this type, to refer to it. */
1062 dbxout_type_index (type
);
1064 #ifdef DBX_TYPE_DEFINED
1065 if (DBX_TYPE_DEFINED (type
))
1069 /* If this type's definition has been output or is now being output,
1072 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1077 /* If we have already had a cross reference,
1078 and either that's all we want or that's the best we could do,
1079 don't repeat the cross reference.
1080 Sun dbx crashes if we do. */
1081 if (! full
|| TYPE_SIZE (type
) == 0
1082 /* No way in DBX fmt to describe a variable size. */
1083 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1091 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1092 leave the type-number completely undefined rather than output
1093 a cross-reference. If we have already used GNU debug info extensions,
1094 then it is OK to output a cross reference. This is necessary to get
1095 proper C++ debug output. */
1096 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1097 || TREE_CODE (type
) == QUAL_UNION_TYPE
1098 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1099 && ! use_gnu_debug_info_extensions
)
1100 /* We must use the same test here as we use twice below when deciding
1101 whether to emit a cross-reference. */
1102 if ((TYPE_NAME (type
) != 0
1103 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1104 && DECL_IGNORED_P (TYPE_NAME (type
)))
1106 || TYPE_SIZE (type
) == 0
1107 /* No way in DBX fmt to describe a variable size. */
1108 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1110 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1115 /* Output a definition now. */
1117 fprintf (asmfile
, "=");
1120 /* Mark it as defined, so that if it is self-referent
1121 we will not get into an infinite recursion of definitions. */
1123 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1125 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1126 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1128 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0, 0);
1132 switch (TREE_CODE (type
))
1136 /* For a void type, just define it as itself; ie, "5=5".
1137 This makes us consider it defined
1138 without saying what it is. The debugger will make it
1139 a void type when the reference is seen, and nothing will
1140 ever override that default. */
1141 dbxout_type_index (type
);
1145 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1147 /* Output the type `char' as a subrange of itself!
1148 I don't understand this definition, just copied it
1149 from the output of pcc.
1150 This used to use `r2' explicitly and we used to
1151 take care to make sure that `char' was type number 2. */
1152 fprintf (asmfile
, "r");
1153 dbxout_type_index (type
);
1154 fprintf (asmfile
, ";0;127;");
1157 /* If this is a subtype of another integer type, always prefer to
1158 write it as a subtype. */
1159 else if (TREE_TYPE (type
) != 0
1160 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_CST
)
1161 dbxout_range_type (type
);
1165 /* If the size is non-standard, say what it is if we can use
1168 if (use_gnu_debug_info_extensions
1169 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1170 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1172 /* If we can use GDB extensions and the size is wider than a
1173 long (the size used by GDB to read them) or we may have
1174 trouble writing the bounds the usual way, write them in
1175 octal. Note the test is for the *target's* size of "long",
1176 not that of the host. The host test is just to make sure we
1177 can write it out in case the host wide int is narrower than the
1180 if (use_gnu_debug_info_extensions
1181 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1182 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
))
1184 fprintf (asmfile
, "r");
1185 dbxout_type_index (type
);
1186 fprintf (asmfile
, ";");
1187 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1188 fprintf (asmfile
, ";");
1189 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1190 fprintf (asmfile
, ";");
1194 /* Output other integer types as subranges of `int'. */
1195 dbxout_range_type (type
);
1202 /* This used to say `r1' and we used to take care
1203 to make sure that `int' was type number 1. */
1204 fprintf (asmfile
, "r");
1205 dbxout_type_index (integer_type_node
);
1206 fputc (';', asmfile
);
1207 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1208 fputs (";0;", asmfile
);
1213 if (use_gnu_debug_info_extensions
)
1215 fputs ("@s", asmfile
);
1216 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1217 BITS_PER_UNIT
* int_size_in_bytes (type
));
1218 fputs (";-20;", asmfile
);
1222 /* Output the type `char' as a subrange of itself.
1223 That is what pcc seems to do. */
1224 fprintf (asmfile
, "r");
1225 dbxout_type_index (char_type_node
);
1226 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1232 if (use_gnu_debug_info_extensions
)
1234 fputs ("@s", asmfile
);
1235 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1236 BITS_PER_UNIT
* int_size_in_bytes (type
));
1237 fputs (";-16;", asmfile
);
1239 else /* Define as enumeral type (False, True) */
1240 fprintf (asmfile
, "eFalse:0,True:1,;");
1245 putc ('d', asmfile
);
1247 dbxout_type (TREE_TYPE (type
), 0, 0);
1251 /* Differs from the REAL_TYPE by its new data type number */
1253 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1255 fprintf (asmfile
, "r");
1256 dbxout_type_index (type
);
1257 fputc (';', asmfile
);
1258 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1259 int_size_in_bytes (TREE_TYPE (type
)));
1260 fputs (";0;", asmfile
);
1261 CHARS (12); /* The number is probably incorrect here. */
1265 /* Output a complex integer type as a structure,
1266 pending some other way to do it. */
1267 fputc ('s', asmfile
);
1268 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1270 fprintf (asmfile
, "real:");
1272 dbxout_type (TREE_TYPE (type
), 0, 0);
1273 fprintf (asmfile
, ",%d,%d;",
1274 0, TYPE_PRECISION (TREE_TYPE (type
)));
1276 fprintf (asmfile
, "imag:");
1278 dbxout_type (TREE_TYPE (type
), 0, 0);
1279 fprintf (asmfile
, ",%d,%d;;",
1280 TYPE_PRECISION (TREE_TYPE (type
)),
1281 TYPE_PRECISION (TREE_TYPE (type
)));
1287 if (use_gnu_debug_info_extensions
)
1289 have_used_extensions
= 1;
1290 fputs ("@s", asmfile
);
1291 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1292 BITS_PER_UNIT
* int_size_in_bytes (type
));
1293 fputc (';', asmfile
);
1294 /* Check if a bitstring type, which in Chill is
1295 different from a [power]set. */
1296 if (TYPE_STRING_FLAG (type
))
1297 fprintf (asmfile
, "@S;");
1299 putc ('S', asmfile
);
1301 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1305 /* Make arrays of packed bits look like bitstrings for chill. */
1306 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1308 have_used_extensions
= 1;
1309 fputs ("@s", asmfile
);
1310 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1311 BITS_PER_UNIT
* int_size_in_bytes (type
));
1312 fputc (';', asmfile
);
1313 fprintf (asmfile
, "@S;");
1314 putc ('S', asmfile
);
1316 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1319 /* Output "a" followed by a range type definition
1320 for the index type of the array
1321 followed by a reference to the target-type.
1322 ar1;0;N;M for a C array of type M and size N+1. */
1323 /* Check if a character string type, which in Chill is
1324 different from an array of characters. */
1325 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1327 have_used_extensions
= 1;
1328 fprintf (asmfile
, "@S;");
1330 tem
= TYPE_DOMAIN (type
);
1333 fprintf (asmfile
, "ar");
1334 dbxout_type_index (integer_type_node
);
1335 fprintf (asmfile
, ";0;-1;");
1339 fprintf (asmfile
, "a");
1340 dbxout_range_type (tem
);
1343 dbxout_type (TREE_TYPE (type
), 0, 0);
1348 case QUAL_UNION_TYPE
:
1350 int i
, n_baseclasses
= 0;
1352 if (TYPE_BINFO (type
) != 0
1353 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1354 && TYPE_BINFO_BASETYPES (type
) != 0)
1355 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1357 /* Output a structure type. We must use the same test here as we
1358 use in the DBX_NO_XREFS case above. */
1359 if ((TYPE_NAME (type
) != 0
1360 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1361 && DECL_IGNORED_P (TYPE_NAME (type
)))
1363 || TYPE_SIZE (type
) == 0
1364 /* No way in DBX fmt to describe a variable size. */
1365 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1367 /* If the type is just a cross reference, output one
1368 and mark the type as partially described.
1369 If it later becomes defined, we will output
1370 its real definition.
1371 If the type has a name, don't nest its definition within
1372 another type's definition; instead, output an xref
1373 and let the definition come when the name is defined. */
1374 fprintf (asmfile
, (TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu");
1376 #if 0 /* This assertion is legitimately false in C++. */
1377 /* We shouldn't be outputting a reference to a type before its
1378 definition unless the type has a tag name.
1379 A typedef name without a tag name should be impossible. */
1380 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1383 if (TYPE_NAME (type
) != 0)
1384 dbxout_type_name (type
);
1386 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1387 fprintf (asmfile
, ":");
1388 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1392 /* Identify record or union, and print its size. */
1393 fputc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1394 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1395 int_size_in_bytes (type
));
1397 if (use_gnu_debug_info_extensions
)
1401 have_used_extensions
= 1;
1402 fprintf (asmfile
, "!%d,", n_baseclasses
);
1406 for (i
= 0; i
< n_baseclasses
; i
++)
1408 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1409 if (use_gnu_debug_info_extensions
)
1411 have_used_extensions
= 1;
1412 putc (TREE_VIA_VIRTUAL (child
) ? '1'
1415 putc (TREE_VIA_PUBLIC (child
) ? '2'
1418 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1419 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1420 fputc (',', asmfile
);
1422 dbxout_type (BINFO_TYPE (child
), 0, 0);
1423 putc (';', asmfile
);
1427 /* Print out the base class information with fields
1428 which have the same names at the types they hold. */
1429 dbxout_type_name (BINFO_TYPE (child
));
1430 putc (':', asmfile
);
1431 dbxout_type (BINFO_TYPE (child
), full
, 0);
1432 fputc (',', asmfile
);
1433 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1434 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1435 fputc (',', asmfile
);
1436 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1437 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child
)))) * BITS_PER_UNIT
);
1438 fputc (';', asmfile
);
1446 /* Write out the field declarations. */
1447 dbxout_type_fields (type
);
1448 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1450 have_used_extensions
= 1;
1451 dbxout_type_methods (type
);
1453 putc (';', asmfile
);
1455 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1456 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1457 && TYPE_VFIELD (type
))
1459 have_used_extensions
= 1;
1461 /* Tell GDB+ that it may keep reading. */
1462 putc ('~', asmfile
);
1464 /* We need to write out info about what field this class
1465 uses as its "main" vtable pointer field, because if this
1466 field is inherited from a base class, GDB cannot necessarily
1467 figure out which field it's using in time. */
1468 if (TYPE_VFIELD (type
))
1470 putc ('%', asmfile
);
1471 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0, 0);
1473 putc (';', asmfile
);
1479 /* We must use the same test here as we use in the DBX_NO_XREFS case
1480 above. We simplify it a bit since an enum will never have a variable
1482 if ((TYPE_NAME (type
) != 0
1483 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1484 && DECL_IGNORED_P (TYPE_NAME (type
)))
1486 || TYPE_SIZE (type
) == 0)
1488 fprintf (asmfile
, "xe");
1490 dbxout_type_name (type
);
1491 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1492 fprintf (asmfile
, ":");
1495 #ifdef DBX_OUTPUT_ENUM
1496 DBX_OUTPUT_ENUM (asmfile
, type
);
1498 if (use_gnu_debug_info_extensions
1499 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1500 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1501 putc ('e', asmfile
);
1503 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1505 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1506 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1507 fprintf (asmfile
, HOST_WIDE_INT_PRINT_UNSIGNED
,
1508 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1509 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1510 && TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1511 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1512 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1514 print_int_cst_octal (TREE_VALUE (tem
));
1515 fprintf (asmfile
, ",");
1516 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)));
1517 if (TREE_CHAIN (tem
) != 0)
1522 putc (';', asmfile
);
1528 putc ('*', asmfile
);
1530 dbxout_type (TREE_TYPE (type
), 0, 0);
1534 if (use_gnu_debug_info_extensions
)
1536 have_used_extensions
= 1;
1537 putc ('#', asmfile
);
1539 if (flag_minimal_debug
&& !show_arg_types
)
1541 /* Normally, just output the return type.
1542 The argument types are encoded in the method name. */
1543 putc ('#', asmfile
);
1545 dbxout_type (TREE_TYPE (type
), 0, 0);
1546 putc (';', asmfile
);
1551 /* When outputting destructors, we need to write
1552 the argument types out longhand. */
1553 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0, 0);
1554 putc (',', asmfile
);
1556 dbxout_type (TREE_TYPE (type
), 0, 0);
1557 dbxout_args (TYPE_ARG_TYPES (type
));
1558 putc (';', asmfile
);
1564 /* Treat it as a function type. */
1565 dbxout_type (TREE_TYPE (type
), 0, 0);
1570 if (use_gnu_debug_info_extensions
)
1572 have_used_extensions
= 1;
1573 putc ('@', asmfile
);
1575 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0, 0);
1576 putc (',', asmfile
);
1578 dbxout_type (TREE_TYPE (type
), 0, 0);
1582 /* Should print as an int, because it is really
1584 dbxout_type (integer_type_node
, 0, 0);
1588 case REFERENCE_TYPE
:
1589 if (use_gnu_debug_info_extensions
)
1590 have_used_extensions
= 1;
1591 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1593 dbxout_type (TREE_TYPE (type
), 0, 0);
1597 putc ('f', asmfile
);
1599 dbxout_type (TREE_TYPE (type
), 0, 0);
1607 /* Print the value of integer constant C, in octal,
1608 handling double precision. */
1611 print_int_cst_octal (c
)
1614 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1615 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1616 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1617 int width
= TYPE_PRECISION (TREE_TYPE (c
));
1619 /* GDB wants constants with no extra leading "1" bits, so
1620 we need to remove any sign-extension that might be
1622 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1624 else if (width
> HOST_BITS_PER_WIDE_INT
)
1625 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1626 else if (width
== HOST_BITS_PER_WIDE_INT
)
1629 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1631 fprintf (asmfile
, "0");
1635 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1636 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1640 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1641 unsigned HOST_WIDE_INT middle
1642 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1643 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1644 unsigned HOST_WIDE_INT end
1645 = low
& (((unsigned HOST_WIDE_INT
) 1
1646 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1649 fprintf (asmfile
, "%o%01o", (int)beg
, (int)middle
);
1650 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1655 print_octal (value
, digits
)
1656 unsigned HOST_WIDE_INT value
;
1661 for (i
= digits
- 1; i
>= 0; i
--)
1662 fprintf (asmfile
, "%01o", (int)((value
>> (3 * i
)) & 7));
1665 /* Output the name of type TYPE, with no punctuation.
1666 Such names can be set up either by typedef declarations
1667 or by struct, enum and union tags. */
1670 dbxout_type_name (type
)
1674 if (TYPE_NAME (type
) == 0)
1676 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1678 t
= TYPE_NAME (type
);
1680 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1682 t
= DECL_NAME (TYPE_NAME (type
));
1687 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1688 CHARS (IDENTIFIER_LENGTH (t
));
1691 /* Output a .stabs for the symbol defined by DECL,
1692 which must be a ..._DECL node in the normal namespace.
1693 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1694 LOCAL is nonzero if the scope is less than the entire file. */
1697 dbxout_symbol (decl
, local
)
1699 int local ATTRIBUTE_UNUSED
;
1701 tree type
= TREE_TYPE (decl
);
1702 tree context
= NULL_TREE
;
1704 /* Cast avoids warning in old compilers. */
1705 current_sym_code
= (STAB_CODE_TYPE
) 0;
1706 current_sym_value
= 0;
1707 current_sym_addr
= 0;
1709 /* Ignore nameless syms, but don't ignore type tags. */
1711 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1712 || DECL_IGNORED_P (decl
))
1715 dbxout_prepare_symbol (decl
);
1717 /* The output will always start with the symbol name,
1718 so always count that in the length-output-so-far. */
1720 if (DECL_NAME (decl
) != 0)
1721 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1723 switch (TREE_CODE (decl
))
1726 /* Enum values are defined by defining the enum type. */
1730 if (DECL_RTL (decl
) == 0)
1732 if (DECL_EXTERNAL (decl
))
1734 /* Don't mention a nested function under its parent. */
1735 context
= decl_function_context (decl
);
1736 if (context
== current_function_decl
)
1738 if (GET_CODE (DECL_RTL (decl
)) != MEM
1739 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1743 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
1744 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1745 TREE_PUBLIC (decl
) ? 'F' : 'f');
1747 current_sym_code
= N_FUN
;
1748 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1750 if (TREE_TYPE (type
))
1751 dbxout_type (TREE_TYPE (type
), 0, 0);
1753 dbxout_type (void_type_node
, 0, 0);
1755 /* For a nested function, when that function is compiled,
1756 mention the containing function name
1757 as well as (since dbx wants it) our own assembler-name. */
1759 fprintf (asmfile
, ",%s,%s",
1760 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1761 IDENTIFIER_POINTER (DECL_NAME (context
)));
1763 dbxout_finish_symbol (decl
);
1768 /* This seems all wrong. Outputting most kinds of types gives no name
1769 at all. A true definition gives no name; a cross-ref for a
1770 structure can give the tag name, but not a type name.
1771 It seems that no typedef name is defined by outputting a type. */
1773 /* If this typedef name was defined by outputting the type,
1774 don't duplicate it. */
1775 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1776 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1779 /* Don't output the same typedef twice.
1780 And don't output what language-specific stuff doesn't want output. */
1781 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1790 if (DECL_NAME (decl
))
1792 /* Nonzero means we must output a tag as well as a typedef. */
1795 /* Handle the case of a C++ structure or union
1796 where the TYPE_NAME is a TYPE_DECL
1797 which gives both a typedef name and a tag. */
1798 /* dbx requires the tag first and the typedef second. */
1799 if ((TREE_CODE (type
) == RECORD_TYPE
1800 || TREE_CODE (type
) == UNION_TYPE
1801 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1802 && TYPE_NAME (type
) == decl
1803 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1804 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1805 /* Distinguish the implicit typedefs of C++
1806 from explicit ones that might be found in C. */
1807 && DECL_ARTIFICIAL (decl
))
1809 tree name
= TYPE_NAME (type
);
1810 if (TREE_CODE (name
) == TYPE_DECL
)
1811 name
= DECL_NAME (name
);
1813 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1814 current_sym_value
= 0;
1815 current_sym_addr
= 0;
1816 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1818 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1819 IDENTIFIER_POINTER (name
));
1820 dbxout_type (type
, 1, 0);
1821 dbxout_finish_symbol (NULL_TREE
);
1824 /* Output typedef name. */
1825 fprintf (asmfile
, "%s \"%s:", ASM_STABS_OP
,
1826 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1828 /* Short cut way to output a tag also. */
1829 if ((TREE_CODE (type
) == RECORD_TYPE
1830 || TREE_CODE (type
) == UNION_TYPE
1831 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1832 && TYPE_NAME (type
) == decl
1833 /* Distinguish the implicit typedefs of C++
1834 from explicit ones that might be found in C. */
1835 && DECL_ARTIFICIAL (decl
))
1837 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1839 putc ('T', asmfile
);
1840 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1842 #if 0 /* Now we generate the tag for this case up above. */
1848 putc ('t', asmfile
);
1849 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1851 dbxout_type (type
, 1, 0);
1852 dbxout_finish_symbol (decl
);
1856 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1857 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1859 if (tag_needed
&& TYPE_NAME (type
) != 0
1860 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1861 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1862 && TYPE_SIZE (type
) != 0
1863 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1865 /* For a TYPE_DECL with no name, but the type has a name,
1867 This is what represents `struct foo' with no typedef. */
1868 /* In C++, the name of a type is the corresponding typedef.
1869 In C, it is an IDENTIFIER_NODE. */
1870 tree name
= TYPE_NAME (type
);
1871 if (TREE_CODE (name
) == TYPE_DECL
)
1872 name
= DECL_NAME (name
);
1874 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1875 current_sym_value
= 0;
1876 current_sym_addr
= 0;
1877 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1879 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1880 IDENTIFIER_POINTER (name
));
1881 dbxout_type (type
, 1, 0);
1882 dbxout_finish_symbol (NULL_TREE
);
1886 /* If an enum type has no name, it cannot be referred to,
1887 but we must output it anyway, since the enumeration constants
1888 can be referred to. */
1889 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1891 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1892 current_sym_value
= 0;
1893 current_sym_addr
= 0;
1894 current_sym_nchars
= 2;
1896 /* Some debuggers fail when given NULL names, so give this a
1897 harmless name of ` '. */
1898 fprintf (asmfile
, "%s \" :T", ASM_STABS_OP
);
1899 dbxout_type (type
, 1, 0);
1900 dbxout_finish_symbol (NULL_TREE
);
1903 /* Prevent duplicate output of a typedef. */
1904 TREE_ASM_WRITTEN (decl
) = 1;
1909 /* Parm decls go in their own separate chains
1910 and are output by dbxout_reg_parms and dbxout_parms. */
1914 /* Named return value, treat like a VAR_DECL. */
1916 if (DECL_RTL (decl
) == 0)
1918 /* Don't mention a variable that is external.
1919 Let the file that defines it describe it. */
1920 if (DECL_EXTERNAL (decl
))
1923 /* If the variable is really a constant
1924 and not written in memory, inform the debugger. */
1925 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
1926 && DECL_INITIAL (decl
) != 0
1927 && ! TREE_ASM_WRITTEN (decl
)
1928 && (DECL_FIELD_CONTEXT (decl
) == NULL_TREE
1929 || TREE_CODE (DECL_FIELD_CONTEXT (decl
)) == BLOCK
))
1931 if (TREE_PUBLIC (decl
) == 0)
1933 /* The sun4 assembler does not grok this. */
1934 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
1935 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
1936 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
1938 HOST_WIDE_INT ival
= TREE_INT_CST_LOW (DECL_INITIAL (decl
));
1939 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1940 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
1942 fprintf (asmfile
, "%s \"%s:c=i", ASM_STABS_OP
, name
);
1944 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
1945 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
1949 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
1951 /* don't know how to do this yet. */
1955 /* else it is something we handle like a normal variable. */
1958 DECL_RTL (decl
) = eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
);
1959 #ifdef LEAF_REG_REMAP
1960 if (current_function_uses_only_leaf_regs
)
1961 leaf_renumber_regs_insn (DECL_RTL (decl
));
1964 dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
1972 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1973 Add SUFFIX to its name, if SUFFIX is not 0.
1974 Describe the variable as residing in HOME
1975 (usually HOME is DECL_RTL (DECL), but not always). */
1978 dbxout_symbol_location (decl
, type
, suffix
, home
)
1986 /* Don't mention a variable at all
1987 if it was completely optimized into nothingness.
1989 If the decl was from an inline function, then its rtl
1990 is not identically the rtl that was used in this
1991 particular compilation. */
1992 if (GET_CODE (home
) == REG
)
1994 regno
= REGNO (home
);
1995 if (regno
>= FIRST_PSEUDO_REGISTER
)
1998 else if (GET_CODE (home
) == SUBREG
)
2002 while (GET_CODE (value
) == SUBREG
)
2004 offset
+= SUBREG_WORD (value
);
2005 value
= SUBREG_REG (value
);
2007 if (GET_CODE (value
) == REG
)
2009 regno
= REGNO (value
);
2010 if (regno
>= FIRST_PSEUDO_REGISTER
)
2014 alter_subreg (home
);
2017 /* The kind-of-variable letter depends on where
2018 the variable is and on the scope of its name:
2019 G and N_GSYM for static storage and global scope,
2020 S for static storage and file scope,
2021 V for static storage and local scope,
2022 for those two, use N_LCSYM if data is in bss segment,
2023 N_STSYM if in data segment, N_FUN otherwise.
2024 (We used N_FUN originally, then changed to N_STSYM
2025 to please GDB. However, it seems that confused ld.
2026 Now GDB has been fixed to like N_FUN, says Kingdon.)
2027 no letter at all, and N_LSYM, for auto variable,
2028 r and N_RSYM for register variable. */
2030 if (GET_CODE (home
) == MEM
2031 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2033 if (TREE_PUBLIC (decl
))
2036 current_sym_code
= N_GSYM
;
2040 current_sym_addr
= XEXP (home
, 0);
2042 letter
= decl_function_context (decl
) ? 'V' : 'S';
2044 /* This should be the same condition as in assemble_variable, but
2045 we don't have access to dont_output_data here. So, instead,
2046 we rely on the fact that error_mark_node initializers always
2047 end up in bss for C++ and never end up in bss for C. */
2048 if (DECL_INITIAL (decl
) == 0
2049 || (!strcmp (lang_identify (), "cplusplus")
2050 && DECL_INITIAL (decl
) == error_mark_node
))
2051 current_sym_code
= N_LCSYM
;
2052 else if (DECL_IN_TEXT_SECTION (decl
))
2053 /* This is not quite right, but it's the closest
2054 of all the codes that Unix defines. */
2055 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2058 /* Ultrix `as' seems to need this. */
2059 #ifdef DBX_STATIC_STAB_DATA_SECTION
2062 current_sym_code
= N_STSYM
;
2066 else if (regno
>= 0)
2069 current_sym_code
= N_RSYM
;
2070 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2072 else if (GET_CODE (home
) == MEM
2073 && (GET_CODE (XEXP (home
, 0)) == MEM
2074 || (GET_CODE (XEXP (home
, 0)) == REG
2075 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2076 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2077 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2078 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2081 /* If the value is indirect by memory or by a register
2082 that isn't the frame pointer
2083 then it means the object is variable-sized and address through
2084 that register or stack slot. DBX has no way to represent this
2085 so all we can do is output the variable as a pointer.
2086 If it's not a parameter, ignore it.
2087 (VAR_DECLs like this can be made by integrate.c.) */
2089 if (GET_CODE (XEXP (home
, 0)) == REG
)
2092 current_sym_code
= N_RSYM
;
2093 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2097 current_sym_code
= N_LSYM
;
2098 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2099 We want the value of that CONST_INT. */
2101 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2104 /* Effectively do build_pointer_type, but don't cache this type,
2105 since it might be temporary whereas the type it points to
2106 might have been saved for inlining. */
2107 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2108 type
= make_node (POINTER_TYPE
);
2109 TREE_TYPE (type
) = TREE_TYPE (decl
);
2111 else if (GET_CODE (home
) == MEM
2112 && GET_CODE (XEXP (home
, 0)) == REG
)
2114 current_sym_code
= N_LSYM
;
2115 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2117 else if (GET_CODE (home
) == MEM
2118 && GET_CODE (XEXP (home
, 0)) == PLUS
2119 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2121 current_sym_code
= N_LSYM
;
2122 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2123 We want the value of that CONST_INT. */
2124 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2126 else if (GET_CODE (home
) == MEM
2127 && GET_CODE (XEXP (home
, 0)) == CONST
)
2129 /* Handle an obscure case which can arise when optimizing and
2130 when there are few available registers. (This is *always*
2131 the case for i386/i486 targets). The RTL looks like
2132 (MEM (CONST ...)) even though this variable is a local `auto'
2133 or a local `register' variable. In effect, what has happened
2134 is that the reload pass has seen that all assignments and
2135 references for one such a local variable can be replaced by
2136 equivalent assignments and references to some static storage
2137 variable, thereby avoiding the need for a register. In such
2138 cases we're forced to lie to debuggers and tell them that
2139 this variable was itself `static'. */
2140 current_sym_code
= N_LCSYM
;
2142 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2144 else if (GET_CODE (home
) == CONCAT
)
2146 tree subtype
= TREE_TYPE (type
);
2148 /* If the variable's storage is in two parts,
2149 output each as a separate stab with a modified name. */
2150 if (WORDS_BIG_ENDIAN
)
2151 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2153 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2155 /* Cast avoids warning in old compilers. */
2156 current_sym_code
= (STAB_CODE_TYPE
) 0;
2157 current_sym_value
= 0;
2158 current_sym_addr
= 0;
2159 dbxout_prepare_symbol (decl
);
2161 if (WORDS_BIG_ENDIAN
)
2162 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2164 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2168 /* Address might be a MEM, when DECL is a variable-sized object.
2169 Or it might be const0_rtx, meaning previous passes
2170 want us to ignore this variable. */
2173 /* Ok, start a symtab entry and output the variable name. */
2176 #ifdef DBX_STATIC_BLOCK_START
2177 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2180 dbxout_symbol_name (decl
, suffix
, letter
);
2181 dbxout_type (type
, 0, 0);
2182 dbxout_finish_symbol (decl
);
2184 #ifdef DBX_STATIC_BLOCK_END
2185 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2189 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2190 Then output LETTER to indicate the kind of location the symbol has. */
2193 dbxout_symbol_name (decl
, suffix
, letter
)
2198 /* One slight hitch: if this is a VAR_DECL which is a static
2199 class member, we must put out the mangled name instead of the
2200 DECL_NAME. Note also that static member (variable) names DO NOT begin
2201 with underscores in .stabs directives. */
2202 const char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2205 fprintf (asmfile
, "%s \"%s%s:", ASM_STABS_OP
, name
,
2206 (suffix
? suffix
: ""));
2208 if (letter
) putc (letter
, asmfile
);
2212 dbxout_prepare_symbol (decl
)
2213 tree decl ATTRIBUTE_UNUSED
;
2216 const char *filename
= DECL_SOURCE_FILE (decl
);
2218 dbxout_source_file (asmfile
, filename
);
2223 dbxout_finish_symbol (sym
)
2226 #ifdef DBX_FINISH_SYMBOL
2227 DBX_FINISH_SYMBOL (sym
);
2230 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2231 line
= DECL_SOURCE_LINE (sym
);
2233 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2234 if (current_sym_addr
)
2235 output_addr_const (asmfile
, current_sym_addr
);
2237 fprintf (asmfile
, "%d", current_sym_value
);
2238 putc ('\n', asmfile
);
2242 /* Output definitions of all the decls in a chain. */
2250 dbxout_symbol (syms
, 1);
2251 syms
= TREE_CHAIN (syms
);
2255 /* The following two functions output definitions of function parameters.
2256 Each parameter gets a definition locating it in the parameter list.
2257 Each parameter that is a register variable gets a second definition
2258 locating it in the register.
2260 Printing or argument lists in gdb uses the definitions that
2261 locate in the parameter list. But reference to the variable in
2262 expressions uses preferentially the definition as a register. */
2264 /* Output definitions, referring to storage in the parmlist,
2265 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2268 dbxout_parms (parms
)
2271 for (; parms
; parms
= TREE_CHAIN (parms
))
2272 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2274 dbxout_prepare_symbol (parms
);
2276 /* Perform any necessary register eliminations on the parameter's rtl,
2277 so that the debugging output will be accurate. */
2278 DECL_INCOMING_RTL (parms
)
2279 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2280 DECL_RTL (parms
) = eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
);
2281 #ifdef LEAF_REG_REMAP
2282 if (current_function_uses_only_leaf_regs
)
2284 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2285 leaf_renumber_regs_insn (DECL_RTL (parms
));
2289 if (PARM_PASSED_IN_MEMORY (parms
))
2291 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2293 /* ??? Here we assume that the parm address is indexed
2294 off the frame pointer or arg pointer.
2295 If that is not true, we produce meaningless results,
2296 but do not crash. */
2297 if (GET_CODE (addr
) == PLUS
2298 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2299 current_sym_value
= INTVAL (XEXP (addr
, 1));
2301 current_sym_value
= 0;
2303 current_sym_code
= N_PSYM
;
2304 current_sym_addr
= 0;
2307 if (DECL_NAME (parms
))
2309 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2311 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2312 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2313 DBX_MEMPARM_STABS_LETTER
);
2317 current_sym_nchars
= 8;
2318 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2319 DBX_MEMPARM_STABS_LETTER
);
2322 /* It is quite tempting to use:
2324 dbxout_type (TREE_TYPE (parms), 0, 0);
2326 as the next statement, rather than using DECL_ARG_TYPE(), so
2327 that gcc reports the actual type of the parameter, rather
2328 than the promoted type. This certainly makes GDB's life
2329 easier, at least for some ports. The change is a bad idea
2330 however, since GDB expects to be able access the type without
2331 performing any conversions. So for example, if we were
2332 passing a float to an unprototyped function, gcc will store a
2333 double on the stack, but if we emit a stab saying the type is a
2334 float, then gdb will only read in a single value, and this will
2335 produce an erropneous value. */
2336 dbxout_type (DECL_ARG_TYPE (parms
), 0, 0);
2337 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2338 dbxout_finish_symbol (parms
);
2340 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2343 char regparm_letter
;
2345 /* Parm passed in registers and lives in registers or nowhere. */
2347 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2348 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2349 current_sym_addr
= 0;
2351 /* If parm lives in a register, use that register;
2352 pretend the parm was passed there. It would be more consistent
2353 to describe the register where the parm was passed,
2354 but in practice that register usually holds something else.
2356 If we use DECL_RTL, then we must use the declared type of
2357 the variable, not the type that it arrived in. */
2358 if (REGNO (DECL_RTL (parms
)) >= 0
2359 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2361 best_rtl
= DECL_RTL (parms
);
2362 parm_type
= TREE_TYPE (parms
);
2364 /* If the parm lives nowhere, use the register where it was
2365 passed. It is also better to use the declared type here. */
2368 best_rtl
= DECL_INCOMING_RTL (parms
);
2369 parm_type
= TREE_TYPE (parms
);
2371 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2374 if (DECL_NAME (parms
))
2376 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2377 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2378 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2383 current_sym_nchars
= 8;
2384 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2388 dbxout_type (parm_type
, 0, 0);
2389 dbxout_finish_symbol (parms
);
2391 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2392 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2393 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2394 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2395 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2396 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2400 /* Parm was passed via invisible reference.
2401 That is, its address was passed in a register.
2402 Output it as if it lived in that register.
2403 The debugger will know from the type
2404 that it was actually passed by invisible reference. */
2406 char regparm_letter
;
2407 /* Parm passed in registers and lives in registers or nowhere. */
2409 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2410 if (use_gnu_debug_info_extensions
)
2411 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2413 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2415 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2416 If it is an unallocated pseudo-reg, then use the register where
2417 it was passed instead. */
2418 if (REGNO (XEXP (DECL_RTL (parms
), 0)) >= 0
2419 && REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2420 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2422 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2424 current_sym_addr
= 0;
2427 if (DECL_NAME (parms
))
2429 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2431 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2432 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2437 current_sym_nchars
= 8;
2438 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2442 dbxout_type (TREE_TYPE (parms
), 0, 0);
2443 dbxout_finish_symbol (parms
);
2445 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2446 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2447 /* ??? A constant address for a parm can happen
2448 when the reg it lives in is equiv to a constant in memory.
2449 Should make this not happen, after 2.4. */
2450 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2452 /* Parm was passed in registers but lives on the stack. */
2453 int aux_sym_value
= 0;
2455 current_sym_code
= N_PSYM
;
2456 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2457 in which case we want the value of that CONST_INT,
2458 or (MEM (REG ...)) or (MEM (MEM ...)),
2459 in which case we use a value of zero. */
2460 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2461 current_sym_value
= 0;
2462 else if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2464 /* Remember the location on the stack the parm is moved to */
2466 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2467 current_sym_value
= 0;
2471 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2473 current_sym_addr
= 0;
2475 /* Make a big endian correction if the mode of the type of the
2476 parameter is not the same as the mode of the rtl. */
2477 if (BYTES_BIG_ENDIAN
2478 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2479 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2481 current_sym_value
+= UNITS_PER_WORD
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2485 if (DECL_NAME (parms
))
2488 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2490 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2491 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2492 DBX_MEMPARM_STABS_LETTER
);
2496 current_sym_nchars
= 8;
2497 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2498 DBX_MEMPARM_STABS_LETTER
);
2502 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2503 XEXP (DECL_RTL (parms
), 0));
2504 dbxout_type (TREE_TYPE (parms
), 0, 0);
2505 dbxout_finish_symbol (parms
);
2506 if (aux_sym_value
!= 0)
2508 /* Generate an entry for the stack location */
2510 fprintf (asmfile
, "%s \"%s:", ASM_STABS_OP
,
2511 IDENTIFIER_POINTER (DECL_NAME (parms
)));
2512 current_sym_value
= aux_sym_value
;
2513 current_sym_code
= N_LSYM
;
2514 dbxout_type (build_reference_type (TREE_TYPE (parms
)), 0, 0);
2515 dbxout_finish_symbol (parms
);
2521 /* Output definitions for the places where parms live during the function,
2522 when different from where they were passed, when the parms were passed
2525 It is not useful to do this for parms passed in registers
2526 that live during the function in different registers, because it is
2527 impossible to look in the passed register for the passed value,
2528 so we use the within-the-function register to begin with.
2530 PARMS is a chain of PARM_DECL nodes. */
2533 dbxout_reg_parms (parms
)
2536 for (; parms
; parms
= TREE_CHAIN (parms
))
2537 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2539 dbxout_prepare_symbol (parms
);
2541 /* Report parms that live in registers during the function
2542 but were passed in memory. */
2543 if (GET_CODE (DECL_RTL (parms
)) == REG
2544 && REGNO (DECL_RTL (parms
)) >= 0
2545 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2546 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2547 0, DECL_RTL (parms
));
2548 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2549 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2550 0, DECL_RTL (parms
));
2551 /* Report parms that live in memory but not where they were passed. */
2552 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2553 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2554 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2555 0, DECL_RTL (parms
));
2559 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2560 output definitions of those names, in raw form */
2568 putc (',', asmfile
);
2569 dbxout_type (TREE_VALUE (args
), 0, 0);
2571 args
= TREE_CHAIN (args
);
2575 /* Given a chain of ..._TYPE nodes,
2576 find those which have typedef names and output those names.
2577 This is to ensure those types get output. */
2580 dbxout_types (types
)
2581 register tree types
;
2585 if (TYPE_NAME (types
)
2586 && TREE_CODE (TYPE_NAME (types
)) == TYPE_DECL
2587 && ! TREE_ASM_WRITTEN (TYPE_NAME (types
)))
2588 dbxout_symbol (TYPE_NAME (types
), 1);
2589 types
= TREE_CHAIN (types
);
2593 /* Output everything about a symbol block (a BLOCK node
2594 that represents a scope level),
2595 including recursive output of contained blocks.
2597 BLOCK is the BLOCK node.
2598 DEPTH is its depth within containing symbol blocks.
2599 ARGS is usually zero; but for the outermost block of the
2600 body of a function, it is a chain of PARM_DECLs for the function parameters.
2601 We output definitions of all the register parms
2602 as if they were local variables of that block.
2604 If -g1 was used, we count blocks just the same, but output nothing
2605 except for the outermost block.
2607 Actually, BLOCK may be several blocks chained together.
2608 We handle them all in sequence. */
2611 dbxout_block (block
, depth
, args
)
2612 register tree block
;
2620 /* Ignore blocks never expanded or otherwise marked as real. */
2621 if (TREE_USED (block
))
2623 #ifndef DBX_LBRAC_FIRST
2624 /* In dbx format, the syms of a block come before the N_LBRAC. */
2625 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2626 dbxout_syms (BLOCK_VARS (block
));
2628 dbxout_reg_parms (args
);
2631 /* Now output an N_LBRAC symbol to represent the beginning of
2632 the block. Use the block's tree-walk order to generate
2633 the assembler symbols LBBn and LBEn
2634 that final will define around the code in this block. */
2635 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2638 blocknum
= next_block_number
++;
2639 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2641 if (BLOCK_HANDLER_BLOCK (block
))
2643 /* A catch block. Must precede N_LBRAC. */
2644 tree decl
= BLOCK_VARS (block
);
2647 #ifdef DBX_OUTPUT_CATCH
2648 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2650 fprintf (asmfile
, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2651 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2652 assemble_name (asmfile
, buf
);
2653 fprintf (asmfile
, "\n");
2655 decl
= TREE_CHAIN (decl
);
2659 #ifdef DBX_OUTPUT_LBRAC
2660 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2662 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2663 assemble_name (asmfile
, buf
);
2664 #if DBX_BLOCKS_FUNCTION_RELATIVE
2665 fputc ('-', asmfile
);
2666 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2668 fprintf (asmfile
, "\n");
2672 /* Count blocks the same way regardless of debug_info_level. */
2673 next_block_number
++;
2675 #ifdef DBX_LBRAC_FIRST
2676 /* On some weird machines, the syms of a block
2677 come after the N_LBRAC. */
2678 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2679 dbxout_syms (BLOCK_VARS (block
));
2681 dbxout_reg_parms (args
);
2684 /* Output the subblocks. */
2685 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2687 /* Refer to the marker for the end of the block. */
2688 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2691 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2692 #ifdef DBX_OUTPUT_RBRAC
2693 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2695 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2696 assemble_name (asmfile
, buf
);
2697 #if DBX_BLOCKS_FUNCTION_RELATIVE
2698 fputc ('-', asmfile
);
2699 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2701 fprintf (asmfile
, "\n");
2705 block
= BLOCK_CHAIN (block
);
2709 /* Output the information about a function and its arguments and result.
2710 Usually this follows the function's code,
2711 but on some systems, it comes before. */
2714 dbxout_really_begin_function (decl
)
2717 dbxout_symbol (decl
, 0);
2718 dbxout_parms (DECL_ARGUMENTS (decl
));
2719 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2720 dbxout_symbol (DECL_RESULT (decl
), 1);
2723 /* Called at beginning of output of function definition. */
2726 dbxout_begin_function (decl
)
2727 tree decl ATTRIBUTE_UNUSED
;
2729 #ifdef DBX_FUNCTION_FIRST
2730 dbxout_really_begin_function (decl
);
2734 /* Output dbx data for a function definition.
2735 This includes a definition of the function name itself (a symbol),
2736 definitions of the parameters (locating them in the parameter list)
2737 and then output the block that makes up the function's body
2738 (including all the auto variables of the function). */
2741 dbxout_function (decl
)
2744 #ifndef DBX_FUNCTION_FIRST
2745 dbxout_really_begin_function (decl
);
2747 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
2748 #ifdef DBX_OUTPUT_FUNCTION_END
2749 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
2751 #if defined(ASM_OUTPUT_SECTION_NAME)
2752 if (use_gnu_debug_info_extensions
2753 #if defined(NO_DBX_FUNCTION_END)
2754 && ! NO_DBX_FUNCTION_END
2757 dbxout_function_end ();
2760 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */