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 if (use_gnu_debug_info_extensions
)
444 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
445 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
448 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
449 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
450 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
451 fprintf (asmfile
, "%s", ASM_STABS_OP
);
452 output_quoted_string (asmfile
, cwd
);
453 fprintf (asmfile
, ",%d,0,0,", N_SO
);
454 assemble_name (asmfile
, ltext_label_name
);
455 fputc ('\n', asmfile
);
456 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
460 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
461 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
462 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
463 /* We include outputting `Ltext:' here,
464 because that gives you a way to override it. */
465 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
466 fprintf (asmfile
, "%s", ASM_STABS_OP
);
467 output_quoted_string (asmfile
, input_file_name
);
468 fprintf (asmfile
, ",%d,0,0,", N_SO
);
469 assemble_name (asmfile
, ltext_label_name
);
470 fputc ('\n', asmfile
);
472 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
473 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
475 #ifdef DBX_OUTPUT_GCC_MARKER
476 DBX_OUTPUT_GCC_MARKER (asmfile
);
478 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
479 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
480 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
483 base_input_file
= lastfile
= input_file_name
;
485 next_type_number
= 1;
488 current_file
= (struct dbx_file
*) ggc_alloc (sizeof *current_file
);
489 current_file
->next
= NULL
;
490 current_file
->file_number
= 0;
491 current_file
->next_type_number
= 1;
492 next_file_number
= 1;
495 /* Make sure that types `int' and `char' have numbers 1 and 2.
496 Definitions of other integer types will refer to those numbers.
497 (Actually it should no longer matter what their numbers are.
498 Also, if any types with tags have been defined, dbxout_symbol
499 will output them first, so the numbers won't be 1 and 2. That
500 happens in C++. So it's a good thing it should no longer matter). */
502 #ifdef DBX_OUTPUT_STANDARD_TYPES
503 DBX_OUTPUT_STANDARD_TYPES (syms
);
505 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
506 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
509 /* Get all permanent types that have typedef names,
510 and output them all, except for those already output. */
512 dbxout_typedefs (syms
);
515 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
516 in the reverse order from that which is found in SYMS. */
519 dbxout_typedefs (syms
)
524 dbxout_typedefs (TREE_CHAIN (syms
));
525 if (TREE_CODE (syms
) == TYPE_DECL
)
527 tree type
= TREE_TYPE (syms
);
529 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
530 && COMPLETE_TYPE_P (type
)
531 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
532 dbxout_symbol (TYPE_NAME (type
), 0);
537 /* Change to reading from a new source file. Generate a N_BINCL stab. */
540 dbxout_start_source_file (line
, filename
)
541 unsigned int line ATTRIBUTE_UNUSED
;
542 const char *filename ATTRIBUTE_UNUSED
;
545 struct dbx_file
*n
= (struct dbx_file
*) ggc_alloc (sizeof *n
);
547 n
->next
= current_file
;
548 n
->file_number
= next_file_number
++;
549 n
->next_type_number
= 1;
551 fprintf (asmfile
, "%s", ASM_STABS_OP
);
552 output_quoted_string (asmfile
, filename
);
553 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
557 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
560 dbxout_end_source_file (line
)
561 unsigned int line ATTRIBUTE_UNUSED
;
564 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
565 current_file
= current_file
->next
;
569 /* Handle a few odd cases that occur when trying to make PCH files work. */
572 dbxout_handle_pch (unsigned at_end
)
576 /* When using the PCH, this file will be included, so we need to output
578 dbxout_start_source_file (0, lastfile
);
580 /* The base file when using the PCH won't be the same as
581 the base file when it's being generated. */
586 /* ... and an EINCL. */
587 dbxout_end_source_file (0);
589 /* Deal with cases where 'lastfile' was never actually changed. */
590 lastfile_is_base
= lastfile
== NULL
;
594 #if defined (DBX_DEBUGGING_INFO)
595 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
598 dbxout_source_file (file
, filename
)
600 const char *filename
;
602 if (lastfile
== 0 && lastfile_is_base
)
604 lastfile
= base_input_file
;
605 lastfile_is_base
= 0;
608 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
610 char ltext_label_name
[100];
612 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
613 source_label_number
);
614 fprintf (file
, "%s", ASM_STABS_OP
);
615 output_quoted_string (file
, filename
);
616 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
617 assemble_name (asmfile
, ltext_label_name
);
618 fputc ('\n', asmfile
);
619 if (current_function_decl
!= NULL_TREE
620 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
621 ; /* Don't change section amid function. */
624 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
625 source_label_number
++;
630 /* Output a line number symbol entry for source file FILENAME and line
634 dbxout_source_line (lineno
, filename
)
636 const char *filename
;
638 dbxout_source_file (asmfile
, filename
);
640 #ifdef ASM_OUTPUT_SOURCE_LINE
641 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
);
643 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
647 /* Describe the beginning of an internal block within a function. */
650 dbxout_begin_block (line
, n
)
651 unsigned int line ATTRIBUTE_UNUSED
;
654 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
657 /* Describe the end line-number of an internal block within a function. */
660 dbxout_end_block (line
, n
)
661 unsigned int line ATTRIBUTE_UNUSED
;
664 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
667 /* Output dbx data for a function definition.
668 This includes a definition of the function name itself (a symbol),
669 definitions of the parameters (locating them in the parameter list)
670 and then output the block that makes up the function's body
671 (including all the auto variables of the function). */
674 dbxout_function_decl (decl
)
677 #ifndef DBX_FUNCTION_FIRST
678 dbxout_begin_function (decl
);
680 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
681 #ifdef DBX_OUTPUT_FUNCTION_END
682 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
684 if (use_gnu_debug_info_extensions
685 #if defined(NO_DBX_FUNCTION_END)
686 && ! NO_DBX_FUNCTION_END
688 && targetm
.have_named_sections
)
689 dbxout_function_end ();
692 #endif /* DBX_DEBUGGING_INFO */
694 /* Debug information for a global DECL. Called from toplev.c after
695 compilation proper has finished. */
697 dbxout_global_decl (decl
)
700 if (TREE_CODE (decl
) == VAR_DECL
701 && ! DECL_EXTERNAL (decl
)
702 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
703 dbxout_symbol (decl
, 0);
706 /* At the end of compilation, finish writing the symbol table.
707 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
711 dbxout_finish (filename
)
712 const char *filename ATTRIBUTE_UNUSED
;
714 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
715 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
716 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
719 /* Output floating point type values used by the 'R' stab letter.
720 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
722 There are only 3 real/complex types defined, and we need 7/6.
723 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
724 complex type. Since we have the type size anyways, we don't really need
725 to distinguish between different FP types, we only need to distinguish
726 between float and complex. This works fine with gdb.
728 We only use this for complex types, to avoid breaking backwards
729 compatibility for real types. complex types aren't in ISO C90, so it is
730 OK if old debuggers don't understand the debug info we emit for them. */
732 /* ??? These are supposed to be IEEE types, but we don't check for that.
733 We could perhaps add additional numbers for non-IEEE types if we need
737 dbxout_fptype_value (type
)
741 enum machine_mode mode
= TYPE_MODE (type
);
743 if (TREE_CODE (type
) == REAL_TYPE
)
747 else if (mode
== DFmode
)
749 else if (mode
== TFmode
|| mode
== XFmode
)
752 /* Use NF_SINGLE as a generic real type for other sizes. */
755 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
759 else if (mode
== DCmode
)
761 else if (mode
== TCmode
|| mode
== XCmode
)
764 /* Use NF_COMPLEX as a generic complex type for other sizes. */
770 putc (value
, asmfile
);
774 /* Output the index of a type. */
777 dbxout_type_index (type
)
780 #ifndef DBX_USE_BINCL
781 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
784 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
785 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
790 #if DBX_CONTIN_LENGTH > 0
791 /* Continue a symbol-description that gets too big.
792 End one symbol table entry with a double-backslash
793 and start a new one, eventually producing something like
794 .stabs "start......\\",code,0,value
795 .stabs "...rest",code,0,value */
800 #ifdef DBX_CONTIN_CHAR
801 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
803 fprintf (asmfile
, "\\\\");
805 dbxout_finish_symbol (NULL_TREE
);
806 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
807 current_sym_nchars
= 0;
809 #endif /* DBX_CONTIN_LENGTH > 0 */
811 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
812 This must be a separate function because anonymous unions require
816 dbxout_type_fields (type
)
821 /* Output the name, type, position (in bits), size (in bits) of each
822 field that we can support. */
823 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
825 /* Omit here local type decls until we know how to support them. */
826 if (TREE_CODE (tem
) == TYPE_DECL
827 /* Omit fields whose position or size are variable or too large to
829 || (TREE_CODE (tem
) == FIELD_DECL
830 && (! host_integerp (bit_position (tem
), 0)
832 || ! host_integerp (DECL_SIZE (tem
), 1)))
833 /* Omit here the nameless fields that are used to skip bits. */
834 || DECL_IGNORED_P (tem
))
837 else if (TREE_CODE (tem
) != CONST_DECL
)
839 /* Continue the line if necessary,
840 but not before the first field. */
841 if (tem
!= TYPE_FIELDS (type
))
846 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
847 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
851 fprintf (asmfile
, ":");
855 if (use_gnu_debug_info_extensions
856 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
857 || TREE_CODE (tem
) != FIELD_DECL
))
859 have_used_extensions
= 1;
861 putc ((TREE_PRIVATE (tem
) ? '0'
862 : TREE_PROTECTED (tem
) ? '1' : '2'),
867 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
868 && DECL_BIT_FIELD_TYPE (tem
))
869 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
871 if (TREE_CODE (tem
) == VAR_DECL
)
873 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
875 tree name
= DECL_ASSEMBLER_NAME (tem
);
877 have_used_extensions
= 1;
878 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
879 CHARS (IDENTIFIER_LENGTH (name
) + 2);
883 /* If TEM is non-static, GDB won't understand it. */
884 fprintf (asmfile
, ",0,0;");
891 print_wide_int (int_bit_position (tem
));
893 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
901 /* Subroutine of `dbxout_type_methods'. Output debug info about the
902 method described DECL. DEBUG_NAME is an encoding of the method's
903 type signature. ??? We may be able to do without DEBUG_NAME altogether
907 dbxout_type_method_1 (decl
, debug_name
)
909 const char *debug_name
;
913 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
915 else /* it's a METHOD_TYPE. */
917 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
918 /* A for normal functions.
919 B for `const' member functions.
920 C for `volatile' member functions.
921 D for `const volatile' member functions. */
922 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
924 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
927 if (DECL_VINDEX (decl
))
933 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
934 TREE_PRIVATE (decl
) ? '0'
935 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
936 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
937 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
939 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
941 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
944 dbxout_type (DECL_CONTEXT (decl
), 0);
945 fprintf (asmfile
, ";");
950 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
954 dbxout_type_methods (type
)
957 /* C++: put out the method names and their parameter lists */
958 tree methods
= TYPE_METHODS (type
);
962 char formatted_type_identifier_length
[16];
963 int type_identifier_length
;
965 if (methods
== NULL_TREE
)
968 type_encoding
= DECL_NAME (TYPE_NAME (type
));
971 /* C++: Template classes break some assumptions made by this code about
972 the class names, constructor names, and encodings for assembler
973 label names. For now, disable output of dbx info for them. */
975 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
976 /* This should use index. (mrs) */
977 while (*ptr
&& *ptr
!= '<') ptr
++;
988 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
990 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
992 if (TREE_CODE (methods
) != TREE_VEC
)
994 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
995 fndecl
= TREE_VEC_ELT (methods
, 0);
997 fndecl
= TREE_VEC_ELT (methods
, 1);
1001 int need_prefix
= 1;
1003 /* Group together all the methods for the same operation.
1004 These differ in the types of the arguments. */
1005 for (last
= NULL_TREE
;
1006 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1007 fndecl
= TREE_CHAIN (fndecl
))
1008 /* Output the name of the field (after overloading), as
1009 well as the name of the field before overloading, along
1010 with its parameter list */
1012 /* This is the "mangled" name of the method.
1013 It encodes the argument types. */
1014 const char *debug_name
;
1016 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1017 include TEMPLATE_DECLs.) The debugger doesn't know what
1018 to do with such entities anyhow. */
1019 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1022 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1028 /* Also ignore abstract methods; those are only interesting to
1029 the DWARF backends. */
1030 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1033 /* Redundantly output the plain name, since that's what gdb
1037 tree name
= DECL_NAME (fndecl
);
1038 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1039 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1043 dbxout_type (TREE_TYPE (fndecl
), 0);
1045 dbxout_type_method_1 (fndecl
, debug_name
);
1049 putc (';', asmfile
);
1055 /* Emit a "range" type specification, which has the form:
1056 "r<index type>;<lower bound>;<upper bound>;".
1057 TYPE is an INTEGER_TYPE. */
1060 dbxout_range_type (type
)
1063 fprintf (asmfile
, "r");
1064 if (TREE_TYPE (type
))
1065 dbxout_type (TREE_TYPE (type
), 0);
1066 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1067 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1070 /* Traditionally, we made sure 'int' was type 1, and builtin types
1071 were defined to be sub-ranges of int. Unfortunately, this
1072 does not allow us to distinguish true sub-ranges from integer
1073 types. So, instead we define integer (non-sub-range) types as
1074 sub-ranges of themselves. This matters for Chill. If this isn't
1075 a subrange type, then we want to define it in terms of itself.
1076 However, in C, this may be an anonymous integer type, and we don't
1077 want to emit debug info referring to it. Just calling
1078 dbxout_type_index won't work anyways, because the type hasn't been
1079 defined yet. We make this work for both cases by checked to see
1080 whether this is a defined type, referring to it if it is, and using
1082 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1083 dbxout_type_index (type
);
1085 dbxout_type_index (integer_type_node
);
1088 if (TYPE_MIN_VALUE (type
) != 0
1089 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1091 putc (';', asmfile
);
1093 if (print_int_cst_bounds_in_octal_p (type
))
1094 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1096 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1100 fprintf (asmfile
, ";0");
1104 if (TYPE_MAX_VALUE (type
) != 0
1105 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1107 putc (';', asmfile
);
1109 if (print_int_cst_bounds_in_octal_p (type
))
1110 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1112 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1113 putc (';', asmfile
);
1118 fprintf (asmfile
, ";-1;");
1123 /* Output a reference to a type. If the type has not yet been
1124 described in the dbx output, output its definition now.
1125 For a type already defined, just refer to its definition
1126 using the type number.
1128 If FULL is nonzero, and the type has been described only with
1129 a forward-reference, output the definition now.
1130 If FULL is zero in this case, just refer to the forward-reference
1131 using the number previously allocated. */
1134 dbxout_type (type
, full
)
1140 static int anonymous_type_number
= 0;
1142 if (TREE_CODE (type
) == VECTOR_TYPE
)
1143 /* The frontend feeds us a representation for the vector as a struct
1144 containing an array. Pull out the array type. */
1145 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1147 /* If there was an input error and we don't really have a type,
1148 avoid crashing and write something that is at least valid
1149 by assuming `int'. */
1150 if (type
== error_mark_node
)
1151 type
= integer_type_node
;
1154 if (TYPE_NAME (type
)
1155 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1156 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1160 /* Try to find the "main variant" with the same name. */
1161 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1162 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1163 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1165 main_variant
= TYPE_MAIN_VARIANT (type
);
1167 /* If we are not using extensions, stabs does not distinguish const and
1168 volatile, so there is no need to make them separate types. */
1169 if (!use_gnu_debug_info_extensions
)
1170 type
= main_variant
;
1172 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1174 /* Type has no dbx number assigned. Assign next available number. */
1175 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1177 /* Make sure type vector is long enough to record about this type. */
1179 if (next_type_number
== typevec_len
)
1182 = (struct typeinfo
*) ggc_realloc (typevec
,
1184 * sizeof typevec
[0]));
1185 memset ((char *) (typevec
+ typevec_len
), 0,
1186 typevec_len
* sizeof typevec
[0]);
1190 #ifdef DBX_USE_BINCL
1191 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1192 = current_file
->file_number
;
1193 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1194 = current_file
->next_type_number
++;
1198 /* Output the number of this type, to refer to it. */
1199 dbxout_type_index (type
);
1201 #ifdef DBX_TYPE_DEFINED
1202 if (DBX_TYPE_DEFINED (type
))
1206 /* If this type's definition has been output or is now being output,
1209 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1214 /* If we have already had a cross reference,
1215 and either that's all we want or that's the best we could do,
1216 don't repeat the cross reference.
1217 Sun dbx crashes if we do. */
1218 if (! full
|| !COMPLETE_TYPE_P (type
)
1219 /* No way in DBX fmt to describe a variable size. */
1220 || ! host_integerp (TYPE_SIZE (type
), 1))
1228 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1229 leave the type-number completely undefined rather than output
1230 a cross-reference. If we have already used GNU debug info extensions,
1231 then it is OK to output a cross reference. This is necessary to get
1232 proper C++ debug output. */
1233 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1234 || TREE_CODE (type
) == QUAL_UNION_TYPE
1235 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1236 && ! use_gnu_debug_info_extensions
)
1237 /* We must use the same test here as we use twice below when deciding
1238 whether to emit a cross-reference. */
1239 if ((TYPE_NAME (type
) != 0
1240 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1241 && DECL_IGNORED_P (TYPE_NAME (type
)))
1243 || !COMPLETE_TYPE_P (type
)
1244 /* No way in DBX fmt to describe a variable size. */
1245 || ! host_integerp (TYPE_SIZE (type
), 1))
1247 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1252 /* Output a definition now. */
1254 fprintf (asmfile
, "=");
1257 /* Mark it as defined, so that if it is self-referent
1258 we will not get into an infinite recursion of definitions. */
1260 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1262 /* If this type is a variant of some other, hand off. Types with
1263 different names are usefully distinguished. We only distinguish
1264 cv-qualified types if we're using extensions. */
1265 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1267 putc ('k', asmfile
);
1269 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1272 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1274 putc ('B', asmfile
);
1276 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1279 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1281 /* 'type' is a typedef; output the type it refers to. */
1282 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1285 /* else continue. */
1287 switch (TREE_CODE (type
))
1291 /* For a void type, just define it as itself; ie, "5=5".
1292 This makes us consider it defined
1293 without saying what it is. The debugger will make it
1294 a void type when the reference is seen, and nothing will
1295 ever override that default. */
1296 dbxout_type_index (type
);
1300 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1302 /* Output the type `char' as a subrange of itself!
1303 I don't understand this definition, just copied it
1304 from the output of pcc.
1305 This used to use `r2' explicitly and we used to
1306 take care to make sure that `char' was type number 2. */
1307 fprintf (asmfile
, "r");
1309 dbxout_type_index (type
);
1310 fprintf (asmfile
, ";0;127;");
1314 /* If this is a subtype of another integer type, always prefer to
1315 write it as a subtype. */
1316 else if (TREE_TYPE (type
) != 0
1317 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1319 /* If the size is non-standard, say what it is if we can use
1322 if (use_gnu_debug_info_extensions
1323 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1325 have_used_extensions
= 1;
1326 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1330 dbxout_range_type (type
);
1335 /* If the size is non-standard, say what it is if we can use
1338 if (use_gnu_debug_info_extensions
1339 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1341 have_used_extensions
= 1;
1342 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1346 if (print_int_cst_bounds_in_octal_p (type
))
1348 fprintf (asmfile
, "r");
1351 /* If this type derives from another type, output type index of
1352 parent type. This is particularly important when parent type
1353 is an enumerated type, because not generating the parent type
1354 index would transform the definition of this enumerated type
1355 into a plain unsigned type. */
1356 if (TREE_TYPE (type
) != 0)
1357 dbxout_type_index (TREE_TYPE (type
));
1359 dbxout_type_index (type
);
1361 fprintf (asmfile
, ";");
1363 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1364 fprintf (asmfile
, ";");
1366 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1367 fprintf (asmfile
, ";");
1372 /* Output other integer types as subranges of `int'. */
1373 dbxout_range_type (type
);
1379 /* This used to say `r1' and we used to take care
1380 to make sure that `int' was type number 1. */
1381 fprintf (asmfile
, "r");
1383 dbxout_type_index (integer_type_node
);
1384 putc (';', asmfile
);
1386 print_wide_int (int_size_in_bytes (type
));
1387 fputs (";0;", asmfile
);
1392 if (use_gnu_debug_info_extensions
)
1394 have_used_extensions
= 1;
1395 fputs ("@s", asmfile
);
1397 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1398 fputs (";-20;", asmfile
);
1403 /* Output the type `char' as a subrange of itself.
1404 That is what pcc seems to do. */
1405 fprintf (asmfile
, "r");
1407 dbxout_type_index (char_type_node
);
1408 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1414 if (use_gnu_debug_info_extensions
)
1416 have_used_extensions
= 1;
1417 fputs ("@s", asmfile
);
1419 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1420 fputs (";-16;", asmfile
);
1423 else /* Define as enumeral type (False, True) */
1425 fprintf (asmfile
, "eFalse:0,True:1,;");
1431 putc ('d', asmfile
);
1433 dbxout_type (TREE_TYPE (type
), 0);
1437 /* Differs from the REAL_TYPE by its new data type number */
1439 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1441 putc ('R', asmfile
);
1443 dbxout_fptype_value (type
);
1444 putc (';', asmfile
);
1446 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1447 fputs (";0;", asmfile
);
1452 /* Output a complex integer type as a structure,
1453 pending some other way to do it. */
1454 putc ('s', asmfile
);
1456 print_wide_int (int_size_in_bytes (type
));
1457 fprintf (asmfile
, "real:");
1460 dbxout_type (TREE_TYPE (type
), 0);
1461 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1463 fprintf (asmfile
, "imag:");
1465 dbxout_type (TREE_TYPE (type
), 0);
1466 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1467 TYPE_PRECISION (TREE_TYPE (type
)));
1473 if (use_gnu_debug_info_extensions
)
1475 have_used_extensions
= 1;
1476 fputs ("@s", asmfile
);
1478 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1479 putc (';', asmfile
);
1482 /* Check if a bitstring type, which in Chill is
1483 different from a [power]set. */
1484 if (TYPE_STRING_FLAG (type
))
1486 fprintf (asmfile
, "@S;");
1490 putc ('S', asmfile
);
1492 dbxout_type (TYPE_DOMAIN (type
), 0);
1496 /* Make arrays of packed bits look like bitstrings for chill. */
1497 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1499 have_used_extensions
= 1;
1500 fputs ("@s", asmfile
);
1502 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1503 fprintf (asmfile
, ";@S;S");
1505 dbxout_type (TYPE_DOMAIN (type
), 0);
1509 /* Output "a" followed by a range type definition
1510 for the index type of the array
1511 followed by a reference to the target-type.
1512 ar1;0;N;M for a C array of type M and size N+1. */
1513 /* Check if a character string type, which in Chill is
1514 different from an array of characters. */
1515 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1517 have_used_extensions
= 1;
1518 fprintf (asmfile
, "@S;");
1521 tem
= TYPE_DOMAIN (type
);
1524 fprintf (asmfile
, "ar");
1526 dbxout_type_index (integer_type_node
);
1527 fprintf (asmfile
, ";0;-1;");
1532 fprintf (asmfile
, "a");
1534 dbxout_range_type (tem
);
1537 dbxout_type (TREE_TYPE (type
), 0);
1542 case QUAL_UNION_TYPE
:
1544 int i
, n_baseclasses
= 0;
1546 if (TYPE_BINFO (type
) != 0
1547 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1548 && TYPE_BINFO_BASETYPES (type
) != 0)
1549 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1551 /* Output a structure type. We must use the same test here as we
1552 use in the DBX_NO_XREFS case above. */
1553 if ((TYPE_NAME (type
) != 0
1554 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1555 && DECL_IGNORED_P (TYPE_NAME (type
)))
1557 || !COMPLETE_TYPE_P (type
)
1558 /* No way in DBX fmt to describe a variable size. */
1559 || ! host_integerp (TYPE_SIZE (type
), 1))
1561 /* If the type is just a cross reference, output one
1562 and mark the type as partially described.
1563 If it later becomes defined, we will output
1564 its real definition.
1565 If the type has a name, don't nest its definition within
1566 another type's definition; instead, output an xref
1567 and let the definition come when the name is defined. */
1568 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1570 #if 0 /* This assertion is legitimately false in C++. */
1571 /* We shouldn't be outputting a reference to a type before its
1572 definition unless the type has a tag name.
1573 A typedef name without a tag name should be impossible. */
1574 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1577 if (TYPE_NAME (type
) != 0)
1578 dbxout_type_name (type
);
1581 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1585 fprintf (asmfile
, ":");
1587 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1591 /* Identify record or union, and print its size. */
1592 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1594 print_wide_int (int_size_in_bytes (type
));
1596 if (use_gnu_debug_info_extensions
)
1600 have_used_extensions
= 1;
1601 fprintf (asmfile
, "!%d,", n_baseclasses
);
1605 for (i
= 0; i
< n_baseclasses
; i
++)
1607 tree binfo
= TYPE_BINFO (type
);
1608 tree child
= BINFO_BASETYPE (binfo
, i
);
1609 tree access
= (BINFO_BASEACCESSES (binfo
)
1610 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1612 if (use_gnu_debug_info_extensions
)
1614 have_used_extensions
= 1;
1615 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1616 putc (access
== access_public_node
? '2' : '0', asmfile
);
1618 if (TREE_VIA_VIRTUAL (child
)
1619 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1620 /* For a virtual base, print the (negative) offset within
1621 the vtable where we must look to find the necessary
1623 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1626 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1628 putc (',', asmfile
);
1630 dbxout_type (BINFO_TYPE (child
), 0);
1631 putc (';', asmfile
);
1636 /* Print out the base class information with fields
1637 which have the same names at the types they hold. */
1638 dbxout_type_name (BINFO_TYPE (child
));
1639 putc (':', asmfile
);
1641 dbxout_type (BINFO_TYPE (child
), full
);
1642 putc (',', asmfile
);
1644 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1646 putc (',', asmfile
);
1648 print_wide_int (tree_low_cst (DECL_SIZE
1650 (BINFO_TYPE (child
))),
1653 putc (';', asmfile
);
1659 /* Write out the field declarations. */
1660 dbxout_type_fields (type
);
1661 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1663 have_used_extensions
= 1;
1664 dbxout_type_methods (type
);
1667 putc (';', asmfile
);
1670 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1671 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1672 && TYPE_VFIELD (type
))
1674 have_used_extensions
= 1;
1676 /* Tell GDB+ that it may keep reading. */
1677 putc ('~', asmfile
);
1680 /* We need to write out info about what field this class
1681 uses as its "main" vtable pointer field, because if this
1682 field is inherited from a base class, GDB cannot necessarily
1683 figure out which field it's using in time. */
1684 if (TYPE_VFIELD (type
))
1686 putc ('%', asmfile
);
1688 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1691 putc (';', asmfile
);
1697 /* We must use the same test here as we use in the DBX_NO_XREFS case
1698 above. We simplify it a bit since an enum will never have a variable
1700 if ((TYPE_NAME (type
) != 0
1701 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1702 && DECL_IGNORED_P (TYPE_NAME (type
)))
1704 || !COMPLETE_TYPE_P (type
))
1706 fprintf (asmfile
, "xe");
1708 dbxout_type_name (type
);
1709 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1710 putc (':', asmfile
);
1714 if (use_gnu_debug_info_extensions
1715 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1717 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1721 putc ('e', asmfile
);
1723 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1725 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1726 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1727 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1728 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1729 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1730 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1731 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1733 print_int_cst_octal (TREE_VALUE (tem
));
1735 putc (',', asmfile
);
1737 if (TREE_CHAIN (tem
) != 0)
1741 putc (';', asmfile
);
1746 putc ('*', asmfile
);
1748 dbxout_type (TREE_TYPE (type
), 0);
1752 if (use_gnu_debug_info_extensions
)
1754 have_used_extensions
= 1;
1755 putc ('#', asmfile
);
1758 /* Write the argument types out longhand. */
1759 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1760 putc (',', asmfile
);
1762 dbxout_type (TREE_TYPE (type
), 0);
1763 dbxout_args (TYPE_ARG_TYPES (type
));
1764 putc (';', asmfile
);
1768 /* Treat it as a function type. */
1769 dbxout_type (TREE_TYPE (type
), 0);
1773 if (use_gnu_debug_info_extensions
)
1775 have_used_extensions
= 1;
1776 putc ('@', asmfile
);
1778 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1779 putc (',', asmfile
);
1781 dbxout_type (TREE_TYPE (type
), 0);
1784 /* Should print as an int, because it is really just an offset. */
1785 dbxout_type (integer_type_node
, 0);
1788 case REFERENCE_TYPE
:
1789 if (use_gnu_debug_info_extensions
)
1790 have_used_extensions
= 1;
1791 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1793 dbxout_type (TREE_TYPE (type
), 0);
1797 putc ('f', asmfile
);
1799 dbxout_type (TREE_TYPE (type
), 0);
1807 /* Return non-zero if the given type represents an integer whose bounds
1808 should be printed in octal format. */
1811 print_int_cst_bounds_in_octal_p (type
)
1814 /* If we can use GDB extensions and the size is wider than a long
1815 (the size used by GDB to read them) or we may have trouble writing
1816 the bounds the usual way, write them in octal. Note the test is for
1817 the *target's* size of "long", not that of the host. The host test
1818 is just to make sure we can write it out in case the host wide int
1819 is narrower than the target "long".
1821 For unsigned types, we use octal if they are the same size or larger.
1822 This is because we print the bounds as signed decimal, and hence they
1823 can't span same size unsigned types. */
1825 if (use_gnu_debug_info_extensions
1826 && TYPE_MIN_VALUE (type
) != 0
1827 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1828 && TYPE_MAX_VALUE (type
) != 0
1829 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1830 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1831 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1832 && TREE_UNSIGNED (type
))
1833 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1834 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1835 && TREE_UNSIGNED (type
))))
1841 /* Print the value of integer constant C, in octal,
1842 handling double precision. */
1845 print_int_cst_octal (c
)
1848 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1849 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1850 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1851 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1853 /* GDB wants constants with no extra leading "1" bits, so
1854 we need to remove any sign-extension that might be
1856 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1858 else if (width
> HOST_BITS_PER_WIDE_INT
)
1859 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1860 else if (width
== HOST_BITS_PER_WIDE_INT
)
1863 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1865 fprintf (asmfile
, "0");
1870 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1871 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1875 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1876 unsigned HOST_WIDE_INT middle
1877 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1878 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1879 unsigned HOST_WIDE_INT end
1880 = low
& (((unsigned HOST_WIDE_INT
) 1
1881 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1884 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1886 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1891 print_octal (value
, digits
)
1892 unsigned HOST_WIDE_INT value
;
1897 for (i
= digits
- 1; i
>= 0; i
--)
1898 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1903 /* Output C in decimal while adjusting the number of digits written. */
1911 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1922 /* Output the name of type TYPE, with no punctuation.
1923 Such names can be set up either by typedef declarations
1924 or by struct, enum and union tags. */
1927 dbxout_type_name (type
)
1931 if (TYPE_NAME (type
) == 0)
1933 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1935 t
= TYPE_NAME (type
);
1937 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1939 t
= DECL_NAME (TYPE_NAME (type
));
1944 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1945 CHARS (IDENTIFIER_LENGTH (t
));
1948 /* Output leading leading struct or class names needed for qualifying
1949 type whose scope is limited to a struct or class. */
1952 dbxout_class_name_qualifiers (decl
)
1955 tree context
= decl_type_context (decl
);
1957 if (context
!= NULL_TREE
1958 && TREE_CODE(context
) == RECORD_TYPE
1959 && TYPE_NAME (context
) != 0
1960 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
1961 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
1963 tree name
= TYPE_NAME (context
);
1965 if (TREE_CODE (name
) == TYPE_DECL
)
1967 dbxout_class_name_qualifiers (name
);
1968 name
= DECL_NAME (name
);
1970 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1971 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1975 /* Output a .stabs for the symbol defined by DECL,
1976 which must be a ..._DECL node in the normal namespace.
1977 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1978 LOCAL is nonzero if the scope is less than the entire file.
1979 Return 1 if a stabs might have been emitted. */
1982 dbxout_symbol (decl
, local
)
1984 int local ATTRIBUTE_UNUSED
;
1986 tree type
= TREE_TYPE (decl
);
1987 tree context
= NULL_TREE
;
1990 /* Cast avoids warning in old compilers. */
1991 current_sym_code
= (STAB_CODE_TYPE
) 0;
1992 current_sym_value
= 0;
1993 current_sym_addr
= 0;
1995 /* Ignore nameless syms, but don't ignore type tags. */
1997 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1998 || DECL_IGNORED_P (decl
))
2001 dbxout_prepare_symbol (decl
);
2003 /* The output will always start with the symbol name,
2004 so always count that in the length-output-so-far. */
2006 if (DECL_NAME (decl
) != 0)
2007 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2009 switch (TREE_CODE (decl
))
2012 /* Enum values are defined by defining the enum type. */
2016 if (DECL_RTL (decl
) == 0)
2018 if (DECL_EXTERNAL (decl
))
2020 /* Don't mention a nested function under its parent. */
2021 context
= decl_function_context (decl
);
2022 if (context
== current_function_decl
)
2024 if (GET_CODE (DECL_RTL (decl
)) != MEM
2025 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2029 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2030 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2031 TREE_PUBLIC (decl
) ? 'F' : 'f');
2034 current_sym_code
= N_FUN
;
2035 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2037 if (TREE_TYPE (type
))
2038 dbxout_type (TREE_TYPE (type
), 0);
2040 dbxout_type (void_type_node
, 0);
2042 /* For a nested function, when that function is compiled,
2043 mention the containing function name
2044 as well as (since dbx wants it) our own assembler-name. */
2046 fprintf (asmfile
, ",%s,%s",
2047 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2048 IDENTIFIER_POINTER (DECL_NAME (context
)));
2050 dbxout_finish_symbol (decl
);
2055 /* This seems all wrong. Outputting most kinds of types gives no name
2056 at all. A true definition gives no name; a cross-ref for a
2057 structure can give the tag name, but not a type name.
2058 It seems that no typedef name is defined by outputting a type. */
2060 /* If this typedef name was defined by outputting the type,
2061 don't duplicate it. */
2062 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
2063 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
2066 /* Don't output the same typedef twice.
2067 And don't output what language-specific stuff doesn't want output. */
2068 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2077 if (DECL_NAME (decl
))
2079 /* Nonzero means we must output a tag as well as a typedef. */
2082 /* Handle the case of a C++ structure or union
2083 where the TYPE_NAME is a TYPE_DECL
2084 which gives both a typedef name and a tag. */
2085 /* dbx requires the tag first and the typedef second. */
2086 if ((TREE_CODE (type
) == RECORD_TYPE
2087 || TREE_CODE (type
) == UNION_TYPE
2088 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2089 && TYPE_NAME (type
) == decl
2090 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2091 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2092 /* Distinguish the implicit typedefs of C++
2093 from explicit ones that might be found in C. */
2094 && DECL_ARTIFICIAL (decl
)
2095 /* Do not generate a tag for records of variable size,
2096 since this type can not be properly described in the
2097 DBX format, and it confuses some tools such as objdump. */
2098 && host_integerp (TYPE_SIZE (type
), 1))
2100 tree name
= TYPE_NAME (type
);
2101 if (TREE_CODE (name
) == TYPE_DECL
)
2102 name
= DECL_NAME (name
);
2104 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2105 current_sym_value
= 0;
2106 current_sym_addr
= 0;
2107 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2109 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2110 IDENTIFIER_POINTER (name
));
2111 dbxout_type (type
, 1);
2112 dbxout_finish_symbol (NULL_TREE
);
2115 /* Output .stabs (or whatever) and leading double quote. */
2116 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2118 if (use_gnu_debug_info_extensions
)
2120 /* Output leading class/struct qualifiers. */
2121 dbxout_class_name_qualifiers (decl
);
2124 /* Output typedef name. */
2125 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2127 /* Short cut way to output a tag also. */
2128 if ((TREE_CODE (type
) == RECORD_TYPE
2129 || TREE_CODE (type
) == UNION_TYPE
2130 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2131 && TYPE_NAME (type
) == decl
2132 /* Distinguish the implicit typedefs of C++
2133 from explicit ones that might be found in C. */
2134 && DECL_ARTIFICIAL (decl
))
2136 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2138 putc ('T', asmfile
);
2139 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2141 #if 0 /* Now we generate the tag for this case up above. */
2147 putc ('t', asmfile
);
2148 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2150 dbxout_type (type
, 1);
2151 dbxout_finish_symbol (decl
);
2155 /* Don't output a tag if this is an incomplete type. This prevents
2156 the sun4 Sun OS 4.x dbx from crashing. */
2158 if (tag_needed
&& TYPE_NAME (type
) != 0
2159 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2160 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2161 && COMPLETE_TYPE_P (type
)
2162 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2164 /* For a TYPE_DECL with no name, but the type has a name,
2166 This is what represents `struct foo' with no typedef. */
2167 /* In C++, the name of a type is the corresponding typedef.
2168 In C, it is an IDENTIFIER_NODE. */
2169 tree name
= TYPE_NAME (type
);
2170 if (TREE_CODE (name
) == TYPE_DECL
)
2171 name
= DECL_NAME (name
);
2173 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2174 current_sym_value
= 0;
2175 current_sym_addr
= 0;
2176 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2178 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2179 IDENTIFIER_POINTER (name
));
2180 dbxout_type (type
, 1);
2181 dbxout_finish_symbol (NULL_TREE
);
2185 /* If an enum type has no name, it cannot be referred to,
2186 but we must output it anyway, since the enumeration constants
2187 can be referred to. */
2188 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2190 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2191 current_sym_value
= 0;
2192 current_sym_addr
= 0;
2193 current_sym_nchars
= 2;
2195 /* Some debuggers fail when given NULL names, so give this a
2196 harmless name of ` '. */
2197 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2198 dbxout_type (type
, 1);
2199 dbxout_finish_symbol (NULL_TREE
);
2202 /* Prevent duplicate output of a typedef. */
2203 TREE_ASM_WRITTEN (decl
) = 1;
2208 /* Parm decls go in their own separate chains
2209 and are output by dbxout_reg_parms and dbxout_parms. */
2213 /* Named return value, treat like a VAR_DECL. */
2215 if (! DECL_RTL_SET_P (decl
))
2217 /* Don't mention a variable that is external.
2218 Let the file that defines it describe it. */
2219 if (DECL_EXTERNAL (decl
))
2222 /* If the variable is really a constant
2223 and not written in memory, inform the debugger. */
2224 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2225 && DECL_INITIAL (decl
) != 0
2226 && host_integerp (DECL_INITIAL (decl
), 0)
2227 && ! TREE_ASM_WRITTEN (decl
)
2228 && (DECL_CONTEXT (decl
) == NULL_TREE
2229 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2231 if (TREE_PUBLIC (decl
) == 0)
2233 /* The sun4 assembler does not grok this. */
2234 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2236 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2237 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2239 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2240 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2242 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2245 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2247 /* don't know how to do this yet. */
2251 /* else it is something we handle like a normal variable. */
2254 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2255 #ifdef LEAF_REG_REMAP
2256 if (current_function_uses_only_leaf_regs
)
2257 leaf_renumber_regs_insn (DECL_RTL (decl
));
2260 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2269 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2270 Add SUFFIX to its name, if SUFFIX is not 0.
2271 Describe the variable as residing in HOME
2272 (usually HOME is DECL_RTL (DECL), but not always).
2273 Returns 1 if the stab was really emitted. */
2276 dbxout_symbol_location (decl
, type
, suffix
, home
)
2284 /* Don't mention a variable at all
2285 if it was completely optimized into nothingness.
2287 If the decl was from an inline function, then its rtl
2288 is not identically the rtl that was used in this
2289 particular compilation. */
2290 if (GET_CODE (home
) == SUBREG
)
2294 while (GET_CODE (value
) == SUBREG
)
2295 value
= SUBREG_REG (value
);
2296 if (GET_CODE (value
) == REG
)
2298 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2301 home
= alter_subreg (&home
);
2303 if (GET_CODE (home
) == REG
)
2305 regno
= REGNO (home
);
2306 if (regno
>= FIRST_PSEUDO_REGISTER
)
2310 /* The kind-of-variable letter depends on where
2311 the variable is and on the scope of its name:
2312 G and N_GSYM for static storage and global scope,
2313 S for static storage and file scope,
2314 V for static storage and local scope,
2315 for those two, use N_LCSYM if data is in bss segment,
2316 N_STSYM if in data segment, N_FUN otherwise.
2317 (We used N_FUN originally, then changed to N_STSYM
2318 to please GDB. However, it seems that confused ld.
2319 Now GDB has been fixed to like N_FUN, says Kingdon.)
2320 no letter at all, and N_LSYM, for auto variable,
2321 r and N_RSYM for register variable. */
2323 if (GET_CODE (home
) == MEM
2324 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2326 if (TREE_PUBLIC (decl
))
2329 current_sym_code
= N_GSYM
;
2333 current_sym_addr
= XEXP (home
, 0);
2335 letter
= decl_function_context (decl
) ? 'V' : 'S';
2337 /* This should be the same condition as in assemble_variable, but
2338 we don't have access to dont_output_data here. So, instead,
2339 we rely on the fact that error_mark_node initializers always
2340 end up in bss for C++ and never end up in bss for C. */
2341 if (DECL_INITIAL (decl
) == 0
2342 || (!strcmp (lang_hooks
.name
, "GNU C++")
2343 && DECL_INITIAL (decl
) == error_mark_node
))
2344 current_sym_code
= N_LCSYM
;
2345 else if (DECL_IN_TEXT_SECTION (decl
))
2346 /* This is not quite right, but it's the closest
2347 of all the codes that Unix defines. */
2348 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2351 /* Some ports can transform a symbol ref into a label ref,
2352 because the symbol ref is too far away and has to be
2353 dumped into a constant pool. Alternatively, the symbol
2354 in the constant pool might be referenced by a different
2356 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2357 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2359 rtx tmp
= get_pool_constant (current_sym_addr
);
2361 if (GET_CODE (tmp
) == SYMBOL_REF
2362 || GET_CODE (tmp
) == LABEL_REF
)
2363 current_sym_addr
= tmp
;
2366 /* Ultrix `as' seems to need this. */
2367 #ifdef DBX_STATIC_STAB_DATA_SECTION
2370 current_sym_code
= N_STSYM
;
2374 else if (regno
>= 0)
2377 current_sym_code
= N_RSYM
;
2378 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2380 else if (GET_CODE (home
) == MEM
2381 && (GET_CODE (XEXP (home
, 0)) == MEM
2382 || (GET_CODE (XEXP (home
, 0)) == REG
2383 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2384 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2385 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2386 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2389 /* If the value is indirect by memory or by a register
2390 that isn't the frame pointer
2391 then it means the object is variable-sized and address through
2392 that register or stack slot. DBX has no way to represent this
2393 so all we can do is output the variable as a pointer.
2394 If it's not a parameter, ignore it.
2395 (VAR_DECLs like this can be made by integrate.c.) */
2397 if (GET_CODE (XEXP (home
, 0)) == REG
)
2400 current_sym_code
= N_RSYM
;
2401 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2403 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2407 current_sym_code
= N_LSYM
;
2408 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2409 We want the value of that CONST_INT. */
2411 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2414 /* Effectively do build_pointer_type, but don't cache this type,
2415 since it might be temporary whereas the type it points to
2416 might have been saved for inlining. */
2417 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2418 type
= make_node (POINTER_TYPE
);
2419 TREE_TYPE (type
) = TREE_TYPE (decl
);
2421 else if (GET_CODE (home
) == MEM
2422 && GET_CODE (XEXP (home
, 0)) == REG
)
2424 current_sym_code
= N_LSYM
;
2425 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2427 else if (GET_CODE (home
) == MEM
2428 && GET_CODE (XEXP (home
, 0)) == PLUS
2429 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2431 current_sym_code
= N_LSYM
;
2432 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2433 We want the value of that CONST_INT. */
2434 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2436 else if (GET_CODE (home
) == MEM
2437 && GET_CODE (XEXP (home
, 0)) == CONST
)
2439 /* Handle an obscure case which can arise when optimizing and
2440 when there are few available registers. (This is *always*
2441 the case for i386/i486 targets). The RTL looks like
2442 (MEM (CONST ...)) even though this variable is a local `auto'
2443 or a local `register' variable. In effect, what has happened
2444 is that the reload pass has seen that all assignments and
2445 references for one such a local variable can be replaced by
2446 equivalent assignments and references to some static storage
2447 variable, thereby avoiding the need for a register. In such
2448 cases we're forced to lie to debuggers and tell them that
2449 this variable was itself `static'. */
2450 current_sym_code
= N_LCSYM
;
2452 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2454 else if (GET_CODE (home
) == CONCAT
)
2458 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2459 for example), then there is no easy way to figure out
2460 what SUBTYPE should be. So, we give up. */
2461 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2464 subtype
= TREE_TYPE (type
);
2466 /* If the variable's storage is in two parts,
2467 output each as a separate stab with a modified name. */
2468 if (WORDS_BIG_ENDIAN
)
2469 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2471 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2473 /* Cast avoids warning in old compilers. */
2474 current_sym_code
= (STAB_CODE_TYPE
) 0;
2475 current_sym_value
= 0;
2476 current_sym_addr
= 0;
2477 dbxout_prepare_symbol (decl
);
2479 if (WORDS_BIG_ENDIAN
)
2480 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2482 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2486 /* Address might be a MEM, when DECL is a variable-sized object.
2487 Or it might be const0_rtx, meaning previous passes
2488 want us to ignore this variable. */
2491 /* Ok, start a symtab entry and output the variable name. */
2494 #ifdef DBX_STATIC_BLOCK_START
2495 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2498 dbxout_symbol_name (decl
, suffix
, letter
);
2499 dbxout_type (type
, 0);
2500 dbxout_finish_symbol (decl
);
2502 #ifdef DBX_STATIC_BLOCK_END
2503 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2508 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2509 Then output LETTER to indicate the kind of location the symbol has. */
2512 dbxout_symbol_name (decl
, suffix
, letter
)
2519 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2520 /* One slight hitch: if this is a VAR_DECL which is a static
2521 class member, we must put out the mangled name instead of the
2522 DECL_NAME. Note also that static member (variable) names DO NOT begin
2523 with underscores in .stabs directives. */
2524 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2526 /* ...but if we're function-local, we don't want to include the junk
2527 added by ASM_FORMAT_PRIVATE_NAME. */
2528 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2532 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2533 (suffix
? suffix
: ""));
2536 putc (letter
, asmfile
);
2540 dbxout_prepare_symbol (decl
)
2541 tree decl ATTRIBUTE_UNUSED
;
2544 const char *filename
= DECL_SOURCE_FILE (decl
);
2546 dbxout_source_file (asmfile
, filename
);
2551 dbxout_finish_symbol (sym
)
2554 #ifdef DBX_FINISH_SYMBOL
2555 DBX_FINISH_SYMBOL (sym
);
2558 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2559 line
= DECL_SOURCE_LINE (sym
);
2561 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2562 if (current_sym_addr
)
2563 output_addr_const (asmfile
, current_sym_addr
);
2565 fprintf (asmfile
, "%d", current_sym_value
);
2566 putc ('\n', asmfile
);
2570 /* Output definitions of all the decls in a chain. Return nonzero if
2571 anything was output */
2580 result
+= dbxout_symbol (syms
, 1);
2581 syms
= TREE_CHAIN (syms
);
2586 /* The following two functions output definitions of function parameters.
2587 Each parameter gets a definition locating it in the parameter list.
2588 Each parameter that is a register variable gets a second definition
2589 locating it in the register.
2591 Printing or argument lists in gdb uses the definitions that
2592 locate in the parameter list. But reference to the variable in
2593 expressions uses preferentially the definition as a register. */
2595 /* Output definitions, referring to storage in the parmlist,
2596 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2599 dbxout_parms (parms
)
2602 for (; parms
; parms
= TREE_CHAIN (parms
))
2603 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2605 dbxout_prepare_symbol (parms
);
2607 /* Perform any necessary register eliminations on the parameter's rtl,
2608 so that the debugging output will be accurate. */
2609 DECL_INCOMING_RTL (parms
)
2610 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2611 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2612 #ifdef LEAF_REG_REMAP
2613 if (current_function_uses_only_leaf_regs
)
2615 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2616 leaf_renumber_regs_insn (DECL_RTL (parms
));
2620 if (PARM_PASSED_IN_MEMORY (parms
))
2622 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2624 /* ??? Here we assume that the parm address is indexed
2625 off the frame pointer or arg pointer.
2626 If that is not true, we produce meaningless results,
2627 but do not crash. */
2628 if (GET_CODE (addr
) == PLUS
2629 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2630 current_sym_value
= INTVAL (XEXP (addr
, 1));
2632 current_sym_value
= 0;
2634 current_sym_code
= N_PSYM
;
2635 current_sym_addr
= 0;
2638 if (DECL_NAME (parms
))
2640 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2642 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2643 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2644 DBX_MEMPARM_STABS_LETTER
);
2648 current_sym_nchars
= 8;
2649 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2650 DBX_MEMPARM_STABS_LETTER
);
2653 /* It is quite tempting to use:
2655 dbxout_type (TREE_TYPE (parms), 0);
2657 as the next statement, rather than using DECL_ARG_TYPE(), so
2658 that gcc reports the actual type of the parameter, rather
2659 than the promoted type. This certainly makes GDB's life
2660 easier, at least for some ports. The change is a bad idea
2661 however, since GDB expects to be able access the type without
2662 performing any conversions. So for example, if we were
2663 passing a float to an unprototyped function, gcc will store a
2664 double on the stack, but if we emit a stab saying the type is a
2665 float, then gdb will only read in a single value, and this will
2666 produce an erroneous value. */
2667 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2668 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2669 dbxout_finish_symbol (parms
);
2671 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2674 char regparm_letter
;
2676 /* Parm passed in registers and lives in registers or nowhere. */
2678 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2679 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2680 current_sym_addr
= 0;
2682 /* If parm lives in a register, use that register;
2683 pretend the parm was passed there. It would be more consistent
2684 to describe the register where the parm was passed,
2685 but in practice that register usually holds something else.
2687 If we use DECL_RTL, then we must use the declared type of
2688 the variable, not the type that it arrived in. */
2689 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2691 best_rtl
= DECL_RTL (parms
);
2692 parm_type
= TREE_TYPE (parms
);
2694 /* If the parm lives nowhere, use the register where it was
2695 passed. It is also better to use the declared type here. */
2698 best_rtl
= DECL_INCOMING_RTL (parms
);
2699 parm_type
= TREE_TYPE (parms
);
2701 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2704 if (DECL_NAME (parms
))
2706 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2707 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2708 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2713 current_sym_nchars
= 8;
2714 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2718 dbxout_type (parm_type
, 0);
2719 dbxout_finish_symbol (parms
);
2721 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2722 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2723 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2724 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2725 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2726 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2730 /* Parm was passed via invisible reference.
2731 That is, its address was passed in a register.
2732 Output it as if it lived in that register.
2733 The debugger will know from the type
2734 that it was actually passed by invisible reference. */
2736 char regparm_letter
;
2737 /* Parm passed in registers and lives in registers or nowhere. */
2739 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2740 if (use_gnu_debug_info_extensions
)
2741 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2743 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2745 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2746 If it is an unallocated pseudo-reg, then use the register where
2747 it was passed instead. */
2748 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2749 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2751 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2753 current_sym_addr
= 0;
2756 if (DECL_NAME (parms
))
2759 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2761 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2762 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2767 current_sym_nchars
= 8;
2768 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2772 dbxout_type (TREE_TYPE (parms
), 0);
2773 dbxout_finish_symbol (parms
);
2775 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2776 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2778 /* Parm was passed via invisible reference, with the reference
2779 living on the stack. DECL_RTL looks like
2780 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2781 could look like (MEM (MEM (REG))). */
2782 const char *const decl_name
= (DECL_NAME (parms
)
2783 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2785 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2786 current_sym_value
= 0;
2789 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2790 current_sym_addr
= 0;
2791 current_sym_code
= N_PSYM
;
2794 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2797 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2798 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2799 dbxout_type (TREE_TYPE (parms
), 0);
2800 dbxout_finish_symbol (parms
);
2802 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2803 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2804 /* ??? A constant address for a parm can happen
2805 when the reg it lives in is equiv to a constant in memory.
2806 Should make this not happen, after 2.4. */
2807 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2809 /* Parm was passed in registers but lives on the stack. */
2811 current_sym_code
= N_PSYM
;
2812 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2813 in which case we want the value of that CONST_INT,
2815 in which case we use a value of zero. */
2816 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2817 current_sym_value
= 0;
2820 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2822 current_sym_addr
= 0;
2824 /* Make a big endian correction if the mode of the type of the
2825 parameter is not the same as the mode of the rtl. */
2826 if (BYTES_BIG_ENDIAN
2827 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2828 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2830 current_sym_value
+=
2831 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2832 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2836 if (DECL_NAME (parms
))
2839 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2841 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2842 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2843 DBX_MEMPARM_STABS_LETTER
);
2847 current_sym_nchars
= 8;
2848 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2849 DBX_MEMPARM_STABS_LETTER
);
2853 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2854 XEXP (DECL_RTL (parms
), 0));
2855 dbxout_type (TREE_TYPE (parms
), 0);
2856 dbxout_finish_symbol (parms
);
2861 /* Output definitions for the places where parms live during the function,
2862 when different from where they were passed, when the parms were passed
2865 It is not useful to do this for parms passed in registers
2866 that live during the function in different registers, because it is
2867 impossible to look in the passed register for the passed value,
2868 so we use the within-the-function register to begin with.
2870 PARMS is a chain of PARM_DECL nodes. */
2873 dbxout_reg_parms (parms
)
2876 for (; parms
; parms
= TREE_CHAIN (parms
))
2877 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2879 dbxout_prepare_symbol (parms
);
2881 /* Report parms that live in registers during the function
2882 but were passed in memory. */
2883 if (GET_CODE (DECL_RTL (parms
)) == REG
2884 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2885 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2886 0, DECL_RTL (parms
));
2887 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2888 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2889 0, DECL_RTL (parms
));
2890 /* Report parms that live in memory but not where they were passed. */
2891 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2892 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2893 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2894 0, DECL_RTL (parms
));
2898 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2899 output definitions of those names, in raw form */
2907 putc (',', asmfile
);
2908 dbxout_type (TREE_VALUE (args
), 0);
2910 args
= TREE_CHAIN (args
);
2914 /* Output everything about a symbol block (a BLOCK node
2915 that represents a scope level),
2916 including recursive output of contained blocks.
2918 BLOCK is the BLOCK node.
2919 DEPTH is its depth within containing symbol blocks.
2920 ARGS is usually zero; but for the outermost block of the
2921 body of a function, it is a chain of PARM_DECLs for the function parameters.
2922 We output definitions of all the register parms
2923 as if they were local variables of that block.
2925 If -g1 was used, we count blocks just the same, but output nothing
2926 except for the outermost block.
2928 Actually, BLOCK may be several blocks chained together.
2929 We handle them all in sequence. */
2932 dbxout_block (block
, depth
, args
)
2939 #if DBX_BLOCKS_FUNCTION_RELATIVE
2940 const char *begin_label
;
2941 if (current_function_func_begin_label
!= NULL_TREE
)
2942 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
2944 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
2949 /* Ignore blocks never expanded or otherwise marked as real. */
2950 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
2954 /* In dbx format, the syms of a block come before the N_LBRAC.
2955 If nothing is output, we don't need the N_LBRAC, either. */
2957 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2958 did_output
= dbxout_syms (BLOCK_VARS (block
));
2960 dbxout_reg_parms (args
);
2962 /* Now output an N_LBRAC symbol to represent the beginning of
2963 the block. Use the block's tree-walk order to generate
2964 the assembler symbols LBBn and LBEn
2965 that final will define around the code in this block. */
2966 if (depth
> 0 && did_output
)
2969 blocknum
= BLOCK_NUMBER (block
);
2970 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2972 if (BLOCK_HANDLER_BLOCK (block
))
2974 /* A catch block. Must precede N_LBRAC. */
2975 tree decl
= BLOCK_VARS (block
);
2978 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2979 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2980 assemble_name (asmfile
, buf
);
2981 fprintf (asmfile
, "\n");
2982 decl
= TREE_CHAIN (decl
);
2986 #ifdef DBX_OUTPUT_LBRAC
2987 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2989 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2990 assemble_name (asmfile
, buf
);
2991 #if DBX_BLOCKS_FUNCTION_RELATIVE
2992 putc ('-', asmfile
);
2993 assemble_name (asmfile
, begin_label
);
2995 fprintf (asmfile
, "\n");
2999 /* Output the subblocks. */
3000 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3002 /* Refer to the marker for the end of the block. */
3003 if (depth
> 0 && did_output
)
3006 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3007 #ifdef DBX_OUTPUT_RBRAC
3008 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3010 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3011 assemble_name (asmfile
, buf
);
3012 #if DBX_BLOCKS_FUNCTION_RELATIVE
3013 putc ('-', asmfile
);
3014 assemble_name (asmfile
, begin_label
);
3016 fprintf (asmfile
, "\n");
3020 block
= BLOCK_CHAIN (block
);
3024 /* Output the information about a function and its arguments and result.
3025 Usually this follows the function's code,
3026 but on some systems, it comes before. */
3028 #if defined (DBX_DEBUGGING_INFO)
3030 dbxout_begin_function (decl
)
3033 dbxout_symbol (decl
, 0);
3034 dbxout_parms (DECL_ARGUMENTS (decl
));
3035 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3036 dbxout_symbol (DECL_RESULT (decl
), 1);
3038 #endif /* DBX_DEBUGGING_INFO */
3040 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3042 #include "gt-dbxout.h"