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 bool print_int_cst_bounds_in_octal_p
PARAMS ((tree
));
314 static void print_int_cst_octal
PARAMS ((tree
));
315 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
316 static void print_wide_int
PARAMS ((HOST_WIDE_INT
));
317 static void dbxout_type_name
PARAMS ((tree
));
318 static void dbxout_class_name_qualifiers
PARAMS ((tree
));
319 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
320 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
321 static void dbxout_prepare_symbol
PARAMS ((tree
));
322 static void dbxout_finish_symbol
PARAMS ((tree
));
323 static void dbxout_block
PARAMS ((tree
, int, tree
));
324 static void dbxout_global_decl
PARAMS ((tree
));
325 static void dbxout_handle_pch
PARAMS ((unsigned));
327 /* The debug hooks structure. */
328 #if defined (DBX_DEBUGGING_INFO)
330 static void dbxout_source_line
PARAMS ((unsigned int, const char *));
331 static void dbxout_source_file
PARAMS ((FILE *, const char *));
332 static void dbxout_function_end
PARAMS ((void));
333 static void dbxout_begin_function
PARAMS ((tree
));
334 static void dbxout_begin_block
PARAMS ((unsigned, unsigned));
335 static void dbxout_end_block
PARAMS ((unsigned, unsigned));
336 static void dbxout_function_decl
PARAMS ((tree
));
338 const struct gcc_debug_hooks dbx_debug_hooks
=
342 debug_nothing_int_charstar
,
343 debug_nothing_int_charstar
,
344 dbxout_start_source_file
,
345 dbxout_end_source_file
,
348 debug_true_tree
, /* ignore_block */
349 dbxout_source_line
, /* source_line */
350 dbxout_source_line
, /* begin_prologue: just output line info */
351 debug_nothing_int_charstar
, /* end_prologue */
352 debug_nothing_int_charstar
, /* end_epilogue */
353 #ifdef DBX_FUNCTION_FIRST
354 dbxout_begin_function
,
356 debug_nothing_tree
, /* begin_function */
358 debug_nothing_int
, /* end_function */
359 dbxout_function_decl
,
360 dbxout_global_decl
, /* global_decl */
361 debug_nothing_tree
, /* deferred_inline_function */
362 debug_nothing_tree
, /* outlining_inline_function */
363 debug_nothing_rtx
, /* label */
364 dbxout_handle_pch
/* handle_pch */
366 #endif /* DBX_DEBUGGING_INFO */
368 #if defined (XCOFF_DEBUGGING_INFO)
369 const struct gcc_debug_hooks xcoff_debug_hooks
=
373 debug_nothing_int_charstar
,
374 debug_nothing_int_charstar
,
375 dbxout_start_source_file
,
376 dbxout_end_source_file
,
377 xcoffout_begin_block
,
379 debug_true_tree
, /* ignore_block */
380 xcoffout_source_line
,
381 xcoffout_begin_prologue
, /* begin_prologue */
382 debug_nothing_int_charstar
, /* end_prologue */
383 xcoffout_end_epilogue
,
384 debug_nothing_tree
, /* begin_function */
385 xcoffout_end_function
,
386 debug_nothing_tree
, /* function_decl */
387 dbxout_global_decl
, /* global_decl */
388 debug_nothing_tree
, /* deferred_inline_function */
389 debug_nothing_tree
, /* outlining_inline_function */
390 debug_nothing_rtx
, /* label */
391 dbxout_handle_pch
/* handle_pch */
393 #endif /* XCOFF_DEBUGGING_INFO */
395 #if defined (DBX_DEBUGGING_INFO)
397 dbxout_function_end ()
399 char lscope_label_name
[100];
400 /* Convert Ltext into the appropriate format for local labels in case
401 the system doesn't insert underscores in front of user generated
403 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
404 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
407 /* By convention, GCC will mark the end of a function with an N_FUN
408 symbol and an empty string. */
409 #ifdef DBX_OUTPUT_NFUN
410 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
412 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
413 assemble_name (asmfile
, lscope_label_name
);
415 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
416 fprintf (asmfile
, "\n");
419 #endif /* DBX_DEBUGGING_INFO */
421 /* At the beginning of compilation, start writing the symbol table.
422 Initialize `typevec' and output the standard data types of C. */
425 dbxout_init (input_file_name
)
426 const char *input_file_name
;
428 char ltext_label_name
[100];
429 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
431 asmfile
= asm_out_file
;
434 typevec
= (struct typeinfo
*) ggc_calloc (typevec_len
, sizeof typevec
[0]);
436 /* Convert Ltext into the appropriate format for local labels in case
437 the system doesn't insert underscores in front of user generated
439 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
441 /* Put the current working directory in an N_SO symbol. */
442 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
443 but GDB always does. */
444 if (use_gnu_debug_info_extensions
)
447 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
448 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
451 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
452 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
453 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
454 fprintf (asmfile
, "%s", ASM_STABS_OP
);
455 output_quoted_string (asmfile
, cwd
);
456 fprintf (asmfile
, ",%d,0,0,", N_SO
);
457 assemble_name (asmfile
, ltext_label_name
);
458 fputc ('\n', asmfile
);
459 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
463 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
464 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
465 would give us an N_SOL, and we want an N_SO. */
466 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
467 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
468 /* We include outputting `Ltext:' here,
469 because that gives you a way to override it. */
470 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
471 fprintf (asmfile
, "%s", ASM_STABS_OP
);
472 output_quoted_string (asmfile
, input_file_name
);
473 fprintf (asmfile
, ",%d,0,0,", N_SO
);
474 assemble_name (asmfile
, ltext_label_name
);
475 fputc ('\n', asmfile
);
477 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
478 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
480 #ifdef DBX_OUTPUT_GCC_MARKER
481 DBX_OUTPUT_GCC_MARKER (asmfile
);
483 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
484 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
485 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
488 base_input_file
= lastfile
= input_file_name
;
490 next_type_number
= 1;
493 current_file
= (struct dbx_file
*) ggc_alloc (sizeof *current_file
);
494 current_file
->next
= NULL
;
495 current_file
->file_number
= 0;
496 current_file
->next_type_number
= 1;
497 next_file_number
= 1;
500 /* Make sure that types `int' and `char' have numbers 1 and 2.
501 Definitions of other integer types will refer to those numbers.
502 (Actually it should no longer matter what their numbers are.
503 Also, if any types with tags have been defined, dbxout_symbol
504 will output them first, so the numbers won't be 1 and 2. That
505 happens in C++. So it's a good thing it should no longer matter). */
507 #ifdef DBX_OUTPUT_STANDARD_TYPES
508 DBX_OUTPUT_STANDARD_TYPES (syms
);
510 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
511 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
514 /* Get all permanent types that have typedef names,
515 and output them all, except for those already output. */
517 dbxout_typedefs (syms
);
520 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
521 in the reverse order from that which is found in SYMS. */
524 dbxout_typedefs (syms
)
529 dbxout_typedefs (TREE_CHAIN (syms
));
530 if (TREE_CODE (syms
) == TYPE_DECL
)
532 tree type
= TREE_TYPE (syms
);
534 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
535 && COMPLETE_TYPE_P (type
)
536 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
537 dbxout_symbol (TYPE_NAME (type
), 0);
542 /* Change to reading from a new source file. Generate a N_BINCL stab. */
545 dbxout_start_source_file (line
, filename
)
546 unsigned int line ATTRIBUTE_UNUSED
;
547 const char *filename ATTRIBUTE_UNUSED
;
550 struct dbx_file
*n
= (struct dbx_file
*) ggc_alloc (sizeof *n
);
552 n
->next
= current_file
;
553 n
->file_number
= next_file_number
++;
554 n
->next_type_number
= 1;
556 fprintf (asmfile
, "%s", ASM_STABS_OP
);
557 output_quoted_string (asmfile
, filename
);
558 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
562 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
565 dbxout_end_source_file (line
)
566 unsigned int line ATTRIBUTE_UNUSED
;
569 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
570 current_file
= current_file
->next
;
574 /* Handle a few odd cases that occur when trying to make PCH files work. */
577 dbxout_handle_pch (unsigned at_end
)
581 /* When using the PCH, this file will be included, so we need to output
583 dbxout_start_source_file (0, lastfile
);
585 /* The base file when using the PCH won't be the same as
586 the base file when it's being generated. */
591 /* ... and an EINCL. */
592 dbxout_end_source_file (0);
594 /* Deal with cases where 'lastfile' was never actually changed. */
595 lastfile_is_base
= lastfile
== NULL
;
599 #if defined (DBX_DEBUGGING_INFO)
600 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
603 dbxout_source_file (file
, filename
)
605 const char *filename
;
607 if (lastfile
== 0 && lastfile_is_base
)
609 lastfile
= base_input_file
;
610 lastfile_is_base
= 0;
613 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
615 #ifdef DBX_OUTPUT_SOURCE_FILENAME
616 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
618 char ltext_label_name
[100];
620 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
621 source_label_number
);
622 fprintf (file
, "%s", ASM_STABS_OP
);
623 output_quoted_string (file
, filename
);
624 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
625 assemble_name (asmfile
, ltext_label_name
);
626 fputc ('\n', asmfile
);
627 if (current_function_decl
!= NULL_TREE
628 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
629 ; /* Don't change section amid function. */
632 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
633 source_label_number
++;
639 /* Output a line number symbol entry for source file FILENAME and line
643 dbxout_source_line (lineno
, filename
)
645 const char *filename
;
647 dbxout_source_file (asmfile
, filename
);
649 #ifdef ASM_OUTPUT_SOURCE_LINE
650 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
);
652 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
656 /* Describe the beginning of an internal block within a function. */
659 dbxout_begin_block (line
, n
)
660 unsigned int line ATTRIBUTE_UNUSED
;
663 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
666 /* Describe the end line-number of an internal block within a function. */
669 dbxout_end_block (line
, n
)
670 unsigned int line ATTRIBUTE_UNUSED
;
673 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
676 /* Output dbx data for a function definition.
677 This includes a definition of the function name itself (a symbol),
678 definitions of the parameters (locating them in the parameter list)
679 and then output the block that makes up the function's body
680 (including all the auto variables of the function). */
683 dbxout_function_decl (decl
)
686 #ifndef DBX_FUNCTION_FIRST
687 dbxout_begin_function (decl
);
689 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
690 #ifdef DBX_OUTPUT_FUNCTION_END
691 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
693 if (use_gnu_debug_info_extensions
694 #if defined(NO_DBX_FUNCTION_END)
695 && ! NO_DBX_FUNCTION_END
697 && targetm
.have_named_sections
)
698 dbxout_function_end ();
701 #endif /* DBX_DEBUGGING_INFO */
703 /* Debug information for a global DECL. Called from toplev.c after
704 compilation proper has finished. */
706 dbxout_global_decl (decl
)
709 if (TREE_CODE (decl
) == VAR_DECL
710 && ! DECL_EXTERNAL (decl
)
711 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
712 dbxout_symbol (decl
, 0);
715 /* At the end of compilation, finish writing the symbol table.
716 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
720 dbxout_finish (filename
)
721 const char *filename ATTRIBUTE_UNUSED
;
723 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
724 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
725 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
728 /* Output floating point type values used by the 'R' stab letter.
729 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
731 There are only 3 real/complex types defined, and we need 7/6.
732 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
733 complex type. Since we have the type size anyways, we don't really need
734 to distinguish between different FP types, we only need to distinguish
735 between float and complex. This works fine with gdb.
737 We only use this for complex types, to avoid breaking backwards
738 compatibility for real types. complex types aren't in ISO C90, so it is
739 OK if old debuggers don't understand the debug info we emit for them. */
741 /* ??? These are supposed to be IEEE types, but we don't check for that.
742 We could perhaps add additional numbers for non-IEEE types if we need
746 dbxout_fptype_value (type
)
750 enum machine_mode mode
= TYPE_MODE (type
);
752 if (TREE_CODE (type
) == REAL_TYPE
)
756 else if (mode
== DFmode
)
758 else if (mode
== TFmode
|| mode
== XFmode
)
761 /* Use NF_SINGLE as a generic real type for other sizes. */
764 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
768 else if (mode
== DCmode
)
770 else if (mode
== TCmode
|| mode
== XCmode
)
773 /* Use NF_COMPLEX as a generic complex type for other sizes. */
779 putc (value
, asmfile
);
783 /* Output the index of a type. */
786 dbxout_type_index (type
)
789 #ifndef DBX_USE_BINCL
790 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
793 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
794 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
799 #if DBX_CONTIN_LENGTH > 0
800 /* Continue a symbol-description that gets too big.
801 End one symbol table entry with a double-backslash
802 and start a new one, eventually producing something like
803 .stabs "start......\\",code,0,value
804 .stabs "...rest",code,0,value */
809 #ifdef DBX_CONTIN_CHAR
810 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
812 fprintf (asmfile
, "\\\\");
814 dbxout_finish_symbol (NULL_TREE
);
815 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
816 current_sym_nchars
= 0;
818 #endif /* DBX_CONTIN_LENGTH > 0 */
820 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
821 This must be a separate function because anonymous unions require
825 dbxout_type_fields (type
)
830 /* Output the name, type, position (in bits), size (in bits) of each
831 field that we can support. */
832 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
834 /* Omit here local type decls until we know how to support them. */
835 if (TREE_CODE (tem
) == TYPE_DECL
836 /* Omit fields whose position or size are variable or too large to
838 || (TREE_CODE (tem
) == FIELD_DECL
839 && (! host_integerp (bit_position (tem
), 0)
841 || ! host_integerp (DECL_SIZE (tem
), 1)))
842 /* Omit here the nameless fields that are used to skip bits. */
843 || DECL_IGNORED_P (tem
))
846 else if (TREE_CODE (tem
) != CONST_DECL
)
848 /* Continue the line if necessary,
849 but not before the first field. */
850 if (tem
!= TYPE_FIELDS (type
))
855 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
856 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
860 fprintf (asmfile
, ":");
864 if (use_gnu_debug_info_extensions
865 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
866 || TREE_CODE (tem
) != FIELD_DECL
))
868 have_used_extensions
= 1;
870 putc ((TREE_PRIVATE (tem
) ? '0'
871 : TREE_PROTECTED (tem
) ? '1' : '2'),
876 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
877 && DECL_BIT_FIELD_TYPE (tem
))
878 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
880 if (TREE_CODE (tem
) == VAR_DECL
)
882 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
884 tree name
= DECL_ASSEMBLER_NAME (tem
);
886 have_used_extensions
= 1;
887 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
888 CHARS (IDENTIFIER_LENGTH (name
) + 2);
892 /* If TEM is non-static, GDB won't understand it. */
893 fprintf (asmfile
, ",0,0;");
900 print_wide_int (int_bit_position (tem
));
902 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
910 /* Subroutine of `dbxout_type_methods'. Output debug info about the
911 method described DECL. DEBUG_NAME is an encoding of the method's
912 type signature. ??? We may be able to do without DEBUG_NAME altogether
916 dbxout_type_method_1 (decl
, debug_name
)
918 const char *debug_name
;
922 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
924 else /* it's a METHOD_TYPE. */
926 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
927 /* A for normal functions.
928 B for `const' member functions.
929 C for `volatile' member functions.
930 D for `const volatile' member functions. */
931 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
933 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
936 if (DECL_VINDEX (decl
))
942 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
943 TREE_PRIVATE (decl
) ? '0'
944 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
945 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
946 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
948 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
950 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
953 dbxout_type (DECL_CONTEXT (decl
), 0);
954 fprintf (asmfile
, ";");
959 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
963 dbxout_type_methods (type
)
966 /* C++: put out the method names and their parameter lists */
967 tree methods
= TYPE_METHODS (type
);
971 char formatted_type_identifier_length
[16];
972 int type_identifier_length
;
974 if (methods
== NULL_TREE
)
977 type_encoding
= DECL_NAME (TYPE_NAME (type
));
980 /* C++: Template classes break some assumptions made by this code about
981 the class names, constructor names, and encodings for assembler
982 label names. For now, disable output of dbx info for them. */
984 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
985 /* This should use index. (mrs) */
986 while (*ptr
&& *ptr
!= '<') ptr
++;
997 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
999 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1001 if (TREE_CODE (methods
) != TREE_VEC
)
1003 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1004 fndecl
= TREE_VEC_ELT (methods
, 0);
1006 fndecl
= TREE_VEC_ELT (methods
, 1);
1010 int need_prefix
= 1;
1012 /* Group together all the methods for the same operation.
1013 These differ in the types of the arguments. */
1014 for (last
= NULL_TREE
;
1015 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1016 fndecl
= TREE_CHAIN (fndecl
))
1017 /* Output the name of the field (after overloading), as
1018 well as the name of the field before overloading, along
1019 with its parameter list */
1021 /* This is the "mangled" name of the method.
1022 It encodes the argument types. */
1023 const char *debug_name
;
1025 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1026 include TEMPLATE_DECLs.) The debugger doesn't know what
1027 to do with such entities anyhow. */
1028 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1031 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1037 /* Also ignore abstract methods; those are only interesting to
1038 the DWARF backends. */
1039 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1042 /* Redundantly output the plain name, since that's what gdb
1046 tree name
= DECL_NAME (fndecl
);
1047 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1048 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1052 dbxout_type (TREE_TYPE (fndecl
), 0);
1054 dbxout_type_method_1 (fndecl
, debug_name
);
1058 putc (';', asmfile
);
1064 /* Emit a "range" type specification, which has the form:
1065 "r<index type>;<lower bound>;<upper bound>;".
1066 TYPE is an INTEGER_TYPE. */
1069 dbxout_range_type (type
)
1072 fprintf (asmfile
, "r");
1073 if (TREE_TYPE (type
))
1074 dbxout_type (TREE_TYPE (type
), 0);
1075 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1076 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1079 /* Traditionally, we made sure 'int' was type 1, and builtin types
1080 were defined to be sub-ranges of int. Unfortunately, this
1081 does not allow us to distinguish true sub-ranges from integer
1082 types. So, instead we define integer (non-sub-range) types as
1083 sub-ranges of themselves. This matters for Chill. If this isn't
1084 a subrange type, then we want to define it in terms of itself.
1085 However, in C, this may be an anonymous integer type, and we don't
1086 want to emit debug info referring to it. Just calling
1087 dbxout_type_index won't work anyways, because the type hasn't been
1088 defined yet. We make this work for both cases by checked to see
1089 whether this is a defined type, referring to it if it is, and using
1091 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1092 dbxout_type_index (type
);
1094 dbxout_type_index (integer_type_node
);
1097 if (TYPE_MIN_VALUE (type
) != 0
1098 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1100 putc (';', asmfile
);
1102 if (print_int_cst_bounds_in_octal_p (type
))
1103 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1105 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1109 fprintf (asmfile
, ";0");
1113 if (TYPE_MAX_VALUE (type
) != 0
1114 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1116 putc (';', asmfile
);
1118 if (print_int_cst_bounds_in_octal_p (type
))
1119 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1121 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1122 putc (';', asmfile
);
1127 fprintf (asmfile
, ";-1;");
1132 /* Output a reference to a type. If the type has not yet been
1133 described in the dbx output, output its definition now.
1134 For a type already defined, just refer to its definition
1135 using the type number.
1137 If FULL is nonzero, and the type has been described only with
1138 a forward-reference, output the definition now.
1139 If FULL is zero in this case, just refer to the forward-reference
1140 using the number previously allocated. */
1143 dbxout_type (type
, full
)
1149 static int anonymous_type_number
= 0;
1151 if (TREE_CODE (type
) == VECTOR_TYPE
)
1152 /* The frontend feeds us a representation for the vector as a struct
1153 containing an array. Pull out the array type. */
1154 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1156 /* If there was an input error and we don't really have a type,
1157 avoid crashing and write something that is at least valid
1158 by assuming `int'. */
1159 if (type
== error_mark_node
)
1160 type
= integer_type_node
;
1163 if (TYPE_NAME (type
)
1164 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1165 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1169 /* Try to find the "main variant" with the same name. */
1170 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1171 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1172 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1174 main_variant
= TYPE_MAIN_VARIANT (type
);
1176 /* If we are not using extensions, stabs does not distinguish const and
1177 volatile, so there is no need to make them separate types. */
1178 if (!use_gnu_debug_info_extensions
)
1179 type
= main_variant
;
1181 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1183 /* Type has no dbx number assigned. Assign next available number. */
1184 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1186 /* Make sure type vector is long enough to record about this type. */
1188 if (next_type_number
== typevec_len
)
1191 = (struct typeinfo
*) ggc_realloc (typevec
,
1193 * sizeof typevec
[0]));
1194 memset ((char *) (typevec
+ typevec_len
), 0,
1195 typevec_len
* sizeof typevec
[0]);
1199 #ifdef DBX_USE_BINCL
1200 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1201 = current_file
->file_number
;
1202 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1203 = current_file
->next_type_number
++;
1207 /* Output the number of this type, to refer to it. */
1208 dbxout_type_index (type
);
1210 #ifdef DBX_TYPE_DEFINED
1211 if (DBX_TYPE_DEFINED (type
))
1215 /* If this type's definition has been output or is now being output,
1218 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1223 /* If we have already had a cross reference,
1224 and either that's all we want or that's the best we could do,
1225 don't repeat the cross reference.
1226 Sun dbx crashes if we do. */
1227 if (! full
|| !COMPLETE_TYPE_P (type
)
1228 /* No way in DBX fmt to describe a variable size. */
1229 || ! host_integerp (TYPE_SIZE (type
), 1))
1237 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1238 leave the type-number completely undefined rather than output
1239 a cross-reference. If we have already used GNU debug info extensions,
1240 then it is OK to output a cross reference. This is necessary to get
1241 proper C++ debug output. */
1242 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1243 || TREE_CODE (type
) == QUAL_UNION_TYPE
1244 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1245 && ! use_gnu_debug_info_extensions
)
1246 /* We must use the same test here as we use twice below when deciding
1247 whether to emit a cross-reference. */
1248 if ((TYPE_NAME (type
) != 0
1249 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1250 && DECL_IGNORED_P (TYPE_NAME (type
)))
1252 || !COMPLETE_TYPE_P (type
)
1253 /* No way in DBX fmt to describe a variable size. */
1254 || ! host_integerp (TYPE_SIZE (type
), 1))
1256 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1261 /* Output a definition now. */
1263 fprintf (asmfile
, "=");
1266 /* Mark it as defined, so that if it is self-referent
1267 we will not get into an infinite recursion of definitions. */
1269 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1271 /* If this type is a variant of some other, hand off. Types with
1272 different names are usefully distinguished. We only distinguish
1273 cv-qualified types if we're using extensions. */
1274 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1276 putc ('k', asmfile
);
1278 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1281 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1283 putc ('B', asmfile
);
1285 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1288 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1290 /* 'type' is a typedef; output the type it refers to. */
1291 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1294 /* else continue. */
1296 switch (TREE_CODE (type
))
1300 /* For a void type, just define it as itself; ie, "5=5".
1301 This makes us consider it defined
1302 without saying what it is. The debugger will make it
1303 a void type when the reference is seen, and nothing will
1304 ever override that default. */
1305 dbxout_type_index (type
);
1309 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1311 /* Output the type `char' as a subrange of itself!
1312 I don't understand this definition, just copied it
1313 from the output of pcc.
1314 This used to use `r2' explicitly and we used to
1315 take care to make sure that `char' was type number 2. */
1316 fprintf (asmfile
, "r");
1318 dbxout_type_index (type
);
1319 fprintf (asmfile
, ";0;127;");
1323 /* If this is a subtype of another integer type, always prefer to
1324 write it as a subtype. */
1325 else if (TREE_TYPE (type
) != 0
1326 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1328 /* If the size is non-standard, say what it is if we can use
1331 if (use_gnu_debug_info_extensions
1332 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1334 have_used_extensions
= 1;
1335 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1339 dbxout_range_type (type
);
1344 /* If the size is non-standard, say what it is if we can use
1347 if (use_gnu_debug_info_extensions
1348 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1350 have_used_extensions
= 1;
1351 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1355 if (print_int_cst_bounds_in_octal_p (type
))
1357 fprintf (asmfile
, "r");
1360 /* If this type derives from another type, output type index of
1361 parent type. This is particularly important when parent type
1362 is an enumerated type, because not generating the parent type
1363 index would transform the definition of this enumerated type
1364 into a plain unsigned type. */
1365 if (TREE_TYPE (type
) != 0)
1366 dbxout_type_index (TREE_TYPE (type
));
1368 dbxout_type_index (type
);
1370 fprintf (asmfile
, ";");
1372 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1373 fprintf (asmfile
, ";");
1375 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1376 fprintf (asmfile
, ";");
1381 /* Output other integer types as subranges of `int'. */
1382 dbxout_range_type (type
);
1388 /* This used to say `r1' and we used to take care
1389 to make sure that `int' was type number 1. */
1390 fprintf (asmfile
, "r");
1392 dbxout_type_index (integer_type_node
);
1393 putc (';', asmfile
);
1395 print_wide_int (int_size_in_bytes (type
));
1396 fputs (";0;", asmfile
);
1401 if (use_gnu_debug_info_extensions
)
1403 have_used_extensions
= 1;
1404 fputs ("@s", asmfile
);
1406 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1407 fputs (";-20;", asmfile
);
1412 /* Output the type `char' as a subrange of itself.
1413 That is what pcc seems to do. */
1414 fprintf (asmfile
, "r");
1416 dbxout_type_index (char_type_node
);
1417 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1423 if (use_gnu_debug_info_extensions
)
1425 have_used_extensions
= 1;
1426 fputs ("@s", asmfile
);
1428 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1429 fputs (";-16;", asmfile
);
1432 else /* Define as enumeral type (False, True) */
1434 fprintf (asmfile
, "eFalse:0,True:1,;");
1440 putc ('d', asmfile
);
1442 dbxout_type (TREE_TYPE (type
), 0);
1446 /* Differs from the REAL_TYPE by its new data type number */
1448 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1450 putc ('R', asmfile
);
1452 dbxout_fptype_value (type
);
1453 putc (';', asmfile
);
1455 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1456 fputs (";0;", asmfile
);
1461 /* Output a complex integer type as a structure,
1462 pending some other way to do it. */
1463 putc ('s', asmfile
);
1465 print_wide_int (int_size_in_bytes (type
));
1466 fprintf (asmfile
, "real:");
1469 dbxout_type (TREE_TYPE (type
), 0);
1470 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1472 fprintf (asmfile
, "imag:");
1474 dbxout_type (TREE_TYPE (type
), 0);
1475 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1476 TYPE_PRECISION (TREE_TYPE (type
)));
1482 if (use_gnu_debug_info_extensions
)
1484 have_used_extensions
= 1;
1485 fputs ("@s", asmfile
);
1487 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1488 putc (';', asmfile
);
1491 /* Check if a bitstring type, which in Chill is
1492 different from a [power]set. */
1493 if (TYPE_STRING_FLAG (type
))
1495 fprintf (asmfile
, "@S;");
1499 putc ('S', asmfile
);
1501 dbxout_type (TYPE_DOMAIN (type
), 0);
1505 /* Make arrays of packed bits look like bitstrings for chill. */
1506 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1508 have_used_extensions
= 1;
1509 fputs ("@s", asmfile
);
1511 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1512 fprintf (asmfile
, ";@S;S");
1514 dbxout_type (TYPE_DOMAIN (type
), 0);
1518 /* Output "a" followed by a range type definition
1519 for the index type of the array
1520 followed by a reference to the target-type.
1521 ar1;0;N;M for a C array of type M and size N+1. */
1522 /* Check if a character string type, which in Chill is
1523 different from an array of characters. */
1524 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1526 have_used_extensions
= 1;
1527 fprintf (asmfile
, "@S;");
1530 tem
= TYPE_DOMAIN (type
);
1533 fprintf (asmfile
, "ar");
1535 dbxout_type_index (integer_type_node
);
1536 fprintf (asmfile
, ";0;-1;");
1541 fprintf (asmfile
, "a");
1543 dbxout_range_type (tem
);
1546 dbxout_type (TREE_TYPE (type
), 0);
1551 case QUAL_UNION_TYPE
:
1553 int i
, n_baseclasses
= 0;
1555 if (TYPE_BINFO (type
) != 0
1556 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1557 && TYPE_BINFO_BASETYPES (type
) != 0)
1558 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1560 /* Output a structure type. We must use the same test here as we
1561 use in the DBX_NO_XREFS case above. */
1562 if ((TYPE_NAME (type
) != 0
1563 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1564 && DECL_IGNORED_P (TYPE_NAME (type
)))
1566 || !COMPLETE_TYPE_P (type
)
1567 /* No way in DBX fmt to describe a variable size. */
1568 || ! host_integerp (TYPE_SIZE (type
), 1))
1570 /* If the type is just a cross reference, output one
1571 and mark the type as partially described.
1572 If it later becomes defined, we will output
1573 its real definition.
1574 If the type has a name, don't nest its definition within
1575 another type's definition; instead, output an xref
1576 and let the definition come when the name is defined. */
1577 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1579 #if 0 /* This assertion is legitimately false in C++. */
1580 /* We shouldn't be outputting a reference to a type before its
1581 definition unless the type has a tag name.
1582 A typedef name without a tag name should be impossible. */
1583 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1586 if (TYPE_NAME (type
) != 0)
1587 dbxout_type_name (type
);
1590 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1594 fprintf (asmfile
, ":");
1596 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1600 /* Identify record or union, and print its size. */
1601 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1603 print_wide_int (int_size_in_bytes (type
));
1605 if (use_gnu_debug_info_extensions
)
1609 have_used_extensions
= 1;
1610 fprintf (asmfile
, "!%d,", n_baseclasses
);
1614 for (i
= 0; i
< n_baseclasses
; i
++)
1616 tree binfo
= TYPE_BINFO (type
);
1617 tree child
= BINFO_BASETYPE (binfo
, i
);
1618 tree access
= (BINFO_BASEACCESSES (binfo
)
1619 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1621 if (use_gnu_debug_info_extensions
)
1623 have_used_extensions
= 1;
1624 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1625 putc (access
== access_public_node
? '2' : '0', asmfile
);
1627 if (TREE_VIA_VIRTUAL (child
)
1628 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1629 /* For a virtual base, print the (negative) offset within
1630 the vtable where we must look to find the necessary
1632 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1635 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1637 putc (',', asmfile
);
1639 dbxout_type (BINFO_TYPE (child
), 0);
1640 putc (';', asmfile
);
1645 /* Print out the base class information with fields
1646 which have the same names at the types they hold. */
1647 dbxout_type_name (BINFO_TYPE (child
));
1648 putc (':', asmfile
);
1650 dbxout_type (BINFO_TYPE (child
), full
);
1651 putc (',', asmfile
);
1653 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1655 putc (',', asmfile
);
1657 print_wide_int (tree_low_cst (DECL_SIZE
1659 (BINFO_TYPE (child
))),
1662 putc (';', asmfile
);
1668 /* Write out the field declarations. */
1669 dbxout_type_fields (type
);
1670 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1672 have_used_extensions
= 1;
1673 dbxout_type_methods (type
);
1676 putc (';', asmfile
);
1679 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1680 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1681 && TYPE_VFIELD (type
))
1683 have_used_extensions
= 1;
1685 /* Tell GDB+ that it may keep reading. */
1686 putc ('~', asmfile
);
1689 /* We need to write out info about what field this class
1690 uses as its "main" vtable pointer field, because if this
1691 field is inherited from a base class, GDB cannot necessarily
1692 figure out which field it's using in time. */
1693 if (TYPE_VFIELD (type
))
1695 putc ('%', asmfile
);
1697 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1700 putc (';', asmfile
);
1706 /* We must use the same test here as we use in the DBX_NO_XREFS case
1707 above. We simplify it a bit since an enum will never have a variable
1709 if ((TYPE_NAME (type
) != 0
1710 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1711 && DECL_IGNORED_P (TYPE_NAME (type
)))
1713 || !COMPLETE_TYPE_P (type
))
1715 fprintf (asmfile
, "xe");
1717 dbxout_type_name (type
);
1718 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1719 putc (':', asmfile
);
1723 #ifdef DBX_OUTPUT_ENUM
1724 DBX_OUTPUT_ENUM (asmfile
, type
);
1726 if (use_gnu_debug_info_extensions
1727 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1729 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1733 putc ('e', asmfile
);
1735 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1737 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1738 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1739 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1740 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1741 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1742 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1743 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1745 print_int_cst_octal (TREE_VALUE (tem
));
1747 putc (',', asmfile
);
1749 if (TREE_CHAIN (tem
) != 0)
1753 putc (';', asmfile
);
1759 putc ('*', asmfile
);
1761 dbxout_type (TREE_TYPE (type
), 0);
1765 if (use_gnu_debug_info_extensions
)
1767 have_used_extensions
= 1;
1768 putc ('#', asmfile
);
1771 /* Write the argument types out longhand. */
1772 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1773 putc (',', asmfile
);
1775 dbxout_type (TREE_TYPE (type
), 0);
1776 dbxout_args (TYPE_ARG_TYPES (type
));
1777 putc (';', asmfile
);
1781 /* Treat it as a function type. */
1782 dbxout_type (TREE_TYPE (type
), 0);
1786 if (use_gnu_debug_info_extensions
)
1788 have_used_extensions
= 1;
1789 putc ('@', asmfile
);
1791 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1792 putc (',', asmfile
);
1794 dbxout_type (TREE_TYPE (type
), 0);
1797 /* Should print as an int, because it is really just an offset. */
1798 dbxout_type (integer_type_node
, 0);
1801 case REFERENCE_TYPE
:
1802 if (use_gnu_debug_info_extensions
)
1803 have_used_extensions
= 1;
1804 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1806 dbxout_type (TREE_TYPE (type
), 0);
1810 putc ('f', asmfile
);
1812 dbxout_type (TREE_TYPE (type
), 0);
1820 /* Return non-zero if the given type represents an integer whose bounds
1821 should be printed in octal format. */
1824 print_int_cst_bounds_in_octal_p (type
)
1827 /* If we can use GDB extensions and the size is wider than a long
1828 (the size used by GDB to read them) or we may have trouble writing
1829 the bounds the usual way, write them in octal. Note the test is for
1830 the *target's* size of "long", not that of the host. The host test
1831 is just to make sure we can write it out in case the host wide int
1832 is narrower than the target "long".
1834 For unsigned types, we use octal if they are the same size or larger.
1835 This is because we print the bounds as signed decimal, and hence they
1836 can't span same size unsigned types. */
1838 if (use_gnu_debug_info_extensions
1839 && TYPE_MIN_VALUE (type
) != 0
1840 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1841 && TYPE_MAX_VALUE (type
) != 0
1842 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1843 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1844 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1845 && TREE_UNSIGNED (type
))
1846 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1847 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1848 && TREE_UNSIGNED (type
))))
1854 /* Print the value of integer constant C, in octal,
1855 handling double precision. */
1858 print_int_cst_octal (c
)
1861 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1862 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1863 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1864 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1866 /* GDB wants constants with no extra leading "1" bits, so
1867 we need to remove any sign-extension that might be
1869 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1871 else if (width
> HOST_BITS_PER_WIDE_INT
)
1872 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1873 else if (width
== HOST_BITS_PER_WIDE_INT
)
1876 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1878 fprintf (asmfile
, "0");
1883 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1884 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1888 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1889 unsigned HOST_WIDE_INT middle
1890 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1891 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1892 unsigned HOST_WIDE_INT end
1893 = low
& (((unsigned HOST_WIDE_INT
) 1
1894 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1897 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1899 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1904 print_octal (value
, digits
)
1905 unsigned HOST_WIDE_INT value
;
1910 for (i
= digits
- 1; i
>= 0; i
--)
1911 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1916 /* Output C in decimal while adjusting the number of digits written. */
1924 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1935 /* Output the name of type TYPE, with no punctuation.
1936 Such names can be set up either by typedef declarations
1937 or by struct, enum and union tags. */
1940 dbxout_type_name (type
)
1944 if (TYPE_NAME (type
) == 0)
1946 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1948 t
= TYPE_NAME (type
);
1950 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1952 t
= DECL_NAME (TYPE_NAME (type
));
1957 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1958 CHARS (IDENTIFIER_LENGTH (t
));
1961 /* Output leading leading struct or class names needed for qualifying
1962 type whose scope is limited to a struct or class. */
1965 dbxout_class_name_qualifiers (decl
)
1968 tree context
= decl_type_context (decl
);
1970 if (context
!= NULL_TREE
1971 && TREE_CODE(context
) == RECORD_TYPE
1972 && TYPE_NAME (context
) != 0
1973 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
1974 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
1976 tree name
= TYPE_NAME (context
);
1978 if (TREE_CODE (name
) == TYPE_DECL
)
1980 dbxout_class_name_qualifiers (name
);
1981 name
= DECL_NAME (name
);
1983 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1984 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1988 /* Output a .stabs for the symbol defined by DECL,
1989 which must be a ..._DECL node in the normal namespace.
1990 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1991 LOCAL is nonzero if the scope is less than the entire file.
1992 Return 1 if a stabs might have been emitted. */
1995 dbxout_symbol (decl
, local
)
1997 int local ATTRIBUTE_UNUSED
;
1999 tree type
= TREE_TYPE (decl
);
2000 tree context
= NULL_TREE
;
2003 /* Cast avoids warning in old compilers. */
2004 current_sym_code
= (STAB_CODE_TYPE
) 0;
2005 current_sym_value
= 0;
2006 current_sym_addr
= 0;
2008 /* Ignore nameless syms, but don't ignore type tags. */
2010 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2011 || DECL_IGNORED_P (decl
))
2014 dbxout_prepare_symbol (decl
);
2016 /* The output will always start with the symbol name,
2017 so always count that in the length-output-so-far. */
2019 if (DECL_NAME (decl
) != 0)
2020 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2022 switch (TREE_CODE (decl
))
2025 /* Enum values are defined by defining the enum type. */
2029 if (DECL_RTL (decl
) == 0)
2031 if (DECL_EXTERNAL (decl
))
2033 /* Don't mention a nested function under its parent. */
2034 context
= decl_function_context (decl
);
2035 if (context
== current_function_decl
)
2037 if (GET_CODE (DECL_RTL (decl
)) != MEM
2038 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2042 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2043 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2044 TREE_PUBLIC (decl
) ? 'F' : 'f');
2047 current_sym_code
= N_FUN
;
2048 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2050 if (TREE_TYPE (type
))
2051 dbxout_type (TREE_TYPE (type
), 0);
2053 dbxout_type (void_type_node
, 0);
2055 /* For a nested function, when that function is compiled,
2056 mention the containing function name
2057 as well as (since dbx wants it) our own assembler-name. */
2059 fprintf (asmfile
, ",%s,%s",
2060 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2061 IDENTIFIER_POINTER (DECL_NAME (context
)));
2063 dbxout_finish_symbol (decl
);
2068 /* This seems all wrong. Outputting most kinds of types gives no name
2069 at all. A true definition gives no name; a cross-ref for a
2070 structure can give the tag name, but not a type name.
2071 It seems that no typedef name is defined by outputting a type. */
2073 /* If this typedef name was defined by outputting the type,
2074 don't duplicate it. */
2075 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
2076 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
2079 /* Don't output the same typedef twice.
2080 And don't output what language-specific stuff doesn't want output. */
2081 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2090 if (DECL_NAME (decl
))
2092 /* Nonzero means we must output a tag as well as a typedef. */
2095 /* Handle the case of a C++ structure or union
2096 where the TYPE_NAME is a TYPE_DECL
2097 which gives both a typedef name and a tag. */
2098 /* dbx requires the tag first and the typedef second. */
2099 if ((TREE_CODE (type
) == RECORD_TYPE
2100 || TREE_CODE (type
) == UNION_TYPE
2101 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2102 && TYPE_NAME (type
) == decl
2103 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2104 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2105 /* Distinguish the implicit typedefs of C++
2106 from explicit ones that might be found in C. */
2107 && DECL_ARTIFICIAL (decl
)
2108 /* Do not generate a tag for records of variable size,
2109 since this type can not be properly described in the
2110 DBX format, and it confuses some tools such as objdump. */
2111 && host_integerp (TYPE_SIZE (type
), 1))
2113 tree name
= TYPE_NAME (type
);
2114 if (TREE_CODE (name
) == TYPE_DECL
)
2115 name
= DECL_NAME (name
);
2117 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2118 current_sym_value
= 0;
2119 current_sym_addr
= 0;
2120 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2122 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2123 IDENTIFIER_POINTER (name
));
2124 dbxout_type (type
, 1);
2125 dbxout_finish_symbol (NULL_TREE
);
2128 /* Output .stabs (or whatever) and leading double quote. */
2129 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2131 if (use_gnu_debug_info_extensions
)
2133 /* Output leading class/struct qualifiers. */
2134 dbxout_class_name_qualifiers (decl
);
2137 /* Output typedef name. */
2138 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2140 /* Short cut way to output a tag also. */
2141 if ((TREE_CODE (type
) == RECORD_TYPE
2142 || TREE_CODE (type
) == UNION_TYPE
2143 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2144 && TYPE_NAME (type
) == decl
2145 /* Distinguish the implicit typedefs of C++
2146 from explicit ones that might be found in C. */
2147 && DECL_ARTIFICIAL (decl
))
2149 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2151 putc ('T', asmfile
);
2152 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2154 #if 0 /* Now we generate the tag for this case up above. */
2160 putc ('t', asmfile
);
2161 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2163 dbxout_type (type
, 1);
2164 dbxout_finish_symbol (decl
);
2168 /* Don't output a tag if this is an incomplete type. This prevents
2169 the sun4 Sun OS 4.x dbx from crashing. */
2171 if (tag_needed
&& TYPE_NAME (type
) != 0
2172 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2173 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2174 && COMPLETE_TYPE_P (type
)
2175 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2177 /* For a TYPE_DECL with no name, but the type has a name,
2179 This is what represents `struct foo' with no typedef. */
2180 /* In C++, the name of a type is the corresponding typedef.
2181 In C, it is an IDENTIFIER_NODE. */
2182 tree name
= TYPE_NAME (type
);
2183 if (TREE_CODE (name
) == TYPE_DECL
)
2184 name
= DECL_NAME (name
);
2186 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2187 current_sym_value
= 0;
2188 current_sym_addr
= 0;
2189 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2191 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2192 IDENTIFIER_POINTER (name
));
2193 dbxout_type (type
, 1);
2194 dbxout_finish_symbol (NULL_TREE
);
2198 /* If an enum type has no name, it cannot be referred to,
2199 but we must output it anyway, since the enumeration constants
2200 can be referred to. */
2201 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2203 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2204 current_sym_value
= 0;
2205 current_sym_addr
= 0;
2206 current_sym_nchars
= 2;
2208 /* Some debuggers fail when given NULL names, so give this a
2209 harmless name of ` '. */
2210 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2211 dbxout_type (type
, 1);
2212 dbxout_finish_symbol (NULL_TREE
);
2215 /* Prevent duplicate output of a typedef. */
2216 TREE_ASM_WRITTEN (decl
) = 1;
2221 /* Parm decls go in their own separate chains
2222 and are output by dbxout_reg_parms and dbxout_parms. */
2226 /* Named return value, treat like a VAR_DECL. */
2228 if (! DECL_RTL_SET_P (decl
))
2230 /* Don't mention a variable that is external.
2231 Let the file that defines it describe it. */
2232 if (DECL_EXTERNAL (decl
))
2235 /* If the variable is really a constant
2236 and not written in memory, inform the debugger. */
2237 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2238 && DECL_INITIAL (decl
) != 0
2239 && host_integerp (DECL_INITIAL (decl
), 0)
2240 && ! TREE_ASM_WRITTEN (decl
)
2241 && (DECL_CONTEXT (decl
) == NULL_TREE
2242 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2244 if (TREE_PUBLIC (decl
) == 0)
2246 /* The sun4 assembler does not grok this. */
2247 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2249 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2250 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2252 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2253 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
2254 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
2256 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2258 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2262 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2264 /* don't know how to do this yet. */
2268 /* else it is something we handle like a normal variable. */
2271 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2272 #ifdef LEAF_REG_REMAP
2273 if (current_function_uses_only_leaf_regs
)
2274 leaf_renumber_regs_insn (DECL_RTL (decl
));
2277 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2286 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2287 Add SUFFIX to its name, if SUFFIX is not 0.
2288 Describe the variable as residing in HOME
2289 (usually HOME is DECL_RTL (DECL), but not always).
2290 Returns 1 if the stab was really emitted. */
2293 dbxout_symbol_location (decl
, type
, suffix
, home
)
2301 /* Don't mention a variable at all
2302 if it was completely optimized into nothingness.
2304 If the decl was from an inline function, then its rtl
2305 is not identically the rtl that was used in this
2306 particular compilation. */
2307 if (GET_CODE (home
) == SUBREG
)
2311 while (GET_CODE (value
) == SUBREG
)
2312 value
= SUBREG_REG (value
);
2313 if (GET_CODE (value
) == REG
)
2315 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2318 home
= alter_subreg (&home
);
2320 if (GET_CODE (home
) == REG
)
2322 regno
= REGNO (home
);
2323 if (regno
>= FIRST_PSEUDO_REGISTER
)
2327 /* The kind-of-variable letter depends on where
2328 the variable is and on the scope of its name:
2329 G and N_GSYM for static storage and global scope,
2330 S for static storage and file scope,
2331 V for static storage and local scope,
2332 for those two, use N_LCSYM if data is in bss segment,
2333 N_STSYM if in data segment, N_FUN otherwise.
2334 (We used N_FUN originally, then changed to N_STSYM
2335 to please GDB. However, it seems that confused ld.
2336 Now GDB has been fixed to like N_FUN, says Kingdon.)
2337 no letter at all, and N_LSYM, for auto variable,
2338 r and N_RSYM for register variable. */
2340 if (GET_CODE (home
) == MEM
2341 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2343 if (TREE_PUBLIC (decl
))
2346 current_sym_code
= N_GSYM
;
2350 current_sym_addr
= XEXP (home
, 0);
2352 letter
= decl_function_context (decl
) ? 'V' : 'S';
2354 /* This should be the same condition as in assemble_variable, but
2355 we don't have access to dont_output_data here. So, instead,
2356 we rely on the fact that error_mark_node initializers always
2357 end up in bss for C++ and never end up in bss for C. */
2358 if (DECL_INITIAL (decl
) == 0
2359 || (!strcmp (lang_hooks
.name
, "GNU C++")
2360 && DECL_INITIAL (decl
) == error_mark_node
))
2361 current_sym_code
= N_LCSYM
;
2362 else if (DECL_IN_TEXT_SECTION (decl
))
2363 /* This is not quite right, but it's the closest
2364 of all the codes that Unix defines. */
2365 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2368 /* Some ports can transform a symbol ref into a label ref,
2369 because the symbol ref is too far away and has to be
2370 dumped into a constant pool. Alternatively, the symbol
2371 in the constant pool might be referenced by a different
2373 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2374 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2376 rtx tmp
= get_pool_constant (current_sym_addr
);
2378 if (GET_CODE (tmp
) == SYMBOL_REF
2379 || GET_CODE (tmp
) == LABEL_REF
)
2380 current_sym_addr
= tmp
;
2383 /* Ultrix `as' seems to need this. */
2384 #ifdef DBX_STATIC_STAB_DATA_SECTION
2387 current_sym_code
= N_STSYM
;
2391 else if (regno
>= 0)
2394 current_sym_code
= N_RSYM
;
2395 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2397 else if (GET_CODE (home
) == MEM
2398 && (GET_CODE (XEXP (home
, 0)) == MEM
2399 || (GET_CODE (XEXP (home
, 0)) == REG
2400 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2401 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2402 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2403 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2406 /* If the value is indirect by memory or by a register
2407 that isn't the frame pointer
2408 then it means the object is variable-sized and address through
2409 that register or stack slot. DBX has no way to represent this
2410 so all we can do is output the variable as a pointer.
2411 If it's not a parameter, ignore it.
2412 (VAR_DECLs like this can be made by integrate.c.) */
2414 if (GET_CODE (XEXP (home
, 0)) == REG
)
2417 current_sym_code
= N_RSYM
;
2418 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2420 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2424 current_sym_code
= N_LSYM
;
2425 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2426 We want the value of that CONST_INT. */
2428 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2431 /* Effectively do build_pointer_type, but don't cache this type,
2432 since it might be temporary whereas the type it points to
2433 might have been saved for inlining. */
2434 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2435 type
= make_node (POINTER_TYPE
);
2436 TREE_TYPE (type
) = TREE_TYPE (decl
);
2438 else if (GET_CODE (home
) == MEM
2439 && GET_CODE (XEXP (home
, 0)) == REG
)
2441 current_sym_code
= N_LSYM
;
2442 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2444 else if (GET_CODE (home
) == MEM
2445 && GET_CODE (XEXP (home
, 0)) == PLUS
2446 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2448 current_sym_code
= N_LSYM
;
2449 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2450 We want the value of that CONST_INT. */
2451 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2453 else if (GET_CODE (home
) == MEM
2454 && GET_CODE (XEXP (home
, 0)) == CONST
)
2456 /* Handle an obscure case which can arise when optimizing and
2457 when there are few available registers. (This is *always*
2458 the case for i386/i486 targets). The RTL looks like
2459 (MEM (CONST ...)) even though this variable is a local `auto'
2460 or a local `register' variable. In effect, what has happened
2461 is that the reload pass has seen that all assignments and
2462 references for one such a local variable can be replaced by
2463 equivalent assignments and references to some static storage
2464 variable, thereby avoiding the need for a register. In such
2465 cases we're forced to lie to debuggers and tell them that
2466 this variable was itself `static'. */
2467 current_sym_code
= N_LCSYM
;
2469 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2471 else if (GET_CODE (home
) == CONCAT
)
2475 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2476 for example), then there is no easy way to figure out
2477 what SUBTYPE should be. So, we give up. */
2478 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2481 subtype
= TREE_TYPE (type
);
2483 /* If the variable's storage is in two parts,
2484 output each as a separate stab with a modified name. */
2485 if (WORDS_BIG_ENDIAN
)
2486 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2488 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2490 /* Cast avoids warning in old compilers. */
2491 current_sym_code
= (STAB_CODE_TYPE
) 0;
2492 current_sym_value
= 0;
2493 current_sym_addr
= 0;
2494 dbxout_prepare_symbol (decl
);
2496 if (WORDS_BIG_ENDIAN
)
2497 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2499 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2503 /* Address might be a MEM, when DECL is a variable-sized object.
2504 Or it might be const0_rtx, meaning previous passes
2505 want us to ignore this variable. */
2508 /* Ok, start a symtab entry and output the variable name. */
2511 #ifdef DBX_STATIC_BLOCK_START
2512 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2515 dbxout_symbol_name (decl
, suffix
, letter
);
2516 dbxout_type (type
, 0);
2517 dbxout_finish_symbol (decl
);
2519 #ifdef DBX_STATIC_BLOCK_END
2520 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2525 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2526 Then output LETTER to indicate the kind of location the symbol has. */
2529 dbxout_symbol_name (decl
, suffix
, letter
)
2536 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2537 /* One slight hitch: if this is a VAR_DECL which is a static
2538 class member, we must put out the mangled name instead of the
2539 DECL_NAME. Note also that static member (variable) names DO NOT begin
2540 with underscores in .stabs directives. */
2541 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2543 /* ...but if we're function-local, we don't want to include the junk
2544 added by ASM_FORMAT_PRIVATE_NAME. */
2545 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2549 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2550 (suffix
? suffix
: ""));
2553 putc (letter
, asmfile
);
2557 dbxout_prepare_symbol (decl
)
2558 tree decl ATTRIBUTE_UNUSED
;
2561 const char *filename
= DECL_SOURCE_FILE (decl
);
2563 dbxout_source_file (asmfile
, filename
);
2568 dbxout_finish_symbol (sym
)
2571 #ifdef DBX_FINISH_SYMBOL
2572 DBX_FINISH_SYMBOL (sym
);
2575 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2576 line
= DECL_SOURCE_LINE (sym
);
2578 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2579 if (current_sym_addr
)
2580 output_addr_const (asmfile
, current_sym_addr
);
2582 fprintf (asmfile
, "%d", current_sym_value
);
2583 putc ('\n', asmfile
);
2587 /* Output definitions of all the decls in a chain. Return nonzero if
2588 anything was output */
2597 result
+= dbxout_symbol (syms
, 1);
2598 syms
= TREE_CHAIN (syms
);
2603 /* The following two functions output definitions of function parameters.
2604 Each parameter gets a definition locating it in the parameter list.
2605 Each parameter that is a register variable gets a second definition
2606 locating it in the register.
2608 Printing or argument lists in gdb uses the definitions that
2609 locate in the parameter list. But reference to the variable in
2610 expressions uses preferentially the definition as a register. */
2612 /* Output definitions, referring to storage in the parmlist,
2613 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2616 dbxout_parms (parms
)
2619 for (; parms
; parms
= TREE_CHAIN (parms
))
2620 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2622 dbxout_prepare_symbol (parms
);
2624 /* Perform any necessary register eliminations on the parameter's rtl,
2625 so that the debugging output will be accurate. */
2626 DECL_INCOMING_RTL (parms
)
2627 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2628 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2629 #ifdef LEAF_REG_REMAP
2630 if (current_function_uses_only_leaf_regs
)
2632 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2633 leaf_renumber_regs_insn (DECL_RTL (parms
));
2637 if (PARM_PASSED_IN_MEMORY (parms
))
2639 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2641 /* ??? Here we assume that the parm address is indexed
2642 off the frame pointer or arg pointer.
2643 If that is not true, we produce meaningless results,
2644 but do not crash. */
2645 if (GET_CODE (addr
) == PLUS
2646 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2647 current_sym_value
= INTVAL (XEXP (addr
, 1));
2649 current_sym_value
= 0;
2651 current_sym_code
= N_PSYM
;
2652 current_sym_addr
= 0;
2655 if (DECL_NAME (parms
))
2657 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2659 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2660 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2661 DBX_MEMPARM_STABS_LETTER
);
2665 current_sym_nchars
= 8;
2666 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2667 DBX_MEMPARM_STABS_LETTER
);
2670 /* It is quite tempting to use:
2672 dbxout_type (TREE_TYPE (parms), 0);
2674 as the next statement, rather than using DECL_ARG_TYPE(), so
2675 that gcc reports the actual type of the parameter, rather
2676 than the promoted type. This certainly makes GDB's life
2677 easier, at least for some ports. The change is a bad idea
2678 however, since GDB expects to be able access the type without
2679 performing any conversions. So for example, if we were
2680 passing a float to an unprototyped function, gcc will store a
2681 double on the stack, but if we emit a stab saying the type is a
2682 float, then gdb will only read in a single value, and this will
2683 produce an erroneous value. */
2684 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2685 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2686 dbxout_finish_symbol (parms
);
2688 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2691 char regparm_letter
;
2693 /* Parm passed in registers and lives in registers or nowhere. */
2695 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2696 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2697 current_sym_addr
= 0;
2699 /* If parm lives in a register, use that register;
2700 pretend the parm was passed there. It would be more consistent
2701 to describe the register where the parm was passed,
2702 but in practice that register usually holds something else.
2704 If we use DECL_RTL, then we must use the declared type of
2705 the variable, not the type that it arrived in. */
2706 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2708 best_rtl
= DECL_RTL (parms
);
2709 parm_type
= TREE_TYPE (parms
);
2711 /* If the parm lives nowhere, use the register where it was
2712 passed. It is also better to use the declared type here. */
2715 best_rtl
= DECL_INCOMING_RTL (parms
);
2716 parm_type
= TREE_TYPE (parms
);
2718 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2721 if (DECL_NAME (parms
))
2723 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2724 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2725 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2730 current_sym_nchars
= 8;
2731 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2735 dbxout_type (parm_type
, 0);
2736 dbxout_finish_symbol (parms
);
2738 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2739 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2740 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2741 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2742 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2743 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2747 /* Parm was passed via invisible reference.
2748 That is, its address was passed in a register.
2749 Output it as if it lived in that register.
2750 The debugger will know from the type
2751 that it was actually passed by invisible reference. */
2753 char regparm_letter
;
2754 /* Parm passed in registers and lives in registers or nowhere. */
2756 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2757 if (use_gnu_debug_info_extensions
)
2758 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2760 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2762 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2763 If it is an unallocated pseudo-reg, then use the register where
2764 it was passed instead. */
2765 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2766 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2768 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2770 current_sym_addr
= 0;
2773 if (DECL_NAME (parms
))
2776 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2778 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2779 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2784 current_sym_nchars
= 8;
2785 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2789 dbxout_type (TREE_TYPE (parms
), 0);
2790 dbxout_finish_symbol (parms
);
2792 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2793 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2795 /* Parm was passed via invisible reference, with the reference
2796 living on the stack. DECL_RTL looks like
2797 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2798 could look like (MEM (MEM (REG))). */
2799 const char *const decl_name
= (DECL_NAME (parms
)
2800 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2802 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2803 current_sym_value
= 0;
2806 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2807 current_sym_addr
= 0;
2808 current_sym_code
= N_PSYM
;
2811 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2814 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2815 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2816 dbxout_type (TREE_TYPE (parms
), 0);
2817 dbxout_finish_symbol (parms
);
2819 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2820 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2821 /* ??? A constant address for a parm can happen
2822 when the reg it lives in is equiv to a constant in memory.
2823 Should make this not happen, after 2.4. */
2824 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2826 /* Parm was passed in registers but lives on the stack. */
2828 current_sym_code
= N_PSYM
;
2829 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2830 in which case we want the value of that CONST_INT,
2832 in which case we use a value of zero. */
2833 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2834 current_sym_value
= 0;
2837 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2839 current_sym_addr
= 0;
2841 /* Make a big endian correction if the mode of the type of the
2842 parameter is not the same as the mode of the rtl. */
2843 if (BYTES_BIG_ENDIAN
2844 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2845 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2847 current_sym_value
+=
2848 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2849 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2853 if (DECL_NAME (parms
))
2856 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2858 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2859 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2860 DBX_MEMPARM_STABS_LETTER
);
2864 current_sym_nchars
= 8;
2865 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2866 DBX_MEMPARM_STABS_LETTER
);
2870 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2871 XEXP (DECL_RTL (parms
), 0));
2872 dbxout_type (TREE_TYPE (parms
), 0);
2873 dbxout_finish_symbol (parms
);
2878 /* Output definitions for the places where parms live during the function,
2879 when different from where they were passed, when the parms were passed
2882 It is not useful to do this for parms passed in registers
2883 that live during the function in different registers, because it is
2884 impossible to look in the passed register for the passed value,
2885 so we use the within-the-function register to begin with.
2887 PARMS is a chain of PARM_DECL nodes. */
2890 dbxout_reg_parms (parms
)
2893 for (; parms
; parms
= TREE_CHAIN (parms
))
2894 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2896 dbxout_prepare_symbol (parms
);
2898 /* Report parms that live in registers during the function
2899 but were passed in memory. */
2900 if (GET_CODE (DECL_RTL (parms
)) == REG
2901 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2902 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2903 0, DECL_RTL (parms
));
2904 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2905 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2906 0, DECL_RTL (parms
));
2907 /* Report parms that live in memory but not where they were passed. */
2908 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2909 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2910 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2911 0, DECL_RTL (parms
));
2915 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2916 output definitions of those names, in raw form */
2924 putc (',', asmfile
);
2925 dbxout_type (TREE_VALUE (args
), 0);
2927 args
= TREE_CHAIN (args
);
2931 /* Output everything about a symbol block (a BLOCK node
2932 that represents a scope level),
2933 including recursive output of contained blocks.
2935 BLOCK is the BLOCK node.
2936 DEPTH is its depth within containing symbol blocks.
2937 ARGS is usually zero; but for the outermost block of the
2938 body of a function, it is a chain of PARM_DECLs for the function parameters.
2939 We output definitions of all the register parms
2940 as if they were local variables of that block.
2942 If -g1 was used, we count blocks just the same, but output nothing
2943 except for the outermost block.
2945 Actually, BLOCK may be several blocks chained together.
2946 We handle them all in sequence. */
2949 dbxout_block (block
, depth
, args
)
2956 #if DBX_BLOCKS_FUNCTION_RELATIVE
2957 const char *begin_label
;
2958 if (current_function_func_begin_label
!= NULL_TREE
)
2959 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2961 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2966 /* Ignore blocks never expanded or otherwise marked as real. */
2967 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2971 #ifdef DBX_LBRAC_FIRST
2974 /* In dbx format, the syms of a block come before the N_LBRAC.
2975 If nothing is output, we don't need the N_LBRAC, either. */
2977 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2978 did_output
= dbxout_syms (BLOCK_VARS (block
));
2980 dbxout_reg_parms (args
);
2983 /* Now output an N_LBRAC symbol to represent the beginning of
2984 the block. Use the block's tree-walk order to generate
2985 the assembler symbols LBBn and LBEn
2986 that final will define around the code in this block. */
2987 if (depth
> 0 && did_output
)
2990 blocknum
= BLOCK_NUMBER (block
);
2991 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2993 if (BLOCK_HANDLER_BLOCK (block
))
2995 /* A catch block. Must precede N_LBRAC. */
2996 tree decl
= BLOCK_VARS (block
);
2999 #ifdef DBX_OUTPUT_CATCH
3000 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
3002 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
3003 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
3004 assemble_name (asmfile
, buf
);
3005 fprintf (asmfile
, "\n");
3007 decl
= TREE_CHAIN (decl
);
3011 #ifdef DBX_OUTPUT_LBRAC
3012 DBX_OUTPUT_LBRAC (asmfile
, buf
);
3014 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
3015 assemble_name (asmfile
, buf
);
3016 #if DBX_BLOCKS_FUNCTION_RELATIVE
3017 putc ('-', asmfile
);
3018 assemble_name (asmfile
, begin_label
);
3020 fprintf (asmfile
, "\n");
3024 #ifdef DBX_LBRAC_FIRST
3025 /* On some weird machines, the syms of a block
3026 come after the N_LBRAC. */
3027 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3028 dbxout_syms (BLOCK_VARS (block
));
3030 dbxout_reg_parms (args
);
3033 /* Output the subblocks. */
3034 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3036 /* Refer to the marker for the end of the block. */
3037 if (depth
> 0 && did_output
)
3040 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3041 #ifdef DBX_OUTPUT_RBRAC
3042 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3044 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3045 assemble_name (asmfile
, buf
);
3046 #if DBX_BLOCKS_FUNCTION_RELATIVE
3047 putc ('-', asmfile
);
3048 assemble_name (asmfile
, begin_label
);
3050 fprintf (asmfile
, "\n");
3054 block
= BLOCK_CHAIN (block
);
3058 /* Output the information about a function and its arguments and result.
3059 Usually this follows the function's code,
3060 but on some systems, it comes before. */
3062 #if defined (DBX_DEBUGGING_INFO)
3064 dbxout_begin_function (decl
)
3067 dbxout_symbol (decl
, 0);
3068 dbxout_parms (DECL_ARGUMENTS (decl
));
3069 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3070 dbxout_symbol (DECL_RESULT (decl
), 1);
3072 #endif /* DBX_DEBUGGING_INFO */
3074 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3076 #include "gt-dbxout.h"