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, 2002, 2003 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'. */
73 #include "coretypes.h"
80 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
90 #include "langhooks.h"
92 #ifdef XCOFF_DEBUGGING_INFO
97 #define ASM_STABS_OP "\t.stabs\t"
101 #define ASM_STABN_OP "\t.stabn\t"
104 #ifndef DBX_TYPE_DECL_STABS_CODE
105 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
108 #ifndef DBX_STATIC_CONST_VAR_CODE
109 #define DBX_STATIC_CONST_VAR_CODE N_FUN
112 #ifndef DBX_REGPARM_STABS_CODE
113 #define DBX_REGPARM_STABS_CODE N_RSYM
116 #ifndef DBX_REGPARM_STABS_LETTER
117 #define DBX_REGPARM_STABS_LETTER 'P'
120 /* This is used for parameters passed by invisible reference in a register. */
121 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
122 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
125 #ifndef DBX_MEMPARM_STABS_LETTER
126 #define DBX_MEMPARM_STABS_LETTER 'p'
129 #ifndef FILE_NAME_JOINER
130 #define FILE_NAME_JOINER "/"
133 /* GDB needs to know that the stabs were generated by GCC. We emit an
134 N_OPT stab at the beginning of the source file to indicate this.
135 The string is historical, and different on a very few targets. */
136 #ifndef STABS_GCC_MARKER
137 #define STABS_GCC_MARKER "gcc2_compiled."
140 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
142 /* Structure recording information about a C data type.
143 The status element says whether we have yet output
144 the definition of the type. TYPE_XREF says we have
145 output it as a cross-reference only.
146 The file_number and type_number elements are used if DBX_USE_BINCL
149 struct typeinfo
GTY(())
151 enum typestatus status
;
156 /* Vector recording information about C data types.
157 When we first notice a data type (a tree node),
158 we assign it a number using next_type_number.
159 That is its index in this vector. */
161 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
163 /* Number of elements of space allocated in `typevec'. */
165 static GTY(()) int typevec_len
;
167 /* In dbx output, each type gets a unique number.
168 This is the number for the next type output.
169 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
171 static GTY(()) int next_type_number
;
173 /* When using N_BINCL in dbx output, each type number is actually a
174 pair of the file number and the type number within the file.
175 This is a stack of input files. */
177 struct dbx_file
GTY(())
179 struct dbx_file
*next
;
181 int next_type_number
;
184 /* This is the top of the stack. */
186 static GTY(()) struct dbx_file
*current_file
;
188 /* This is the next file number to use. */
190 static GTY(()) int next_file_number
;
192 /* A counter for dbxout_function_end. */
194 static GTY(()) int scope_labelno
;
196 /* Nonzero if we have actually used any of the GDB extensions
197 to the debugging format. The idea is that we use them for the
198 first time only if there's a strong reason, but once we have done that,
199 we use them whenever convenient. */
201 static GTY(()) int have_used_extensions
= 0;
203 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
204 for the N_SO filename stabs label. */
206 static GTY(()) int source_label_number
= 1;
208 /* Last source file name mentioned in a NOTE insn. */
210 static GTY(()) const char *lastfile
;
212 /* Used by PCH machinery to detect if 'lastfile' should be reset to
214 static GTY(()) int lastfile_is_base
;
216 /* Typical USG systems don't have stab.h, and they also have
217 no use for DBX-format debugging info. */
219 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
221 /* The original input file name. */
222 static const char *base_input_file
;
224 /* Current working directory. */
226 static const char *cwd
;
228 #ifdef DEBUG_SYMS_TEXT
229 #define FORCE_TEXT function_section (current_function_decl);
236 #define STAB_CODE_TYPE enum __stab_debug_code
238 /* 1 if PARM is passed to this function in memory. */
240 #define PARM_PASSED_IN_MEMORY(PARM) \
241 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
243 /* A C expression for the integer offset value of an automatic variable
244 (N_LSYM) having address X (an RTX). */
245 #ifndef DEBUGGER_AUTO_OFFSET
246 #define DEBUGGER_AUTO_OFFSET(X) \
247 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
250 /* A C expression for the integer offset value of an argument (N_PSYM)
251 having address X (an RTX). The nominal offset is OFFSET. */
252 #ifndef DEBUGGER_ARG_OFFSET
253 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
256 /* Stream for writing to assembler file. */
258 static FILE *asmfile
;
260 /* These variables are for dbxout_symbol to communicate to
261 dbxout_finish_symbol.
262 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
263 current_sym_value and current_sym_addr are two ways to address the
264 value to store in the symtab entry.
265 current_sym_addr if nonzero represents the value as an rtx.
266 If that is zero, current_sym_value is used. This is used
267 when the value is an offset (such as for auto variables,
268 register variables and parms). */
270 static STAB_CODE_TYPE current_sym_code
;
271 static int current_sym_value
;
272 static rtx current_sym_addr
;
274 /* Number of chars of symbol-description generated so far for the
275 current symbol. Used by CHARS and CONTIN. */
277 static int current_sym_nchars
;
279 /* Report having output N chars of the current symbol-description. */
281 #define CHARS(N) (current_sym_nchars += (N))
283 /* Break the current symbol-description, generating a continuation,
284 if it has become long. */
286 #ifndef DBX_CONTIN_LENGTH
287 #define DBX_CONTIN_LENGTH 80
290 #if DBX_CONTIN_LENGTH > 0
292 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
294 #define CONTIN do { } while (0)
297 static void dbxout_init
PARAMS ((const char *));
298 static void dbxout_finish
PARAMS ((const char *));
299 static void dbxout_start_source_file
PARAMS ((unsigned, const char *));
300 static void dbxout_end_source_file
PARAMS ((unsigned));
301 static void dbxout_typedefs
PARAMS ((tree
));
302 static void dbxout_fptype_value
PARAMS ((tree
));
303 static void dbxout_type_index
PARAMS ((tree
));
304 #if DBX_CONTIN_LENGTH > 0
305 static void dbxout_continue
PARAMS ((void));
307 static void dbxout_args
PARAMS ((tree
));
308 static void dbxout_type_fields
PARAMS ((tree
));
309 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
310 static void dbxout_type_methods
PARAMS ((tree
));
311 static void dbxout_range_type
PARAMS ((tree
));
312 static void dbxout_type
PARAMS ((tree
, int));
313 static void print_int_cst_octal
PARAMS ((tree
));
314 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
315 static void print_wide_int
PARAMS ((HOST_WIDE_INT
));
316 static void dbxout_type_name
PARAMS ((tree
));
317 static void dbxout_class_name_qualifiers
PARAMS ((tree
));
318 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
319 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
320 static void dbxout_prepare_symbol
PARAMS ((tree
));
321 static void dbxout_finish_symbol
PARAMS ((tree
));
322 static void dbxout_block
PARAMS ((tree
, int, tree
));
323 static void dbxout_global_decl
PARAMS ((tree
));
325 /* The debug hooks structure. */
326 #if defined (DBX_DEBUGGING_INFO)
328 static void dbxout_source_line
PARAMS ((unsigned int, const char *));
329 static void dbxout_source_file
PARAMS ((FILE *, const char *));
330 static void dbxout_function_end
PARAMS ((void));
331 static void dbxout_begin_function
PARAMS ((tree
));
332 static void dbxout_begin_block
PARAMS ((unsigned, unsigned));
333 static void dbxout_end_block
PARAMS ((unsigned, unsigned));
334 static void dbxout_function_decl
PARAMS ((tree
));
335 static void dbxout_handle_pch
PARAMS ((unsigned));
337 const struct gcc_debug_hooks dbx_debug_hooks
=
341 debug_nothing_int_charstar
,
342 debug_nothing_int_charstar
,
343 dbxout_start_source_file
,
344 dbxout_end_source_file
,
347 debug_true_tree
, /* ignore_block */
348 dbxout_source_line
, /* source_line */
349 dbxout_source_line
, /* begin_prologue: just output line info */
350 debug_nothing_int_charstar
, /* end_prologue */
351 debug_nothing_int_charstar
, /* end_epilogue */
352 #ifdef DBX_FUNCTION_FIRST
353 dbxout_begin_function
,
355 debug_nothing_tree
, /* begin_function */
357 debug_nothing_int
, /* end_function */
358 dbxout_function_decl
,
359 dbxout_global_decl
, /* global_decl */
360 debug_nothing_tree
, /* deferred_inline_function */
361 debug_nothing_tree
, /* outlining_inline_function */
362 debug_nothing_rtx
, /* label */
363 dbxout_handle_pch
/* handle_pch */
365 #endif /* DBX_DEBUGGING_INFO */
367 #if defined (XCOFF_DEBUGGING_INFO)
368 const struct gcc_debug_hooks xcoff_debug_hooks
=
372 debug_nothing_int_charstar
,
373 debug_nothing_int_charstar
,
374 dbxout_start_source_file
,
375 dbxout_end_source_file
,
376 xcoffout_begin_block
,
378 debug_true_tree
, /* ignore_block */
379 xcoffout_source_line
,
380 xcoffout_begin_prologue
, /* begin_prologue */
381 debug_nothing_int_charstar
, /* end_prologue */
382 xcoffout_end_epilogue
,
383 debug_nothing_tree
, /* begin_function */
384 xcoffout_end_function
,
385 debug_nothing_tree
, /* function_decl */
386 dbxout_global_decl
, /* global_decl */
387 debug_nothing_tree
, /* deferred_inline_function */
388 debug_nothing_tree
, /* outlining_inline_function */
389 debug_nothing_rtx
, /* label */
390 dbxout_handle_pch
/* handle_pch */
392 #endif /* XCOFF_DEBUGGING_INFO */
394 #if defined (DBX_DEBUGGING_INFO)
396 dbxout_function_end ()
398 char lscope_label_name
[100];
399 /* Convert Ltext into the appropriate format for local labels in case
400 the system doesn't insert underscores in front of user generated
402 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
403 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
406 /* By convention, GCC will mark the end of a function with an N_FUN
407 symbol and an empty string. */
408 #ifdef DBX_OUTPUT_NFUN
409 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
411 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
412 assemble_name (asmfile
, lscope_label_name
);
414 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
415 fprintf (asmfile
, "\n");
418 #endif /* DBX_DEBUGGING_INFO */
420 /* At the beginning of compilation, start writing the symbol table.
421 Initialize `typevec' and output the standard data types of C. */
424 dbxout_init (input_file_name
)
425 const char *input_file_name
;
427 char ltext_label_name
[100];
428 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
430 asmfile
= asm_out_file
;
433 typevec
= (struct typeinfo
*) ggc_calloc (typevec_len
, sizeof typevec
[0]);
435 /* Convert Ltext into the appropriate format for local labels in case
436 the system doesn't insert underscores in front of user generated
438 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
440 /* Put the current working directory in an N_SO symbol. */
441 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
442 but GDB always does. */
443 if (use_gnu_debug_info_extensions
)
446 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
447 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
450 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
451 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
452 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
453 fprintf (asmfile
, "%s", ASM_STABS_OP
);
454 output_quoted_string (asmfile
, cwd
);
455 fprintf (asmfile
, ",%d,0,0,", N_SO
);
456 assemble_name (asmfile
, ltext_label_name
);
457 fputc ('\n', asmfile
);
458 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
462 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
463 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
464 would give us an N_SOL, and we want an N_SO. */
465 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
466 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
467 /* We include outputting `Ltext:' here,
468 because that gives you a way to override it. */
469 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
470 fprintf (asmfile
, "%s", ASM_STABS_OP
);
471 output_quoted_string (asmfile
, input_file_name
);
472 fprintf (asmfile
, ",%d,0,0,", N_SO
);
473 assemble_name (asmfile
, ltext_label_name
);
474 fputc ('\n', asmfile
);
476 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
477 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
479 #ifdef DBX_OUTPUT_GCC_MARKER
480 DBX_OUTPUT_GCC_MARKER (asmfile
);
482 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
483 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
484 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
487 base_input_file
= lastfile
= input_file_name
;
489 next_type_number
= 1;
492 current_file
= (struct dbx_file
*) ggc_alloc (sizeof *current_file
);
493 current_file
->next
= NULL
;
494 current_file
->file_number
= 0;
495 current_file
->next_type_number
= 1;
496 next_file_number
= 1;
499 /* Make sure that types `int' and `char' have numbers 1 and 2.
500 Definitions of other integer types will refer to those numbers.
501 (Actually it should no longer matter what their numbers are.
502 Also, if any types with tags have been defined, dbxout_symbol
503 will output them first, so the numbers won't be 1 and 2. That
504 happens in C++. So it's a good thing it should no longer matter). */
506 #ifdef DBX_OUTPUT_STANDARD_TYPES
507 DBX_OUTPUT_STANDARD_TYPES (syms
);
509 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
510 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
513 /* Get all permanent types that have typedef names,
514 and output them all, except for those already output. */
516 dbxout_typedefs (syms
);
519 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
520 in the reverse order from that which is found in SYMS. */
523 dbxout_typedefs (syms
)
528 dbxout_typedefs (TREE_CHAIN (syms
));
529 if (TREE_CODE (syms
) == TYPE_DECL
)
531 tree type
= TREE_TYPE (syms
);
533 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
534 && COMPLETE_TYPE_P (type
)
535 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
536 dbxout_symbol (TYPE_NAME (type
), 0);
541 /* Change to reading from a new source file. Generate a N_BINCL stab. */
544 dbxout_start_source_file (line
, filename
)
545 unsigned int line ATTRIBUTE_UNUSED
;
546 const char *filename ATTRIBUTE_UNUSED
;
549 struct dbx_file
*n
= (struct dbx_file
*) ggc_alloc (sizeof *n
);
551 n
->next
= current_file
;
552 n
->file_number
= next_file_number
++;
553 n
->next_type_number
= 1;
555 fprintf (asmfile
, "%s", ASM_STABS_OP
);
556 output_quoted_string (asmfile
, filename
);
557 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
561 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
564 dbxout_end_source_file (line
)
565 unsigned int line ATTRIBUTE_UNUSED
;
568 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
569 current_file
= current_file
->next
;
573 /* Handle a few odd cases that occur when trying to make PCH files work. */
576 dbxout_handle_pch (unsigned at_end
)
580 /* When using the PCH, this file will be included, so we need to output
582 dbxout_start_source_file (0, lastfile
);
584 /* The base file when using the PCH won't be the same as
585 the base file when it's being generated. */
590 /* ... and an EINCL. */
591 dbxout_end_source_file (0);
593 /* Deal with cases where 'lastfile' was never actually changed. */
594 lastfile_is_base
= lastfile
== NULL
;
598 #if defined (DBX_DEBUGGING_INFO)
599 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
602 dbxout_source_file (file
, filename
)
604 const char *filename
;
606 if (lastfile
== 0 && lastfile_is_base
)
608 lastfile
= base_input_file
;
609 lastfile_is_base
= 0;
612 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
614 #ifdef DBX_OUTPUT_SOURCE_FILENAME
615 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
617 char ltext_label_name
[100];
619 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
620 source_label_number
);
621 fprintf (file
, "%s", ASM_STABS_OP
);
622 output_quoted_string (file
, filename
);
623 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
624 assemble_name (asmfile
, ltext_label_name
);
625 fputc ('\n', asmfile
);
626 if (current_function_decl
!= NULL_TREE
627 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
628 ; /* Don't change section amid function. */
631 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
632 source_label_number
++;
638 /* Output a line number symbol entry for source file FILENAME and line
642 dbxout_source_line (lineno
, filename
)
644 const char *filename
;
646 dbxout_source_file (asmfile
, filename
);
648 #ifdef ASM_OUTPUT_SOURCE_LINE
649 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
);
651 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
655 /* Describe the beginning of an internal block within a function. */
658 dbxout_begin_block (line
, n
)
659 unsigned int line ATTRIBUTE_UNUSED
;
662 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
665 /* Describe the end line-number of an internal block within a function. */
668 dbxout_end_block (line
, n
)
669 unsigned int line ATTRIBUTE_UNUSED
;
672 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
675 /* Output dbx data for a function definition.
676 This includes a definition of the function name itself (a symbol),
677 definitions of the parameters (locating them in the parameter list)
678 and then output the block that makes up the function's body
679 (including all the auto variables of the function). */
682 dbxout_function_decl (decl
)
685 #ifndef DBX_FUNCTION_FIRST
686 dbxout_begin_function (decl
);
688 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
689 #ifdef DBX_OUTPUT_FUNCTION_END
690 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
692 if (use_gnu_debug_info_extensions
693 #if defined(NO_DBX_FUNCTION_END)
694 && ! NO_DBX_FUNCTION_END
696 && targetm
.have_named_sections
)
697 dbxout_function_end ();
700 #endif /* DBX_DEBUGGING_INFO */
702 /* Debug information for a global DECL. Called from toplev.c after
703 compilation proper has finished. */
705 dbxout_global_decl (decl
)
708 if (TREE_CODE (decl
) == VAR_DECL
709 && ! DECL_EXTERNAL (decl
)
710 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
711 dbxout_symbol (decl
, 0);
714 /* At the end of compilation, finish writing the symbol table.
715 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
719 dbxout_finish (filename
)
720 const char *filename ATTRIBUTE_UNUSED
;
722 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
723 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
724 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
727 /* Output floating point type values used by the 'R' stab letter.
728 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
730 There are only 3 real/complex types defined, and we need 7/6.
731 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
732 complex type. Since we have the type size anyways, we don't really need
733 to distinguish between different FP types, we only need to distinguish
734 between float and complex. This works fine with gdb.
736 We only use this for complex types, to avoid breaking backwards
737 compatibility for real types. complex types aren't in ISO C90, so it is
738 OK if old debuggers don't understand the debug info we emit for them. */
740 /* ??? These are supposed to be IEEE types, but we don't check for that.
741 We could perhaps add additional numbers for non-IEEE types if we need
745 dbxout_fptype_value (type
)
749 enum machine_mode mode
= TYPE_MODE (type
);
751 if (TREE_CODE (type
) == REAL_TYPE
)
755 else if (mode
== DFmode
)
757 else if (mode
== TFmode
|| mode
== XFmode
)
760 /* Use NF_SINGLE as a generic real type for other sizes. */
763 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
767 else if (mode
== DCmode
)
769 else if (mode
== TCmode
|| mode
== XCmode
)
772 /* Use NF_COMPLEX as a generic complex type for other sizes. */
778 putc (value
, asmfile
);
782 /* Output the index of a type. */
785 dbxout_type_index (type
)
788 #ifndef DBX_USE_BINCL
789 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
792 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
793 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
798 #if DBX_CONTIN_LENGTH > 0
799 /* Continue a symbol-description that gets too big.
800 End one symbol table entry with a double-backslash
801 and start a new one, eventually producing something like
802 .stabs "start......\\",code,0,value
803 .stabs "...rest",code,0,value */
808 #ifdef DBX_CONTIN_CHAR
809 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
811 fprintf (asmfile
, "\\\\");
813 dbxout_finish_symbol (NULL_TREE
);
814 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
815 current_sym_nchars
= 0;
817 #endif /* DBX_CONTIN_LENGTH > 0 */
819 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
820 This must be a separate function because anonymous unions require
824 dbxout_type_fields (type
)
829 /* Output the name, type, position (in bits), size (in bits) of each
830 field that we can support. */
831 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
833 /* Omit here local type decls until we know how to support them. */
834 if (TREE_CODE (tem
) == TYPE_DECL
835 /* Omit fields whose position or size are variable or too large to
837 || (TREE_CODE (tem
) == FIELD_DECL
838 && (! host_integerp (bit_position (tem
), 0)
840 || ! host_integerp (DECL_SIZE (tem
), 1)))
841 /* Omit here the nameless fields that are used to skip bits. */
842 || DECL_IGNORED_P (tem
))
845 else if (TREE_CODE (tem
) != CONST_DECL
)
847 /* Continue the line if necessary,
848 but not before the first field. */
849 if (tem
!= TYPE_FIELDS (type
))
854 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
855 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
859 fprintf (asmfile
, ":");
863 if (use_gnu_debug_info_extensions
864 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
865 || TREE_CODE (tem
) != FIELD_DECL
))
867 have_used_extensions
= 1;
869 putc ((TREE_PRIVATE (tem
) ? '0'
870 : TREE_PROTECTED (tem
) ? '1' : '2'),
875 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
876 && DECL_BIT_FIELD_TYPE (tem
))
877 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
879 if (TREE_CODE (tem
) == VAR_DECL
)
881 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
883 tree name
= DECL_ASSEMBLER_NAME (tem
);
885 have_used_extensions
= 1;
886 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
887 CHARS (IDENTIFIER_LENGTH (name
) + 2);
891 /* If TEM is non-static, GDB won't understand it. */
892 fprintf (asmfile
, ",0,0;");
899 print_wide_int (int_bit_position (tem
));
901 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
909 /* Subroutine of `dbxout_type_methods'. Output debug info about the
910 method described DECL. DEBUG_NAME is an encoding of the method's
911 type signature. ??? We may be able to do without DEBUG_NAME altogether
915 dbxout_type_method_1 (decl
, debug_name
)
917 const char *debug_name
;
921 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
923 else /* it's a METHOD_TYPE. */
925 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
926 /* A for normal functions.
927 B for `const' member functions.
928 C for `volatile' member functions.
929 D for `const volatile' member functions. */
930 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
932 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
935 if (DECL_VINDEX (decl
))
941 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
942 TREE_PRIVATE (decl
) ? '0'
943 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
944 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
945 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
947 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
949 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
952 dbxout_type (DECL_CONTEXT (decl
), 0);
953 fprintf (asmfile
, ";");
958 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
962 dbxout_type_methods (type
)
965 /* C++: put out the method names and their parameter lists */
966 tree methods
= TYPE_METHODS (type
);
970 char formatted_type_identifier_length
[16];
971 int type_identifier_length
;
973 if (methods
== NULL_TREE
)
976 type_encoding
= DECL_NAME (TYPE_NAME (type
));
979 /* C++: Template classes break some assumptions made by this code about
980 the class names, constructor names, and encodings for assembler
981 label names. For now, disable output of dbx info for them. */
983 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
984 /* This should use index. (mrs) */
985 while (*ptr
&& *ptr
!= '<') ptr
++;
996 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
998 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1000 if (TREE_CODE (methods
) != TREE_VEC
)
1002 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1003 fndecl
= TREE_VEC_ELT (methods
, 0);
1005 fndecl
= TREE_VEC_ELT (methods
, 1);
1009 int need_prefix
= 1;
1011 /* Group together all the methods for the same operation.
1012 These differ in the types of the arguments. */
1013 for (last
= NULL_TREE
;
1014 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1015 fndecl
= TREE_CHAIN (fndecl
))
1016 /* Output the name of the field (after overloading), as
1017 well as the name of the field before overloading, along
1018 with its parameter list */
1020 /* This is the "mangled" name of the method.
1021 It encodes the argument types. */
1022 const char *debug_name
;
1024 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1025 include TEMPLATE_DECLs.) The debugger doesn't know what
1026 to do with such entities anyhow. */
1027 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1030 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1036 /* Also ignore abstract methods; those are only interesting to
1037 the DWARF backends. */
1038 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1041 /* Redundantly output the plain name, since that's what gdb
1045 tree name
= DECL_NAME (fndecl
);
1046 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1047 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1051 dbxout_type (TREE_TYPE (fndecl
), 0);
1053 dbxout_type_method_1 (fndecl
, debug_name
);
1057 putc (';', asmfile
);
1063 /* Emit a "range" type specification, which has the form:
1064 "r<index type>;<lower bound>;<upper bound>;".
1065 TYPE is an INTEGER_TYPE. */
1068 dbxout_range_type (type
)
1071 fprintf (asmfile
, "r");
1072 if (TREE_TYPE (type
))
1073 dbxout_type (TREE_TYPE (type
), 0);
1074 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1075 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1078 /* Traditionally, we made sure 'int' was type 1, and builtin types
1079 were defined to be sub-ranges of int. Unfortunately, this
1080 does not allow us to distinguish true sub-ranges from integer
1081 types. So, instead we define integer (non-sub-range) types as
1082 sub-ranges of themselves. This matters for Chill. If this isn't
1083 a subrange type, then we want to define it in terms of itself.
1084 However, in C, this may be an anonymous integer type, and we don't
1085 want to emit debug info referring to it. Just calling
1086 dbxout_type_index won't work anyways, because the type hasn't been
1087 defined yet. We make this work for both cases by checked to see
1088 whether this is a defined type, referring to it if it is, and using
1090 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1091 dbxout_type_index (type
);
1093 dbxout_type_index (integer_type_node
);
1096 if (TYPE_MIN_VALUE (type
) != 0
1097 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1099 putc (';', asmfile
);
1101 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1105 fprintf (asmfile
, ";0");
1109 if (TYPE_MAX_VALUE (type
) != 0
1110 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1112 putc (';', asmfile
);
1114 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1115 putc (';', asmfile
);
1120 fprintf (asmfile
, ";-1;");
1125 /* Output a reference to a type. If the type has not yet been
1126 described in the dbx output, output its definition now.
1127 For a type already defined, just refer to its definition
1128 using the type number.
1130 If FULL is nonzero, and the type has been described only with
1131 a forward-reference, output the definition now.
1132 If FULL is zero in this case, just refer to the forward-reference
1133 using the number previously allocated. */
1136 dbxout_type (type
, full
)
1142 static int anonymous_type_number
= 0;
1144 if (TREE_CODE (type
) == VECTOR_TYPE
)
1145 /* The frontend feeds us a representation for the vector as a struct
1146 containing an array. Pull out the array type. */
1147 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1149 /* If there was an input error and we don't really have a type,
1150 avoid crashing and write something that is at least valid
1151 by assuming `int'. */
1152 if (type
== error_mark_node
)
1153 type
= integer_type_node
;
1156 if (TYPE_NAME (type
)
1157 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1158 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1162 /* Try to find the "main variant" with the same name. */
1163 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1164 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1165 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1167 main_variant
= TYPE_MAIN_VARIANT (type
);
1169 /* If we are not using extensions, stabs does not distinguish const and
1170 volatile, so there is no need to make them separate types. */
1171 if (!use_gnu_debug_info_extensions
)
1172 type
= main_variant
;
1174 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1176 /* Type has no dbx number assigned. Assign next available number. */
1177 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1179 /* Make sure type vector is long enough to record about this type. */
1181 if (next_type_number
== typevec_len
)
1184 = (struct typeinfo
*) ggc_realloc (typevec
,
1186 * sizeof typevec
[0]));
1187 memset ((char *) (typevec
+ typevec_len
), 0,
1188 typevec_len
* sizeof typevec
[0]);
1192 #ifdef DBX_USE_BINCL
1193 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1194 = current_file
->file_number
;
1195 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1196 = current_file
->next_type_number
++;
1200 /* Output the number of this type, to refer to it. */
1201 dbxout_type_index (type
);
1203 #ifdef DBX_TYPE_DEFINED
1204 if (DBX_TYPE_DEFINED (type
))
1208 /* If this type's definition has been output or is now being output,
1211 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1216 /* If we have already had a cross reference,
1217 and either that's all we want or that's the best we could do,
1218 don't repeat the cross reference.
1219 Sun dbx crashes if we do. */
1220 if (! full
|| !COMPLETE_TYPE_P (type
)
1221 /* No way in DBX fmt to describe a variable size. */
1222 || ! host_integerp (TYPE_SIZE (type
), 1))
1230 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1231 leave the type-number completely undefined rather than output
1232 a cross-reference. If we have already used GNU debug info extensions,
1233 then it is OK to output a cross reference. This is necessary to get
1234 proper C++ debug output. */
1235 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1236 || TREE_CODE (type
) == QUAL_UNION_TYPE
1237 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1238 && ! use_gnu_debug_info_extensions
)
1239 /* We must use the same test here as we use twice below when deciding
1240 whether to emit a cross-reference. */
1241 if ((TYPE_NAME (type
) != 0
1242 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1243 && DECL_IGNORED_P (TYPE_NAME (type
)))
1245 || !COMPLETE_TYPE_P (type
)
1246 /* No way in DBX fmt to describe a variable size. */
1247 || ! host_integerp (TYPE_SIZE (type
), 1))
1249 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1254 /* Output a definition now. */
1256 fprintf (asmfile
, "=");
1259 /* Mark it as defined, so that if it is self-referent
1260 we will not get into an infinite recursion of definitions. */
1262 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1264 /* If this type is a variant of some other, hand off. Types with
1265 different names are usefully distinguished. We only distinguish
1266 cv-qualified types if we're using extensions. */
1267 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1269 putc ('k', asmfile
);
1271 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1274 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1276 putc ('B', asmfile
);
1278 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1281 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1283 /* 'type' is a typedef; output the type it refers to. */
1284 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1287 /* else continue. */
1289 switch (TREE_CODE (type
))
1293 /* For a void type, just define it as itself; ie, "5=5".
1294 This makes us consider it defined
1295 without saying what it is. The debugger will make it
1296 a void type when the reference is seen, and nothing will
1297 ever override that default. */
1298 dbxout_type_index (type
);
1302 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1304 /* Output the type `char' as a subrange of itself!
1305 I don't understand this definition, just copied it
1306 from the output of pcc.
1307 This used to use `r2' explicitly and we used to
1308 take care to make sure that `char' was type number 2. */
1309 fprintf (asmfile
, "r");
1311 dbxout_type_index (type
);
1312 fprintf (asmfile
, ";0;127;");
1316 /* If this is a subtype of another integer type, always prefer to
1317 write it as a subtype. */
1318 else if (TREE_TYPE (type
) != 0
1319 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1321 /* If the size is non-standard, say what it is if we can use
1324 if (use_gnu_debug_info_extensions
1325 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1327 have_used_extensions
= 1;
1328 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1332 dbxout_range_type (type
);
1337 /* If the size is non-standard, say what it is if we can use
1340 if (use_gnu_debug_info_extensions
1341 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1343 have_used_extensions
= 1;
1344 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1348 /* If we can use GDB extensions and the size is wider than a
1349 long (the size used by GDB to read them) or we may have
1350 trouble writing the bounds the usual way, write them in
1351 octal. Note the test is for the *target's* size of "long",
1352 not that of the host. The host test is just to make sure we
1353 can write it out in case the host wide int is narrower than the
1356 /* For unsigned types, we use octal if they are the same size or
1357 larger. This is because we print the bounds as signed decimal,
1358 and hence they can't span same size unsigned types. */
1360 if (use_gnu_debug_info_extensions
1361 && TYPE_MIN_VALUE (type
) != 0
1362 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1363 && TYPE_MAX_VALUE (type
) != 0
1364 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1365 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1366 || ((TYPE_PRECISION (type
)
1367 == TYPE_PRECISION (integer_type_node
))
1368 && TREE_UNSIGNED (type
))
1369 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1370 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1371 && TREE_UNSIGNED (type
))))
1373 fprintf (asmfile
, "r");
1376 /* If this type derives from another type, output type index of
1377 parent type. This is particularly important when parent type
1378 is an enumerated type, because not generating the parent type
1379 index would transform the definition of this enumerated type
1380 into a plain unsigned type. */
1381 if (TREE_TYPE (type
) != 0)
1382 dbxout_type_index (TREE_TYPE (type
));
1384 dbxout_type_index (type
);
1386 fprintf (asmfile
, ";");
1388 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1389 fprintf (asmfile
, ";");
1391 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1392 fprintf (asmfile
, ";");
1397 /* Output other integer types as subranges of `int'. */
1398 dbxout_range_type (type
);
1404 /* This used to say `r1' and we used to take care
1405 to make sure that `int' was type number 1. */
1406 fprintf (asmfile
, "r");
1408 dbxout_type_index (integer_type_node
);
1409 putc (';', asmfile
);
1411 print_wide_int (int_size_in_bytes (type
));
1412 fputs (";0;", asmfile
);
1417 if (use_gnu_debug_info_extensions
)
1419 have_used_extensions
= 1;
1420 fputs ("@s", asmfile
);
1422 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1423 fputs (";-20;", asmfile
);
1428 /* Output the type `char' as a subrange of itself.
1429 That is what pcc seems to do. */
1430 fprintf (asmfile
, "r");
1432 dbxout_type_index (char_type_node
);
1433 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1439 if (use_gnu_debug_info_extensions
)
1441 have_used_extensions
= 1;
1442 fputs ("@s", asmfile
);
1444 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1445 fputs (";-16;", asmfile
);
1448 else /* Define as enumeral type (False, True) */
1450 fprintf (asmfile
, "eFalse:0,True:1,;");
1456 putc ('d', asmfile
);
1458 dbxout_type (TREE_TYPE (type
), 0);
1462 /* Differs from the REAL_TYPE by its new data type number */
1464 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1466 putc ('R', asmfile
);
1468 dbxout_fptype_value (type
);
1469 putc (';', asmfile
);
1471 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1472 fputs (";0;", asmfile
);
1477 /* Output a complex integer type as a structure,
1478 pending some other way to do it. */
1479 putc ('s', asmfile
);
1481 print_wide_int (int_size_in_bytes (type
));
1482 fprintf (asmfile
, "real:");
1485 dbxout_type (TREE_TYPE (type
), 0);
1486 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1488 fprintf (asmfile
, "imag:");
1490 dbxout_type (TREE_TYPE (type
), 0);
1491 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1492 TYPE_PRECISION (TREE_TYPE (type
)));
1498 if (use_gnu_debug_info_extensions
)
1500 have_used_extensions
= 1;
1501 fputs ("@s", asmfile
);
1503 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1504 putc (';', asmfile
);
1507 /* Check if a bitstring type, which in Chill is
1508 different from a [power]set. */
1509 if (TYPE_STRING_FLAG (type
))
1511 fprintf (asmfile
, "@S;");
1515 putc ('S', asmfile
);
1517 dbxout_type (TYPE_DOMAIN (type
), 0);
1521 /* Make arrays of packed bits look like bitstrings for chill. */
1522 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1524 have_used_extensions
= 1;
1525 fputs ("@s", asmfile
);
1527 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1528 fprintf (asmfile
, ";@S;S");
1530 dbxout_type (TYPE_DOMAIN (type
), 0);
1534 /* Output "a" followed by a range type definition
1535 for the index type of the array
1536 followed by a reference to the target-type.
1537 ar1;0;N;M for a C array of type M and size N+1. */
1538 /* Check if a character string type, which in Chill is
1539 different from an array of characters. */
1540 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1542 have_used_extensions
= 1;
1543 fprintf (asmfile
, "@S;");
1546 tem
= TYPE_DOMAIN (type
);
1549 fprintf (asmfile
, "ar");
1551 dbxout_type_index (integer_type_node
);
1552 fprintf (asmfile
, ";0;-1;");
1557 fprintf (asmfile
, "a");
1559 dbxout_range_type (tem
);
1562 dbxout_type (TREE_TYPE (type
), 0);
1567 case QUAL_UNION_TYPE
:
1569 int i
, n_baseclasses
= 0;
1571 if (TYPE_BINFO (type
) != 0
1572 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1573 && TYPE_BINFO_BASETYPES (type
) != 0)
1574 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1576 /* Output a structure type. We must use the same test here as we
1577 use in the DBX_NO_XREFS case above. */
1578 if ((TYPE_NAME (type
) != 0
1579 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1580 && DECL_IGNORED_P (TYPE_NAME (type
)))
1582 || !COMPLETE_TYPE_P (type
)
1583 /* No way in DBX fmt to describe a variable size. */
1584 || ! host_integerp (TYPE_SIZE (type
), 1))
1586 /* If the type is just a cross reference, output one
1587 and mark the type as partially described.
1588 If it later becomes defined, we will output
1589 its real definition.
1590 If the type has a name, don't nest its definition within
1591 another type's definition; instead, output an xref
1592 and let the definition come when the name is defined. */
1593 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1595 #if 0 /* This assertion is legitimately false in C++. */
1596 /* We shouldn't be outputting a reference to a type before its
1597 definition unless the type has a tag name.
1598 A typedef name without a tag name should be impossible. */
1599 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1602 if (TYPE_NAME (type
) != 0)
1603 dbxout_type_name (type
);
1606 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1610 fprintf (asmfile
, ":");
1612 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1616 /* Identify record or union, and print its size. */
1617 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1619 print_wide_int (int_size_in_bytes (type
));
1621 if (use_gnu_debug_info_extensions
)
1625 have_used_extensions
= 1;
1626 fprintf (asmfile
, "!%d,", n_baseclasses
);
1630 for (i
= 0; i
< n_baseclasses
; i
++)
1632 tree binfo
= TYPE_BINFO (type
);
1633 tree child
= BINFO_BASETYPE (binfo
, i
);
1634 tree access
= (BINFO_BASEACCESSES (binfo
)
1635 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1637 if (use_gnu_debug_info_extensions
)
1639 have_used_extensions
= 1;
1640 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1641 putc (access
== access_public_node
? '2' : '0', asmfile
);
1643 if (TREE_VIA_VIRTUAL (child
)
1644 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1645 /* For a virtual base, print the (negative) offset within
1646 the vtable where we must look to find the necessary
1648 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1651 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1653 putc (',', asmfile
);
1655 dbxout_type (BINFO_TYPE (child
), 0);
1656 putc (';', asmfile
);
1661 /* Print out the base class information with fields
1662 which have the same names at the types they hold. */
1663 dbxout_type_name (BINFO_TYPE (child
));
1664 putc (':', asmfile
);
1666 dbxout_type (BINFO_TYPE (child
), full
);
1667 putc (',', asmfile
);
1669 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1671 putc (',', asmfile
);
1673 print_wide_int (tree_low_cst (DECL_SIZE
1675 (BINFO_TYPE (child
))),
1678 putc (';', asmfile
);
1684 /* Write out the field declarations. */
1685 dbxout_type_fields (type
);
1686 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1688 have_used_extensions
= 1;
1689 dbxout_type_methods (type
);
1692 putc (';', asmfile
);
1695 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1696 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1697 && TYPE_VFIELD (type
))
1699 have_used_extensions
= 1;
1701 /* Tell GDB+ that it may keep reading. */
1702 putc ('~', asmfile
);
1705 /* We need to write out info about what field this class
1706 uses as its "main" vtable pointer field, because if this
1707 field is inherited from a base class, GDB cannot necessarily
1708 figure out which field it's using in time. */
1709 if (TYPE_VFIELD (type
))
1711 putc ('%', asmfile
);
1713 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1716 putc (';', asmfile
);
1722 /* We must use the same test here as we use in the DBX_NO_XREFS case
1723 above. We simplify it a bit since an enum will never have a variable
1725 if ((TYPE_NAME (type
) != 0
1726 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1727 && DECL_IGNORED_P (TYPE_NAME (type
)))
1729 || !COMPLETE_TYPE_P (type
))
1731 fprintf (asmfile
, "xe");
1733 dbxout_type_name (type
);
1734 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1735 putc (':', asmfile
);
1739 #ifdef DBX_OUTPUT_ENUM
1740 DBX_OUTPUT_ENUM (asmfile
, type
);
1742 if (use_gnu_debug_info_extensions
1743 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1745 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1749 putc ('e', asmfile
);
1751 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1753 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1754 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1755 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1756 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1757 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1758 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1759 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1761 print_int_cst_octal (TREE_VALUE (tem
));
1763 putc (',', asmfile
);
1765 if (TREE_CHAIN (tem
) != 0)
1769 putc (';', asmfile
);
1775 putc ('*', asmfile
);
1777 dbxout_type (TREE_TYPE (type
), 0);
1781 if (use_gnu_debug_info_extensions
)
1783 have_used_extensions
= 1;
1784 putc ('#', asmfile
);
1787 /* Write the argument types out longhand. */
1788 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1789 putc (',', asmfile
);
1791 dbxout_type (TREE_TYPE (type
), 0);
1792 dbxout_args (TYPE_ARG_TYPES (type
));
1793 putc (';', asmfile
);
1797 /* Treat it as a function type. */
1798 dbxout_type (TREE_TYPE (type
), 0);
1802 if (use_gnu_debug_info_extensions
)
1804 have_used_extensions
= 1;
1805 putc ('@', asmfile
);
1807 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1808 putc (',', asmfile
);
1810 dbxout_type (TREE_TYPE (type
), 0);
1813 /* Should print as an int, because it is really just an offset. */
1814 dbxout_type (integer_type_node
, 0);
1817 case REFERENCE_TYPE
:
1818 if (use_gnu_debug_info_extensions
)
1819 have_used_extensions
= 1;
1820 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1822 dbxout_type (TREE_TYPE (type
), 0);
1826 putc ('f', asmfile
);
1828 dbxout_type (TREE_TYPE (type
), 0);
1836 /* Print the value of integer constant C, in octal,
1837 handling double precision. */
1840 print_int_cst_octal (c
)
1843 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1844 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1845 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1846 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1848 /* GDB wants constants with no extra leading "1" bits, so
1849 we need to remove any sign-extension that might be
1851 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1853 else if (width
> HOST_BITS_PER_WIDE_INT
)
1854 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1855 else if (width
== HOST_BITS_PER_WIDE_INT
)
1858 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1860 fprintf (asmfile
, "0");
1865 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1866 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1870 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1871 unsigned HOST_WIDE_INT middle
1872 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1873 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1874 unsigned HOST_WIDE_INT end
1875 = low
& (((unsigned HOST_WIDE_INT
) 1
1876 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1879 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1881 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1886 print_octal (value
, digits
)
1887 unsigned HOST_WIDE_INT value
;
1892 for (i
= digits
- 1; i
>= 0; i
--)
1893 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1898 /* Output C in decimal while adjusting the number of digits written. */
1906 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1917 /* Output the name of type TYPE, with no punctuation.
1918 Such names can be set up either by typedef declarations
1919 or by struct, enum and union tags. */
1922 dbxout_type_name (type
)
1926 if (TYPE_NAME (type
) == 0)
1928 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1930 t
= TYPE_NAME (type
);
1932 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1934 t
= DECL_NAME (TYPE_NAME (type
));
1939 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1940 CHARS (IDENTIFIER_LENGTH (t
));
1943 /* Output leading leading struct or class names needed for qualifying
1944 type whose scope is limited to a struct or class. */
1947 dbxout_class_name_qualifiers (decl
)
1950 tree context
= decl_type_context (decl
);
1952 if (context
!= NULL_TREE
1953 && TREE_CODE(context
) == RECORD_TYPE
1954 && TYPE_NAME (context
) != 0
1955 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
1956 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
1958 tree name
= TYPE_NAME (context
);
1960 if (TREE_CODE (name
) == TYPE_DECL
)
1962 dbxout_class_name_qualifiers (name
);
1963 name
= DECL_NAME (name
);
1965 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1966 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1970 /* Output a .stabs for the symbol defined by DECL,
1971 which must be a ..._DECL node in the normal namespace.
1972 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1973 LOCAL is nonzero if the scope is less than the entire file.
1974 Return 1 if a stabs might have been emitted. */
1977 dbxout_symbol (decl
, local
)
1979 int local ATTRIBUTE_UNUSED
;
1981 tree type
= TREE_TYPE (decl
);
1982 tree context
= NULL_TREE
;
1985 /* Cast avoids warning in old compilers. */
1986 current_sym_code
= (STAB_CODE_TYPE
) 0;
1987 current_sym_value
= 0;
1988 current_sym_addr
= 0;
1990 /* Ignore nameless syms, but don't ignore type tags. */
1992 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1993 || DECL_IGNORED_P (decl
))
1996 dbxout_prepare_symbol (decl
);
1998 /* The output will always start with the symbol name,
1999 so always count that in the length-output-so-far. */
2001 if (DECL_NAME (decl
) != 0)
2002 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2004 switch (TREE_CODE (decl
))
2007 /* Enum values are defined by defining the enum type. */
2011 if (DECL_RTL (decl
) == 0)
2013 if (DECL_EXTERNAL (decl
))
2015 /* Don't mention a nested function under its parent. */
2016 context
= decl_function_context (decl
);
2017 if (context
== current_function_decl
)
2019 if (GET_CODE (DECL_RTL (decl
)) != MEM
2020 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2024 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2025 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2026 TREE_PUBLIC (decl
) ? 'F' : 'f');
2029 current_sym_code
= N_FUN
;
2030 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2032 if (TREE_TYPE (type
))
2033 dbxout_type (TREE_TYPE (type
), 0);
2035 dbxout_type (void_type_node
, 0);
2037 /* For a nested function, when that function is compiled,
2038 mention the containing function name
2039 as well as (since dbx wants it) our own assembler-name. */
2041 fprintf (asmfile
, ",%s,%s",
2042 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2043 IDENTIFIER_POINTER (DECL_NAME (context
)));
2045 dbxout_finish_symbol (decl
);
2050 /* This seems all wrong. Outputting most kinds of types gives no name
2051 at all. A true definition gives no name; a cross-ref for a
2052 structure can give the tag name, but not a type name.
2053 It seems that no typedef name is defined by outputting a type. */
2055 /* If this typedef name was defined by outputting the type,
2056 don't duplicate it. */
2057 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
2058 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
2061 /* Don't output the same typedef twice.
2062 And don't output what language-specific stuff doesn't want output. */
2063 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2072 if (DECL_NAME (decl
))
2074 /* Nonzero means we must output a tag as well as a typedef. */
2077 /* Handle the case of a C++ structure or union
2078 where the TYPE_NAME is a TYPE_DECL
2079 which gives both a typedef name and a tag. */
2080 /* dbx requires the tag first and the typedef second. */
2081 if ((TREE_CODE (type
) == RECORD_TYPE
2082 || TREE_CODE (type
) == UNION_TYPE
2083 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2084 && TYPE_NAME (type
) == decl
2085 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2086 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2087 /* Distinguish the implicit typedefs of C++
2088 from explicit ones that might be found in C. */
2089 && DECL_ARTIFICIAL (decl
)
2090 /* Do not generate a tag for records of variable size,
2091 since this type can not be properly described in the
2092 DBX format, and it confuses some tools such as objdump. */
2093 && host_integerp (TYPE_SIZE (type
), 1))
2095 tree name
= TYPE_NAME (type
);
2096 if (TREE_CODE (name
) == TYPE_DECL
)
2097 name
= DECL_NAME (name
);
2099 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2100 current_sym_value
= 0;
2101 current_sym_addr
= 0;
2102 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2104 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2105 IDENTIFIER_POINTER (name
));
2106 dbxout_type (type
, 1);
2107 dbxout_finish_symbol (NULL_TREE
);
2110 /* Output .stabs (or whatever) and leading double quote. */
2111 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2113 if (use_gnu_debug_info_extensions
)
2115 /* Output leading class/struct qualifiers. */
2116 dbxout_class_name_qualifiers (decl
);
2119 /* Output typedef name. */
2120 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2122 /* Short cut way to output a tag also. */
2123 if ((TREE_CODE (type
) == RECORD_TYPE
2124 || TREE_CODE (type
) == UNION_TYPE
2125 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2126 && TYPE_NAME (type
) == decl
2127 /* Distinguish the implicit typedefs of C++
2128 from explicit ones that might be found in C. */
2129 && DECL_ARTIFICIAL (decl
))
2131 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2133 putc ('T', asmfile
);
2134 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2136 #if 0 /* Now we generate the tag for this case up above. */
2142 putc ('t', asmfile
);
2143 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2145 dbxout_type (type
, 1);
2146 dbxout_finish_symbol (decl
);
2150 /* Don't output a tag if this is an incomplete type. This prevents
2151 the sun4 Sun OS 4.x dbx from crashing. */
2153 if (tag_needed
&& TYPE_NAME (type
) != 0
2154 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2155 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2156 && COMPLETE_TYPE_P (type
)
2157 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2159 /* For a TYPE_DECL with no name, but the type has a name,
2161 This is what represents `struct foo' with no typedef. */
2162 /* In C++, the name of a type is the corresponding typedef.
2163 In C, it is an IDENTIFIER_NODE. */
2164 tree name
= TYPE_NAME (type
);
2165 if (TREE_CODE (name
) == TYPE_DECL
)
2166 name
= DECL_NAME (name
);
2168 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2169 current_sym_value
= 0;
2170 current_sym_addr
= 0;
2171 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2173 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2174 IDENTIFIER_POINTER (name
));
2175 dbxout_type (type
, 1);
2176 dbxout_finish_symbol (NULL_TREE
);
2180 /* If an enum type has no name, it cannot be referred to,
2181 but we must output it anyway, since the enumeration constants
2182 can be referred to. */
2183 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2185 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2186 current_sym_value
= 0;
2187 current_sym_addr
= 0;
2188 current_sym_nchars
= 2;
2190 /* Some debuggers fail when given NULL names, so give this a
2191 harmless name of ` '. */
2192 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2193 dbxout_type (type
, 1);
2194 dbxout_finish_symbol (NULL_TREE
);
2197 /* Prevent duplicate output of a typedef. */
2198 TREE_ASM_WRITTEN (decl
) = 1;
2203 /* Parm decls go in their own separate chains
2204 and are output by dbxout_reg_parms and dbxout_parms. */
2208 /* Named return value, treat like a VAR_DECL. */
2210 if (! DECL_RTL_SET_P (decl
))
2212 /* Don't mention a variable that is external.
2213 Let the file that defines it describe it. */
2214 if (DECL_EXTERNAL (decl
))
2217 /* If the variable is really a constant
2218 and not written in memory, inform the debugger. */
2219 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2220 && DECL_INITIAL (decl
) != 0
2221 && host_integerp (DECL_INITIAL (decl
), 0)
2222 && ! TREE_ASM_WRITTEN (decl
)
2223 && (DECL_CONTEXT (decl
) == NULL_TREE
2224 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2226 if (TREE_PUBLIC (decl
) == 0)
2228 /* The sun4 assembler does not grok this. */
2229 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2231 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2232 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2234 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2235 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
2236 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
2238 fprintf (asmfile
, "%s\"%s:c=i", ASM_STABS_OP
, name
);
2240 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
2241 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
2245 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2247 /* don't know how to do this yet. */
2251 /* else it is something we handle like a normal variable. */
2254 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2255 #ifdef LEAF_REG_REMAP
2256 if (current_function_uses_only_leaf_regs
)
2257 leaf_renumber_regs_insn (DECL_RTL (decl
));
2260 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2269 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2270 Add SUFFIX to its name, if SUFFIX is not 0.
2271 Describe the variable as residing in HOME
2272 (usually HOME is DECL_RTL (DECL), but not always).
2273 Returns 1 if the stab was really emitted. */
2276 dbxout_symbol_location (decl
, type
, suffix
, home
)
2284 /* Don't mention a variable at all
2285 if it was completely optimized into nothingness.
2287 If the decl was from an inline function, then its rtl
2288 is not identically the rtl that was used in this
2289 particular compilation. */
2290 if (GET_CODE (home
) == SUBREG
)
2294 while (GET_CODE (value
) == SUBREG
)
2295 value
= SUBREG_REG (value
);
2296 if (GET_CODE (value
) == REG
)
2298 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2301 home
= alter_subreg (&home
);
2303 if (GET_CODE (home
) == REG
)
2305 regno
= REGNO (home
);
2306 if (regno
>= FIRST_PSEUDO_REGISTER
)
2310 /* The kind-of-variable letter depends on where
2311 the variable is and on the scope of its name:
2312 G and N_GSYM for static storage and global scope,
2313 S for static storage and file scope,
2314 V for static storage and local scope,
2315 for those two, use N_LCSYM if data is in bss segment,
2316 N_STSYM if in data segment, N_FUN otherwise.
2317 (We used N_FUN originally, then changed to N_STSYM
2318 to please GDB. However, it seems that confused ld.
2319 Now GDB has been fixed to like N_FUN, says Kingdon.)
2320 no letter at all, and N_LSYM, for auto variable,
2321 r and N_RSYM for register variable. */
2323 if (GET_CODE (home
) == MEM
2324 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2326 if (TREE_PUBLIC (decl
))
2329 current_sym_code
= N_GSYM
;
2333 current_sym_addr
= XEXP (home
, 0);
2335 letter
= decl_function_context (decl
) ? 'V' : 'S';
2337 /* This should be the same condition as in assemble_variable, but
2338 we don't have access to dont_output_data here. So, instead,
2339 we rely on the fact that error_mark_node initializers always
2340 end up in bss for C++ and never end up in bss for C. */
2341 if (DECL_INITIAL (decl
) == 0
2342 || (!strcmp (lang_hooks
.name
, "GNU C++")
2343 && DECL_INITIAL (decl
) == error_mark_node
))
2344 current_sym_code
= N_LCSYM
;
2345 else if (DECL_IN_TEXT_SECTION (decl
))
2346 /* This is not quite right, but it's the closest
2347 of all the codes that Unix defines. */
2348 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2351 /* Some ports can transform a symbol ref into a label ref,
2352 because the symbol ref is too far away and has to be
2353 dumped into a constant pool. Alternatively, the symbol
2354 in the constant pool might be referenced by a different
2356 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2357 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2359 rtx tmp
= get_pool_constant (current_sym_addr
);
2361 if (GET_CODE (tmp
) == SYMBOL_REF
2362 || GET_CODE (tmp
) == LABEL_REF
)
2363 current_sym_addr
= tmp
;
2366 /* Ultrix `as' seems to need this. */
2367 #ifdef DBX_STATIC_STAB_DATA_SECTION
2370 current_sym_code
= N_STSYM
;
2374 else if (regno
>= 0)
2377 current_sym_code
= N_RSYM
;
2378 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2380 else if (GET_CODE (home
) == MEM
2381 && (GET_CODE (XEXP (home
, 0)) == MEM
2382 || (GET_CODE (XEXP (home
, 0)) == REG
2383 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2384 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2385 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2386 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2389 /* If the value is indirect by memory or by a register
2390 that isn't the frame pointer
2391 then it means the object is variable-sized and address through
2392 that register or stack slot. DBX has no way to represent this
2393 so all we can do is output the variable as a pointer.
2394 If it's not a parameter, ignore it.
2395 (VAR_DECLs like this can be made by integrate.c.) */
2397 if (GET_CODE (XEXP (home
, 0)) == REG
)
2400 current_sym_code
= N_RSYM
;
2401 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2403 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2407 current_sym_code
= N_LSYM
;
2408 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2409 We want the value of that CONST_INT. */
2411 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2414 /* Effectively do build_pointer_type, but don't cache this type,
2415 since it might be temporary whereas the type it points to
2416 might have been saved for inlining. */
2417 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2418 type
= make_node (POINTER_TYPE
);
2419 TREE_TYPE (type
) = TREE_TYPE (decl
);
2421 else if (GET_CODE (home
) == MEM
2422 && GET_CODE (XEXP (home
, 0)) == REG
)
2424 current_sym_code
= N_LSYM
;
2425 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2427 else if (GET_CODE (home
) == MEM
2428 && GET_CODE (XEXP (home
, 0)) == PLUS
2429 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2431 current_sym_code
= N_LSYM
;
2432 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2433 We want the value of that CONST_INT. */
2434 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2436 else if (GET_CODE (home
) == MEM
2437 && GET_CODE (XEXP (home
, 0)) == CONST
)
2439 /* Handle an obscure case which can arise when optimizing and
2440 when there are few available registers. (This is *always*
2441 the case for i386/i486 targets). The RTL looks like
2442 (MEM (CONST ...)) even though this variable is a local `auto'
2443 or a local `register' variable. In effect, what has happened
2444 is that the reload pass has seen that all assignments and
2445 references for one such a local variable can be replaced by
2446 equivalent assignments and references to some static storage
2447 variable, thereby avoiding the need for a register. In such
2448 cases we're forced to lie to debuggers and tell them that
2449 this variable was itself `static'. */
2450 current_sym_code
= N_LCSYM
;
2452 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2454 else if (GET_CODE (home
) == CONCAT
)
2458 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2459 for example), then there is no easy way to figure out
2460 what SUBTYPE should be. So, we give up. */
2461 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2464 subtype
= TREE_TYPE (type
);
2466 /* If the variable's storage is in two parts,
2467 output each as a separate stab with a modified name. */
2468 if (WORDS_BIG_ENDIAN
)
2469 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2471 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2473 /* Cast avoids warning in old compilers. */
2474 current_sym_code
= (STAB_CODE_TYPE
) 0;
2475 current_sym_value
= 0;
2476 current_sym_addr
= 0;
2477 dbxout_prepare_symbol (decl
);
2479 if (WORDS_BIG_ENDIAN
)
2480 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2482 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2486 /* Address might be a MEM, when DECL is a variable-sized object.
2487 Or it might be const0_rtx, meaning previous passes
2488 want us to ignore this variable. */
2491 /* Ok, start a symtab entry and output the variable name. */
2494 #ifdef DBX_STATIC_BLOCK_START
2495 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2498 dbxout_symbol_name (decl
, suffix
, letter
);
2499 dbxout_type (type
, 0);
2500 dbxout_finish_symbol (decl
);
2502 #ifdef DBX_STATIC_BLOCK_END
2503 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2508 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2509 Then output LETTER to indicate the kind of location the symbol has. */
2512 dbxout_symbol_name (decl
, suffix
, letter
)
2519 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2520 /* One slight hitch: if this is a VAR_DECL which is a static
2521 class member, we must put out the mangled name instead of the
2522 DECL_NAME. Note also that static member (variable) names DO NOT begin
2523 with underscores in .stabs directives. */
2524 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2526 /* ...but if we're function-local, we don't want to include the junk
2527 added by ASM_FORMAT_PRIVATE_NAME. */
2528 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2532 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2533 (suffix
? suffix
: ""));
2536 putc (letter
, asmfile
);
2540 dbxout_prepare_symbol (decl
)
2541 tree decl ATTRIBUTE_UNUSED
;
2544 const char *filename
= DECL_SOURCE_FILE (decl
);
2546 dbxout_source_file (asmfile
, filename
);
2551 dbxout_finish_symbol (sym
)
2554 #ifdef DBX_FINISH_SYMBOL
2555 DBX_FINISH_SYMBOL (sym
);
2558 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2559 line
= DECL_SOURCE_LINE (sym
);
2561 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2562 if (current_sym_addr
)
2563 output_addr_const (asmfile
, current_sym_addr
);
2565 fprintf (asmfile
, "%d", current_sym_value
);
2566 putc ('\n', asmfile
);
2570 /* Output definitions of all the decls in a chain. Return nonzero if
2571 anything was output */
2580 result
+= dbxout_symbol (syms
, 1);
2581 syms
= TREE_CHAIN (syms
);
2586 /* The following two functions output definitions of function parameters.
2587 Each parameter gets a definition locating it in the parameter list.
2588 Each parameter that is a register variable gets a second definition
2589 locating it in the register.
2591 Printing or argument lists in gdb uses the definitions that
2592 locate in the parameter list. But reference to the variable in
2593 expressions uses preferentially the definition as a register. */
2595 /* Output definitions, referring to storage in the parmlist,
2596 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2599 dbxout_parms (parms
)
2602 for (; parms
; parms
= TREE_CHAIN (parms
))
2603 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2605 dbxout_prepare_symbol (parms
);
2607 /* Perform any necessary register eliminations on the parameter's rtl,
2608 so that the debugging output will be accurate. */
2609 DECL_INCOMING_RTL (parms
)
2610 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2611 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2612 #ifdef LEAF_REG_REMAP
2613 if (current_function_uses_only_leaf_regs
)
2615 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2616 leaf_renumber_regs_insn (DECL_RTL (parms
));
2620 if (PARM_PASSED_IN_MEMORY (parms
))
2622 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2624 /* ??? Here we assume that the parm address is indexed
2625 off the frame pointer or arg pointer.
2626 If that is not true, we produce meaningless results,
2627 but do not crash. */
2628 if (GET_CODE (addr
) == PLUS
2629 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2630 current_sym_value
= INTVAL (XEXP (addr
, 1));
2632 current_sym_value
= 0;
2634 current_sym_code
= N_PSYM
;
2635 current_sym_addr
= 0;
2638 if (DECL_NAME (parms
))
2640 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2642 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2643 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2644 DBX_MEMPARM_STABS_LETTER
);
2648 current_sym_nchars
= 8;
2649 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2650 DBX_MEMPARM_STABS_LETTER
);
2653 /* It is quite tempting to use:
2655 dbxout_type (TREE_TYPE (parms), 0);
2657 as the next statement, rather than using DECL_ARG_TYPE(), so
2658 that gcc reports the actual type of the parameter, rather
2659 than the promoted type. This certainly makes GDB's life
2660 easier, at least for some ports. The change is a bad idea
2661 however, since GDB expects to be able access the type without
2662 performing any conversions. So for example, if we were
2663 passing a float to an unprototyped function, gcc will store a
2664 double on the stack, but if we emit a stab saying the type is a
2665 float, then gdb will only read in a single value, and this will
2666 produce an erroneous value. */
2667 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2668 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2669 dbxout_finish_symbol (parms
);
2671 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2674 char regparm_letter
;
2676 /* Parm passed in registers and lives in registers or nowhere. */
2678 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2679 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2680 current_sym_addr
= 0;
2682 /* If parm lives in a register, use that register;
2683 pretend the parm was passed there. It would be more consistent
2684 to describe the register where the parm was passed,
2685 but in practice that register usually holds something else.
2687 If we use DECL_RTL, then we must use the declared type of
2688 the variable, not the type that it arrived in. */
2689 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2691 best_rtl
= DECL_RTL (parms
);
2692 parm_type
= TREE_TYPE (parms
);
2694 /* If the parm lives nowhere, use the register where it was
2695 passed. It is also better to use the declared type here. */
2698 best_rtl
= DECL_INCOMING_RTL (parms
);
2699 parm_type
= TREE_TYPE (parms
);
2701 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2704 if (DECL_NAME (parms
))
2706 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2707 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2708 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2713 current_sym_nchars
= 8;
2714 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2718 dbxout_type (parm_type
, 0);
2719 dbxout_finish_symbol (parms
);
2721 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2722 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2723 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2724 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2725 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2726 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2730 /* Parm was passed via invisible reference.
2731 That is, its address was passed in a register.
2732 Output it as if it lived in that register.
2733 The debugger will know from the type
2734 that it was actually passed by invisible reference. */
2736 char regparm_letter
;
2737 /* Parm passed in registers and lives in registers or nowhere. */
2739 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2740 if (use_gnu_debug_info_extensions
)
2741 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2743 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2745 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2746 If it is an unallocated pseudo-reg, then use the register where
2747 it was passed instead. */
2748 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2749 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2751 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2753 current_sym_addr
= 0;
2756 if (DECL_NAME (parms
))
2759 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2761 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2762 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2767 current_sym_nchars
= 8;
2768 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2772 dbxout_type (TREE_TYPE (parms
), 0);
2773 dbxout_finish_symbol (parms
);
2775 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2776 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2778 /* Parm was passed via invisible reference, with the reference
2779 living on the stack. DECL_RTL looks like
2780 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2781 could look like (MEM (MEM (REG))). */
2782 const char *const decl_name
= (DECL_NAME (parms
)
2783 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2785 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2786 current_sym_value
= 0;
2789 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2790 current_sym_addr
= 0;
2791 current_sym_code
= N_PSYM
;
2794 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2797 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2798 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2799 dbxout_type (TREE_TYPE (parms
), 0);
2800 dbxout_finish_symbol (parms
);
2802 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2803 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2804 /* ??? A constant address for a parm can happen
2805 when the reg it lives in is equiv to a constant in memory.
2806 Should make this not happen, after 2.4. */
2807 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2809 /* Parm was passed in registers but lives on the stack. */
2811 current_sym_code
= N_PSYM
;
2812 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2813 in which case we want the value of that CONST_INT,
2815 in which case we use a value of zero. */
2816 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2817 current_sym_value
= 0;
2820 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2822 current_sym_addr
= 0;
2824 /* Make a big endian correction if the mode of the type of the
2825 parameter is not the same as the mode of the rtl. */
2826 if (BYTES_BIG_ENDIAN
2827 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2828 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2830 current_sym_value
+=
2831 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2832 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2836 if (DECL_NAME (parms
))
2839 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2841 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2842 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2843 DBX_MEMPARM_STABS_LETTER
);
2847 current_sym_nchars
= 8;
2848 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2849 DBX_MEMPARM_STABS_LETTER
);
2853 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2854 XEXP (DECL_RTL (parms
), 0));
2855 dbxout_type (TREE_TYPE (parms
), 0);
2856 dbxout_finish_symbol (parms
);
2861 /* Output definitions for the places where parms live during the function,
2862 when different from where they were passed, when the parms were passed
2865 It is not useful to do this for parms passed in registers
2866 that live during the function in different registers, because it is
2867 impossible to look in the passed register for the passed value,
2868 so we use the within-the-function register to begin with.
2870 PARMS is a chain of PARM_DECL nodes. */
2873 dbxout_reg_parms (parms
)
2876 for (; parms
; parms
= TREE_CHAIN (parms
))
2877 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2879 dbxout_prepare_symbol (parms
);
2881 /* Report parms that live in registers during the function
2882 but were passed in memory. */
2883 if (GET_CODE (DECL_RTL (parms
)) == REG
2884 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2885 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2886 0, DECL_RTL (parms
));
2887 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2888 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2889 0, DECL_RTL (parms
));
2890 /* Report parms that live in memory but not where they were passed. */
2891 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2892 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2893 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2894 0, DECL_RTL (parms
));
2898 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2899 output definitions of those names, in raw form */
2907 putc (',', asmfile
);
2908 dbxout_type (TREE_VALUE (args
), 0);
2910 args
= TREE_CHAIN (args
);
2914 /* Output everything about a symbol block (a BLOCK node
2915 that represents a scope level),
2916 including recursive output of contained blocks.
2918 BLOCK is the BLOCK node.
2919 DEPTH is its depth within containing symbol blocks.
2920 ARGS is usually zero; but for the outermost block of the
2921 body of a function, it is a chain of PARM_DECLs for the function parameters.
2922 We output definitions of all the register parms
2923 as if they were local variables of that block.
2925 If -g1 was used, we count blocks just the same, but output nothing
2926 except for the outermost block.
2928 Actually, BLOCK may be several blocks chained together.
2929 We handle them all in sequence. */
2932 dbxout_block (block
, depth
, args
)
2939 #if DBX_BLOCKS_FUNCTION_RELATIVE
2940 const char *begin_label
;
2941 if (current_function_func_begin_label
!= NULL_TREE
)
2942 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2944 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2949 /* Ignore blocks never expanded or otherwise marked as real. */
2950 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2954 #ifdef DBX_LBRAC_FIRST
2957 /* In dbx format, the syms of a block come before the N_LBRAC.
2958 If nothing is output, we don't need the N_LBRAC, either. */
2960 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2961 did_output
= dbxout_syms (BLOCK_VARS (block
));
2963 dbxout_reg_parms (args
);
2966 /* Now output an N_LBRAC symbol to represent the beginning of
2967 the block. Use the block's tree-walk order to generate
2968 the assembler symbols LBBn and LBEn
2969 that final will define around the code in this block. */
2970 if (depth
> 0 && did_output
)
2973 blocknum
= BLOCK_NUMBER (block
);
2974 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2976 if (BLOCK_HANDLER_BLOCK (block
))
2978 /* A catch block. Must precede N_LBRAC. */
2979 tree decl
= BLOCK_VARS (block
);
2982 #ifdef DBX_OUTPUT_CATCH
2983 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2985 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2986 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2987 assemble_name (asmfile
, buf
);
2988 fprintf (asmfile
, "\n");
2990 decl
= TREE_CHAIN (decl
);
2994 #ifdef DBX_OUTPUT_LBRAC
2995 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2997 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2998 assemble_name (asmfile
, buf
);
2999 #if DBX_BLOCKS_FUNCTION_RELATIVE
3000 putc ('-', asmfile
);
3001 assemble_name (asmfile
, begin_label
);
3003 fprintf (asmfile
, "\n");
3007 #ifdef DBX_LBRAC_FIRST
3008 /* On some weird machines, the syms of a block
3009 come after the N_LBRAC. */
3010 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3011 dbxout_syms (BLOCK_VARS (block
));
3013 dbxout_reg_parms (args
);
3016 /* Output the subblocks. */
3017 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3019 /* Refer to the marker for the end of the block. */
3020 if (depth
> 0 && did_output
)
3023 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3024 #ifdef DBX_OUTPUT_RBRAC
3025 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3027 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3028 assemble_name (asmfile
, buf
);
3029 #if DBX_BLOCKS_FUNCTION_RELATIVE
3030 putc ('-', asmfile
);
3031 assemble_name (asmfile
, begin_label
);
3033 fprintf (asmfile
, "\n");
3037 block
= BLOCK_CHAIN (block
);
3041 /* Output the information about a function and its arguments and result.
3042 Usually this follows the function's code,
3043 but on some systems, it comes before. */
3045 #if defined (DBX_DEBUGGING_INFO)
3047 dbxout_begin_function (decl
)
3050 dbxout_symbol (decl
, 0);
3051 dbxout_parms (DECL_ARGUMENTS (decl
));
3052 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3053 dbxout_symbol (DECL_RESULT (decl
), 1);
3055 #endif /* DBX_DEBUGGING_INFO */
3057 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3059 #include "gt-dbxout.h"