1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
78 #include "insn-config.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
88 #ifdef XCOFF_DEBUGGING_INFO
93 #define ASM_STABS_OP "\t.stabs\t"
97 #define ASM_STABN_OP "\t.stabn\t"
100 #ifndef DBX_TYPE_DECL_STABS_CODE
101 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
104 #ifndef DBX_STATIC_CONST_VAR_CODE
105 #define DBX_STATIC_CONST_VAR_CODE N_FUN
108 #ifndef DBX_REGPARM_STABS_CODE
109 #define DBX_REGPARM_STABS_CODE N_RSYM
112 #ifndef DBX_REGPARM_STABS_LETTER
113 #define DBX_REGPARM_STABS_LETTER 'P'
116 /* This is used for parameters passed by invisible reference in a register. */
117 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
118 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
121 #ifndef DBX_MEMPARM_STABS_LETTER
122 #define DBX_MEMPARM_STABS_LETTER 'p'
125 #ifndef FILE_NAME_JOINER
126 #define FILE_NAME_JOINER "/"
129 /* GDB needs to know that the stabs were generated by GCC. We emit an
130 N_OPT stab at the beginning of the source file to indicate this.
131 The string is historical, and different on a very few targets. */
132 #ifndef STABS_GCC_MARKER
133 #define STABS_GCC_MARKER "gcc2_compiled."
136 /* Typical USG systems don't have stab.h, and they also have
137 no use for DBX-format debugging info. */
139 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
141 /* Nonzero if we have actually used any of the GDB extensions
142 to the debugging format. The idea is that we use them for the
143 first time only if there's a strong reason, but once we have done that,
144 we use them whenever convenient. */
146 static int have_used_extensions
= 0;
148 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
149 for the N_SO filename stabs label. */
151 static int source_label_number
= 1;
153 #ifdef DEBUG_SYMS_TEXT
154 #define FORCE_TEXT text_section ();
161 #define STAB_CODE_TYPE enum __stab_debug_code
163 /* 1 if PARM is passed to this function in memory. */
165 #define PARM_PASSED_IN_MEMORY(PARM) \
166 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
168 /* A C expression for the integer offset value of an automatic variable
169 (N_LSYM) having address X (an RTX). */
170 #ifndef DEBUGGER_AUTO_OFFSET
171 #define DEBUGGER_AUTO_OFFSET(X) \
172 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
175 /* A C expression for the integer offset value of an argument (N_PSYM)
176 having address X (an RTX). The nominal offset is OFFSET. */
177 #ifndef DEBUGGER_ARG_OFFSET
178 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
181 /* Stream for writing to assembler file. */
183 static FILE *asmfile
;
185 /* Last source file name mentioned in a NOTE insn. */
187 static const char *lastfile
;
189 /* Current working directory. */
191 static const char *cwd
;
193 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
195 /* Structure recording information about a C data type.
196 The status element says whether we have yet output
197 the definition of the type. TYPE_XREF says we have
198 output it as a cross-reference only.
199 The file_number and type_number elements are used if DBX_USE_BINCL
204 enum typestatus status
;
211 /* Vector recording information about C data types.
212 When we first notice a data type (a tree node),
213 we assign it a number using next_type_number.
214 That is its index in this vector. */
216 struct typeinfo
*typevec
;
218 /* Number of elements of space allocated in `typevec'. */
220 static int typevec_len
;
222 /* In dbx output, each type gets a unique number.
223 This is the number for the next type output.
224 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
226 static int next_type_number
;
230 /* When using N_BINCL in dbx output, each type number is actually a
231 pair of the file number and the type number within the file.
232 This is a stack of input files. */
236 struct dbx_file
*next
;
238 int next_type_number
;
241 /* This is the top of the stack. */
243 static struct dbx_file
*current_file
;
245 /* This is the next file number to use. */
247 static int next_file_number
;
249 #endif /* DBX_USE_BINCL */
251 /* These variables are for dbxout_symbol to communicate to
252 dbxout_finish_symbol.
253 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
254 current_sym_value and current_sym_addr are two ways to address the
255 value to store in the symtab entry.
256 current_sym_addr if nonzero represents the value as an rtx.
257 If that is zero, current_sym_value is used. This is used
258 when the value is an offset (such as for auto variables,
259 register variables and parms). */
261 static STAB_CODE_TYPE current_sym_code
;
262 static int current_sym_value
;
263 static rtx current_sym_addr
;
265 /* Number of chars of symbol-description generated so far for the
266 current symbol. Used by CHARS and CONTIN. */
268 static int current_sym_nchars
;
270 /* Report having output N chars of the current symbol-description. */
272 #define CHARS(N) (current_sym_nchars += (N))
274 /* Break the current symbol-description, generating a continuation,
275 if it has become long. */
277 #ifndef DBX_CONTIN_LENGTH
278 #define DBX_CONTIN_LENGTH 80
281 #if DBX_CONTIN_LENGTH > 0
283 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
285 #define CONTIN do { } while (0)
288 static void dbxout_init
PARAMS ((const char *));
289 static void dbxout_finish
PARAMS ((const char *));
290 static void dbxout_start_source_file
PARAMS ((unsigned, const char *));
291 static void dbxout_end_source_file
PARAMS ((unsigned));
292 static void dbxout_source_line
PARAMS ((unsigned int, const char *));
293 static void dbxout_source_file
PARAMS ((FILE *, const char *));
294 static void dbxout_function_end
PARAMS ((void));
295 static void dbxout_typedefs
PARAMS ((tree
));
296 static void dbxout_type_index
PARAMS ((tree
));
297 #if DBX_CONTIN_LENGTH > 0
298 static void dbxout_continue
PARAMS ((void));
300 static void dbxout_args
PARAMS ((tree
));
301 static void dbxout_type_fields
PARAMS ((tree
));
302 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
303 static void dbxout_type_methods
PARAMS ((tree
));
304 static void dbxout_range_type
PARAMS ((tree
));
305 static void dbxout_type
PARAMS ((tree
, int));
306 static void print_int_cst_octal
PARAMS ((tree
));
307 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
308 static void print_wide_int
PARAMS ((HOST_WIDE_INT
));
309 static void dbxout_type_name
PARAMS ((tree
));
310 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
311 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
312 static void dbxout_prepare_symbol
PARAMS ((tree
));
313 static void dbxout_finish_symbol
PARAMS ((tree
));
314 static void dbxout_block
PARAMS ((tree
, int, tree
));
315 static void dbxout_begin_function
PARAMS ((tree
));
316 static void dbxout_global_decl
PARAMS ((tree
));
318 /* The debug hooks structure. */
319 #if defined (DBX_DEBUGGING_INFO)
321 static void dbxout_begin_block
PARAMS ((unsigned, unsigned));
322 static void dbxout_end_block
PARAMS ((unsigned, unsigned));
323 static void dbxout_function_decl
PARAMS ((tree
));
325 struct gcc_debug_hooks dbx_debug_hooks
=
329 debug_nothing_int_charstar
,
330 debug_nothing_int_charstar
,
331 dbxout_start_source_file
,
332 dbxout_end_source_file
,
335 debug_true_tree
, /* ignore_block */
336 dbxout_source_line
, /* source_line */
337 dbxout_source_line
, /* begin_prologue: just output line info */
338 debug_nothing_int
, /* end_prologue */
339 debug_nothing_void
, /* end_epilogue */
340 #ifdef DBX_FUNCTION_FIRST
341 dbxout_begin_function
,
343 debug_nothing_tree
, /* begin_function */
345 debug_nothing_int
, /* end_function */
346 dbxout_function_decl
,
347 dbxout_global_decl
, /* global_decl */
348 debug_nothing_tree
, /* deferred_inline_function */
349 debug_nothing_tree
, /* outlining_inline_function */
350 debug_nothing_rtx
/* label */
352 #endif /* DBX_DEBUGGING_INFO */
354 #if defined (XCOFF_DEBUGGING_INFO)
355 struct gcc_debug_hooks xcoff_debug_hooks
=
359 debug_nothing_int_charstar
,
360 debug_nothing_int_charstar
,
361 dbxout_start_source_file
,
362 dbxout_end_source_file
,
363 xcoffout_begin_block
,
365 debug_true_tree
, /* ignore_block */
366 xcoffout_source_line
,
367 xcoffout_begin_prologue
, /* begin_prologue */
368 debug_nothing_int
, /* end_prologue */
369 xcoffout_end_epilogue
,
370 debug_nothing_tree
, /* begin_function */
371 xcoffout_end_function
,
372 debug_nothing_tree
, /* function_decl */
373 dbxout_global_decl
, /* global_decl */
374 debug_nothing_tree
, /* deferred_inline_function */
375 debug_nothing_tree
, /* outlining_inline_function */
376 debug_nothing_rtx
/* label */
378 #endif /* XCOFF_DEBUGGING_INFO */
381 dbxout_function_end ()
383 static int scope_labelno
= 0;
384 char lscope_label_name
[100];
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 (lscope_label_name
, "Lscope", scope_labelno
);
389 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
392 /* By convention, GCC will mark the end of a function with an N_FUN
393 symbol and an empty string. */
394 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
395 assemble_name (asmfile
, lscope_label_name
);
397 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
398 fprintf (asmfile
, "\n");
401 /* At the beginning of compilation, start writing the symbol table.
402 Initialize `typevec' and output the standard data types of C. */
405 dbxout_init (input_file_name
)
406 const char *input_file_name
;
408 char ltext_label_name
[100];
409 tree syms
= getdecls ();
411 asmfile
= asm_out_file
;
414 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
416 /* Convert Ltext into the appropriate format for local labels in case
417 the system doesn't insert underscores in front of user generated
419 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
421 /* Put the current working directory in an N_SO symbol. */
422 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
423 but GDB always does. */
424 if (use_gnu_debug_info_extensions
)
427 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
428 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
431 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
432 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
433 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
434 fprintf (asmfile
, "%s", ASM_STABS_OP
);
435 output_quoted_string (asmfile
, cwd
);
436 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
437 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
441 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
442 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
443 would give us an N_SOL, and we want an N_SO. */
444 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
445 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
446 /* We include outputting `Ltext:' here,
447 because that gives you a way to override it. */
448 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
449 fprintf (asmfile
, "%s", ASM_STABS_OP
);
450 output_quoted_string (asmfile
, input_file_name
);
451 fprintf (asmfile
, ",%d,0,0,%s\n",
452 N_SO
, <ext_label_name
[1]);
454 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
455 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
457 #ifdef DBX_OUTPUT_GCC_MARKER
458 DBX_OUTPUT_GCC_MARKER (asmfile
);
460 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
461 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
462 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
465 lastfile
= input_file_name
;
467 next_type_number
= 1;
470 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
471 current_file
->next
= NULL
;
472 current_file
->file_number
= 0;
473 current_file
->next_type_number
= 1;
474 next_file_number
= 1;
477 /* Make sure that types `int' and `char' have numbers 1 and 2.
478 Definitions of other integer types will refer to those numbers.
479 (Actually it should no longer matter what their numbers are.
480 Also, if any types with tags have been defined, dbxout_symbol
481 will output them first, so the numbers won't be 1 and 2. That
482 happens in C++. So it's a good thing it should no longer matter). */
484 #ifdef DBX_OUTPUT_STANDARD_TYPES
485 DBX_OUTPUT_STANDARD_TYPES (syms
);
487 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
488 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
491 /* Get all permanent types that have typedef names,
492 and output them all, except for those already output. */
494 dbxout_typedefs (syms
);
497 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
498 in the reverse order from that which is found in SYMS. */
501 dbxout_typedefs (syms
)
506 dbxout_typedefs (TREE_CHAIN (syms
));
507 if (TREE_CODE (syms
) == TYPE_DECL
)
509 tree type
= TREE_TYPE (syms
);
511 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
512 && COMPLETE_TYPE_P (type
)
513 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
514 dbxout_symbol (TYPE_NAME (type
), 0);
519 /* Change to reading from a new source file. Generate a N_BINCL stab. */
522 dbxout_start_source_file (line
, filename
)
523 unsigned int line ATTRIBUTE_UNUSED
;
524 const char *filename ATTRIBUTE_UNUSED
;
527 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
529 n
->next
= current_file
;
530 n
->file_number
= next_file_number
++;
531 n
->next_type_number
= 1;
533 fprintf (asmfile
, "%s", ASM_STABS_OP
);
534 output_quoted_string (asmfile
, filename
);
535 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
539 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
542 dbxout_end_source_file (line
)
543 unsigned int line ATTRIBUTE_UNUSED
;
546 struct dbx_file
*next
;
548 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
549 next
= current_file
->next
;
555 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
558 dbxout_source_file (file
, filename
)
560 const char *filename
;
562 char ltext_label_name
[100];
564 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
566 #ifdef DBX_OUTPUT_SOURCE_FILENAME
567 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
569 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
570 source_label_number
);
571 fprintf (file
, "%s", ASM_STABS_OP
);
572 output_quoted_string (file
, filename
);
573 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
574 if (current_function_decl
!= NULL_TREE
575 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
576 ; /* Don't change section amid function. */
579 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
580 source_label_number
++;
586 /* Output a line number symbol entry for source file FILENAME and line
590 dbxout_source_line (lineno
, filename
)
592 const char *filename
;
594 dbxout_source_file (asmfile
, filename
);
596 #ifdef ASM_OUTPUT_SOURCE_LINE
597 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
);
599 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
603 #if defined (DBX_DEBUGGING_INFO)
605 /* Describe the beginning of an internal block within a function. */
608 dbxout_begin_block (line
, n
)
609 unsigned int line ATTRIBUTE_UNUSED
;
612 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "LBB", n
);
615 /* Describe the end line-number of an internal block within a function. */
618 dbxout_end_block (line
, n
)
619 unsigned int line ATTRIBUTE_UNUSED
;
622 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "LBE", n
);
625 /* Output dbx data for a function definition.
626 This includes a definition of the function name itself (a symbol),
627 definitions of the parameters (locating them in the parameter list)
628 and then output the block that makes up the function's body
629 (including all the auto variables of the function). */
632 dbxout_function_decl (decl
)
635 #ifndef DBX_FUNCTION_FIRST
636 dbxout_begin_function (decl
);
638 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
639 #ifdef DBX_OUTPUT_FUNCTION_END
640 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
642 if (use_gnu_debug_info_extensions
643 #if defined(NO_DBX_FUNCTION_END)
644 && ! NO_DBX_FUNCTION_END
646 && targetm
.have_named_sections
)
647 dbxout_function_end ();
650 #endif /* DBX_DEBUGGING_INFO */
652 /* Debug information for a global DECL. Called from toplev.c after
653 compilation proper has finished. */
655 dbxout_global_decl (decl
)
658 if (TREE_CODE (decl
) == VAR_DECL
659 && ! DECL_EXTERNAL (decl
)
660 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
661 dbxout_symbol (decl
, 0);
664 /* At the end of compilation, finish writing the symbol table.
665 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
669 dbxout_finish (filename
)
670 const char *filename ATTRIBUTE_UNUSED
;
672 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
673 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
674 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
677 /* Output the index of a type. */
680 dbxout_type_index (type
)
683 #ifndef DBX_USE_BINCL
684 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
687 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
688 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
693 #if DBX_CONTIN_LENGTH > 0
694 /* Continue a symbol-description that gets too big.
695 End one symbol table entry with a double-backslash
696 and start a new one, eventually producing something like
697 .stabs "start......\\",code,0,value
698 .stabs "...rest",code,0,value */
703 #ifdef DBX_CONTIN_CHAR
704 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
706 fprintf (asmfile
, "\\\\");
708 dbxout_finish_symbol (NULL_TREE
);
709 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
710 current_sym_nchars
= 0;
712 #endif /* DBX_CONTIN_LENGTH > 0 */
714 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
715 This must be a separate function because anonymous unions require
719 dbxout_type_fields (type
)
724 /* Output the name, type, position (in bits), size (in bits) of each
725 field that we can support. */
726 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
728 /* Omit here local type decls until we know how to support them. */
729 if (TREE_CODE (tem
) == TYPE_DECL
730 /* Omit fields whose position or size are variable or too large to
732 || (TREE_CODE (tem
) == FIELD_DECL
733 && (! host_integerp (bit_position (tem
), 0)
735 || ! host_integerp (DECL_SIZE (tem
), 1)))
736 /* Omit here the nameless fields that are used to skip bits. */
737 || DECL_IGNORED_P (tem
))
740 else if (TREE_CODE (tem
) != CONST_DECL
)
742 /* Continue the line if necessary,
743 but not before the first field. */
744 if (tem
!= TYPE_FIELDS (type
))
749 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
750 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
754 fprintf (asmfile
, ":");
758 if (use_gnu_debug_info_extensions
759 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
760 || TREE_CODE (tem
) != FIELD_DECL
))
762 have_used_extensions
= 1;
764 putc ((TREE_PRIVATE (tem
) ? '0'
765 : TREE_PROTECTED (tem
) ? '1' : '2'),
770 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
771 && DECL_BIT_FIELD_TYPE (tem
))
772 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
774 if (TREE_CODE (tem
) == VAR_DECL
)
776 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
778 tree name
= DECL_ASSEMBLER_NAME (tem
);
780 have_used_extensions
= 1;
781 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
782 CHARS (IDENTIFIER_LENGTH (name
) + 2);
786 /* If TEM is non-static, GDB won't understand it. */
787 fprintf (asmfile
, ",0,0;");
794 print_wide_int (int_bit_position (tem
));
796 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
804 /* Subroutine of `dbxout_type_methods'. Output debug info about the
805 method described DECL. DEBUG_NAME is an encoding of the method's
806 type signature. ??? We may be able to do without DEBUG_NAME altogether
810 dbxout_type_method_1 (decl
, debug_name
)
812 const char *debug_name
;
816 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
818 else /* it's a METHOD_TYPE. */
820 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
821 /* A for normal functions.
822 B for `const' member functions.
823 C for `volatile' member functions.
824 D for `const volatile' member functions. */
825 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
827 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
830 if (DECL_VINDEX (decl
))
836 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
837 TREE_PRIVATE (decl
) ? '0'
838 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
839 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
840 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
842 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
844 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
847 dbxout_type (DECL_CONTEXT (decl
), 0);
848 fprintf (asmfile
, ";");
853 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
857 dbxout_type_methods (type
)
860 /* C++: put out the method names and their parameter lists */
861 tree methods
= TYPE_METHODS (type
);
863 register tree fndecl
;
865 char formatted_type_identifier_length
[16];
866 register int type_identifier_length
;
868 if (methods
== NULL_TREE
)
871 type_encoding
= DECL_NAME (TYPE_NAME (type
));
874 /* C++: Template classes break some assumptions made by this code about
875 the class names, constructor names, and encodings for assembler
876 label names. For now, disable output of dbx info for them. */
878 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
879 /* This should use index. (mrs) */
880 while (*ptr
&& *ptr
!= '<') ptr
++;
891 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
893 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
895 if (TREE_CODE (methods
) != TREE_VEC
)
897 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
898 fndecl
= TREE_VEC_ELT (methods
, 0);
900 fndecl
= TREE_VEC_ELT (methods
, 1);
906 /* Group together all the methods for the same operation.
907 These differ in the types of the arguments. */
908 for (last
= NULL_TREE
;
909 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
910 fndecl
= TREE_CHAIN (fndecl
))
911 /* Output the name of the field (after overloading), as
912 well as the name of the field before overloading, along
913 with its parameter list */
915 /* This is the "mangled" name of the method.
916 It encodes the argument types. */
917 const char *debug_name
;
919 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
920 include TEMPLATE_DECLs.) The debugger doesn't know what
921 to do with such entities anyhow. */
922 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
925 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
931 /* Also ignore abstract methods; those are only interesting to
932 the DWARF backends. */
933 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
936 /* Redundantly output the plain name, since that's what gdb
940 tree name
= DECL_NAME (fndecl
);
941 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
942 CHARS (IDENTIFIER_LENGTH (name
) + 2);
946 dbxout_type (TREE_TYPE (fndecl
), 0);
948 dbxout_type_method_1 (fndecl
, debug_name
);
958 /* Emit a "range" type specification, which has the form:
959 "r<index type>;<lower bound>;<upper bound>;".
960 TYPE is an INTEGER_TYPE. */
963 dbxout_range_type (type
)
966 fprintf (asmfile
, "r");
967 if (TREE_TYPE (type
))
968 dbxout_type (TREE_TYPE (type
), 0);
969 else if (TREE_CODE (type
) != INTEGER_TYPE
)
970 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
973 /* Traditionally, we made sure 'int' was type 1, and builtin types
974 were defined to be sub-ranges of int. Unfortunately, this
975 does not allow us to distinguish true sub-ranges from integer
976 types. So, instead we define integer (non-sub-range) types as
977 sub-ranges of themselves. This matters for Chill. If this isn't
978 a subrange type, then we want to define it in terms of itself.
979 However, in C, this may be an anonymous integer type, and we don't
980 want to emit debug info referring to it. Just calling
981 dbxout_type_index won't work anyways, because the type hasn't been
982 defined yet. We make this work for both cases by checked to see
983 whether this is a defined type, referring to it if it is, and using
985 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
986 dbxout_type_index (type
);
988 dbxout_type_index (integer_type_node
);
991 if (TYPE_MIN_VALUE (type
) != 0
992 && host_integerp (TYPE_MIN_VALUE (type
), 0))
996 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1000 fprintf (asmfile
, ";0");
1004 if (TYPE_MAX_VALUE (type
) != 0
1005 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1007 putc (';', asmfile
);
1009 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1010 putc (';', asmfile
);
1015 fprintf (asmfile
, ";-1;");
1020 /* Output a reference to a type. If the type has not yet been
1021 described in the dbx output, output its definition now.
1022 For a type already defined, just refer to its definition
1023 using the type number.
1025 If FULL is nonzero, and the type has been described only with
1026 a forward-reference, output the definition now.
1027 If FULL is zero in this case, just refer to the forward-reference
1028 using the number previously allocated. */
1031 dbxout_type (type
, full
)
1036 static int anonymous_type_number
= 0;
1038 if (TREE_CODE (type
) == VECTOR_TYPE
)
1039 type
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
1041 /* If there was an input error and we don't really have a type,
1042 avoid crashing and write something that is at least valid
1043 by assuming `int'. */
1044 if (type
== error_mark_node
)
1045 type
= integer_type_node
;
1048 /* Try to find the "main variant" with the same name but not const
1049 or volatile. (Since stabs does not distinguish const and volatile,
1050 there is no need to make them separate types. But types with
1051 different names are usefully distinguished.) */
1053 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
1054 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
1055 && TYPE_NAME (tem
) == TYPE_NAME (type
))
1060 if (TYPE_NAME (type
)
1061 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1062 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1066 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1068 /* Type has no dbx number assigned. Assign next available number. */
1069 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1071 /* Make sure type vector is long enough to record about this type. */
1073 if (next_type_number
== typevec_len
)
1076 = (struct typeinfo
*) xrealloc (typevec
,
1077 typevec_len
* 2 * sizeof typevec
[0]);
1078 memset ((char *) (typevec
+ typevec_len
), 0,
1079 typevec_len
* sizeof typevec
[0]);
1083 #ifdef DBX_USE_BINCL
1084 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1085 = current_file
->file_number
;
1086 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1087 = current_file
->next_type_number
++;
1091 /* Output the number of this type, to refer to it. */
1092 dbxout_type_index (type
);
1094 #ifdef DBX_TYPE_DEFINED
1095 if (DBX_TYPE_DEFINED (type
))
1099 /* If this type's definition has been output or is now being output,
1102 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1107 /* If we have already had a cross reference,
1108 and either that's all we want or that's the best we could do,
1109 don't repeat the cross reference.
1110 Sun dbx crashes if we do. */
1111 if (! full
|| !COMPLETE_TYPE_P (type
)
1112 /* No way in DBX fmt to describe a variable size. */
1113 || ! host_integerp (TYPE_SIZE (type
), 1))
1121 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1122 leave the type-number completely undefined rather than output
1123 a cross-reference. If we have already used GNU debug info extensions,
1124 then it is OK to output a cross reference. This is necessary to get
1125 proper C++ debug output. */
1126 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1127 || TREE_CODE (type
) == QUAL_UNION_TYPE
1128 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1129 && ! use_gnu_debug_info_extensions
)
1130 /* We must use the same test here as we use twice below when deciding
1131 whether to emit a cross-reference. */
1132 if ((TYPE_NAME (type
) != 0
1133 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1134 && DECL_IGNORED_P (TYPE_NAME (type
)))
1136 || !COMPLETE_TYPE_P (type
)
1137 /* No way in DBX fmt to describe a variable size. */
1138 || ! host_integerp (TYPE_SIZE (type
), 1))
1140 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1145 /* Output a definition now. */
1147 fprintf (asmfile
, "=");
1150 /* Mark it as defined, so that if it is self-referent
1151 we will not get into an infinite recursion of definitions. */
1153 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1155 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1156 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1158 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1162 switch (TREE_CODE (type
))
1166 /* For a void type, just define it as itself; ie, "5=5".
1167 This makes us consider it defined
1168 without saying what it is. The debugger will make it
1169 a void type when the reference is seen, and nothing will
1170 ever override that default. */
1171 dbxout_type_index (type
);
1175 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1177 /* Output the type `char' as a subrange of itself!
1178 I don't understand this definition, just copied it
1179 from the output of pcc.
1180 This used to use `r2' explicitly and we used to
1181 take care to make sure that `char' was type number 2. */
1182 fprintf (asmfile
, "r");
1184 dbxout_type_index (type
);
1185 fprintf (asmfile
, ";0;127;");
1189 /* If this is a subtype of another integer type, always prefer to
1190 write it as a subtype. */
1191 else if (TREE_TYPE (type
) != 0
1192 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1193 dbxout_range_type (type
);
1197 /* If the size is non-standard, say what it is if we can use
1200 if (use_gnu_debug_info_extensions
1201 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1203 have_used_extensions
= 1;
1204 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1208 /* If we can use GDB extensions and the size is wider than a
1209 long (the size used by GDB to read them) or we may have
1210 trouble writing the bounds the usual way, write them in
1211 octal. Note the test is for the *target's* size of "long",
1212 not that of the host. The host test is just to make sure we
1213 can write it out in case the host wide int is narrower than the
1216 /* For unsigned types, we use octal if they are the same size or
1217 larger. This is because we print the bounds as signed decimal,
1218 and hence they can't span same size unsigned types. */
1220 if (use_gnu_debug_info_extensions
1221 && TYPE_MIN_VALUE (type
) != 0
1222 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1223 && TYPE_MAX_VALUE (type
) != 0
1224 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1225 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1226 || ((TYPE_PRECISION (type
)
1227 == TYPE_PRECISION (integer_type_node
))
1228 && TREE_UNSIGNED (type
))
1229 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1230 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1231 && TREE_UNSIGNED (type
))))
1233 fprintf (asmfile
, "r");
1235 dbxout_type_index (type
);
1236 fprintf (asmfile
, ";");
1238 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1239 fprintf (asmfile
, ";");
1241 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1242 fprintf (asmfile
, ";");
1247 /* Output other integer types as subranges of `int'. */
1248 dbxout_range_type (type
);
1254 /* This used to say `r1' and we used to take care
1255 to make sure that `int' was type number 1. */
1256 fprintf (asmfile
, "r");
1258 dbxout_type_index (integer_type_node
);
1259 putc (';', asmfile
);
1261 print_wide_int (int_size_in_bytes (type
));
1262 fputs (";0;", asmfile
);
1267 if (use_gnu_debug_info_extensions
)
1269 have_used_extensions
= 1;
1270 fputs ("@s", asmfile
);
1272 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1273 fputs (";-20;", asmfile
);
1278 /* Output the type `char' as a subrange of itself.
1279 That is what pcc seems to do. */
1280 fprintf (asmfile
, "r");
1282 dbxout_type_index (char_type_node
);
1283 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1289 if (use_gnu_debug_info_extensions
)
1291 have_used_extensions
= 1;
1292 fputs ("@s", asmfile
);
1294 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1295 fputs (";-16;", asmfile
);
1298 else /* Define as enumeral type (False, True) */
1300 fprintf (asmfile
, "eFalse:0,True:1,;");
1306 putc ('d', asmfile
);
1308 dbxout_type (TREE_TYPE (type
), 0);
1312 /* Differs from the REAL_TYPE by its new data type number */
1314 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1316 fprintf (asmfile
, "r");
1318 dbxout_type_index (type
);
1319 putc (';', asmfile
);
1321 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1322 fputs (";0;", asmfile
);
1327 /* Output a complex integer type as a structure,
1328 pending some other way to do it. */
1329 putc ('s', asmfile
);
1331 print_wide_int (int_size_in_bytes (type
));
1332 fprintf (asmfile
, "real:");
1335 dbxout_type (TREE_TYPE (type
), 0);
1336 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1338 fprintf (asmfile
, "imag:");
1340 dbxout_type (TREE_TYPE (type
), 0);
1341 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1342 TYPE_PRECISION (TREE_TYPE (type
)));
1348 if (use_gnu_debug_info_extensions
)
1350 have_used_extensions
= 1;
1351 fputs ("@s", asmfile
);
1353 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1354 putc (';', asmfile
);
1357 /* Check if a bitstring type, which in Chill is
1358 different from a [power]set. */
1359 if (TYPE_STRING_FLAG (type
))
1361 fprintf (asmfile
, "@S;");
1365 putc ('S', asmfile
);
1367 dbxout_type (TYPE_DOMAIN (type
), 0);
1371 /* Make arrays of packed bits look like bitstrings for chill. */
1372 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1374 have_used_extensions
= 1;
1375 fputs ("@s", asmfile
);
1377 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1378 fprintf (asmfile
, ";@S;S");
1380 dbxout_type (TYPE_DOMAIN (type
), 0);
1384 /* Output "a" followed by a range type definition
1385 for the index type of the array
1386 followed by a reference to the target-type.
1387 ar1;0;N;M for a C array of type M and size N+1. */
1388 /* Check if a character string type, which in Chill is
1389 different from an array of characters. */
1390 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1392 have_used_extensions
= 1;
1393 fprintf (asmfile
, "@S;");
1396 tem
= TYPE_DOMAIN (type
);
1399 fprintf (asmfile
, "ar");
1401 dbxout_type_index (integer_type_node
);
1402 fprintf (asmfile
, ";0;-1;");
1407 fprintf (asmfile
, "a");
1409 dbxout_range_type (tem
);
1412 dbxout_type (TREE_TYPE (type
), 0);
1417 case QUAL_UNION_TYPE
:
1419 int i
, n_baseclasses
= 0;
1421 if (TYPE_BINFO (type
) != 0
1422 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1423 && TYPE_BINFO_BASETYPES (type
) != 0)
1424 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1426 /* Output a structure type. We must use the same test here as we
1427 use in the DBX_NO_XREFS case above. */
1428 if ((TYPE_NAME (type
) != 0
1429 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1430 && DECL_IGNORED_P (TYPE_NAME (type
)))
1432 || !COMPLETE_TYPE_P (type
)
1433 /* No way in DBX fmt to describe a variable size. */
1434 || ! host_integerp (TYPE_SIZE (type
), 1))
1436 /* If the type is just a cross reference, output one
1437 and mark the type as partially described.
1438 If it later becomes defined, we will output
1439 its real definition.
1440 If the type has a name, don't nest its definition within
1441 another type's definition; instead, output an xref
1442 and let the definition come when the name is defined. */
1443 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1445 #if 0 /* This assertion is legitimately false in C++. */
1446 /* We shouldn't be outputting a reference to a type before its
1447 definition unless the type has a tag name.
1448 A typedef name without a tag name should be impossible. */
1449 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1452 if (TYPE_NAME (type
) != 0)
1453 dbxout_type_name (type
);
1456 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1460 fprintf (asmfile
, ":");
1462 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1466 /* Identify record or union, and print its size. */
1467 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1469 print_wide_int (int_size_in_bytes (type
));
1471 if (use_gnu_debug_info_extensions
)
1475 have_used_extensions
= 1;
1476 fprintf (asmfile
, "!%d,", n_baseclasses
);
1480 for (i
= 0; i
< n_baseclasses
; i
++)
1482 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1484 if (use_gnu_debug_info_extensions
)
1486 have_used_extensions
= 1;
1487 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1488 putc (TREE_VIA_PUBLIC (child
) ? '2' : '0', asmfile
);
1490 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1492 putc (',', asmfile
);
1494 dbxout_type (BINFO_TYPE (child
), 0);
1495 putc (';', asmfile
);
1500 /* Print out the base class information with fields
1501 which have the same names at the types they hold. */
1502 dbxout_type_name (BINFO_TYPE (child
));
1503 putc (':', asmfile
);
1505 dbxout_type (BINFO_TYPE (child
), full
);
1506 putc (',', asmfile
);
1508 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1510 putc (',', asmfile
);
1512 print_wide_int (tree_low_cst (DECL_SIZE
1514 (BINFO_TYPE (child
))),
1517 putc (';', asmfile
);
1523 /* Write out the field declarations. */
1524 dbxout_type_fields (type
);
1525 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1527 have_used_extensions
= 1;
1528 dbxout_type_methods (type
);
1531 putc (';', asmfile
);
1534 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1535 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1536 && TYPE_VFIELD (type
))
1538 have_used_extensions
= 1;
1540 /* Tell GDB+ that it may keep reading. */
1541 putc ('~', asmfile
);
1544 /* We need to write out info about what field this class
1545 uses as its "main" vtable pointer field, because if this
1546 field is inherited from a base class, GDB cannot necessarily
1547 figure out which field it's using in time. */
1548 if (TYPE_VFIELD (type
))
1550 putc ('%', asmfile
);
1552 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1555 putc (';', asmfile
);
1561 /* We must use the same test here as we use in the DBX_NO_XREFS case
1562 above. We simplify it a bit since an enum will never have a variable
1564 if ((TYPE_NAME (type
) != 0
1565 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1566 && DECL_IGNORED_P (TYPE_NAME (type
)))
1568 || !COMPLETE_TYPE_P (type
))
1570 fprintf (asmfile
, "xe");
1572 dbxout_type_name (type
);
1573 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1574 putc (':', asmfile
);
1578 #ifdef DBX_OUTPUT_ENUM
1579 DBX_OUTPUT_ENUM (asmfile
, type
);
1581 if (use_gnu_debug_info_extensions
1582 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1584 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1588 putc ('e', asmfile
);
1590 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1592 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1593 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1594 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1595 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1596 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1597 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1598 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1600 print_int_cst_octal (TREE_VALUE (tem
));
1602 putc (',', asmfile
);
1604 if (TREE_CHAIN (tem
) != 0)
1608 putc (';', asmfile
);
1614 putc ('*', asmfile
);
1616 dbxout_type (TREE_TYPE (type
), 0);
1620 if (use_gnu_debug_info_extensions
)
1622 have_used_extensions
= 1;
1623 putc ('#', asmfile
);
1626 /* Write the argument types out longhand. */
1627 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1628 putc (',', asmfile
);
1630 dbxout_type (TREE_TYPE (type
), 0);
1631 dbxout_args (TYPE_ARG_TYPES (type
));
1632 putc (';', asmfile
);
1636 /* Treat it as a function type. */
1637 dbxout_type (TREE_TYPE (type
), 0);
1641 if (use_gnu_debug_info_extensions
)
1643 have_used_extensions
= 1;
1644 putc ('@', asmfile
);
1646 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1647 putc (',', asmfile
);
1649 dbxout_type (TREE_TYPE (type
), 0);
1652 /* Should print as an int, because it is really just an offset. */
1653 dbxout_type (integer_type_node
, 0);
1656 case REFERENCE_TYPE
:
1657 if (use_gnu_debug_info_extensions
)
1658 have_used_extensions
= 1;
1659 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1661 dbxout_type (TREE_TYPE (type
), 0);
1665 putc ('f', asmfile
);
1667 dbxout_type (TREE_TYPE (type
), 0);
1675 /* Print the value of integer constant C, in octal,
1676 handling double precision. */
1679 print_int_cst_octal (c
)
1682 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1683 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1684 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1685 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1687 /* GDB wants constants with no extra leading "1" bits, so
1688 we need to remove any sign-extension that might be
1690 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1692 else if (width
> HOST_BITS_PER_WIDE_INT
)
1693 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1694 else if (width
== HOST_BITS_PER_WIDE_INT
)
1697 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1699 fprintf (asmfile
, "0");
1704 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1705 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1709 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1710 unsigned HOST_WIDE_INT middle
1711 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1712 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1713 unsigned HOST_WIDE_INT end
1714 = low
& (((unsigned HOST_WIDE_INT
) 1
1715 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1718 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1720 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1725 print_octal (value
, digits
)
1726 unsigned HOST_WIDE_INT value
;
1731 for (i
= digits
- 1; i
>= 0; i
--)
1732 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1737 /* Output C in decimal while adjusting the number of digits written. */
1745 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1756 /* Output the name of type TYPE, with no punctuation.
1757 Such names can be set up either by typedef declarations
1758 or by struct, enum and union tags. */
1761 dbxout_type_name (type
)
1765 if (TYPE_NAME (type
) == 0)
1767 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1769 t
= TYPE_NAME (type
);
1771 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1773 t
= DECL_NAME (TYPE_NAME (type
));
1778 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1779 CHARS (IDENTIFIER_LENGTH (t
));
1782 /* Output a .stabs for the symbol defined by DECL,
1783 which must be a ..._DECL node in the normal namespace.
1784 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1785 LOCAL is nonzero if the scope is less than the entire file.
1786 Return 1 if a stabs might have been emitted. */
1789 dbxout_symbol (decl
, local
)
1791 int local ATTRIBUTE_UNUSED
;
1793 tree type
= TREE_TYPE (decl
);
1794 tree context
= NULL_TREE
;
1797 /* Cast avoids warning in old compilers. */
1798 current_sym_code
= (STAB_CODE_TYPE
) 0;
1799 current_sym_value
= 0;
1800 current_sym_addr
= 0;
1802 /* Ignore nameless syms, but don't ignore type tags. */
1804 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1805 || DECL_IGNORED_P (decl
))
1808 dbxout_prepare_symbol (decl
);
1810 /* The output will always start with the symbol name,
1811 so always count that in the length-output-so-far. */
1813 if (DECL_NAME (decl
) != 0)
1814 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1816 switch (TREE_CODE (decl
))
1819 /* Enum values are defined by defining the enum type. */
1823 if (DECL_RTL (decl
) == 0)
1825 if (DECL_EXTERNAL (decl
))
1827 /* Don't mention a nested function under its parent. */
1828 context
= decl_function_context (decl
);
1829 if (context
== current_function_decl
)
1831 if (GET_CODE (DECL_RTL (decl
)) != MEM
1832 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1836 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
1837 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1838 TREE_PUBLIC (decl
) ? 'F' : 'f');
1841 current_sym_code
= N_FUN
;
1842 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1844 if (TREE_TYPE (type
))
1845 dbxout_type (TREE_TYPE (type
), 0);
1847 dbxout_type (void_type_node
, 0);
1849 /* For a nested function, when that function is compiled,
1850 mention the containing function name
1851 as well as (since dbx wants it) our own assembler-name. */
1853 fprintf (asmfile
, ",%s,%s",
1854 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1855 IDENTIFIER_POINTER (DECL_NAME (context
)));
1857 dbxout_finish_symbol (decl
);
1862 /* This seems all wrong. Outputting most kinds of types gives no name
1863 at all. A true definition gives no name; a cross-ref for a
1864 structure can give the tag name, but not a type name.
1865 It seems that no typedef name is defined by outputting a type. */
1867 /* If this typedef name was defined by outputting the type,
1868 don't duplicate it. */
1869 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1870 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1873 /* Don't output the same typedef twice.
1874 And don't output what language-specific stuff doesn't want output. */
1875 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1884 if (DECL_NAME (decl
))
1886 /* Nonzero means we must output a tag as well as a typedef. */
1889 /* Handle the case of a C++ structure or union
1890 where the TYPE_NAME is a TYPE_DECL
1891 which gives both a typedef name and a tag. */
1892 /* dbx requires the tag first and the typedef second. */
1893 if ((TREE_CODE (type
) == RECORD_TYPE
1894 || TREE_CODE (type
) == UNION_TYPE
1895 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1896 && TYPE_NAME (type
) == decl
1897 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1898 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1899 /* Distinguish the implicit typedefs of C++
1900 from explicit ones that might be found in C. */
1901 && DECL_ARTIFICIAL (decl
)
1902 /* Do not generate a tag for records of variable size,
1903 since this type can not be properly described in the
1904 DBX format, and it confuses some tools such as objdump. */
1905 && host_integerp (TYPE_SIZE (type
), 1))
1907 tree name
= TYPE_NAME (type
);
1908 if (TREE_CODE (name
) == TYPE_DECL
)
1909 name
= DECL_NAME (name
);
1911 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1912 current_sym_value
= 0;
1913 current_sym_addr
= 0;
1914 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1916 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1917 IDENTIFIER_POINTER (name
));
1918 dbxout_type (type
, 1);
1919 dbxout_finish_symbol (NULL_TREE
);
1922 /* Output typedef name. */
1923 fprintf (asmfile
, "%s\"%s:", ASM_STABS_OP
,
1924 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1926 /* Short cut way to output a tag also. */
1927 if ((TREE_CODE (type
) == RECORD_TYPE
1928 || TREE_CODE (type
) == UNION_TYPE
1929 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1930 && TYPE_NAME (type
) == decl
1931 /* Distinguish the implicit typedefs of C++
1932 from explicit ones that might be found in C. */
1933 && DECL_ARTIFICIAL (decl
))
1935 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1937 putc ('T', asmfile
);
1938 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1940 #if 0 /* Now we generate the tag for this case up above. */
1946 putc ('t', asmfile
);
1947 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1949 dbxout_type (type
, 1);
1950 dbxout_finish_symbol (decl
);
1954 /* Don't output a tag if this is an incomplete type. This prevents
1955 the sun4 Sun OS 4.x dbx from crashing. */
1957 if (tag_needed
&& TYPE_NAME (type
) != 0
1958 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1959 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1960 && COMPLETE_TYPE_P (type
)
1961 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1963 /* For a TYPE_DECL with no name, but the type has a name,
1965 This is what represents `struct foo' with no typedef. */
1966 /* In C++, the name of a type is the corresponding typedef.
1967 In C, it is an IDENTIFIER_NODE. */
1968 tree name
= TYPE_NAME (type
);
1969 if (TREE_CODE (name
) == TYPE_DECL
)
1970 name
= DECL_NAME (name
);
1972 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1973 current_sym_value
= 0;
1974 current_sym_addr
= 0;
1975 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1977 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
1978 IDENTIFIER_POINTER (name
));
1979 dbxout_type (type
, 1);
1980 dbxout_finish_symbol (NULL_TREE
);
1984 /* If an enum type has no name, it cannot be referred to,
1985 but we must output it anyway, since the enumeration constants
1986 can be referred to. */
1987 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1989 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1990 current_sym_value
= 0;
1991 current_sym_addr
= 0;
1992 current_sym_nchars
= 2;
1994 /* Some debuggers fail when given NULL names, so give this a
1995 harmless name of ` '. */
1996 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
1997 dbxout_type (type
, 1);
1998 dbxout_finish_symbol (NULL_TREE
);
2001 /* Prevent duplicate output of a typedef. */
2002 TREE_ASM_WRITTEN (decl
) = 1;
2007 /* Parm decls go in their own separate chains
2008 and are output by dbxout_reg_parms and dbxout_parms. */
2012 /* Named return value, treat like a VAR_DECL. */
2014 if (! DECL_RTL_SET_P (decl
))
2016 /* Don't mention a variable that is external.
2017 Let the file that defines it describe it. */
2018 if (DECL_EXTERNAL (decl
))
2021 /* If the variable is really a constant
2022 and not written in memory, inform the debugger. */
2023 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2024 && DECL_INITIAL (decl
) != 0
2025 && host_integerp (DECL_INITIAL (decl
), 0)
2026 && ! TREE_ASM_WRITTEN (decl
)
2027 && (DECL_CONTEXT (decl
) == NULL_TREE
2028 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2030 if (TREE_PUBLIC (decl
) == 0)
2032 /* The sun4 assembler does not grok this. */
2033 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2035 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2036 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2038 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2039 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
2040 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
2042 fprintf (asmfile
, "%s\"%s:c=i", ASM_STABS_OP
, name
);
2044 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
2045 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
2049 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2051 /* don't know how to do this yet. */
2055 /* else it is something we handle like a normal variable. */
2058 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2059 #ifdef LEAF_REG_REMAP
2060 if (current_function_uses_only_leaf_regs
)
2061 leaf_renumber_regs_insn (DECL_RTL (decl
));
2064 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2073 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2074 Add SUFFIX to its name, if SUFFIX is not 0.
2075 Describe the variable as residing in HOME
2076 (usually HOME is DECL_RTL (DECL), but not always).
2077 Returns 1 if the stab was really emitted. */
2080 dbxout_symbol_location (decl
, type
, suffix
, home
)
2088 /* Don't mention a variable at all
2089 if it was completely optimized into nothingness.
2091 If the decl was from an inline function, then its rtl
2092 is not identically the rtl that was used in this
2093 particular compilation. */
2094 if (GET_CODE (home
) == SUBREG
)
2098 while (GET_CODE (value
) == SUBREG
)
2099 value
= SUBREG_REG (value
);
2100 if (GET_CODE (value
) == REG
)
2102 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2105 home
= alter_subreg (home
);
2107 if (GET_CODE (home
) == REG
)
2109 regno
= REGNO (home
);
2110 if (regno
>= FIRST_PSEUDO_REGISTER
)
2114 /* The kind-of-variable letter depends on where
2115 the variable is and on the scope of its name:
2116 G and N_GSYM for static storage and global scope,
2117 S for static storage and file scope,
2118 V for static storage and local scope,
2119 for those two, use N_LCSYM if data is in bss segment,
2120 N_STSYM if in data segment, N_FUN otherwise.
2121 (We used N_FUN originally, then changed to N_STSYM
2122 to please GDB. However, it seems that confused ld.
2123 Now GDB has been fixed to like N_FUN, says Kingdon.)
2124 no letter at all, and N_LSYM, for auto variable,
2125 r and N_RSYM for register variable. */
2127 if (GET_CODE (home
) == MEM
2128 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2130 if (TREE_PUBLIC (decl
))
2133 current_sym_code
= N_GSYM
;
2137 current_sym_addr
= XEXP (home
, 0);
2139 letter
= decl_function_context (decl
) ? 'V' : 'S';
2141 /* This should be the same condition as in assemble_variable, but
2142 we don't have access to dont_output_data here. So, instead,
2143 we rely on the fact that error_mark_node initializers always
2144 end up in bss for C++ and never end up in bss for C. */
2145 if (DECL_INITIAL (decl
) == 0
2146 || (!strcmp (lang_identify (), "cplusplus")
2147 && DECL_INITIAL (decl
) == error_mark_node
))
2148 current_sym_code
= N_LCSYM
;
2149 else if (DECL_IN_TEXT_SECTION (decl
))
2150 /* This is not quite right, but it's the closest
2151 of all the codes that Unix defines. */
2152 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2155 /* Ultrix `as' seems to need this. */
2156 #ifdef DBX_STATIC_STAB_DATA_SECTION
2159 current_sym_code
= N_STSYM
;
2163 else if (regno
>= 0)
2166 current_sym_code
= N_RSYM
;
2167 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2169 else if (GET_CODE (home
) == MEM
2170 && (GET_CODE (XEXP (home
, 0)) == MEM
2171 || (GET_CODE (XEXP (home
, 0)) == REG
2172 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2173 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2174 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2175 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2178 /* If the value is indirect by memory or by a register
2179 that isn't the frame pointer
2180 then it means the object is variable-sized and address through
2181 that register or stack slot. DBX has no way to represent this
2182 so all we can do is output the variable as a pointer.
2183 If it's not a parameter, ignore it.
2184 (VAR_DECLs like this can be made by integrate.c.) */
2186 if (GET_CODE (XEXP (home
, 0)) == REG
)
2189 current_sym_code
= N_RSYM
;
2190 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2194 current_sym_code
= N_LSYM
;
2195 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2196 We want the value of that CONST_INT. */
2198 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2201 /* Effectively do build_pointer_type, but don't cache this type,
2202 since it might be temporary whereas the type it points to
2203 might have been saved for inlining. */
2204 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2205 type
= make_node (POINTER_TYPE
);
2206 TREE_TYPE (type
) = TREE_TYPE (decl
);
2208 else if (GET_CODE (home
) == MEM
2209 && GET_CODE (XEXP (home
, 0)) == REG
)
2211 current_sym_code
= N_LSYM
;
2212 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2214 else if (GET_CODE (home
) == MEM
2215 && GET_CODE (XEXP (home
, 0)) == PLUS
2216 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2218 current_sym_code
= N_LSYM
;
2219 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2220 We want the value of that CONST_INT. */
2221 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2223 else if (GET_CODE (home
) == MEM
2224 && GET_CODE (XEXP (home
, 0)) == CONST
)
2226 /* Handle an obscure case which can arise when optimizing and
2227 when there are few available registers. (This is *always*
2228 the case for i386/i486 targets). The RTL looks like
2229 (MEM (CONST ...)) even though this variable is a local `auto'
2230 or a local `register' variable. In effect, what has happened
2231 is that the reload pass has seen that all assignments and
2232 references for one such a local variable can be replaced by
2233 equivalent assignments and references to some static storage
2234 variable, thereby avoiding the need for a register. In such
2235 cases we're forced to lie to debuggers and tell them that
2236 this variable was itself `static'. */
2237 current_sym_code
= N_LCSYM
;
2239 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2241 else if (GET_CODE (home
) == CONCAT
)
2245 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2246 for example), then there is no easy way to figure out
2247 what SUBTYPE should be. So, we give up. */
2248 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2251 subtype
= TREE_TYPE (type
);
2253 /* If the variable's storage is in two parts,
2254 output each as a separate stab with a modified name. */
2255 if (WORDS_BIG_ENDIAN
)
2256 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2258 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2260 /* Cast avoids warning in old compilers. */
2261 current_sym_code
= (STAB_CODE_TYPE
) 0;
2262 current_sym_value
= 0;
2263 current_sym_addr
= 0;
2264 dbxout_prepare_symbol (decl
);
2266 if (WORDS_BIG_ENDIAN
)
2267 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2269 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2273 /* Address might be a MEM, when DECL is a variable-sized object.
2274 Or it might be const0_rtx, meaning previous passes
2275 want us to ignore this variable. */
2278 /* Ok, start a symtab entry and output the variable name. */
2281 #ifdef DBX_STATIC_BLOCK_START
2282 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2285 dbxout_symbol_name (decl
, suffix
, letter
);
2286 dbxout_type (type
, 0);
2287 dbxout_finish_symbol (decl
);
2289 #ifdef DBX_STATIC_BLOCK_END
2290 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2295 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2296 Then output LETTER to indicate the kind of location the symbol has. */
2299 dbxout_symbol_name (decl
, suffix
, letter
)
2306 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2307 /* One slight hitch: if this is a VAR_DECL which is a static
2308 class member, we must put out the mangled name instead of the
2309 DECL_NAME. Note also that static member (variable) names DO NOT begin
2310 with underscores in .stabs directives. */
2311 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2313 /* ...but if we're function-local, we don't want to include the junk
2314 added by ASM_FORMAT_PRIVATE_NAME. */
2315 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2319 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2320 (suffix
? suffix
: ""));
2323 putc (letter
, asmfile
);
2327 dbxout_prepare_symbol (decl
)
2328 tree decl ATTRIBUTE_UNUSED
;
2331 const char *filename
= DECL_SOURCE_FILE (decl
);
2333 dbxout_source_file (asmfile
, filename
);
2338 dbxout_finish_symbol (sym
)
2341 #ifdef DBX_FINISH_SYMBOL
2342 DBX_FINISH_SYMBOL (sym
);
2345 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2346 line
= DECL_SOURCE_LINE (sym
);
2348 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2349 if (current_sym_addr
)
2350 output_addr_const (asmfile
, current_sym_addr
);
2352 fprintf (asmfile
, "%d", current_sym_value
);
2353 putc ('\n', asmfile
);
2357 /* Output definitions of all the decls in a chain. Return non-zero if
2358 anything was output */
2367 result
+= dbxout_symbol (syms
, 1);
2368 syms
= TREE_CHAIN (syms
);
2373 /* The following two functions output definitions of function parameters.
2374 Each parameter gets a definition locating it in the parameter list.
2375 Each parameter that is a register variable gets a second definition
2376 locating it in the register.
2378 Printing or argument lists in gdb uses the definitions that
2379 locate in the parameter list. But reference to the variable in
2380 expressions uses preferentially the definition as a register. */
2382 /* Output definitions, referring to storage in the parmlist,
2383 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2386 dbxout_parms (parms
)
2389 for (; parms
; parms
= TREE_CHAIN (parms
))
2390 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2392 dbxout_prepare_symbol (parms
);
2394 /* Perform any necessary register eliminations on the parameter's rtl,
2395 so that the debugging output will be accurate. */
2396 DECL_INCOMING_RTL (parms
)
2397 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2398 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2399 #ifdef LEAF_REG_REMAP
2400 if (current_function_uses_only_leaf_regs
)
2402 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2403 leaf_renumber_regs_insn (DECL_RTL (parms
));
2407 if (PARM_PASSED_IN_MEMORY (parms
))
2409 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2411 /* ??? Here we assume that the parm address is indexed
2412 off the frame pointer or arg pointer.
2413 If that is not true, we produce meaningless results,
2414 but do not crash. */
2415 if (GET_CODE (addr
) == PLUS
2416 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2417 current_sym_value
= INTVAL (XEXP (addr
, 1));
2419 current_sym_value
= 0;
2421 current_sym_code
= N_PSYM
;
2422 current_sym_addr
= 0;
2425 if (DECL_NAME (parms
))
2427 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2429 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2430 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2431 DBX_MEMPARM_STABS_LETTER
);
2435 current_sym_nchars
= 8;
2436 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2437 DBX_MEMPARM_STABS_LETTER
);
2440 /* It is quite tempting to use:
2442 dbxout_type (TREE_TYPE (parms), 0);
2444 as the next statement, rather than using DECL_ARG_TYPE(), so
2445 that gcc reports the actual type of the parameter, rather
2446 than the promoted type. This certainly makes GDB's life
2447 easier, at least for some ports. The change is a bad idea
2448 however, since GDB expects to be able access the type without
2449 performing any conversions. So for example, if we were
2450 passing a float to an unprototyped function, gcc will store a
2451 double on the stack, but if we emit a stab saying the type is a
2452 float, then gdb will only read in a single value, and this will
2453 produce an erropneous value. */
2454 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2455 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2456 dbxout_finish_symbol (parms
);
2458 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2461 char regparm_letter
;
2463 /* Parm passed in registers and lives in registers or nowhere. */
2465 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2466 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2467 current_sym_addr
= 0;
2469 /* If parm lives in a register, use that register;
2470 pretend the parm was passed there. It would be more consistent
2471 to describe the register where the parm was passed,
2472 but in practice that register usually holds something else.
2474 If we use DECL_RTL, then we must use the declared type of
2475 the variable, not the type that it arrived in. */
2476 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2478 best_rtl
= DECL_RTL (parms
);
2479 parm_type
= TREE_TYPE (parms
);
2481 /* If the parm lives nowhere, use the register where it was
2482 passed. It is also better to use the declared type here. */
2485 best_rtl
= DECL_INCOMING_RTL (parms
);
2486 parm_type
= TREE_TYPE (parms
);
2488 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2491 if (DECL_NAME (parms
))
2493 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2494 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2495 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2500 current_sym_nchars
= 8;
2501 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2505 dbxout_type (parm_type
, 0);
2506 dbxout_finish_symbol (parms
);
2508 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2509 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2510 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2511 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2512 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2513 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2517 /* Parm was passed via invisible reference.
2518 That is, its address was passed in a register.
2519 Output it as if it lived in that register.
2520 The debugger will know from the type
2521 that it was actually passed by invisible reference. */
2523 char regparm_letter
;
2524 /* Parm passed in registers and lives in registers or nowhere. */
2526 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2527 if (use_gnu_debug_info_extensions
)
2528 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2530 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2532 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2533 If it is an unallocated pseudo-reg, then use the register where
2534 it was passed instead. */
2535 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2536 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2538 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2540 current_sym_addr
= 0;
2543 if (DECL_NAME (parms
))
2546 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2548 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2549 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2554 current_sym_nchars
= 8;
2555 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2559 dbxout_type (TREE_TYPE (parms
), 0);
2560 dbxout_finish_symbol (parms
);
2562 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2563 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2565 /* Parm was passed via invisible reference, with the reference
2566 living on the stack. DECL_RTL looks like
2567 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2568 could look like (MEM (MEM (REG))). */
2569 const char *decl_name
= (DECL_NAME (parms
)
2570 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2572 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2573 current_sym_value
= 0;
2576 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2577 current_sym_addr
= 0;
2580 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2581 dbxout_type (TREE_TYPE (parms
), 0);
2582 dbxout_finish_symbol (parms
);
2584 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2585 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2586 /* ??? A constant address for a parm can happen
2587 when the reg it lives in is equiv to a constant in memory.
2588 Should make this not happen, after 2.4. */
2589 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2591 /* Parm was passed in registers but lives on the stack. */
2593 current_sym_code
= N_PSYM
;
2594 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2595 in which case we want the value of that CONST_INT,
2597 in which case we use a value of zero. */
2598 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2599 current_sym_value
= 0;
2602 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2604 current_sym_addr
= 0;
2606 /* Make a big endian correction if the mode of the type of the
2607 parameter is not the same as the mode of the rtl. */
2608 if (BYTES_BIG_ENDIAN
2609 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2610 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2612 current_sym_value
+=
2613 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2614 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2618 if (DECL_NAME (parms
))
2621 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2623 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2624 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2625 DBX_MEMPARM_STABS_LETTER
);
2629 current_sym_nchars
= 8;
2630 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2631 DBX_MEMPARM_STABS_LETTER
);
2635 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2636 XEXP (DECL_RTL (parms
), 0));
2637 dbxout_type (TREE_TYPE (parms
), 0);
2638 dbxout_finish_symbol (parms
);
2643 /* Output definitions for the places where parms live during the function,
2644 when different from where they were passed, when the parms were passed
2647 It is not useful to do this for parms passed in registers
2648 that live during the function in different registers, because it is
2649 impossible to look in the passed register for the passed value,
2650 so we use the within-the-function register to begin with.
2652 PARMS is a chain of PARM_DECL nodes. */
2655 dbxout_reg_parms (parms
)
2658 for (; parms
; parms
= TREE_CHAIN (parms
))
2659 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2661 dbxout_prepare_symbol (parms
);
2663 /* Report parms that live in registers during the function
2664 but were passed in memory. */
2665 if (GET_CODE (DECL_RTL (parms
)) == REG
2666 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2667 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2668 0, DECL_RTL (parms
));
2669 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2670 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2671 0, DECL_RTL (parms
));
2672 /* Report parms that live in memory but not where they were passed. */
2673 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2674 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2675 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2676 0, DECL_RTL (parms
));
2680 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2681 output definitions of those names, in raw form */
2689 putc (',', asmfile
);
2690 dbxout_type (TREE_VALUE (args
), 0);
2692 args
= TREE_CHAIN (args
);
2696 /* Output everything about a symbol block (a BLOCK node
2697 that represents a scope level),
2698 including recursive output of contained blocks.
2700 BLOCK is the BLOCK node.
2701 DEPTH is its depth within containing symbol blocks.
2702 ARGS is usually zero; but for the outermost block of the
2703 body of a function, it is a chain of PARM_DECLs for the function parameters.
2704 We output definitions of all the register parms
2705 as if they were local variables of that block.
2707 If -g1 was used, we count blocks just the same, but output nothing
2708 except for the outermost block.
2710 Actually, BLOCK may be several blocks chained together.
2711 We handle them all in sequence. */
2714 dbxout_block (block
, depth
, args
)
2715 register tree block
;
2721 #if DBX_BLOCKS_FUNCTION_RELATIVE
2722 const char *begin_label
;
2723 if (current_function_func_begin_label
!= NULL_TREE
)
2724 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2726 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2731 /* Ignore blocks never expanded or otherwise marked as real. */
2732 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2736 #ifdef DBX_LBRAC_FIRST
2739 /* In dbx format, the syms of a block come before the N_LBRAC.
2740 If nothing is output, we don't need the N_LBRAC, either. */
2742 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2743 did_output
= dbxout_syms (BLOCK_VARS (block
));
2745 dbxout_reg_parms (args
);
2748 /* Now output an N_LBRAC symbol to represent the beginning of
2749 the block. Use the block's tree-walk order to generate
2750 the assembler symbols LBBn and LBEn
2751 that final will define around the code in this block. */
2752 if (depth
> 0 && did_output
)
2755 blocknum
= BLOCK_NUMBER (block
);
2756 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2758 if (BLOCK_HANDLER_BLOCK (block
))
2760 /* A catch block. Must precede N_LBRAC. */
2761 tree decl
= BLOCK_VARS (block
);
2764 #ifdef DBX_OUTPUT_CATCH
2765 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2767 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2768 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2769 assemble_name (asmfile
, buf
);
2770 fprintf (asmfile
, "\n");
2772 decl
= TREE_CHAIN (decl
);
2776 #ifdef DBX_OUTPUT_LBRAC
2777 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2779 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2780 assemble_name (asmfile
, buf
);
2781 #if DBX_BLOCKS_FUNCTION_RELATIVE
2782 putc ('-', asmfile
);
2783 assemble_name (asmfile
, begin_label
);
2785 fprintf (asmfile
, "\n");
2789 #ifdef DBX_LBRAC_FIRST
2790 /* On some weird machines, the syms of a block
2791 come after the N_LBRAC. */
2792 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2793 dbxout_syms (BLOCK_VARS (block
));
2795 dbxout_reg_parms (args
);
2798 /* Output the subblocks. */
2799 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2801 /* Refer to the marker for the end of the block. */
2802 if (depth
> 0 && did_output
)
2805 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2806 #ifdef DBX_OUTPUT_RBRAC
2807 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2809 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2810 assemble_name (asmfile
, buf
);
2811 #if DBX_BLOCKS_FUNCTION_RELATIVE
2812 putc ('-', asmfile
);
2813 assemble_name (asmfile
, begin_label
);
2815 fprintf (asmfile
, "\n");
2819 block
= BLOCK_CHAIN (block
);
2823 /* Output the information about a function and its arguments and result.
2824 Usually this follows the function's code,
2825 but on some systems, it comes before. */
2828 dbxout_begin_function (decl
)
2831 dbxout_symbol (decl
, 0);
2832 dbxout_parms (DECL_ARGUMENTS (decl
));
2833 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2834 dbxout_symbol (DECL_RESULT (decl
), 1);
2837 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */