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 /* A counter for dbxout_source_line. */
198 static GTY(()) int dbxout_source_line_counter
;
200 /* Nonzero if we have actually used any of the GDB extensions
201 to the debugging format. The idea is that we use them for the
202 first time only if there's a strong reason, but once we have done that,
203 we use them whenever convenient. */
205 static GTY(()) int have_used_extensions
= 0;
207 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
208 for the N_SO filename stabs label. */
210 static GTY(()) int source_label_number
= 1;
212 /* Last source file name mentioned in a NOTE insn. */
214 static GTY(()) const char *lastfile
;
216 /* Used by PCH machinery to detect if 'lastfile' should be reset to
218 static GTY(()) int lastfile_is_base
;
220 /* Typical USG systems don't have stab.h, and they also have
221 no use for DBX-format debugging info. */
223 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
225 /* The original input file name. */
226 static const char *base_input_file
;
228 /* Current working directory. */
230 static const char *cwd
;
232 #ifdef DEBUG_SYMS_TEXT
233 #define FORCE_TEXT function_section (current_function_decl);
240 #define STAB_CODE_TYPE enum __stab_debug_code
242 /* 1 if PARM is passed to this function in memory. */
244 #define PARM_PASSED_IN_MEMORY(PARM) \
245 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
247 /* A C expression for the integer offset value of an automatic variable
248 (N_LSYM) having address X (an RTX). */
249 #ifndef DEBUGGER_AUTO_OFFSET
250 #define DEBUGGER_AUTO_OFFSET(X) \
251 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
254 /* A C expression for the integer offset value of an argument (N_PSYM)
255 having address X (an RTX). The nominal offset is OFFSET. */
256 #ifndef DEBUGGER_ARG_OFFSET
257 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
260 /* Stream for writing to assembler file. */
262 static FILE *asmfile
;
264 /* These variables are for dbxout_symbol to communicate to
265 dbxout_finish_symbol.
266 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
267 current_sym_value and current_sym_addr are two ways to address the
268 value to store in the symtab entry.
269 current_sym_addr if nonzero represents the value as an rtx.
270 If that is zero, current_sym_value is used. This is used
271 when the value is an offset (such as for auto variables,
272 register variables and parms). */
274 static STAB_CODE_TYPE current_sym_code
;
275 static int current_sym_value
;
276 static rtx current_sym_addr
;
278 /* Number of chars of symbol-description generated so far for the
279 current symbol. Used by CHARS and CONTIN. */
281 static int current_sym_nchars
;
283 /* Report having output N chars of the current symbol-description. */
285 #define CHARS(N) (current_sym_nchars += (N))
287 /* Break the current symbol-description, generating a continuation,
288 if it has become long. */
290 #ifndef DBX_CONTIN_LENGTH
291 #define DBX_CONTIN_LENGTH 80
294 #if DBX_CONTIN_LENGTH > 0
296 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
298 #define CONTIN do { } while (0)
301 static void dbxout_init
PARAMS ((const char *));
302 static void dbxout_finish
PARAMS ((const char *));
303 static void dbxout_start_source_file
PARAMS ((unsigned, const char *));
304 static void dbxout_end_source_file
PARAMS ((unsigned));
305 static void dbxout_typedefs
PARAMS ((tree
));
306 static void dbxout_fptype_value
PARAMS ((tree
));
307 static void dbxout_type_index
PARAMS ((tree
));
308 #if DBX_CONTIN_LENGTH > 0
309 static void dbxout_continue
PARAMS ((void));
311 static void dbxout_args
PARAMS ((tree
));
312 static void dbxout_type_fields
PARAMS ((tree
));
313 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
314 static void dbxout_type_methods
PARAMS ((tree
));
315 static void dbxout_range_type
PARAMS ((tree
));
316 static void dbxout_type
PARAMS ((tree
, int));
317 static bool print_int_cst_bounds_in_octal_p
PARAMS ((tree
));
318 static void print_int_cst_octal
PARAMS ((tree
));
319 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
320 static void print_wide_int
PARAMS ((HOST_WIDE_INT
));
321 static void dbxout_type_name
PARAMS ((tree
));
322 static void dbxout_class_name_qualifiers
PARAMS ((tree
));
323 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
324 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
325 static void dbxout_prepare_symbol
PARAMS ((tree
));
326 static void dbxout_finish_symbol
PARAMS ((tree
));
327 static void dbxout_block
PARAMS ((tree
, int, tree
));
328 static void dbxout_global_decl
PARAMS ((tree
));
329 static void dbxout_handle_pch
PARAMS ((unsigned));
331 /* The debug hooks structure. */
332 #if defined (DBX_DEBUGGING_INFO)
334 static void dbxout_source_line
PARAMS ((unsigned int, const char *));
335 static void dbxout_source_file
PARAMS ((FILE *, const char *));
336 static void dbxout_function_end
PARAMS ((void));
337 static void dbxout_begin_function
PARAMS ((tree
));
338 static void dbxout_begin_block
PARAMS ((unsigned, unsigned));
339 static void dbxout_end_block
PARAMS ((unsigned, unsigned));
340 static void dbxout_function_decl
PARAMS ((tree
));
342 const struct gcc_debug_hooks dbx_debug_hooks
=
346 debug_nothing_int_charstar
,
347 debug_nothing_int_charstar
,
348 dbxout_start_source_file
,
349 dbxout_end_source_file
,
352 debug_true_tree
, /* ignore_block */
353 dbxout_source_line
, /* source_line */
354 dbxout_source_line
, /* begin_prologue: just output line info */
355 debug_nothing_int_charstar
, /* end_prologue */
356 debug_nothing_int_charstar
, /* end_epilogue */
357 #ifdef DBX_FUNCTION_FIRST
358 dbxout_begin_function
,
360 debug_nothing_tree
, /* begin_function */
362 debug_nothing_int
, /* end_function */
363 dbxout_function_decl
,
364 dbxout_global_decl
, /* global_decl */
365 debug_nothing_tree
, /* deferred_inline_function */
366 debug_nothing_tree
, /* outlining_inline_function */
367 debug_nothing_rtx
, /* label */
368 dbxout_handle_pch
/* handle_pch */
370 #endif /* DBX_DEBUGGING_INFO */
372 #if defined (XCOFF_DEBUGGING_INFO)
373 const struct gcc_debug_hooks xcoff_debug_hooks
=
377 debug_nothing_int_charstar
,
378 debug_nothing_int_charstar
,
379 dbxout_start_source_file
,
380 dbxout_end_source_file
,
381 xcoffout_begin_block
,
383 debug_true_tree
, /* ignore_block */
384 xcoffout_source_line
,
385 xcoffout_begin_prologue
, /* begin_prologue */
386 debug_nothing_int_charstar
, /* end_prologue */
387 xcoffout_end_epilogue
,
388 debug_nothing_tree
, /* begin_function */
389 xcoffout_end_function
,
390 debug_nothing_tree
, /* function_decl */
391 dbxout_global_decl
, /* global_decl */
392 debug_nothing_tree
, /* deferred_inline_function */
393 debug_nothing_tree
, /* outlining_inline_function */
394 debug_nothing_rtx
, /* label */
395 dbxout_handle_pch
/* handle_pch */
397 #endif /* XCOFF_DEBUGGING_INFO */
399 #if defined (DBX_DEBUGGING_INFO)
401 dbxout_function_end ()
403 char lscope_label_name
[100];
404 /* Convert Ltext into the appropriate format for local labels in case
405 the system doesn't insert underscores in front of user generated
407 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
408 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
411 /* By convention, GCC will mark the end of a function with an N_FUN
412 symbol and an empty string. */
413 #ifdef DBX_OUTPUT_NFUN
414 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
416 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
417 assemble_name (asmfile
, lscope_label_name
);
419 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
420 fprintf (asmfile
, "\n");
423 #endif /* DBX_DEBUGGING_INFO */
425 /* At the beginning of compilation, start writing the symbol table.
426 Initialize `typevec' and output the standard data types of C. */
429 dbxout_init (input_file_name
)
430 const char *input_file_name
;
432 char ltext_label_name
[100];
433 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
435 asmfile
= asm_out_file
;
438 typevec
= (struct typeinfo
*) ggc_calloc (typevec_len
, sizeof typevec
[0]);
440 /* Convert Ltext into the appropriate format for local labels in case
441 the system doesn't insert underscores in front of user generated
443 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
445 /* Put the current working directory in an N_SO symbol. */
446 if (use_gnu_debug_info_extensions
)
448 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
449 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
452 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
453 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
454 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
455 fprintf (asmfile
, "%s", ASM_STABS_OP
);
456 output_quoted_string (asmfile
, cwd
);
457 fprintf (asmfile
, ",%d,0,0,", N_SO
);
458 assemble_name (asmfile
, ltext_label_name
);
459 fputc ('\n', asmfile
);
460 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
464 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
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 char ltext_label_name
[100];
616 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
617 source_label_number
);
618 fprintf (file
, "%s", ASM_STABS_OP
);
619 output_quoted_string (file
, filename
);
620 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
621 assemble_name (asmfile
, ltext_label_name
);
622 fputc ('\n', asmfile
);
623 if (current_function_decl
!= NULL_TREE
624 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
625 ; /* Don't change section amid function. */
628 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
629 source_label_number
++;
634 /* Output a line number symbol entry for source file FILENAME and line
638 dbxout_source_line (lineno
, filename
)
640 const char *filename
;
642 dbxout_source_file (asmfile
, filename
);
644 #ifdef ASM_OUTPUT_SOURCE_LINE
645 dbxout_source_line_counter
+= 1;
646 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
, dbxout_source_line_counter
);
648 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
652 /* Describe the beginning of an internal block within a function. */
655 dbxout_begin_block (line
, n
)
656 unsigned int line ATTRIBUTE_UNUSED
;
659 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
662 /* Describe the end line-number of an internal block within a function. */
665 dbxout_end_block (line
, n
)
666 unsigned int line ATTRIBUTE_UNUSED
;
669 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
672 /* Output dbx data for a function definition.
673 This includes a definition of the function name itself (a symbol),
674 definitions of the parameters (locating them in the parameter list)
675 and then output the block that makes up the function's body
676 (including all the auto variables of the function). */
679 dbxout_function_decl (decl
)
682 #ifndef DBX_FUNCTION_FIRST
683 dbxout_begin_function (decl
);
685 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
686 #ifdef DBX_OUTPUT_FUNCTION_END
687 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
689 if (use_gnu_debug_info_extensions
690 #if defined(NO_DBX_FUNCTION_END)
691 && ! NO_DBX_FUNCTION_END
693 && targetm
.have_named_sections
)
694 dbxout_function_end ();
697 #endif /* DBX_DEBUGGING_INFO */
699 /* Debug information for a global DECL. Called from toplev.c after
700 compilation proper has finished. */
702 dbxout_global_decl (decl
)
705 if (TREE_CODE (decl
) == VAR_DECL
706 && ! DECL_EXTERNAL (decl
)
707 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
708 dbxout_symbol (decl
, 0);
711 /* At the end of compilation, finish writing the symbol table.
712 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
716 dbxout_finish (filename
)
717 const char *filename ATTRIBUTE_UNUSED
;
719 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
720 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
721 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
724 /* Output floating point type values used by the 'R' stab letter.
725 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
727 There are only 3 real/complex types defined, and we need 7/6.
728 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
729 complex type. Since we have the type size anyways, we don't really need
730 to distinguish between different FP types, we only need to distinguish
731 between float and complex. This works fine with gdb.
733 We only use this for complex types, to avoid breaking backwards
734 compatibility for real types. complex types aren't in ISO C90, so it is
735 OK if old debuggers don't understand the debug info we emit for them. */
737 /* ??? These are supposed to be IEEE types, but we don't check for that.
738 We could perhaps add additional numbers for non-IEEE types if we need
742 dbxout_fptype_value (type
)
746 enum machine_mode mode
= TYPE_MODE (type
);
748 if (TREE_CODE (type
) == REAL_TYPE
)
752 else if (mode
== DFmode
)
754 else if (mode
== TFmode
|| mode
== XFmode
)
757 /* Use NF_SINGLE as a generic real type for other sizes. */
760 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
764 else if (mode
== DCmode
)
766 else if (mode
== TCmode
|| mode
== XCmode
)
769 /* Use NF_COMPLEX as a generic complex type for other sizes. */
775 putc (value
, asmfile
);
779 /* Output the index of a type. */
782 dbxout_type_index (type
)
785 #ifndef DBX_USE_BINCL
786 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
789 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
790 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
795 #if DBX_CONTIN_LENGTH > 0
796 /* Continue a symbol-description that gets too big.
797 End one symbol table entry with a double-backslash
798 and start a new one, eventually producing something like
799 .stabs "start......\\",code,0,value
800 .stabs "...rest",code,0,value */
805 #ifdef DBX_CONTIN_CHAR
806 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
808 fprintf (asmfile
, "\\\\");
810 dbxout_finish_symbol (NULL_TREE
);
811 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
812 current_sym_nchars
= 0;
814 #endif /* DBX_CONTIN_LENGTH > 0 */
816 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
817 This must be a separate function because anonymous unions require
821 dbxout_type_fields (type
)
826 /* Output the name, type, position (in bits), size (in bits) of each
827 field that we can support. */
828 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
830 /* Omit here local type decls until we know how to support them. */
831 if (TREE_CODE (tem
) == TYPE_DECL
832 /* Omit fields whose position or size are variable or too large to
834 || (TREE_CODE (tem
) == FIELD_DECL
835 && (! host_integerp (bit_position (tem
), 0)
837 || ! host_integerp (DECL_SIZE (tem
), 1)))
838 /* Omit here the nameless fields that are used to skip bits. */
839 || DECL_IGNORED_P (tem
))
842 else if (TREE_CODE (tem
) != CONST_DECL
)
844 /* Continue the line if necessary,
845 but not before the first field. */
846 if (tem
!= TYPE_FIELDS (type
))
851 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
852 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
856 fprintf (asmfile
, ":");
860 if (use_gnu_debug_info_extensions
861 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
862 || TREE_CODE (tem
) != FIELD_DECL
))
864 have_used_extensions
= 1;
866 putc ((TREE_PRIVATE (tem
) ? '0'
867 : TREE_PROTECTED (tem
) ? '1' : '2'),
872 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
873 && DECL_BIT_FIELD_TYPE (tem
))
874 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
876 if (TREE_CODE (tem
) == VAR_DECL
)
878 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
880 tree name
= DECL_ASSEMBLER_NAME (tem
);
882 have_used_extensions
= 1;
883 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
884 CHARS (IDENTIFIER_LENGTH (name
) + 2);
888 /* If TEM is non-static, GDB won't understand it. */
889 fprintf (asmfile
, ",0,0;");
896 print_wide_int (int_bit_position (tem
));
898 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
906 /* Subroutine of `dbxout_type_methods'. Output debug info about the
907 method described DECL. DEBUG_NAME is an encoding of the method's
908 type signature. ??? We may be able to do without DEBUG_NAME altogether
912 dbxout_type_method_1 (decl
, debug_name
)
914 const char *debug_name
;
918 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
920 else /* it's a METHOD_TYPE. */
922 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
923 /* A for normal functions.
924 B for `const' member functions.
925 C for `volatile' member functions.
926 D for `const volatile' member functions. */
927 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
929 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
932 if (DECL_VINDEX (decl
))
938 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
939 TREE_PRIVATE (decl
) ? '0'
940 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
941 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
942 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
944 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
946 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
949 dbxout_type (DECL_CONTEXT (decl
), 0);
950 fprintf (asmfile
, ";");
955 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
959 dbxout_type_methods (type
)
962 /* C++: put out the method names and their parameter lists */
963 tree methods
= TYPE_METHODS (type
);
967 char formatted_type_identifier_length
[16];
968 int type_identifier_length
;
970 if (methods
== NULL_TREE
)
973 type_encoding
= DECL_NAME (TYPE_NAME (type
));
976 /* C++: Template classes break some assumptions made by this code about
977 the class names, constructor names, and encodings for assembler
978 label names. For now, disable output of dbx info for them. */
980 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
981 /* This should use index. (mrs) */
982 while (*ptr
&& *ptr
!= '<') ptr
++;
993 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
995 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
997 if (TREE_CODE (methods
) != TREE_VEC
)
999 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1000 fndecl
= TREE_VEC_ELT (methods
, 0);
1002 fndecl
= TREE_VEC_ELT (methods
, 1);
1006 int need_prefix
= 1;
1008 /* Group together all the methods for the same operation.
1009 These differ in the types of the arguments. */
1010 for (last
= NULL_TREE
;
1011 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1012 fndecl
= TREE_CHAIN (fndecl
))
1013 /* Output the name of the field (after overloading), as
1014 well as the name of the field before overloading, along
1015 with its parameter list */
1017 /* This is the "mangled" name of the method.
1018 It encodes the argument types. */
1019 const char *debug_name
;
1021 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1022 include TEMPLATE_DECLs.) The debugger doesn't know what
1023 to do with such entities anyhow. */
1024 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1027 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1033 /* Also ignore abstract methods; those are only interesting to
1034 the DWARF backends. */
1035 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1038 /* Redundantly output the plain name, since that's what gdb
1042 tree name
= DECL_NAME (fndecl
);
1043 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1044 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1048 dbxout_type (TREE_TYPE (fndecl
), 0);
1050 dbxout_type_method_1 (fndecl
, debug_name
);
1054 putc (';', asmfile
);
1060 /* Emit a "range" type specification, which has the form:
1061 "r<index type>;<lower bound>;<upper bound>;".
1062 TYPE is an INTEGER_TYPE. */
1065 dbxout_range_type (type
)
1068 fprintf (asmfile
, "r");
1069 if (TREE_TYPE (type
))
1070 dbxout_type (TREE_TYPE (type
), 0);
1071 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1072 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1075 /* Traditionally, we made sure 'int' was type 1, and builtin types
1076 were defined to be sub-ranges of int. Unfortunately, this
1077 does not allow us to distinguish true sub-ranges from integer
1078 types. So, instead we define integer (non-sub-range) types as
1079 sub-ranges of themselves. This matters for Chill. If this isn't
1080 a subrange type, then we want to define it in terms of itself.
1081 However, in C, this may be an anonymous integer type, and we don't
1082 want to emit debug info referring to it. Just calling
1083 dbxout_type_index won't work anyways, because the type hasn't been
1084 defined yet. We make this work for both cases by checked to see
1085 whether this is a defined type, referring to it if it is, and using
1087 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1088 dbxout_type_index (type
);
1090 dbxout_type_index (integer_type_node
);
1093 if (TYPE_MIN_VALUE (type
) != 0
1094 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1096 putc (';', asmfile
);
1098 if (print_int_cst_bounds_in_octal_p (type
))
1099 print_int_cst_octal (TYPE_MIN_VALUE (type
));
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 if (print_int_cst_bounds_in_octal_p (type
))
1115 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1117 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1118 putc (';', asmfile
);
1123 fprintf (asmfile
, ";-1;");
1128 /* Output a reference to a type. If the type has not yet been
1129 described in the dbx output, output its definition now.
1130 For a type already defined, just refer to its definition
1131 using the type number.
1133 If FULL is nonzero, and the type has been described only with
1134 a forward-reference, output the definition now.
1135 If FULL is zero in this case, just refer to the forward-reference
1136 using the number previously allocated. */
1139 dbxout_type (type
, full
)
1145 static int anonymous_type_number
= 0;
1147 if (TREE_CODE (type
) == VECTOR_TYPE
)
1148 /* The frontend feeds us a representation for the vector as a struct
1149 containing an array. Pull out the array type. */
1150 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1152 /* If there was an input error and we don't really have a type,
1153 avoid crashing and write something that is at least valid
1154 by assuming `int'. */
1155 if (type
== error_mark_node
)
1156 type
= integer_type_node
;
1159 if (TYPE_NAME (type
)
1160 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1161 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1165 /* Try to find the "main variant" with the same name. */
1166 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1167 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1168 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1170 main_variant
= TYPE_MAIN_VARIANT (type
);
1172 /* If we are not using extensions, stabs does not distinguish const and
1173 volatile, so there is no need to make them separate types. */
1174 if (!use_gnu_debug_info_extensions
)
1175 type
= main_variant
;
1177 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1179 /* Type has no dbx number assigned. Assign next available number. */
1180 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1182 /* Make sure type vector is long enough to record about this type. */
1184 if (next_type_number
== typevec_len
)
1187 = (struct typeinfo
*) ggc_realloc (typevec
,
1189 * sizeof typevec
[0]));
1190 memset ((char *) (typevec
+ typevec_len
), 0,
1191 typevec_len
* sizeof typevec
[0]);
1195 #ifdef DBX_USE_BINCL
1196 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1197 = current_file
->file_number
;
1198 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1199 = current_file
->next_type_number
++;
1203 /* Output the number of this type, to refer to it. */
1204 dbxout_type_index (type
);
1206 #ifdef DBX_TYPE_DEFINED
1207 if (DBX_TYPE_DEFINED (type
))
1211 /* If this type's definition has been output or is now being output,
1214 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1219 /* If we have already had a cross reference,
1220 and either that's all we want or that's the best we could do,
1221 don't repeat the cross reference.
1222 Sun dbx crashes if we do. */
1223 if (! full
|| !COMPLETE_TYPE_P (type
)
1224 /* No way in DBX fmt to describe a variable size. */
1225 || ! host_integerp (TYPE_SIZE (type
), 1))
1233 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1234 leave the type-number completely undefined rather than output
1235 a cross-reference. If we have already used GNU debug info extensions,
1236 then it is OK to output a cross reference. This is necessary to get
1237 proper C++ debug output. */
1238 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1239 || TREE_CODE (type
) == QUAL_UNION_TYPE
1240 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1241 && ! use_gnu_debug_info_extensions
)
1242 /* We must use the same test here as we use twice below when deciding
1243 whether to emit a cross-reference. */
1244 if ((TYPE_NAME (type
) != 0
1245 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1246 && DECL_IGNORED_P (TYPE_NAME (type
)))
1248 || !COMPLETE_TYPE_P (type
)
1249 /* No way in DBX fmt to describe a variable size. */
1250 || ! host_integerp (TYPE_SIZE (type
), 1))
1252 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1257 /* Output a definition now. */
1259 fprintf (asmfile
, "=");
1262 /* Mark it as defined, so that if it is self-referent
1263 we will not get into an infinite recursion of definitions. */
1265 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1267 /* If this type is a variant of some other, hand off. Types with
1268 different names are usefully distinguished. We only distinguish
1269 cv-qualified types if we're using extensions. */
1270 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1272 putc ('k', asmfile
);
1274 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1277 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1279 putc ('B', asmfile
);
1281 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1284 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1286 /* 'type' is a typedef; output the type it refers to. */
1287 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1290 /* else continue. */
1292 switch (TREE_CODE (type
))
1296 /* For a void type, just define it as itself; ie, "5=5".
1297 This makes us consider it defined
1298 without saying what it is. The debugger will make it
1299 a void type when the reference is seen, and nothing will
1300 ever override that default. */
1301 dbxout_type_index (type
);
1305 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1307 /* Output the type `char' as a subrange of itself!
1308 I don't understand this definition, just copied it
1309 from the output of pcc.
1310 This used to use `r2' explicitly and we used to
1311 take care to make sure that `char' was type number 2. */
1312 fprintf (asmfile
, "r");
1314 dbxout_type_index (type
);
1315 fprintf (asmfile
, ";0;127;");
1319 /* If this is a subtype of another integer type, always prefer to
1320 write it as a subtype. */
1321 else if (TREE_TYPE (type
) != 0
1322 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1324 /* If the size is non-standard, say what it is if we can use
1327 if (use_gnu_debug_info_extensions
1328 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1330 have_used_extensions
= 1;
1331 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1335 dbxout_range_type (type
);
1340 /* If the size is non-standard, say what it is if we can use
1343 if (use_gnu_debug_info_extensions
1344 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1346 have_used_extensions
= 1;
1347 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1351 if (print_int_cst_bounds_in_octal_p (type
))
1353 fprintf (asmfile
, "r");
1356 /* If this type derives from another type, output type index of
1357 parent type. This is particularly important when parent type
1358 is an enumerated type, because not generating the parent type
1359 index would transform the definition of this enumerated type
1360 into a plain unsigned type. */
1361 if (TREE_TYPE (type
) != 0)
1362 dbxout_type_index (TREE_TYPE (type
));
1364 dbxout_type_index (type
);
1366 fprintf (asmfile
, ";");
1368 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1369 fprintf (asmfile
, ";");
1371 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1372 fprintf (asmfile
, ";");
1377 /* Output other integer types as subranges of `int'. */
1378 dbxout_range_type (type
);
1384 /* This used to say `r1' and we used to take care
1385 to make sure that `int' was type number 1. */
1386 fprintf (asmfile
, "r");
1388 dbxout_type_index (integer_type_node
);
1389 putc (';', asmfile
);
1391 print_wide_int (int_size_in_bytes (type
));
1392 fputs (";0;", asmfile
);
1397 if (use_gnu_debug_info_extensions
)
1399 have_used_extensions
= 1;
1400 fputs ("@s", asmfile
);
1402 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1403 fputs (";-20;", asmfile
);
1408 /* Output the type `char' as a subrange of itself.
1409 That is what pcc seems to do. */
1410 fprintf (asmfile
, "r");
1412 dbxout_type_index (char_type_node
);
1413 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1419 if (use_gnu_debug_info_extensions
)
1421 have_used_extensions
= 1;
1422 fputs ("@s", asmfile
);
1424 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1425 fputs (";-16;", asmfile
);
1428 else /* Define as enumeral type (False, True) */
1430 fprintf (asmfile
, "eFalse:0,True:1,;");
1436 putc ('d', asmfile
);
1438 dbxout_type (TREE_TYPE (type
), 0);
1442 /* Differs from the REAL_TYPE by its new data type number */
1444 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1446 putc ('R', asmfile
);
1448 dbxout_fptype_value (type
);
1449 putc (';', asmfile
);
1451 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1452 fputs (";0;", asmfile
);
1457 /* Output a complex integer type as a structure,
1458 pending some other way to do it. */
1459 putc ('s', asmfile
);
1461 print_wide_int (int_size_in_bytes (type
));
1462 fprintf (asmfile
, "real:");
1465 dbxout_type (TREE_TYPE (type
), 0);
1466 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1468 fprintf (asmfile
, "imag:");
1470 dbxout_type (TREE_TYPE (type
), 0);
1471 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1472 TYPE_PRECISION (TREE_TYPE (type
)));
1478 if (use_gnu_debug_info_extensions
)
1480 have_used_extensions
= 1;
1481 fputs ("@s", asmfile
);
1483 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1484 putc (';', asmfile
);
1487 /* Check if a bitstring type, which in Chill is
1488 different from a [power]set. */
1489 if (TYPE_STRING_FLAG (type
))
1491 fprintf (asmfile
, "@S;");
1495 putc ('S', asmfile
);
1497 dbxout_type (TYPE_DOMAIN (type
), 0);
1501 /* Make arrays of packed bits look like bitstrings for chill. */
1502 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1504 have_used_extensions
= 1;
1505 fputs ("@s", asmfile
);
1507 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1508 fprintf (asmfile
, ";@S;S");
1510 dbxout_type (TYPE_DOMAIN (type
), 0);
1514 /* Output "a" followed by a range type definition
1515 for the index type of the array
1516 followed by a reference to the target-type.
1517 ar1;0;N;M for a C array of type M and size N+1. */
1518 /* Check if a character string type, which in Chill is
1519 different from an array of characters. */
1520 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1522 have_used_extensions
= 1;
1523 fprintf (asmfile
, "@S;");
1526 tem
= TYPE_DOMAIN (type
);
1529 fprintf (asmfile
, "ar");
1531 dbxout_type_index (integer_type_node
);
1532 fprintf (asmfile
, ";0;-1;");
1537 fprintf (asmfile
, "a");
1539 dbxout_range_type (tem
);
1542 dbxout_type (TREE_TYPE (type
), 0);
1547 case QUAL_UNION_TYPE
:
1549 int i
, n_baseclasses
= 0;
1551 if (TYPE_BINFO (type
) != 0
1552 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1553 && TYPE_BINFO_BASETYPES (type
) != 0)
1554 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1556 /* Output a structure type. We must use the same test here as we
1557 use in the DBX_NO_XREFS case above. */
1558 if ((TYPE_NAME (type
) != 0
1559 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1560 && DECL_IGNORED_P (TYPE_NAME (type
)))
1562 || !COMPLETE_TYPE_P (type
)
1563 /* No way in DBX fmt to describe a variable size. */
1564 || ! host_integerp (TYPE_SIZE (type
), 1))
1566 /* If the type is just a cross reference, output one
1567 and mark the type as partially described.
1568 If it later becomes defined, we will output
1569 its real definition.
1570 If the type has a name, don't nest its definition within
1571 another type's definition; instead, output an xref
1572 and let the definition come when the name is defined. */
1573 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1575 #if 0 /* This assertion is legitimately false in C++. */
1576 /* We shouldn't be outputting a reference to a type before its
1577 definition unless the type has a tag name.
1578 A typedef name without a tag name should be impossible. */
1579 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1582 if (TYPE_NAME (type
) != 0)
1583 dbxout_type_name (type
);
1586 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1590 fprintf (asmfile
, ":");
1592 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1596 /* Identify record or union, and print its size. */
1597 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1599 print_wide_int (int_size_in_bytes (type
));
1601 if (use_gnu_debug_info_extensions
)
1605 have_used_extensions
= 1;
1606 fprintf (asmfile
, "!%d,", n_baseclasses
);
1610 for (i
= 0; i
< n_baseclasses
; i
++)
1612 tree binfo
= TYPE_BINFO (type
);
1613 tree child
= BINFO_BASETYPE (binfo
, i
);
1614 tree access
= (BINFO_BASEACCESSES (binfo
)
1615 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1617 if (use_gnu_debug_info_extensions
)
1619 have_used_extensions
= 1;
1620 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1621 putc (access
== access_public_node
? '2' : '0', asmfile
);
1623 if (TREE_VIA_VIRTUAL (child
)
1624 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1625 /* For a virtual base, print the (negative) offset within
1626 the vtable where we must look to find the necessary
1628 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1631 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1633 putc (',', asmfile
);
1635 dbxout_type (BINFO_TYPE (child
), 0);
1636 putc (';', asmfile
);
1641 /* Print out the base class information with fields
1642 which have the same names at the types they hold. */
1643 dbxout_type_name (BINFO_TYPE (child
));
1644 putc (':', asmfile
);
1646 dbxout_type (BINFO_TYPE (child
), full
);
1647 putc (',', asmfile
);
1649 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1651 putc (',', asmfile
);
1653 print_wide_int (tree_low_cst (DECL_SIZE
1655 (BINFO_TYPE (child
))),
1658 putc (';', asmfile
);
1664 /* Write out the field declarations. */
1665 dbxout_type_fields (type
);
1666 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1668 have_used_extensions
= 1;
1669 dbxout_type_methods (type
);
1672 putc (';', asmfile
);
1675 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1676 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1677 && TYPE_VFIELD (type
))
1679 have_used_extensions
= 1;
1681 /* Tell GDB+ that it may keep reading. */
1682 putc ('~', asmfile
);
1685 /* We need to write out info about what field this class
1686 uses as its "main" vtable pointer field, because if this
1687 field is inherited from a base class, GDB cannot necessarily
1688 figure out which field it's using in time. */
1689 if (TYPE_VFIELD (type
))
1691 putc ('%', asmfile
);
1693 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1696 putc (';', asmfile
);
1702 /* We must use the same test here as we use in the DBX_NO_XREFS case
1703 above. We simplify it a bit since an enum will never have a variable
1705 if ((TYPE_NAME (type
) != 0
1706 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1707 && DECL_IGNORED_P (TYPE_NAME (type
)))
1709 || !COMPLETE_TYPE_P (type
))
1711 fprintf (asmfile
, "xe");
1713 dbxout_type_name (type
);
1714 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1715 putc (':', asmfile
);
1719 if (use_gnu_debug_info_extensions
1720 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1722 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1726 putc ('e', asmfile
);
1728 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1730 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1731 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1732 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1733 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1734 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1735 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1736 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1738 print_int_cst_octal (TREE_VALUE (tem
));
1740 putc (',', asmfile
);
1742 if (TREE_CHAIN (tem
) != 0)
1746 putc (';', asmfile
);
1751 putc ('*', asmfile
);
1753 dbxout_type (TREE_TYPE (type
), 0);
1757 if (use_gnu_debug_info_extensions
)
1759 have_used_extensions
= 1;
1760 putc ('#', asmfile
);
1763 /* Write the argument types out longhand. */
1764 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1765 putc (',', asmfile
);
1767 dbxout_type (TREE_TYPE (type
), 0);
1768 dbxout_args (TYPE_ARG_TYPES (type
));
1769 putc (';', asmfile
);
1773 /* Treat it as a function type. */
1774 dbxout_type (TREE_TYPE (type
), 0);
1778 if (use_gnu_debug_info_extensions
)
1780 have_used_extensions
= 1;
1781 putc ('@', asmfile
);
1783 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1784 putc (',', asmfile
);
1786 dbxout_type (TREE_TYPE (type
), 0);
1789 /* Should print as an int, because it is really just an offset. */
1790 dbxout_type (integer_type_node
, 0);
1793 case REFERENCE_TYPE
:
1794 if (use_gnu_debug_info_extensions
)
1795 have_used_extensions
= 1;
1796 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1798 dbxout_type (TREE_TYPE (type
), 0);
1802 putc ('f', asmfile
);
1804 dbxout_type (TREE_TYPE (type
), 0);
1812 /* Return nonzero if the given type represents an integer whose bounds
1813 should be printed in octal format. */
1816 print_int_cst_bounds_in_octal_p (type
)
1819 /* If we can use GDB extensions and the size is wider than a long
1820 (the size used by GDB to read them) or we may have trouble writing
1821 the bounds the usual way, write them in octal. Note the test is for
1822 the *target's* size of "long", not that of the host. The host test
1823 is just to make sure we can write it out in case the host wide int
1824 is narrower than the target "long".
1826 For unsigned types, we use octal if they are the same size or larger.
1827 This is because we print the bounds as signed decimal, and hence they
1828 can't span same size unsigned types. */
1830 if (use_gnu_debug_info_extensions
1831 && TYPE_MIN_VALUE (type
) != 0
1832 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1833 && TYPE_MAX_VALUE (type
) != 0
1834 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1835 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1836 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1837 && TREE_UNSIGNED (type
))
1838 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1839 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1840 && TREE_UNSIGNED (type
))))
1846 /* Print the value of integer constant C, in octal,
1847 handling double precision. */
1850 print_int_cst_octal (c
)
1853 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1854 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1855 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1856 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1858 /* GDB wants constants with no extra leading "1" bits, so
1859 we need to remove any sign-extension that might be
1861 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1863 else if (width
> HOST_BITS_PER_WIDE_INT
)
1864 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1865 else if (width
== HOST_BITS_PER_WIDE_INT
)
1868 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1870 fprintf (asmfile
, "0");
1875 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1876 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1880 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1881 unsigned HOST_WIDE_INT middle
1882 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1883 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1884 unsigned HOST_WIDE_INT end
1885 = low
& (((unsigned HOST_WIDE_INT
) 1
1886 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1889 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1891 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1896 print_octal (value
, digits
)
1897 unsigned HOST_WIDE_INT value
;
1902 for (i
= digits
- 1; i
>= 0; i
--)
1903 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1908 /* Output C in decimal while adjusting the number of digits written. */
1916 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1927 /* Output the name of type TYPE, with no punctuation.
1928 Such names can be set up either by typedef declarations
1929 or by struct, enum and union tags. */
1932 dbxout_type_name (type
)
1936 if (TYPE_NAME (type
) == 0)
1938 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1940 t
= TYPE_NAME (type
);
1942 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1944 t
= DECL_NAME (TYPE_NAME (type
));
1949 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1950 CHARS (IDENTIFIER_LENGTH (t
));
1953 /* Output leading leading struct or class names needed for qualifying
1954 type whose scope is limited to a struct or class. */
1957 dbxout_class_name_qualifiers (decl
)
1960 tree context
= decl_type_context (decl
);
1962 if (context
!= NULL_TREE
1963 && TREE_CODE(context
) == RECORD_TYPE
1964 && TYPE_NAME (context
) != 0
1965 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
1966 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
1968 tree name
= TYPE_NAME (context
);
1970 if (TREE_CODE (name
) == TYPE_DECL
)
1972 dbxout_class_name_qualifiers (name
);
1973 name
= DECL_NAME (name
);
1975 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1976 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1980 /* Output a .stabs for the symbol defined by DECL,
1981 which must be a ..._DECL node in the normal namespace.
1982 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1983 LOCAL is nonzero if the scope is less than the entire file.
1984 Return 1 if a stabs might have been emitted. */
1987 dbxout_symbol (decl
, local
)
1989 int local ATTRIBUTE_UNUSED
;
1991 tree type
= TREE_TYPE (decl
);
1992 tree context
= NULL_TREE
;
1995 /* Cast avoids warning in old compilers. */
1996 current_sym_code
= (STAB_CODE_TYPE
) 0;
1997 current_sym_value
= 0;
1998 current_sym_addr
= 0;
2000 /* Ignore nameless syms, but don't ignore type tags. */
2002 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2003 || DECL_IGNORED_P (decl
))
2006 dbxout_prepare_symbol (decl
);
2008 /* The output will always start with the symbol name,
2009 so always count that in the length-output-so-far. */
2011 if (DECL_NAME (decl
) != 0)
2012 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2014 switch (TREE_CODE (decl
))
2017 /* Enum values are defined by defining the enum type. */
2021 if (DECL_RTL (decl
) == 0)
2023 if (DECL_EXTERNAL (decl
))
2025 /* Don't mention a nested function under its parent. */
2026 context
= decl_function_context (decl
);
2027 if (context
== current_function_decl
)
2029 if (GET_CODE (DECL_RTL (decl
)) != MEM
2030 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2034 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2035 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2036 TREE_PUBLIC (decl
) ? 'F' : 'f');
2039 current_sym_code
= N_FUN
;
2040 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2042 if (TREE_TYPE (type
))
2043 dbxout_type (TREE_TYPE (type
), 0);
2045 dbxout_type (void_type_node
, 0);
2047 /* For a nested function, when that function is compiled,
2048 mention the containing function name
2049 as well as (since dbx wants it) our own assembler-name. */
2051 fprintf (asmfile
, ",%s,%s",
2052 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2053 IDENTIFIER_POINTER (DECL_NAME (context
)));
2055 dbxout_finish_symbol (decl
);
2060 /* This seems all wrong. Outputting most kinds of types gives no name
2061 at all. A true definition gives no name; a cross-ref for a
2062 structure can give the tag name, but not a type name.
2063 It seems that no typedef name is defined by outputting a type. */
2065 /* If this typedef name was defined by outputting the type,
2066 don't duplicate it. */
2067 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
2068 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
2071 /* Don't output the same typedef twice.
2072 And don't output what language-specific stuff doesn't want output. */
2073 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2082 if (DECL_NAME (decl
))
2084 /* Nonzero means we must output a tag as well as a typedef. */
2087 /* Handle the case of a C++ structure or union
2088 where the TYPE_NAME is a TYPE_DECL
2089 which gives both a typedef name and a tag. */
2090 /* dbx requires the tag first and the typedef second. */
2091 if ((TREE_CODE (type
) == RECORD_TYPE
2092 || TREE_CODE (type
) == UNION_TYPE
2093 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2094 && TYPE_NAME (type
) == decl
2095 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2096 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2097 /* Distinguish the implicit typedefs of C++
2098 from explicit ones that might be found in C. */
2099 && DECL_ARTIFICIAL (decl
)
2100 /* Do not generate a tag for records of variable size,
2101 since this type can not be properly described in the
2102 DBX format, and it confuses some tools such as objdump. */
2103 && host_integerp (TYPE_SIZE (type
), 1))
2105 tree name
= TYPE_NAME (type
);
2106 if (TREE_CODE (name
) == TYPE_DECL
)
2107 name
= DECL_NAME (name
);
2109 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2110 current_sym_value
= 0;
2111 current_sym_addr
= 0;
2112 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2114 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2115 IDENTIFIER_POINTER (name
));
2116 dbxout_type (type
, 1);
2117 dbxout_finish_symbol (NULL_TREE
);
2120 /* Output .stabs (or whatever) and leading double quote. */
2121 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2123 if (use_gnu_debug_info_extensions
)
2125 /* Output leading class/struct qualifiers. */
2126 dbxout_class_name_qualifiers (decl
);
2129 /* Output typedef name. */
2130 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2132 /* Short cut way to output a tag also. */
2133 if ((TREE_CODE (type
) == RECORD_TYPE
2134 || TREE_CODE (type
) == UNION_TYPE
2135 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2136 && TYPE_NAME (type
) == decl
2137 /* Distinguish the implicit typedefs of C++
2138 from explicit ones that might be found in C. */
2139 && DECL_ARTIFICIAL (decl
))
2141 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2143 putc ('T', asmfile
);
2144 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2146 #if 0 /* Now we generate the tag for this case up above. */
2152 putc ('t', asmfile
);
2153 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2155 dbxout_type (type
, 1);
2156 dbxout_finish_symbol (decl
);
2160 /* Don't output a tag if this is an incomplete type. This prevents
2161 the sun4 Sun OS 4.x dbx from crashing. */
2163 if (tag_needed
&& TYPE_NAME (type
) != 0
2164 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2165 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2166 && COMPLETE_TYPE_P (type
)
2167 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2169 /* For a TYPE_DECL with no name, but the type has a name,
2171 This is what represents `struct foo' with no typedef. */
2172 /* In C++, the name of a type is the corresponding typedef.
2173 In C, it is an IDENTIFIER_NODE. */
2174 tree name
= TYPE_NAME (type
);
2175 if (TREE_CODE (name
) == TYPE_DECL
)
2176 name
= DECL_NAME (name
);
2178 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2179 current_sym_value
= 0;
2180 current_sym_addr
= 0;
2181 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2183 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2184 IDENTIFIER_POINTER (name
));
2185 dbxout_type (type
, 1);
2186 dbxout_finish_symbol (NULL_TREE
);
2190 /* If an enum type has no name, it cannot be referred to,
2191 but we must output it anyway, since the enumeration constants
2192 can be referred to. */
2193 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2195 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2196 current_sym_value
= 0;
2197 current_sym_addr
= 0;
2198 current_sym_nchars
= 2;
2200 /* Some debuggers fail when given NULL names, so give this a
2201 harmless name of ` '. */
2202 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2203 dbxout_type (type
, 1);
2204 dbxout_finish_symbol (NULL_TREE
);
2207 /* Prevent duplicate output of a typedef. */
2208 TREE_ASM_WRITTEN (decl
) = 1;
2213 /* Parm decls go in their own separate chains
2214 and are output by dbxout_reg_parms and dbxout_parms. */
2218 /* Named return value, treat like a VAR_DECL. */
2220 if (! DECL_RTL_SET_P (decl
))
2222 /* Don't mention a variable that is external.
2223 Let the file that defines it describe it. */
2224 if (DECL_EXTERNAL (decl
))
2227 /* If the variable is really a constant
2228 and not written in memory, inform the debugger. */
2229 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2230 && DECL_INITIAL (decl
) != 0
2231 && host_integerp (DECL_INITIAL (decl
), 0)
2232 && ! TREE_ASM_WRITTEN (decl
)
2233 && (DECL_CONTEXT (decl
) == NULL_TREE
2234 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2236 if (TREE_PUBLIC (decl
) == 0)
2238 /* The sun4 assembler does not grok this. */
2239 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2241 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2242 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2244 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2245 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2247 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2250 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2252 /* don't know how to do this yet. */
2256 /* else it is something we handle like a normal variable. */
2259 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2260 #ifdef LEAF_REG_REMAP
2261 if (current_function_uses_only_leaf_regs
)
2262 leaf_renumber_regs_insn (DECL_RTL (decl
));
2265 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2274 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2275 Add SUFFIX to its name, if SUFFIX is not 0.
2276 Describe the variable as residing in HOME
2277 (usually HOME is DECL_RTL (DECL), but not always).
2278 Returns 1 if the stab was really emitted. */
2281 dbxout_symbol_location (decl
, type
, suffix
, home
)
2289 /* Don't mention a variable at all
2290 if it was completely optimized into nothingness.
2292 If the decl was from an inline function, then its rtl
2293 is not identically the rtl that was used in this
2294 particular compilation. */
2295 if (GET_CODE (home
) == SUBREG
)
2299 while (GET_CODE (value
) == SUBREG
)
2300 value
= SUBREG_REG (value
);
2301 if (GET_CODE (value
) == REG
)
2303 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2306 home
= alter_subreg (&home
);
2308 if (GET_CODE (home
) == REG
)
2310 regno
= REGNO (home
);
2311 if (regno
>= FIRST_PSEUDO_REGISTER
)
2315 /* The kind-of-variable letter depends on where
2316 the variable is and on the scope of its name:
2317 G and N_GSYM for static storage and global scope,
2318 S for static storage and file scope,
2319 V for static storage and local scope,
2320 for those two, use N_LCSYM if data is in bss segment,
2321 N_STSYM if in data segment, N_FUN otherwise.
2322 (We used N_FUN originally, then changed to N_STSYM
2323 to please GDB. However, it seems that confused ld.
2324 Now GDB has been fixed to like N_FUN, says Kingdon.)
2325 no letter at all, and N_LSYM, for auto variable,
2326 r and N_RSYM for register variable. */
2328 if (GET_CODE (home
) == MEM
2329 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2331 if (TREE_PUBLIC (decl
))
2334 current_sym_code
= N_GSYM
;
2338 current_sym_addr
= XEXP (home
, 0);
2340 letter
= decl_function_context (decl
) ? 'V' : 'S';
2342 /* This should be the same condition as in assemble_variable, but
2343 we don't have access to dont_output_data here. So, instead,
2344 we rely on the fact that error_mark_node initializers always
2345 end up in bss for C++ and never end up in bss for C. */
2346 if (DECL_INITIAL (decl
) == 0
2347 || (!strcmp (lang_hooks
.name
, "GNU C++")
2348 && DECL_INITIAL (decl
) == error_mark_node
))
2349 current_sym_code
= N_LCSYM
;
2350 else if (DECL_IN_TEXT_SECTION (decl
))
2351 /* This is not quite right, but it's the closest
2352 of all the codes that Unix defines. */
2353 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2356 /* Some ports can transform a symbol ref into a label ref,
2357 because the symbol ref is too far away and has to be
2358 dumped into a constant pool. Alternatively, the symbol
2359 in the constant pool might be referenced by a different
2361 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2362 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2364 rtx tmp
= get_pool_constant (current_sym_addr
);
2366 if (GET_CODE (tmp
) == SYMBOL_REF
2367 || GET_CODE (tmp
) == LABEL_REF
)
2368 current_sym_addr
= tmp
;
2371 /* Ultrix `as' seems to need this. */
2372 #ifdef DBX_STATIC_STAB_DATA_SECTION
2375 current_sym_code
= N_STSYM
;
2379 else if (regno
>= 0)
2382 current_sym_code
= N_RSYM
;
2383 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2385 else if (GET_CODE (home
) == MEM
2386 && (GET_CODE (XEXP (home
, 0)) == MEM
2387 || (GET_CODE (XEXP (home
, 0)) == REG
2388 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2389 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2390 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2391 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2394 /* If the value is indirect by memory or by a register
2395 that isn't the frame pointer
2396 then it means the object is variable-sized and address through
2397 that register or stack slot. DBX has no way to represent this
2398 so all we can do is output the variable as a pointer.
2399 If it's not a parameter, ignore it.
2400 (VAR_DECLs like this can be made by integrate.c.) */
2402 if (GET_CODE (XEXP (home
, 0)) == REG
)
2405 current_sym_code
= N_RSYM
;
2406 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2408 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2412 current_sym_code
= N_LSYM
;
2413 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2414 We want the value of that CONST_INT. */
2416 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2419 /* Effectively do build_pointer_type, but don't cache this type,
2420 since it might be temporary whereas the type it points to
2421 might have been saved for inlining. */
2422 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2423 type
= make_node (POINTER_TYPE
);
2424 TREE_TYPE (type
) = TREE_TYPE (decl
);
2426 else if (GET_CODE (home
) == MEM
2427 && GET_CODE (XEXP (home
, 0)) == REG
)
2429 current_sym_code
= N_LSYM
;
2430 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2432 else if (GET_CODE (home
) == MEM
2433 && GET_CODE (XEXP (home
, 0)) == PLUS
2434 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2436 current_sym_code
= N_LSYM
;
2437 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2438 We want the value of that CONST_INT. */
2439 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2441 else if (GET_CODE (home
) == MEM
2442 && GET_CODE (XEXP (home
, 0)) == CONST
)
2444 /* Handle an obscure case which can arise when optimizing and
2445 when there are few available registers. (This is *always*
2446 the case for i386/i486 targets). The RTL looks like
2447 (MEM (CONST ...)) even though this variable is a local `auto'
2448 or a local `register' variable. In effect, what has happened
2449 is that the reload pass has seen that all assignments and
2450 references for one such a local variable can be replaced by
2451 equivalent assignments and references to some static storage
2452 variable, thereby avoiding the need for a register. In such
2453 cases we're forced to lie to debuggers and tell them that
2454 this variable was itself `static'. */
2455 current_sym_code
= N_LCSYM
;
2457 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2459 else if (GET_CODE (home
) == CONCAT
)
2463 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2464 for example), then there is no easy way to figure out
2465 what SUBTYPE should be. So, we give up. */
2466 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2469 subtype
= TREE_TYPE (type
);
2471 /* If the variable's storage is in two parts,
2472 output each as a separate stab with a modified name. */
2473 if (WORDS_BIG_ENDIAN
)
2474 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2476 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2478 /* Cast avoids warning in old compilers. */
2479 current_sym_code
= (STAB_CODE_TYPE
) 0;
2480 current_sym_value
= 0;
2481 current_sym_addr
= 0;
2482 dbxout_prepare_symbol (decl
);
2484 if (WORDS_BIG_ENDIAN
)
2485 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2487 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2491 /* Address might be a MEM, when DECL is a variable-sized object.
2492 Or it might be const0_rtx, meaning previous passes
2493 want us to ignore this variable. */
2496 /* Ok, start a symtab entry and output the variable name. */
2499 #ifdef DBX_STATIC_BLOCK_START
2500 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2503 dbxout_symbol_name (decl
, suffix
, letter
);
2504 dbxout_type (type
, 0);
2505 dbxout_finish_symbol (decl
);
2507 #ifdef DBX_STATIC_BLOCK_END
2508 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2513 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2514 Then output LETTER to indicate the kind of location the symbol has. */
2517 dbxout_symbol_name (decl
, suffix
, letter
)
2524 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2525 /* One slight hitch: if this is a VAR_DECL which is a static
2526 class member, we must put out the mangled name instead of the
2527 DECL_NAME. Note also that static member (variable) names DO NOT begin
2528 with underscores in .stabs directives. */
2529 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2531 /* ...but if we're function-local, we don't want to include the junk
2532 added by ASM_FORMAT_PRIVATE_NAME. */
2533 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2537 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2538 (suffix
? suffix
: ""));
2541 putc (letter
, asmfile
);
2545 dbxout_prepare_symbol (decl
)
2546 tree decl ATTRIBUTE_UNUSED
;
2549 const char *filename
= DECL_SOURCE_FILE (decl
);
2551 dbxout_source_file (asmfile
, filename
);
2556 dbxout_finish_symbol (sym
)
2559 #ifdef DBX_FINISH_SYMBOL
2560 DBX_FINISH_SYMBOL (sym
);
2563 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2564 line
= DECL_SOURCE_LINE (sym
);
2566 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2567 if (current_sym_addr
)
2568 output_addr_const (asmfile
, current_sym_addr
);
2570 fprintf (asmfile
, "%d", current_sym_value
);
2571 putc ('\n', asmfile
);
2575 /* Output definitions of all the decls in a chain. Return nonzero if
2576 anything was output */
2585 result
+= dbxout_symbol (syms
, 1);
2586 syms
= TREE_CHAIN (syms
);
2591 /* The following two functions output definitions of function parameters.
2592 Each parameter gets a definition locating it in the parameter list.
2593 Each parameter that is a register variable gets a second definition
2594 locating it in the register.
2596 Printing or argument lists in gdb uses the definitions that
2597 locate in the parameter list. But reference to the variable in
2598 expressions uses preferentially the definition as a register. */
2600 /* Output definitions, referring to storage in the parmlist,
2601 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2604 dbxout_parms (parms
)
2607 for (; parms
; parms
= TREE_CHAIN (parms
))
2608 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2610 dbxout_prepare_symbol (parms
);
2612 /* Perform any necessary register eliminations on the parameter's rtl,
2613 so that the debugging output will be accurate. */
2614 DECL_INCOMING_RTL (parms
)
2615 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2616 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2617 #ifdef LEAF_REG_REMAP
2618 if (current_function_uses_only_leaf_regs
)
2620 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2621 leaf_renumber_regs_insn (DECL_RTL (parms
));
2625 if (PARM_PASSED_IN_MEMORY (parms
))
2627 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2629 /* ??? Here we assume that the parm address is indexed
2630 off the frame pointer or arg pointer.
2631 If that is not true, we produce meaningless results,
2632 but do not crash. */
2633 if (GET_CODE (addr
) == PLUS
2634 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2635 current_sym_value
= INTVAL (XEXP (addr
, 1));
2637 current_sym_value
= 0;
2639 current_sym_code
= N_PSYM
;
2640 current_sym_addr
= 0;
2643 if (DECL_NAME (parms
))
2645 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2647 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2648 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2649 DBX_MEMPARM_STABS_LETTER
);
2653 current_sym_nchars
= 8;
2654 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2655 DBX_MEMPARM_STABS_LETTER
);
2658 /* It is quite tempting to use:
2660 dbxout_type (TREE_TYPE (parms), 0);
2662 as the next statement, rather than using DECL_ARG_TYPE(), so
2663 that gcc reports the actual type of the parameter, rather
2664 than the promoted type. This certainly makes GDB's life
2665 easier, at least for some ports. The change is a bad idea
2666 however, since GDB expects to be able access the type without
2667 performing any conversions. So for example, if we were
2668 passing a float to an unprototyped function, gcc will store a
2669 double on the stack, but if we emit a stab saying the type is a
2670 float, then gdb will only read in a single value, and this will
2671 produce an erroneous value. */
2672 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2673 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2674 dbxout_finish_symbol (parms
);
2676 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2679 char regparm_letter
;
2681 /* Parm passed in registers and lives in registers or nowhere. */
2683 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2684 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2685 current_sym_addr
= 0;
2687 /* If parm lives in a register, use that register;
2688 pretend the parm was passed there. It would be more consistent
2689 to describe the register where the parm was passed,
2690 but in practice that register usually holds something else.
2692 If we use DECL_RTL, then we must use the declared type of
2693 the variable, not the type that it arrived in. */
2694 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2696 best_rtl
= DECL_RTL (parms
);
2697 parm_type
= TREE_TYPE (parms
);
2699 /* If the parm lives nowhere, use the register where it was
2700 passed. It is also better to use the declared type here. */
2703 best_rtl
= DECL_INCOMING_RTL (parms
);
2704 parm_type
= TREE_TYPE (parms
);
2706 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2709 if (DECL_NAME (parms
))
2711 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2712 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2713 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2718 current_sym_nchars
= 8;
2719 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2723 dbxout_type (parm_type
, 0);
2724 dbxout_finish_symbol (parms
);
2726 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2727 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2728 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2729 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2730 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2731 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2735 /* Parm was passed via invisible reference.
2736 That is, its address was passed in a register.
2737 Output it as if it lived in that register.
2738 The debugger will know from the type
2739 that it was actually passed by invisible reference. */
2741 char regparm_letter
;
2742 /* Parm passed in registers and lives in registers or nowhere. */
2744 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2745 if (use_gnu_debug_info_extensions
)
2746 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2748 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2750 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2751 If it is an unallocated pseudo-reg, then use the register where
2752 it was passed instead. */
2753 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2754 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2756 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2758 current_sym_addr
= 0;
2761 if (DECL_NAME (parms
))
2764 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2766 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2767 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2772 current_sym_nchars
= 8;
2773 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2777 dbxout_type (TREE_TYPE (parms
), 0);
2778 dbxout_finish_symbol (parms
);
2780 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2781 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2783 /* Parm was passed via invisible reference, with the reference
2784 living on the stack. DECL_RTL looks like
2785 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2786 could look like (MEM (MEM (REG))). */
2787 const char *const decl_name
= (DECL_NAME (parms
)
2788 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2790 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2791 current_sym_value
= 0;
2794 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2795 current_sym_addr
= 0;
2796 current_sym_code
= N_PSYM
;
2799 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2802 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2803 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2804 dbxout_type (TREE_TYPE (parms
), 0);
2805 dbxout_finish_symbol (parms
);
2807 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2808 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2809 /* ??? A constant address for a parm can happen
2810 when the reg it lives in is equiv to a constant in memory.
2811 Should make this not happen, after 2.4. */
2812 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2814 /* Parm was passed in registers but lives on the stack. */
2816 current_sym_code
= N_PSYM
;
2817 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2818 in which case we want the value of that CONST_INT,
2820 in which case we use a value of zero. */
2821 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2822 current_sym_value
= 0;
2825 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2827 current_sym_addr
= 0;
2829 /* Make a big endian correction if the mode of the type of the
2830 parameter is not the same as the mode of the rtl. */
2831 if (BYTES_BIG_ENDIAN
2832 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2833 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2835 current_sym_value
+=
2836 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2837 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2841 if (DECL_NAME (parms
))
2844 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2846 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2847 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2848 DBX_MEMPARM_STABS_LETTER
);
2852 current_sym_nchars
= 8;
2853 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2854 DBX_MEMPARM_STABS_LETTER
);
2858 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2859 XEXP (DECL_RTL (parms
), 0));
2860 dbxout_type (TREE_TYPE (parms
), 0);
2861 dbxout_finish_symbol (parms
);
2866 /* Output definitions for the places where parms live during the function,
2867 when different from where they were passed, when the parms were passed
2870 It is not useful to do this for parms passed in registers
2871 that live during the function in different registers, because it is
2872 impossible to look in the passed register for the passed value,
2873 so we use the within-the-function register to begin with.
2875 PARMS is a chain of PARM_DECL nodes. */
2878 dbxout_reg_parms (parms
)
2881 for (; parms
; parms
= TREE_CHAIN (parms
))
2882 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2884 dbxout_prepare_symbol (parms
);
2886 /* Report parms that live in registers during the function
2887 but were passed in memory. */
2888 if (GET_CODE (DECL_RTL (parms
)) == REG
2889 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2890 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2891 0, DECL_RTL (parms
));
2892 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2893 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2894 0, DECL_RTL (parms
));
2895 /* Report parms that live in memory but not where they were passed. */
2896 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2897 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2898 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2899 0, DECL_RTL (parms
));
2903 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2904 output definitions of those names, in raw form */
2912 putc (',', asmfile
);
2913 dbxout_type (TREE_VALUE (args
), 0);
2915 args
= TREE_CHAIN (args
);
2919 /* Output everything about a symbol block (a BLOCK node
2920 that represents a scope level),
2921 including recursive output of contained blocks.
2923 BLOCK is the BLOCK node.
2924 DEPTH is its depth within containing symbol blocks.
2925 ARGS is usually zero; but for the outermost block of the
2926 body of a function, it is a chain of PARM_DECLs for the function parameters.
2927 We output definitions of all the register parms
2928 as if they were local variables of that block.
2930 If -g1 was used, we count blocks just the same, but output nothing
2931 except for the outermost block.
2933 Actually, BLOCK may be several blocks chained together.
2934 We handle them all in sequence. */
2937 dbxout_block (block
, depth
, args
)
2944 #if DBX_BLOCKS_FUNCTION_RELATIVE
2945 const char *begin_label
;
2946 if (current_function_func_begin_label
!= NULL_TREE
)
2947 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2949 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2954 /* Ignore blocks never expanded or otherwise marked as real. */
2955 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2959 /* In dbx format, the syms of a block come before the N_LBRAC.
2960 If nothing is output, we don't need the N_LBRAC, either. */
2962 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2963 did_output
= dbxout_syms (BLOCK_VARS (block
));
2965 dbxout_reg_parms (args
);
2967 /* Now output an N_LBRAC symbol to represent the beginning of
2968 the block. Use the block's tree-walk order to generate
2969 the assembler symbols LBBn and LBEn
2970 that final will define around the code in this block. */
2971 if (depth
> 0 && did_output
)
2974 blocknum
= BLOCK_NUMBER (block
);
2975 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2977 if (BLOCK_HANDLER_BLOCK (block
))
2979 /* A catch block. Must precede N_LBRAC. */
2980 tree decl
= BLOCK_VARS (block
);
2983 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2984 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2985 assemble_name (asmfile
, buf
);
2986 fprintf (asmfile
, "\n");
2987 decl
= TREE_CHAIN (decl
);
2991 #ifdef DBX_OUTPUT_LBRAC
2992 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2994 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2995 assemble_name (asmfile
, buf
);
2996 #if DBX_BLOCKS_FUNCTION_RELATIVE
2997 putc ('-', asmfile
);
2998 assemble_name (asmfile
, begin_label
);
3000 fprintf (asmfile
, "\n");
3004 /* Output the subblocks. */
3005 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3007 /* Refer to the marker for the end of the block. */
3008 if (depth
> 0 && did_output
)
3011 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3012 #ifdef DBX_OUTPUT_RBRAC
3013 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3015 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3016 assemble_name (asmfile
, buf
);
3017 #if DBX_BLOCKS_FUNCTION_RELATIVE
3018 putc ('-', asmfile
);
3019 assemble_name (asmfile
, begin_label
);
3021 fprintf (asmfile
, "\n");
3025 block
= BLOCK_CHAIN (block
);
3029 /* Output the information about a function and its arguments and result.
3030 Usually this follows the function's code,
3031 but on some systems, it comes before. */
3033 #if defined (DBX_DEBUGGING_INFO)
3035 dbxout_begin_function (decl
)
3038 dbxout_symbol (decl
, 0);
3039 dbxout_parms (DECL_ARGUMENTS (decl
));
3040 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3041 dbxout_symbol (DECL_RESULT (decl
), 1);
3043 #endif /* DBX_DEBUGGING_INFO */
3045 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3047 #include "gt-dbxout.h"