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
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103 do {--debug_nesting; return (x);} while (0)
106 #define ASM_STABS_OP "\t.stabs\t"
110 #define ASM_STABN_OP "\t.stabn\t"
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
129 /* This is used for parameters passed by invisible reference in a register. */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
142 /* GDB needs to know that the stabs were generated by GCC. We emit an
143 N_OPT stab at the beginning of the source file to indicate this.
144 The string is historical, and different on a very few targets. */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
149 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
151 /* Structure recording information about a C data type.
152 The status element says whether we have yet output
153 the definition of the type. TYPE_XREF says we have
154 output it as a cross-reference only.
155 The file_number and type_number elements are used if DBX_USE_BINCL
158 struct typeinfo
GTY(())
160 enum typestatus status
;
165 /* Vector recording information about C data types.
166 When we first notice a data type (a tree node),
167 we assign it a number using next_type_number.
168 That is its index in this vector. */
170 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
172 /* Number of elements of space allocated in `typevec'. */
174 static GTY(()) int typevec_len
;
176 /* In dbx output, each type gets a unique number.
177 This is the number for the next type output.
178 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
180 static GTY(()) int next_type_number
;
182 enum binclstatus
{BINCL_NOT_REQUIRED
, BINCL_PENDING
, BINCL_PROCESSED
};
184 /* When using N_BINCL in dbx output, each type number is actually a
185 pair of the file number and the type number within the file.
186 This is a stack of input files. */
190 struct dbx_file
*next
;
192 int next_type_number
;
193 enum binclstatus bincl_status
; /* Keep track of lazy bincl. */
194 const char *pending_bincl_name
; /* Name of bincl. */
195 struct dbx_file
*prev
; /* Chain to traverse all pending bincls. */
198 /* This is the top of the stack.
200 This is not saved for PCH, because restoring a PCH should not change it.
201 next_file_number does have to be saved, because the PCH may use some
202 file numbers; however, just before restoring a PCH, next_file_number
203 should always be 0 because we should not have needed any file numbers
206 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
207 && defined (DBX_USE_BINCL)
208 static struct dbx_file
*current_file
;
211 /* This is the next file number to use. */
213 static GTY(()) int next_file_number
;
215 /* A counter for dbxout_function_end. */
217 static GTY(()) int scope_labelno
;
219 /* A counter for dbxout_source_line. */
221 static GTY(()) int dbxout_source_line_counter
;
223 /* Nonzero if we have actually used any of the GDB extensions
224 to the debugging format. The idea is that we use them for the
225 first time only if there's a strong reason, but once we have done that,
226 we use them whenever convenient. */
228 static GTY(()) int have_used_extensions
= 0;
230 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
231 for the N_SO filename stabs label. */
233 static GTY(()) int source_label_number
= 1;
235 /* Last source file name mentioned in a NOTE insn. */
237 static GTY(()) const char *lastfile
;
239 /* Used by PCH machinery to detect if 'lastfile' should be reset to
241 static GTY(()) int lastfile_is_base
;
243 /* Typical USG systems don't have stab.h, and they also have
244 no use for DBX-format debugging info. */
246 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
249 /* If zero then there is no pending BINCL. */
250 static int pending_bincls
= 0;
253 /* The original input file name. */
254 static const char *base_input_file
;
256 /* Current working directory. */
258 static const char *cwd
;
260 #ifdef DEBUG_SYMS_TEXT
261 #define FORCE_TEXT function_section (current_function_decl);
268 #define STAB_CODE_TYPE enum __stab_debug_code
270 /* 1 if PARM is passed to this function in memory. */
272 #define PARM_PASSED_IN_MEMORY(PARM) \
273 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
275 /* A C expression for the integer offset value of an automatic variable
276 (N_LSYM) having address X (an RTX). */
277 #ifndef DEBUGGER_AUTO_OFFSET
278 #define DEBUGGER_AUTO_OFFSET(X) \
279 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
282 /* A C expression for the integer offset value of an argument (N_PSYM)
283 having address X (an RTX). The nominal offset is OFFSET. */
284 #ifndef DEBUGGER_ARG_OFFSET
285 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
288 /* Stream for writing to assembler file. */
290 static FILE *asmfile
;
292 /* These variables are for dbxout_symbol to communicate to
293 dbxout_finish_symbol.
294 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
295 current_sym_value and current_sym_addr are two ways to address the
296 value to store in the symtab entry.
297 current_sym_addr if nonzero represents the value as an rtx.
298 If that is zero, current_sym_value is used. This is used
299 when the value is an offset (such as for auto variables,
300 register variables and parms). */
302 static STAB_CODE_TYPE current_sym_code
;
303 static int current_sym_value
;
304 static rtx current_sym_addr
;
306 /* Number of chars of symbol-description generated so far for the
307 current symbol. Used by CHARS and CONTIN. */
309 static int current_sym_nchars
;
311 /* Report having output N chars of the current symbol-description. */
313 #define CHARS(N) (current_sym_nchars += (N))
315 /* Break the current symbol-description, generating a continuation,
316 if it has become long. */
318 #ifndef DBX_CONTIN_LENGTH
319 #define DBX_CONTIN_LENGTH 80
322 #if DBX_CONTIN_LENGTH > 0
324 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
326 #define CONTIN do { } while (0)
330 static void emit_bincl_stab (const char *c
);
331 static void emit_pending_bincls (void);
333 static inline void emit_pending_bincls_if_required (void);
335 static void dbxout_init (const char *);
336 static void dbxout_finish (const char *);
337 static void dbxout_start_source_file (unsigned, const char *);
338 static void dbxout_end_source_file (unsigned);
339 static void dbxout_typedefs (tree
);
340 static void dbxout_type_index (tree
);
341 #if DBX_CONTIN_LENGTH > 0
342 static void dbxout_continue (void);
344 static void dbxout_args (tree
);
345 static void dbxout_type_fields (tree
);
346 static void dbxout_type_method_1 (tree
, const char *);
347 static void dbxout_type_methods (tree
);
348 static void dbxout_range_type (tree
);
349 static void dbxout_type (tree
, int);
350 static bool print_int_cst_bounds_in_octal_p (tree
);
351 static void print_int_cst_octal (tree
);
352 static void print_octal (unsigned HOST_WIDE_INT
, int);
353 static void print_wide_int (HOST_WIDE_INT
);
354 static void dbxout_type_name (tree
);
355 static void dbxout_class_name_qualifiers (tree
);
356 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
357 static void dbxout_symbol_name (tree
, const char *, int);
358 static void dbxout_prepare_symbol (tree
);
359 static void dbxout_finish_symbol (tree
);
360 static void dbxout_block (tree
, int, tree
);
361 static void dbxout_global_decl (tree
);
362 static void dbxout_handle_pch (unsigned);
364 /* The debug hooks structure. */
365 #if defined (DBX_DEBUGGING_INFO)
367 static void dbxout_source_line (unsigned int, const char *);
368 static void dbxout_source_file (FILE *, const char *);
369 static void dbxout_function_end (void);
370 static void dbxout_begin_function (tree
);
371 static void dbxout_begin_block (unsigned, unsigned);
372 static void dbxout_end_block (unsigned, unsigned);
373 static void dbxout_function_decl (tree
);
375 const struct gcc_debug_hooks dbx_debug_hooks
=
379 debug_nothing_int_charstar
,
380 debug_nothing_int_charstar
,
381 dbxout_start_source_file
,
382 dbxout_end_source_file
,
385 debug_true_tree
, /* ignore_block */
386 dbxout_source_line
, /* source_line */
387 dbxout_source_line
, /* begin_prologue: just output line info */
388 debug_nothing_int_charstar
, /* end_prologue */
389 debug_nothing_int_charstar
, /* end_epilogue */
390 #ifdef DBX_FUNCTION_FIRST
391 dbxout_begin_function
,
393 debug_nothing_tree
, /* begin_function */
395 debug_nothing_int
, /* end_function */
396 dbxout_function_decl
,
397 dbxout_global_decl
, /* global_decl */
398 debug_nothing_tree
, /* deferred_inline_function */
399 debug_nothing_tree
, /* outlining_inline_function */
400 debug_nothing_rtx
, /* label */
401 dbxout_handle_pch
/* handle_pch */
403 #endif /* DBX_DEBUGGING_INFO */
405 #if defined (XCOFF_DEBUGGING_INFO)
406 const struct gcc_debug_hooks xcoff_debug_hooks
=
410 debug_nothing_int_charstar
,
411 debug_nothing_int_charstar
,
412 dbxout_start_source_file
,
413 dbxout_end_source_file
,
414 xcoffout_begin_block
,
416 debug_true_tree
, /* ignore_block */
417 xcoffout_source_line
,
418 xcoffout_begin_prologue
, /* begin_prologue */
419 debug_nothing_int_charstar
, /* end_prologue */
420 xcoffout_end_epilogue
,
421 debug_nothing_tree
, /* begin_function */
422 xcoffout_end_function
,
423 debug_nothing_tree
, /* function_decl */
424 dbxout_global_decl
, /* global_decl */
425 debug_nothing_tree
, /* deferred_inline_function */
426 debug_nothing_tree
, /* outlining_inline_function */
427 debug_nothing_rtx
, /* label */
428 dbxout_handle_pch
/* handle_pch */
430 #endif /* XCOFF_DEBUGGING_INFO */
432 #if defined (DBX_DEBUGGING_INFO)
434 dbxout_function_end (void)
436 char lscope_label_name
[100];
437 /* Convert Ltext into the appropriate format for local labels in case
438 the system doesn't insert underscores in front of user generated
440 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
441 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
444 /* By convention, GCC will mark the end of a function with an N_FUN
445 symbol and an empty string. */
446 #ifdef DBX_OUTPUT_NFUN
447 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
449 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
450 assemble_name (asmfile
, lscope_label_name
);
452 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
453 fprintf (asmfile
, "\n");
456 #endif /* DBX_DEBUGGING_INFO */
458 /* At the beginning of compilation, start writing the symbol table.
459 Initialize `typevec' and output the standard data types of C. */
462 dbxout_init (const char *input_file_name
)
464 char ltext_label_name
[100];
465 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
467 asmfile
= asm_out_file
;
470 typevec
= ggc_calloc (typevec_len
, sizeof typevec
[0]);
472 /* Convert Ltext into the appropriate format for local labels in case
473 the system doesn't insert underscores in front of user generated
475 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
477 /* Put the current working directory in an N_SO symbol. */
478 if (use_gnu_debug_info_extensions
)
480 if (!cwd
&& (cwd
= get_src_pwd ())
481 && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
482 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
485 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
486 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
487 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
488 fprintf (asmfile
, "%s", ASM_STABS_OP
);
489 output_quoted_string (asmfile
, cwd
);
490 fprintf (asmfile
, ",%d,0,0,", N_SO
);
491 assemble_name (asmfile
, ltext_label_name
);
492 fputc ('\n', asmfile
);
493 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
497 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
498 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
499 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
500 /* We include outputting `Ltext:' here,
501 because that gives you a way to override it. */
502 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
503 fprintf (asmfile
, "%s", ASM_STABS_OP
);
504 output_quoted_string (asmfile
, input_file_name
);
505 fprintf (asmfile
, ",%d,0,0,", N_SO
);
506 assemble_name (asmfile
, ltext_label_name
);
507 fputc ('\n', asmfile
);
509 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
510 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
512 #ifdef DBX_OUTPUT_GCC_MARKER
513 DBX_OUTPUT_GCC_MARKER (asmfile
);
515 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
516 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
517 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
520 base_input_file
= lastfile
= input_file_name
;
522 next_type_number
= 1;
525 current_file
= xmalloc (sizeof *current_file
);
526 current_file
->next
= NULL
;
527 current_file
->file_number
= 0;
528 current_file
->next_type_number
= 1;
529 next_file_number
= 1;
530 current_file
->prev
= NULL
;
531 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
532 current_file
->pending_bincl_name
= NULL
;
535 /* Make sure that types `int' and `char' have numbers 1 and 2.
536 Definitions of other integer types will refer to those numbers.
537 (Actually it should no longer matter what their numbers are.
538 Also, if any types with tags have been defined, dbxout_symbol
539 will output them first, so the numbers won't be 1 and 2. That
540 happens in C++. So it's a good thing it should no longer matter). */
542 #ifdef DBX_OUTPUT_STANDARD_TYPES
543 DBX_OUTPUT_STANDARD_TYPES (syms
);
546 /* Get all permanent types that have typedef names, and output them
547 all, except for those already output. Some language front ends
548 put these declarations in the top-level scope; some do not. */
549 dbxout_typedefs ((*lang_hooks
.decls
.builtin_type_decls
) ());
550 dbxout_typedefs (syms
);
553 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
556 dbxout_typedefs (tree syms
)
558 for (; syms
!= NULL_TREE
; syms
= TREE_CHAIN (syms
))
560 if (TREE_CODE (syms
) == TYPE_DECL
)
562 tree type
= TREE_TYPE (syms
);
564 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
565 && COMPLETE_OR_VOID_TYPE_P (type
)
566 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
567 dbxout_symbol (TYPE_NAME (type
), 0);
573 /* Emit BINCL stab using given name. */
575 emit_bincl_stab (const char *name
)
577 fprintf (asmfile
, "%s", ASM_STABS_OP
);
578 output_quoted_string (asmfile
, name
);
579 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
582 /* If there are pending bincls then it is time to emit all of them. */
585 emit_pending_bincls_if_required (void)
588 emit_pending_bincls ();
591 /* Emit all pending bincls. */
594 emit_pending_bincls (void)
596 struct dbx_file
*f
= current_file
;
598 /* Find first pending bincl. */
599 while (f
->bincl_status
== BINCL_PENDING
)
602 /* Now emit all bincls. */
607 if (f
->bincl_status
== BINCL_PENDING
)
609 emit_bincl_stab (f
->pending_bincl_name
);
611 /* Update file number and status. */
612 f
->file_number
= next_file_number
++;
613 f
->bincl_status
= BINCL_PROCESSED
;
615 if (f
== current_file
)
620 /* All pending bincls have been emitted. */
627 emit_pending_bincls_if_required (void) {}
630 /* Change to reading from a new source file. Generate a N_BINCL stab. */
633 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
634 const char *filename ATTRIBUTE_UNUSED
)
637 struct dbx_file
*n
= xmalloc (sizeof *n
);
639 n
->next
= current_file
;
640 n
->next_type_number
= 1;
641 /* Do not assign file number now.
642 Delay it until we actually emit BINCL. */
645 current_file
->prev
= n
;
646 n
->bincl_status
= BINCL_PENDING
;
647 n
->pending_bincl_name
= filename
;
653 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
656 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
659 /* Emit EINCL stab only if BINCL is not pending. */
660 if (current_file
->bincl_status
== BINCL_PROCESSED
)
661 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
662 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
663 current_file
= current_file
->next
;
667 /* Handle a few odd cases that occur when trying to make PCH files work. */
670 dbxout_handle_pch (unsigned at_end
)
674 /* When using the PCH, this file will be included, so we need to output
676 dbxout_start_source_file (0, lastfile
);
678 /* The base file when using the PCH won't be the same as
679 the base file when it's being generated. */
684 /* ... and an EINCL. */
685 dbxout_end_source_file (0);
687 /* Deal with cases where 'lastfile' was never actually changed. */
688 lastfile_is_base
= lastfile
== NULL
;
692 #if defined (DBX_DEBUGGING_INFO)
693 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
696 dbxout_source_file (FILE *file
, const char *filename
)
698 if (lastfile
== 0 && lastfile_is_base
)
700 lastfile
= base_input_file
;
701 lastfile_is_base
= 0;
704 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
706 char ltext_label_name
[100];
708 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
709 source_label_number
);
710 fprintf (file
, "%s", ASM_STABS_OP
);
711 output_quoted_string (file
, filename
);
712 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
713 assemble_name (asmfile
, ltext_label_name
);
714 fputc ('\n', asmfile
);
715 if (current_function_decl
!= NULL_TREE
716 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
717 ; /* Don't change section amid function. */
720 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
721 source_label_number
++;
726 /* Output a line number symbol entry for source file FILENAME and line
730 dbxout_source_line (unsigned int lineno
, const char *filename
)
732 dbxout_source_file (asmfile
, filename
);
734 #ifdef ASM_OUTPUT_SOURCE_LINE
735 dbxout_source_line_counter
+= 1;
736 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
, dbxout_source_line_counter
);
738 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
742 /* Describe the beginning of an internal block within a function. */
745 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
747 emit_pending_bincls_if_required ();
748 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
751 /* Describe the end line-number of an internal block within a function. */
754 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
756 emit_pending_bincls_if_required ();
757 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
760 /* Output dbx data for a function definition.
761 This includes a definition of the function name itself (a symbol),
762 definitions of the parameters (locating them in the parameter list)
763 and then output the block that makes up the function's body
764 (including all the auto variables of the function). */
767 dbxout_function_decl (tree decl
)
769 emit_pending_bincls_if_required ();
770 #ifndef DBX_FUNCTION_FIRST
771 dbxout_begin_function (decl
);
773 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
774 #ifdef DBX_OUTPUT_FUNCTION_END
775 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
777 if (use_gnu_debug_info_extensions
778 #if defined(NO_DBX_FUNCTION_END)
779 && ! NO_DBX_FUNCTION_END
781 && targetm
.have_named_sections
)
782 dbxout_function_end ();
785 #endif /* DBX_DEBUGGING_INFO */
787 /* Debug information for a global DECL. Called from toplev.c after
788 compilation proper has finished. */
790 dbxout_global_decl (tree decl
)
792 if (TREE_CODE (decl
) == VAR_DECL
793 && ! DECL_EXTERNAL (decl
)
794 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
796 int saved_tree_used
= TREE_USED (decl
);
797 TREE_USED (decl
) = 1;
798 dbxout_symbol (decl
, 0);
799 TREE_USED (decl
) = saved_tree_used
;
803 /* At the end of compilation, finish writing the symbol table.
804 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
808 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
810 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
811 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
812 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
817 /* Output the index of a type. */
820 dbxout_type_index (tree type
)
822 #ifndef DBX_USE_BINCL
823 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
826 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
827 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
832 #if DBX_CONTIN_LENGTH > 0
833 /* Continue a symbol-description that gets too big.
834 End one symbol table entry with a double-backslash
835 and start a new one, eventually producing something like
836 .stabs "start......\\",code,0,value
837 .stabs "...rest",code,0,value */
840 dbxout_continue (void)
842 emit_pending_bincls_if_required ();
843 #ifdef DBX_CONTIN_CHAR
844 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
846 fprintf (asmfile
, "\\\\");
848 dbxout_finish_symbol (NULL_TREE
);
849 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
850 current_sym_nchars
= 0;
852 #endif /* DBX_CONTIN_LENGTH > 0 */
854 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
855 This must be a separate function because anonymous unions require
859 dbxout_type_fields (tree type
)
863 /* Output the name, type, position (in bits), size (in bits) of each
864 field that we can support. */
865 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
867 /* Omit here local type decls until we know how to support them. */
868 if (TREE_CODE (tem
) == TYPE_DECL
869 /* Omit fields whose position or size are variable or too large to
871 || (TREE_CODE (tem
) == FIELD_DECL
872 && (! host_integerp (bit_position (tem
), 0)
874 || ! host_integerp (DECL_SIZE (tem
), 1)))
875 /* Omit here the nameless fields that are used to skip bits. */
876 || DECL_IGNORED_P (tem
))
879 else if (TREE_CODE (tem
) != CONST_DECL
)
881 /* Continue the line if necessary,
882 but not before the first field. */
883 if (tem
!= TYPE_FIELDS (type
))
888 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
889 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
893 fprintf (asmfile
, ":");
897 if (use_gnu_debug_info_extensions
898 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
899 || TREE_CODE (tem
) != FIELD_DECL
))
901 have_used_extensions
= 1;
903 putc ((TREE_PRIVATE (tem
) ? '0'
904 : TREE_PROTECTED (tem
) ? '1' : '2'),
909 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
910 && DECL_BIT_FIELD_TYPE (tem
))
911 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
913 if (TREE_CODE (tem
) == VAR_DECL
)
915 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
917 tree name
= DECL_ASSEMBLER_NAME (tem
);
919 have_used_extensions
= 1;
920 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
921 CHARS (IDENTIFIER_LENGTH (name
) + 2);
925 /* If TEM is non-static, GDB won't understand it. */
926 fprintf (asmfile
, ",0,0;");
933 print_wide_int (int_bit_position (tem
));
935 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
943 /* Subroutine of `dbxout_type_methods'. Output debug info about the
944 method described DECL. DEBUG_NAME is an encoding of the method's
945 type signature. ??? We may be able to do without DEBUG_NAME altogether
949 dbxout_type_method_1 (tree decl
, const char *debug_name
)
953 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
955 else /* it's a METHOD_TYPE. */
957 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
958 /* A for normal functions.
959 B for `const' member functions.
960 C for `volatile' member functions.
961 D for `const volatile' member functions. */
962 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
964 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
967 if (DECL_VINDEX (decl
))
973 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
974 TREE_PRIVATE (decl
) ? '0'
975 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
976 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
977 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
979 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
981 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
984 dbxout_type (DECL_CONTEXT (decl
), 0);
985 fprintf (asmfile
, ";");
990 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
994 dbxout_type_methods (tree type
)
996 /* C++: put out the method names and their parameter lists */
997 tree methods
= TYPE_METHODS (type
);
1001 char formatted_type_identifier_length
[16];
1002 int type_identifier_length
;
1004 if (methods
== NULL_TREE
)
1007 type_encoding
= DECL_NAME (TYPE_NAME (type
));
1010 /* C++: Template classes break some assumptions made by this code about
1011 the class names, constructor names, and encodings for assembler
1012 label names. For now, disable output of dbx info for them. */
1014 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
1015 /* This should use index. (mrs) */
1016 while (*ptr
&& *ptr
!= '<') ptr
++;
1027 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
1029 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1031 if (TREE_CODE (methods
) != TREE_VEC
)
1033 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1034 fndecl
= TREE_VEC_ELT (methods
, 0);
1036 fndecl
= TREE_VEC_ELT (methods
, 1);
1040 int need_prefix
= 1;
1042 /* Group together all the methods for the same operation.
1043 These differ in the types of the arguments. */
1044 for (last
= NULL_TREE
;
1045 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1046 fndecl
= TREE_CHAIN (fndecl
))
1047 /* Output the name of the field (after overloading), as
1048 well as the name of the field before overloading, along
1049 with its parameter list */
1051 /* This is the "mangled" name of the method.
1052 It encodes the argument types. */
1053 const char *debug_name
;
1055 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1056 include TEMPLATE_DECLs.) The debugger doesn't know what
1057 to do with such entities anyhow. */
1058 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1061 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1067 /* Also ignore abstract methods; those are only interesting to
1068 the DWARF backends. */
1069 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1072 /* Redundantly output the plain name, since that's what gdb
1076 tree name
= DECL_NAME (fndecl
);
1077 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1078 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1082 dbxout_type (TREE_TYPE (fndecl
), 0);
1084 dbxout_type_method_1 (fndecl
, debug_name
);
1088 putc (';', asmfile
);
1094 /* Emit a "range" type specification, which has the form:
1095 "r<index type>;<lower bound>;<upper bound>;".
1096 TYPE is an INTEGER_TYPE. */
1099 dbxout_range_type (tree type
)
1101 fprintf (asmfile
, "r");
1102 if (TREE_TYPE (type
))
1103 dbxout_type (TREE_TYPE (type
), 0);
1104 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1105 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1108 /* Traditionally, we made sure 'int' was type 1, and builtin types
1109 were defined to be sub-ranges of int. Unfortunately, this
1110 does not allow us to distinguish true sub-ranges from integer
1111 types. So, instead we define integer (non-sub-range) types as
1112 sub-ranges of themselves. This matters for Chill. If this isn't
1113 a subrange type, then we want to define it in terms of itself.
1114 However, in C, this may be an anonymous integer type, and we don't
1115 want to emit debug info referring to it. Just calling
1116 dbxout_type_index won't work anyways, because the type hasn't been
1117 defined yet. We make this work for both cases by checked to see
1118 whether this is a defined type, referring to it if it is, and using
1120 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1121 dbxout_type_index (type
);
1123 dbxout_type_index (integer_type_node
);
1126 if (TYPE_MIN_VALUE (type
) != 0
1127 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1129 putc (';', asmfile
);
1131 if (print_int_cst_bounds_in_octal_p (type
))
1132 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1134 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1138 fprintf (asmfile
, ";0");
1142 if (TYPE_MAX_VALUE (type
) != 0
1143 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1145 putc (';', asmfile
);
1147 if (print_int_cst_bounds_in_octal_p (type
))
1148 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1150 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1151 putc (';', asmfile
);
1156 fprintf (asmfile
, ";-1;");
1162 /* Output a reference to a type. If the type has not yet been
1163 described in the dbx output, output its definition now.
1164 For a type already defined, just refer to its definition
1165 using the type number.
1167 If FULL is nonzero, and the type has been described only with
1168 a forward-reference, output the definition now.
1169 If FULL is zero in this case, just refer to the forward-reference
1170 using the number previously allocated. */
1173 dbxout_type (tree type
, int full
)
1177 static int anonymous_type_number
= 0;
1179 if (TREE_CODE (type
) == VECTOR_TYPE
)
1180 /* The frontend feeds us a representation for the vector as a struct
1181 containing an array. Pull out the array type. */
1182 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1184 /* If there was an input error and we don't really have a type,
1185 avoid crashing and write something that is at least valid
1186 by assuming `int'. */
1187 if (type
== error_mark_node
)
1188 type
= integer_type_node
;
1191 if (TYPE_NAME (type
)
1192 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1193 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1197 /* Try to find the "main variant" with the same name. */
1198 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1199 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1200 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1202 main_variant
= TYPE_MAIN_VARIANT (type
);
1204 /* If we are not using extensions, stabs does not distinguish const and
1205 volatile, so there is no need to make them separate types. */
1206 if (!use_gnu_debug_info_extensions
)
1207 type
= main_variant
;
1209 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1211 /* Type has no dbx number assigned. Assign next available number. */
1212 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1214 /* Make sure type vector is long enough to record about this type. */
1216 if (next_type_number
== typevec_len
)
1219 = ggc_realloc (typevec
, (typevec_len
* 2 * sizeof typevec
[0]));
1220 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1224 #ifdef DBX_USE_BINCL
1225 emit_pending_bincls_if_required ();
1226 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1227 = current_file
->file_number
;
1228 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1229 = current_file
->next_type_number
++;
1233 if (flag_debug_only_used_symbols
)
1235 if ((TREE_CODE (type
) == RECORD_TYPE
1236 || TREE_CODE (type
) == UNION_TYPE
1237 || TREE_CODE (type
) == QUAL_UNION_TYPE
1238 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1239 && TYPE_STUB_DECL (type
)
1240 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type
))) == 'd'
1241 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1242 debug_queue_symbol (TYPE_STUB_DECL (type
));
1243 else if (TYPE_NAME (type
)
1244 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1245 debug_queue_symbol (TYPE_NAME (type
));
1248 /* Output the number of this type, to refer to it. */
1249 dbxout_type_index (type
);
1251 #ifdef DBX_TYPE_DEFINED
1252 if (DBX_TYPE_DEFINED (type
))
1256 /* If this type's definition has been output or is now being output,
1259 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1264 /* If we have already had a cross reference,
1265 and either that's all we want or that's the best we could do,
1266 don't repeat the cross reference.
1267 Sun dbx crashes if we do. */
1268 if (! full
|| !COMPLETE_TYPE_P (type
)
1269 /* No way in DBX fmt to describe a variable size. */
1270 || ! host_integerp (TYPE_SIZE (type
), 1))
1278 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1279 leave the type-number completely undefined rather than output
1280 a cross-reference. If we have already used GNU debug info extensions,
1281 then it is OK to output a cross reference. This is necessary to get
1282 proper C++ debug output. */
1283 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1284 || TREE_CODE (type
) == QUAL_UNION_TYPE
1285 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1286 && ! use_gnu_debug_info_extensions
)
1287 /* We must use the same test here as we use twice below when deciding
1288 whether to emit a cross-reference. */
1289 if ((TYPE_NAME (type
) != 0
1290 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1291 && DECL_IGNORED_P (TYPE_NAME (type
)))
1293 || !COMPLETE_TYPE_P (type
)
1294 /* No way in DBX fmt to describe a variable size. */
1295 || ! host_integerp (TYPE_SIZE (type
), 1))
1297 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1302 /* Output a definition now. */
1304 fprintf (asmfile
, "=");
1307 /* Mark it as defined, so that if it is self-referent
1308 we will not get into an infinite recursion of definitions. */
1310 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1312 /* If this type is a variant of some other, hand off. Types with
1313 different names are usefully distinguished. We only distinguish
1314 cv-qualified types if we're using extensions. */
1315 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1317 putc ('k', asmfile
);
1319 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1322 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1324 putc ('B', asmfile
);
1326 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1329 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1331 if (flag_debug_only_used_symbols
)
1333 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1335 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1336 || TREE_CODE (orig_type
) == UNION_TYPE
1337 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1338 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1339 && TYPE_STUB_DECL (orig_type
)
1340 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1341 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1343 /* 'type' is a typedef; output the type it refers to. */
1344 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1347 /* else continue. */
1349 switch (TREE_CODE (type
))
1353 /* For a void type, just define it as itself; ie, "5=5".
1354 This makes us consider it defined
1355 without saying what it is. The debugger will make it
1356 a void type when the reference is seen, and nothing will
1357 ever override that default. */
1358 dbxout_type_index (type
);
1362 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1364 /* Output the type `char' as a subrange of itself!
1365 I don't understand this definition, just copied it
1366 from the output of pcc.
1367 This used to use `r2' explicitly and we used to
1368 take care to make sure that `char' was type number 2. */
1369 fprintf (asmfile
, "r");
1371 dbxout_type_index (type
);
1372 fprintf (asmfile
, ";0;127;");
1376 /* If this is a subtype of another integer type, always prefer to
1377 write it as a subtype. */
1378 else if (TREE_TYPE (type
) != 0
1379 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1381 /* If the size is non-standard, say what it is if we can use
1384 if (use_gnu_debug_info_extensions
1385 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1387 have_used_extensions
= 1;
1388 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1392 dbxout_range_type (type
);
1397 /* If the size is non-standard, say what it is if we can use
1400 if (use_gnu_debug_info_extensions
1401 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1403 have_used_extensions
= 1;
1404 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1408 if (print_int_cst_bounds_in_octal_p (type
))
1410 fprintf (asmfile
, "r");
1413 /* If this type derives from another type, output type index of
1414 parent type. This is particularly important when parent type
1415 is an enumerated type, because not generating the parent type
1416 index would transform the definition of this enumerated type
1417 into a plain unsigned type. */
1418 if (TREE_TYPE (type
) != 0)
1419 dbxout_type_index (TREE_TYPE (type
));
1421 dbxout_type_index (type
);
1423 fprintf (asmfile
, ";");
1425 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1426 fprintf (asmfile
, ";");
1428 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1429 fprintf (asmfile
, ";");
1434 /* Output other integer types as subranges of `int'. */
1435 dbxout_range_type (type
);
1441 /* This used to say `r1' and we used to take care
1442 to make sure that `int' was type number 1. */
1443 fprintf (asmfile
, "r");
1445 dbxout_type_index (integer_type_node
);
1446 putc (';', asmfile
);
1448 print_wide_int (int_size_in_bytes (type
));
1449 fputs (";0;", asmfile
);
1454 if (use_gnu_debug_info_extensions
)
1456 have_used_extensions
= 1;
1457 fputs ("@s", asmfile
);
1459 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1460 fputs (";-20;", asmfile
);
1465 /* Output the type `char' as a subrange of itself.
1466 That is what pcc seems to do. */
1467 fprintf (asmfile
, "r");
1469 dbxout_type_index (char_type_node
);
1470 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1476 if (use_gnu_debug_info_extensions
)
1478 have_used_extensions
= 1;
1479 fputs ("@s", asmfile
);
1481 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1482 fputs (";-16;", asmfile
);
1485 else /* Define as enumeral type (False, True) */
1487 fprintf (asmfile
, "eFalse:0,True:1,;");
1493 putc ('d', asmfile
);
1495 dbxout_type (TREE_TYPE (type
), 0);
1499 /* Differs from the REAL_TYPE by its new data type number.
1500 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1501 codes since gdb doesn't care anyway. */
1503 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1505 fputs ("R3;", asmfile
);
1507 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1508 fputs (";0;", asmfile
);
1513 /* Output a complex integer type as a structure,
1514 pending some other way to do it. */
1515 putc ('s', asmfile
);
1517 print_wide_int (int_size_in_bytes (type
));
1518 fprintf (asmfile
, "real:");
1521 dbxout_type (TREE_TYPE (type
), 0);
1522 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1524 fprintf (asmfile
, "imag:");
1526 dbxout_type (TREE_TYPE (type
), 0);
1527 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1528 TYPE_PRECISION (TREE_TYPE (type
)));
1534 if (use_gnu_debug_info_extensions
)
1536 have_used_extensions
= 1;
1537 fputs ("@s", asmfile
);
1539 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1540 putc (';', asmfile
);
1543 /* Check if a bitstring type, which in Chill is
1544 different from a [power]set. */
1545 if (TYPE_STRING_FLAG (type
))
1547 fprintf (asmfile
, "@S;");
1551 putc ('S', asmfile
);
1553 dbxout_type (TYPE_DOMAIN (type
), 0);
1557 /* Make arrays of packed bits look like bitstrings for chill. */
1558 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1560 have_used_extensions
= 1;
1561 fputs ("@s", asmfile
);
1563 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1564 fprintf (asmfile
, ";@S;S");
1566 dbxout_type (TYPE_DOMAIN (type
), 0);
1570 /* Output "a" followed by a range type definition
1571 for the index type of the array
1572 followed by a reference to the target-type.
1573 ar1;0;N;M for a C array of type M and size N+1. */
1574 /* Check if a character string type, which in Chill is
1575 different from an array of characters. */
1576 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1578 have_used_extensions
= 1;
1579 fprintf (asmfile
, "@S;");
1582 tem
= TYPE_DOMAIN (type
);
1585 fprintf (asmfile
, "ar");
1587 dbxout_type_index (integer_type_node
);
1588 fprintf (asmfile
, ";0;-1;");
1593 fprintf (asmfile
, "a");
1595 dbxout_range_type (tem
);
1598 dbxout_type (TREE_TYPE (type
), 0);
1603 case QUAL_UNION_TYPE
:
1605 int i
, n_baseclasses
= 0;
1607 if (TYPE_BINFO (type
) != 0
1608 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1609 && TYPE_BINFO_BASETYPES (type
) != 0)
1610 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1612 /* Output a structure type. We must use the same test here as we
1613 use in the DBX_NO_XREFS case above. */
1614 if ((TYPE_NAME (type
) != 0
1615 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1616 && DECL_IGNORED_P (TYPE_NAME (type
)))
1618 || !COMPLETE_TYPE_P (type
)
1619 /* No way in DBX fmt to describe a variable size. */
1620 || ! host_integerp (TYPE_SIZE (type
), 1))
1622 /* If the type is just a cross reference, output one
1623 and mark the type as partially described.
1624 If it later becomes defined, we will output
1625 its real definition.
1626 If the type has a name, don't nest its definition within
1627 another type's definition; instead, output an xref
1628 and let the definition come when the name is defined. */
1629 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1631 #if 0 /* This assertion is legitimately false in C++. */
1632 /* We shouldn't be outputting a reference to a type before its
1633 definition unless the type has a tag name.
1634 A typedef name without a tag name should be impossible. */
1635 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1638 if (TYPE_NAME (type
) != 0)
1639 dbxout_type_name (type
);
1642 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1646 fprintf (asmfile
, ":");
1648 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1652 /* Identify record or union, and print its size. */
1653 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1655 print_wide_int (int_size_in_bytes (type
));
1657 if (use_gnu_debug_info_extensions
)
1661 have_used_extensions
= 1;
1662 fprintf (asmfile
, "!%d,", n_baseclasses
);
1666 for (i
= 0; i
< n_baseclasses
; i
++)
1668 tree binfo
= TYPE_BINFO (type
);
1669 tree child
= BINFO_BASETYPE (binfo
, i
);
1670 tree access
= (BINFO_BASEACCESSES (binfo
)
1671 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1673 if (use_gnu_debug_info_extensions
)
1675 have_used_extensions
= 1;
1676 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1677 putc (access
== access_public_node
? '2' : '0', asmfile
);
1679 if (TREE_VIA_VIRTUAL (child
)
1680 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1681 /* For a virtual base, print the (negative) offset within
1682 the vtable where we must look to find the necessary
1684 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1687 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1689 putc (',', asmfile
);
1691 dbxout_type (BINFO_TYPE (child
), 0);
1692 putc (';', asmfile
);
1697 /* Print out the base class information with fields
1698 which have the same names at the types they hold. */
1699 dbxout_type_name (BINFO_TYPE (child
));
1700 putc (':', asmfile
);
1702 dbxout_type (BINFO_TYPE (child
), full
);
1703 putc (',', asmfile
);
1705 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1707 putc (',', asmfile
);
1709 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child
)),
1712 putc (';', asmfile
);
1718 /* Write out the field declarations. */
1719 dbxout_type_fields (type
);
1720 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1722 have_used_extensions
= 1;
1723 dbxout_type_methods (type
);
1726 putc (';', asmfile
);
1729 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1730 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1731 && TYPE_VFIELD (type
))
1733 have_used_extensions
= 1;
1735 /* Tell GDB+ that it may keep reading. */
1736 putc ('~', asmfile
);
1739 /* We need to write out info about what field this class
1740 uses as its "main" vtable pointer field, because if this
1741 field is inherited from a base class, GDB cannot necessarily
1742 figure out which field it's using in time. */
1743 if (TYPE_VFIELD (type
))
1745 putc ('%', asmfile
);
1747 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1750 putc (';', asmfile
);
1756 /* We must use the same test here as we use in the DBX_NO_XREFS case
1757 above. We simplify it a bit since an enum will never have a variable
1759 if ((TYPE_NAME (type
) != 0
1760 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1761 && DECL_IGNORED_P (TYPE_NAME (type
)))
1763 || !COMPLETE_TYPE_P (type
))
1765 fprintf (asmfile
, "xe");
1767 dbxout_type_name (type
);
1768 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1769 putc (':', asmfile
);
1773 if (use_gnu_debug_info_extensions
1774 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1776 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1780 putc ('e', asmfile
);
1782 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1784 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1785 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1786 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1787 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1788 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1789 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1790 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1792 print_int_cst_octal (TREE_VALUE (tem
));
1794 putc (',', asmfile
);
1796 if (TREE_CHAIN (tem
) != 0)
1800 putc (';', asmfile
);
1805 putc ('*', asmfile
);
1807 dbxout_type (TREE_TYPE (type
), 0);
1811 if (use_gnu_debug_info_extensions
)
1813 have_used_extensions
= 1;
1814 putc ('#', asmfile
);
1817 /* Write the argument types out longhand. */
1818 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1819 putc (',', asmfile
);
1821 dbxout_type (TREE_TYPE (type
), 0);
1822 dbxout_args (TYPE_ARG_TYPES (type
));
1823 putc (';', asmfile
);
1827 /* Treat it as a function type. */
1828 dbxout_type (TREE_TYPE (type
), 0);
1832 if (use_gnu_debug_info_extensions
)
1834 have_used_extensions
= 1;
1835 putc ('@', asmfile
);
1837 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1838 putc (',', asmfile
);
1840 dbxout_type (TREE_TYPE (type
), 0);
1843 /* Should print as an int, because it is really just an offset. */
1844 dbxout_type (integer_type_node
, 0);
1847 case REFERENCE_TYPE
:
1848 if (use_gnu_debug_info_extensions
)
1849 have_used_extensions
= 1;
1850 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1852 dbxout_type (TREE_TYPE (type
), 0);
1856 putc ('f', asmfile
);
1858 dbxout_type (TREE_TYPE (type
), 0);
1866 /* Return nonzero if the given type represents an integer whose bounds
1867 should be printed in octal format. */
1870 print_int_cst_bounds_in_octal_p (tree type
)
1872 /* If we can use GDB extensions and the size is wider than a long
1873 (the size used by GDB to read them) or we may have trouble writing
1874 the bounds the usual way, write them in octal. Note the test is for
1875 the *target's* size of "long", not that of the host. The host test
1876 is just to make sure we can write it out in case the host wide int
1877 is narrower than the target "long".
1879 For unsigned types, we use octal if they are the same size or larger.
1880 This is because we print the bounds as signed decimal, and hence they
1881 can't span same size unsigned types. */
1883 if (use_gnu_debug_info_extensions
1884 && TYPE_MIN_VALUE (type
) != 0
1885 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1886 && TYPE_MAX_VALUE (type
) != 0
1887 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1888 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1889 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1890 && TREE_UNSIGNED (type
))
1891 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1892 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1893 && TREE_UNSIGNED (type
))))
1899 /* Print the value of integer constant C, in octal,
1900 handling double precision. */
1903 print_int_cst_octal (tree c
)
1905 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1906 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1907 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1908 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1910 /* GDB wants constants with no extra leading "1" bits, so
1911 we need to remove any sign-extension that might be
1913 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1915 else if (width
> HOST_BITS_PER_WIDE_INT
)
1916 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1917 else if (width
== HOST_BITS_PER_WIDE_INT
)
1920 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1922 fprintf (asmfile
, "0");
1927 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1928 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1932 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1933 unsigned HOST_WIDE_INT middle
1934 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1935 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1936 unsigned HOST_WIDE_INT end
1937 = low
& (((unsigned HOST_WIDE_INT
) 1
1938 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1941 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1943 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1948 print_octal (unsigned HOST_WIDE_INT value
, int digits
)
1952 for (i
= digits
- 1; i
>= 0; i
--)
1953 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1958 /* Output C in decimal while adjusting the number of digits written. */
1961 print_wide_int (HOST_WIDE_INT c
)
1965 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1976 /* Output the name of type TYPE, with no punctuation.
1977 Such names can be set up either by typedef declarations
1978 or by struct, enum and union tags. */
1981 dbxout_type_name (tree type
)
1984 if (TYPE_NAME (type
) == 0)
1986 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1988 t
= TYPE_NAME (type
);
1990 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1992 t
= DECL_NAME (TYPE_NAME (type
));
1997 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1998 CHARS (IDENTIFIER_LENGTH (t
));
2001 /* Output leading leading struct or class names needed for qualifying
2002 type whose scope is limited to a struct or class. */
2005 dbxout_class_name_qualifiers (tree decl
)
2007 tree context
= decl_type_context (decl
);
2009 if (context
!= NULL_TREE
2010 && TREE_CODE(context
) == RECORD_TYPE
2011 && TYPE_NAME (context
) != 0
2012 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2013 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2015 tree name
= TYPE_NAME (context
);
2017 emit_pending_bincls_if_required ();
2019 if (TREE_CODE (name
) == TYPE_DECL
)
2021 dbxout_class_name_qualifiers (name
);
2022 name
= DECL_NAME (name
);
2024 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
2025 CHARS (IDENTIFIER_LENGTH (name
) + 2);
2029 /* Output a .stabs for the symbol defined by DECL,
2030 which must be a ..._DECL node in the normal namespace.
2031 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2032 LOCAL is nonzero if the scope is less than the entire file.
2033 Return 1 if a stabs might have been emitted. */
2036 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2038 tree type
= TREE_TYPE (decl
);
2039 tree context
= NULL_TREE
;
2042 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2045 /* Cast avoids warning in old compilers. */
2046 current_sym_code
= (STAB_CODE_TYPE
) 0;
2047 current_sym_value
= 0;
2048 current_sym_addr
= 0;
2050 /* Ignore nameless syms, but don't ignore type tags. */
2052 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2053 || DECL_IGNORED_P (decl
))
2054 DBXOUT_DECR_NESTING_AND_RETURN (0);
2056 /* If we are to generate only the symbols actually used then such
2057 symbol nodees are flagged with TREE_USED. Ignore any that
2058 aren't flaged as TREE_USED. */
2060 if (flag_debug_only_used_symbols
)
2064 if (!TREE_USED (decl
)
2065 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
)))
2066 DBXOUT_DECR_NESTING_AND_RETURN (0);
2068 /* We now have a used symbol. We need to generate the info for
2069 the symbol's type in addition to the symbol itself. These
2070 type symbols are queued to be generated after were done with
2071 the symbol itself (done because the symbol's info is generated
2072 with fprintf's, etc. as it determines what's needed).
2074 Note, because the TREE_TYPE(type) might be something like a
2075 pointer to a named type we need to look for the first name
2076 we see following the TREE_TYPE chain. */
2079 while (POINTER_TYPE_P (t
))
2082 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2083 need special treatment. The TYPE_STUB_DECL field in these
2084 types generally represents the tag name type we want to
2085 output. In addition there could be a typedef type with
2086 a different name. In that case we also want to output
2089 if ((TREE_CODE (t
) == RECORD_TYPE
2090 || TREE_CODE (t
) == UNION_TYPE
2091 || TREE_CODE (t
) == QUAL_UNION_TYPE
2092 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2093 && TYPE_STUB_DECL (t
)
2094 && TYPE_STUB_DECL (t
) != decl
2095 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t
))) == 'd'
2096 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2098 debug_queue_symbol (TYPE_STUB_DECL (t
));
2100 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2101 && TYPE_NAME (t
) != decl
2102 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2103 debug_queue_symbol (TYPE_NAME (t
));
2105 else if (TYPE_NAME (t
)
2106 && TYPE_NAME (t
) != decl
2107 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2108 debug_queue_symbol (TYPE_NAME (t
));
2111 emit_pending_bincls_if_required ();
2113 dbxout_prepare_symbol (decl
);
2115 /* The output will always start with the symbol name,
2116 so always count that in the length-output-so-far. */
2118 if (DECL_NAME (decl
) != 0)
2119 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2121 switch (TREE_CODE (decl
))
2124 /* Enum values are defined by defining the enum type. */
2128 if (DECL_RTL (decl
) == 0)
2129 DBXOUT_DECR_NESTING_AND_RETURN (0);
2130 if (DECL_EXTERNAL (decl
))
2132 /* Don't mention a nested function under its parent. */
2133 context
= decl_function_context (decl
);
2134 if (context
== current_function_decl
)
2136 if (GET_CODE (DECL_RTL (decl
)) != MEM
2137 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2141 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2142 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2143 TREE_PUBLIC (decl
) ? 'F' : 'f');
2146 current_sym_code
= N_FUN
;
2147 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2149 if (TREE_TYPE (type
))
2150 dbxout_type (TREE_TYPE (type
), 0);
2152 dbxout_type (void_type_node
, 0);
2154 /* For a nested function, when that function is compiled,
2155 mention the containing function name
2156 as well as (since dbx wants it) our own assembler-name. */
2158 fprintf (asmfile
, ",%s,%s",
2159 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2160 IDENTIFIER_POINTER (DECL_NAME (context
)));
2162 dbxout_finish_symbol (decl
);
2166 /* Don't output the same typedef twice.
2167 And don't output what language-specific stuff doesn't want output. */
2168 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2169 DBXOUT_DECR_NESTING_AND_RETURN (0);
2177 if (DECL_NAME (decl
))
2179 /* Nonzero means we must output a tag as well as a typedef. */
2182 /* Handle the case of a C++ structure or union
2183 where the TYPE_NAME is a TYPE_DECL
2184 which gives both a typedef name and a tag. */
2185 /* dbx requires the tag first and the typedef second. */
2186 if ((TREE_CODE (type
) == RECORD_TYPE
2187 || TREE_CODE (type
) == UNION_TYPE
2188 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2189 && TYPE_NAME (type
) == decl
2190 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2191 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2192 /* Distinguish the implicit typedefs of C++
2193 from explicit ones that might be found in C. */
2194 && DECL_ARTIFICIAL (decl
)
2195 /* Do not generate a tag for incomplete records. */
2196 && COMPLETE_TYPE_P (type
)
2197 /* Do not generate a tag for records of variable size,
2198 since this type can not be properly described in the
2199 DBX format, and it confuses some tools such as objdump. */
2200 && host_integerp (TYPE_SIZE (type
), 1))
2202 tree name
= TYPE_NAME (type
);
2203 if (TREE_CODE (name
) == TYPE_DECL
)
2204 name
= DECL_NAME (name
);
2206 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2207 current_sym_value
= 0;
2208 current_sym_addr
= 0;
2209 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2211 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2212 IDENTIFIER_POINTER (name
));
2213 dbxout_type (type
, 1);
2214 dbxout_finish_symbol (NULL_TREE
);
2217 /* Output .stabs (or whatever) and leading double quote. */
2218 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2220 if (use_gnu_debug_info_extensions
)
2222 /* Output leading class/struct qualifiers. */
2223 dbxout_class_name_qualifiers (decl
);
2226 /* Output typedef name. */
2227 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2229 /* Short cut way to output a tag also. */
2230 if ((TREE_CODE (type
) == RECORD_TYPE
2231 || TREE_CODE (type
) == UNION_TYPE
2232 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2233 && TYPE_NAME (type
) == decl
2234 /* Distinguish the implicit typedefs of C++
2235 from explicit ones that might be found in C. */
2236 && DECL_ARTIFICIAL (decl
))
2238 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2240 putc ('T', asmfile
);
2241 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2243 #if 0 /* Now we generate the tag for this case up above. */
2249 putc ('t', asmfile
);
2250 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2252 dbxout_type (type
, 1);
2253 dbxout_finish_symbol (decl
);
2257 /* Don't output a tag if this is an incomplete type. This prevents
2258 the sun4 Sun OS 4.x dbx from crashing. */
2260 if (tag_needed
&& TYPE_NAME (type
) != 0
2261 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2262 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2263 && COMPLETE_TYPE_P (type
)
2264 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2266 /* For a TYPE_DECL with no name, but the type has a name,
2268 This is what represents `struct foo' with no typedef. */
2269 /* In C++, the name of a type is the corresponding typedef.
2270 In C, it is an IDENTIFIER_NODE. */
2271 tree name
= TYPE_NAME (type
);
2272 if (TREE_CODE (name
) == TYPE_DECL
)
2273 name
= DECL_NAME (name
);
2275 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2276 current_sym_value
= 0;
2277 current_sym_addr
= 0;
2278 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2280 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2281 IDENTIFIER_POINTER (name
));
2282 dbxout_type (type
, 1);
2283 dbxout_finish_symbol (NULL_TREE
);
2287 /* If an enum type has no name, it cannot be referred to,
2288 but we must output it anyway, since the enumeration constants
2289 can be referred to. */
2290 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2292 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2293 current_sym_value
= 0;
2294 current_sym_addr
= 0;
2295 current_sym_nchars
= 2;
2297 /* Some debuggers fail when given NULL names, so give this a
2298 harmless name of ` '. */
2299 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2300 dbxout_type (type
, 1);
2301 dbxout_finish_symbol (NULL_TREE
);
2304 /* Prevent duplicate output of a typedef. */
2305 TREE_ASM_WRITTEN (decl
) = 1;
2310 /* Parm decls go in their own separate chains
2311 and are output by dbxout_reg_parms and dbxout_parms. */
2315 /* Named return value, treat like a VAR_DECL. */
2317 if (! DECL_RTL_SET_P (decl
))
2318 DBXOUT_DECR_NESTING_AND_RETURN (0);
2319 /* Don't mention a variable that is external.
2320 Let the file that defines it describe it. */
2321 if (DECL_EXTERNAL (decl
))
2324 /* If the variable is really a constant
2325 and not written in memory, inform the debugger. */
2326 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2327 && DECL_INITIAL (decl
) != 0
2328 && host_integerp (DECL_INITIAL (decl
), 0)
2329 && ! TREE_ASM_WRITTEN (decl
)
2330 && (DECL_CONTEXT (decl
) == NULL_TREE
2331 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2333 if (TREE_PUBLIC (decl
) == 0)
2335 /* The sun4 assembler does not grok this. */
2336 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2338 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2339 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2341 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2342 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2344 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2345 DBXOUT_DECR_NESTING
;
2348 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2350 /* don't know how to do this yet. */
2354 /* else it is something we handle like a normal variable. */
2357 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2358 #ifdef LEAF_REG_REMAP
2359 if (current_function_uses_only_leaf_regs
)
2360 leaf_renumber_regs_insn (DECL_RTL (decl
));
2363 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2369 DBXOUT_DECR_NESTING
;
2373 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2374 Add SUFFIX to its name, if SUFFIX is not 0.
2375 Describe the variable as residing in HOME
2376 (usually HOME is DECL_RTL (DECL), but not always).
2377 Returns 1 if the stab was really emitted. */
2380 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2385 emit_pending_bincls_if_required ();
2387 /* Don't mention a variable at all
2388 if it was completely optimized into nothingness.
2390 If the decl was from an inline function, then its rtl
2391 is not identically the rtl that was used in this
2392 particular compilation. */
2393 if (GET_CODE (home
) == SUBREG
)
2397 while (GET_CODE (value
) == SUBREG
)
2398 value
= SUBREG_REG (value
);
2399 if (GET_CODE (value
) == REG
)
2401 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2404 home
= alter_subreg (&home
);
2406 if (GET_CODE (home
) == REG
)
2408 regno
= REGNO (home
);
2409 if (regno
>= FIRST_PSEUDO_REGISTER
)
2413 /* The kind-of-variable letter depends on where
2414 the variable is and on the scope of its name:
2415 G and N_GSYM for static storage and global scope,
2416 S for static storage and file scope,
2417 V for static storage and local scope,
2418 for those two, use N_LCSYM if data is in bss segment,
2419 N_STSYM if in data segment, N_FUN otherwise.
2420 (We used N_FUN originally, then changed to N_STSYM
2421 to please GDB. However, it seems that confused ld.
2422 Now GDB has been fixed to like N_FUN, says Kingdon.)
2423 no letter at all, and N_LSYM, for auto variable,
2424 r and N_RSYM for register variable. */
2426 if (GET_CODE (home
) == MEM
2427 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2429 if (TREE_PUBLIC (decl
))
2432 current_sym_code
= N_GSYM
;
2436 current_sym_addr
= XEXP (home
, 0);
2438 letter
= decl_function_context (decl
) ? 'V' : 'S';
2440 /* This should be the same condition as in assemble_variable, but
2441 we don't have access to dont_output_data here. So, instead,
2442 we rely on the fact that error_mark_node initializers always
2443 end up in bss for C++ and never end up in bss for C. */
2444 if (DECL_INITIAL (decl
) == 0
2445 || (!strcmp (lang_hooks
.name
, "GNU C++")
2446 && DECL_INITIAL (decl
) == error_mark_node
))
2447 current_sym_code
= N_LCSYM
;
2448 else if (DECL_IN_TEXT_SECTION (decl
))
2449 /* This is not quite right, but it's the closest
2450 of all the codes that Unix defines. */
2451 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2454 /* Some ports can transform a symbol ref into a label ref,
2455 because the symbol ref is too far away and has to be
2456 dumped into a constant pool. Alternatively, the symbol
2457 in the constant pool might be referenced by a different
2459 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2460 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2462 rtx tmp
= get_pool_constant (current_sym_addr
);
2464 if (GET_CODE (tmp
) == SYMBOL_REF
2465 || GET_CODE (tmp
) == LABEL_REF
)
2466 current_sym_addr
= tmp
;
2469 /* Ultrix `as' seems to need this. */
2470 #ifdef DBX_STATIC_STAB_DATA_SECTION
2473 current_sym_code
= N_STSYM
;
2477 else if (regno
>= 0)
2480 current_sym_code
= N_RSYM
;
2481 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2483 else if (GET_CODE (home
) == MEM
2484 && (GET_CODE (XEXP (home
, 0)) == MEM
2485 || (GET_CODE (XEXP (home
, 0)) == REG
2486 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2487 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2488 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2489 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2492 /* If the value is indirect by memory or by a register
2493 that isn't the frame pointer
2494 then it means the object is variable-sized and address through
2495 that register or stack slot. DBX has no way to represent this
2496 so all we can do is output the variable as a pointer.
2497 If it's not a parameter, ignore it.
2498 (VAR_DECLs like this can be made by integrate.c.) */
2500 if (GET_CODE (XEXP (home
, 0)) == REG
)
2503 current_sym_code
= N_RSYM
;
2504 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2506 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2510 current_sym_code
= N_LSYM
;
2511 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2512 We want the value of that CONST_INT. */
2514 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2517 /* Effectively do build_pointer_type, but don't cache this type,
2518 since it might be temporary whereas the type it points to
2519 might have been saved for inlining. */
2520 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2521 type
= make_node (POINTER_TYPE
);
2522 TREE_TYPE (type
) = TREE_TYPE (decl
);
2524 else if (GET_CODE (home
) == MEM
2525 && GET_CODE (XEXP (home
, 0)) == REG
)
2527 current_sym_code
= N_LSYM
;
2528 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2530 else if (GET_CODE (home
) == MEM
2531 && GET_CODE (XEXP (home
, 0)) == PLUS
2532 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2534 current_sym_code
= N_LSYM
;
2535 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2536 We want the value of that CONST_INT. */
2537 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2539 else if (GET_CODE (home
) == MEM
2540 && GET_CODE (XEXP (home
, 0)) == CONST
)
2542 /* Handle an obscure case which can arise when optimizing and
2543 when there are few available registers. (This is *always*
2544 the case for i386/i486 targets). The RTL looks like
2545 (MEM (CONST ...)) even though this variable is a local `auto'
2546 or a local `register' variable. In effect, what has happened
2547 is that the reload pass has seen that all assignments and
2548 references for one such a local variable can be replaced by
2549 equivalent assignments and references to some static storage
2550 variable, thereby avoiding the need for a register. In such
2551 cases we're forced to lie to debuggers and tell them that
2552 this variable was itself `static'. */
2553 current_sym_code
= N_LCSYM
;
2555 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2557 else if (GET_CODE (home
) == CONCAT
)
2561 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2562 for example), then there is no easy way to figure out
2563 what SUBTYPE should be. So, we give up. */
2564 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2567 subtype
= TREE_TYPE (type
);
2569 /* If the variable's storage is in two parts,
2570 output each as a separate stab with a modified name. */
2571 if (WORDS_BIG_ENDIAN
)
2572 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2574 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2576 /* Cast avoids warning in old compilers. */
2577 current_sym_code
= (STAB_CODE_TYPE
) 0;
2578 current_sym_value
= 0;
2579 current_sym_addr
= 0;
2580 dbxout_prepare_symbol (decl
);
2582 if (WORDS_BIG_ENDIAN
)
2583 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2585 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2589 /* Address might be a MEM, when DECL is a variable-sized object.
2590 Or it might be const0_rtx, meaning previous passes
2591 want us to ignore this variable. */
2594 /* Ok, start a symtab entry and output the variable name. */
2597 #ifdef DBX_STATIC_BLOCK_START
2598 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2601 dbxout_symbol_name (decl
, suffix
, letter
);
2602 dbxout_type (type
, 0);
2603 dbxout_finish_symbol (decl
);
2605 #ifdef DBX_STATIC_BLOCK_END
2606 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2611 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2612 Then output LETTER to indicate the kind of location the symbol has. */
2615 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
2619 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2620 /* One slight hitch: if this is a VAR_DECL which is a static
2621 class member, we must put out the mangled name instead of the
2622 DECL_NAME. Note also that static member (variable) names DO NOT begin
2623 with underscores in .stabs directives. */
2624 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2626 /* ...but if we're function-local, we don't want to include the junk
2627 added by ASM_FORMAT_PRIVATE_NAME. */
2628 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2632 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2633 (suffix
? suffix
: ""));
2636 putc (letter
, asmfile
);
2640 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED
)
2643 const char *filename
= DECL_SOURCE_FILE (decl
);
2645 dbxout_source_file (asmfile
, filename
);
2650 dbxout_finish_symbol (tree sym
)
2652 #ifdef DBX_FINISH_SYMBOL
2653 DBX_FINISH_SYMBOL (sym
);
2656 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2657 line
= DECL_SOURCE_LINE (sym
);
2659 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2660 if (current_sym_addr
)
2661 output_addr_const (asmfile
, current_sym_addr
);
2663 fprintf (asmfile
, "%d", current_sym_value
);
2664 putc ('\n', asmfile
);
2668 /* Output definitions of all the decls in a chain. Return nonzero if
2669 anything was output */
2672 dbxout_syms (tree syms
)
2677 result
+= dbxout_symbol (syms
, 1);
2678 syms
= TREE_CHAIN (syms
);
2683 /* The following two functions output definitions of function parameters.
2684 Each parameter gets a definition locating it in the parameter list.
2685 Each parameter that is a register variable gets a second definition
2686 locating it in the register.
2688 Printing or argument lists in gdb uses the definitions that
2689 locate in the parameter list. But reference to the variable in
2690 expressions uses preferentially the definition as a register. */
2692 /* Output definitions, referring to storage in the parmlist,
2693 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2696 dbxout_parms (tree parms
)
2700 emit_pending_bincls_if_required ();
2702 for (; parms
; parms
= TREE_CHAIN (parms
))
2703 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2705 dbxout_prepare_symbol (parms
);
2707 /* Perform any necessary register eliminations on the parameter's rtl,
2708 so that the debugging output will be accurate. */
2709 DECL_INCOMING_RTL (parms
)
2710 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2711 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2712 #ifdef LEAF_REG_REMAP
2713 if (current_function_uses_only_leaf_regs
)
2715 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2716 leaf_renumber_regs_insn (DECL_RTL (parms
));
2720 if (PARM_PASSED_IN_MEMORY (parms
))
2722 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2724 /* ??? Here we assume that the parm address is indexed
2725 off the frame pointer or arg pointer.
2726 If that is not true, we produce meaningless results,
2727 but do not crash. */
2728 if (GET_CODE (addr
) == PLUS
2729 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2730 current_sym_value
= INTVAL (XEXP (addr
, 1));
2732 current_sym_value
= 0;
2734 current_sym_code
= N_PSYM
;
2735 current_sym_addr
= 0;
2738 if (DECL_NAME (parms
))
2740 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2742 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2743 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2744 DBX_MEMPARM_STABS_LETTER
);
2748 current_sym_nchars
= 8;
2749 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2750 DBX_MEMPARM_STABS_LETTER
);
2753 /* It is quite tempting to use:
2755 dbxout_type (TREE_TYPE (parms), 0);
2757 as the next statement, rather than using DECL_ARG_TYPE(), so
2758 that gcc reports the actual type of the parameter, rather
2759 than the promoted type. This certainly makes GDB's life
2760 easier, at least for some ports. The change is a bad idea
2761 however, since GDB expects to be able access the type without
2762 performing any conversions. So for example, if we were
2763 passing a float to an unprototyped function, gcc will store a
2764 double on the stack, but if we emit a stab saying the type is a
2765 float, then gdb will only read in a single value, and this will
2766 produce an erroneous value. */
2767 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2768 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2769 dbxout_finish_symbol (parms
);
2771 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2774 char regparm_letter
;
2776 /* Parm passed in registers and lives in registers or nowhere. */
2778 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2779 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2780 current_sym_addr
= 0;
2782 /* If parm lives in a register, use that register;
2783 pretend the parm was passed there. It would be more consistent
2784 to describe the register where the parm was passed,
2785 but in practice that register usually holds something else.
2787 If we use DECL_RTL, then we must use the declared type of
2788 the variable, not the type that it arrived in. */
2789 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2791 best_rtl
= DECL_RTL (parms
);
2792 parm_type
= TREE_TYPE (parms
);
2794 /* If the parm lives nowhere, use the register where it was
2795 passed. It is also better to use the declared type here. */
2798 best_rtl
= DECL_INCOMING_RTL (parms
);
2799 parm_type
= TREE_TYPE (parms
);
2801 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2804 if (DECL_NAME (parms
))
2806 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2807 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2808 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2813 current_sym_nchars
= 8;
2814 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2818 dbxout_type (parm_type
, 0);
2819 dbxout_finish_symbol (parms
);
2821 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2822 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2823 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2824 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2825 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2826 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2830 /* Parm was passed via invisible reference.
2831 That is, its address was passed in a register.
2832 Output it as if it lived in that register.
2833 The debugger will know from the type
2834 that it was actually passed by invisible reference. */
2836 char regparm_letter
;
2837 /* Parm passed in registers and lives in registers or nowhere. */
2839 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2840 if (use_gnu_debug_info_extensions
)
2841 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2843 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2845 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2846 If it is an unallocated pseudo-reg, then use the register where
2847 it was passed instead. */
2848 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2849 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2851 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2853 current_sym_addr
= 0;
2856 if (DECL_NAME (parms
))
2859 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2861 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2862 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2867 current_sym_nchars
= 8;
2868 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2872 dbxout_type (TREE_TYPE (parms
), 0);
2873 dbxout_finish_symbol (parms
);
2875 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2876 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2878 /* Parm was passed via invisible reference, with the reference
2879 living on the stack. DECL_RTL looks like
2880 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2881 could look like (MEM (MEM (REG))). */
2882 const char *const decl_name
= (DECL_NAME (parms
)
2883 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2885 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2886 current_sym_value
= 0;
2889 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2890 current_sym_addr
= 0;
2891 current_sym_code
= N_PSYM
;
2894 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2897 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2898 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2899 dbxout_type (TREE_TYPE (parms
), 0);
2900 dbxout_finish_symbol (parms
);
2902 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2903 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2904 /* ??? A constant address for a parm can happen
2905 when the reg it lives in is equiv to a constant in memory.
2906 Should make this not happen, after 2.4. */
2907 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2909 /* Parm was passed in registers but lives on the stack. */
2911 current_sym_code
= N_PSYM
;
2912 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2913 in which case we want the value of that CONST_INT,
2915 in which case we use a value of zero. */
2916 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2917 current_sym_value
= 0;
2920 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2922 current_sym_addr
= 0;
2924 /* Make a big endian correction if the mode of the type of the
2925 parameter is not the same as the mode of the rtl. */
2926 if (BYTES_BIG_ENDIAN
2927 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2928 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2930 current_sym_value
+=
2931 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2932 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2936 if (DECL_NAME (parms
))
2939 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2941 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2942 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2943 DBX_MEMPARM_STABS_LETTER
);
2947 current_sym_nchars
= 8;
2948 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2949 DBX_MEMPARM_STABS_LETTER
);
2953 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2954 XEXP (DECL_RTL (parms
), 0));
2955 dbxout_type (TREE_TYPE (parms
), 0);
2956 dbxout_finish_symbol (parms
);
2959 DBXOUT_DECR_NESTING
;
2962 /* Output definitions for the places where parms live during the function,
2963 when different from where they were passed, when the parms were passed
2966 It is not useful to do this for parms passed in registers
2967 that live during the function in different registers, because it is
2968 impossible to look in the passed register for the passed value,
2969 so we use the within-the-function register to begin with.
2971 PARMS is a chain of PARM_DECL nodes. */
2974 dbxout_reg_parms (tree parms
)
2978 for (; parms
; parms
= TREE_CHAIN (parms
))
2979 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2981 dbxout_prepare_symbol (parms
);
2983 /* Report parms that live in registers during the function
2984 but were passed in memory. */
2985 if (GET_CODE (DECL_RTL (parms
)) == REG
2986 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2987 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2988 0, DECL_RTL (parms
));
2989 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2990 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2991 0, DECL_RTL (parms
));
2992 /* Report parms that live in memory but not where they were passed. */
2993 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2994 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2995 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2996 0, DECL_RTL (parms
));
2998 DBXOUT_DECR_NESTING
;
3001 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3002 output definitions of those names, in raw form */
3005 dbxout_args (tree args
)
3009 putc (',', asmfile
);
3010 dbxout_type (TREE_VALUE (args
), 0);
3012 args
= TREE_CHAIN (args
);
3016 /* Output everything about a symbol block (a BLOCK node
3017 that represents a scope level),
3018 including recursive output of contained blocks.
3020 BLOCK is the BLOCK node.
3021 DEPTH is its depth within containing symbol blocks.
3022 ARGS is usually zero; but for the outermost block of the
3023 body of a function, it is a chain of PARM_DECLs for the function parameters.
3024 We output definitions of all the register parms
3025 as if they were local variables of that block.
3027 If -g1 was used, we count blocks just the same, but output nothing
3028 except for the outermost block.
3030 Actually, BLOCK may be several blocks chained together.
3031 We handle them all in sequence. */
3034 dbxout_block (tree block
, int depth
, tree args
)
3038 #if DBX_BLOCKS_FUNCTION_RELATIVE
3039 const char *begin_label
;
3040 if (current_function_func_begin_label
!= NULL_TREE
)
3041 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
3043 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3048 /* Ignore blocks never expanded or otherwise marked as real. */
3049 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3053 /* In dbx format, the syms of a block come before the N_LBRAC.
3054 If nothing is output, we don't need the N_LBRAC, either. */
3056 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3057 did_output
= dbxout_syms (BLOCK_VARS (block
));
3059 dbxout_reg_parms (args
);
3061 /* Now output an N_LBRAC symbol to represent the beginning of
3062 the block. Use the block's tree-walk order to generate
3063 the assembler symbols LBBn and LBEn
3064 that final will define around the code in this block. */
3065 if (depth
> 0 && did_output
)
3068 blocknum
= BLOCK_NUMBER (block
);
3069 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3071 if (BLOCK_HANDLER_BLOCK (block
))
3073 /* A catch block. Must precede N_LBRAC. */
3074 tree decl
= BLOCK_VARS (block
);
3077 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
3078 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
3079 assemble_name (asmfile
, buf
);
3080 fprintf (asmfile
, "\n");
3081 decl
= TREE_CHAIN (decl
);
3085 #ifdef DBX_OUTPUT_LBRAC
3086 DBX_OUTPUT_LBRAC (asmfile
, buf
);
3088 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
3089 assemble_name (asmfile
, buf
);
3090 #if DBX_BLOCKS_FUNCTION_RELATIVE
3091 putc ('-', asmfile
);
3092 assemble_name (asmfile
, begin_label
);
3094 fprintf (asmfile
, "\n");
3098 /* Output the subblocks. */
3099 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3101 /* Refer to the marker for the end of the block. */
3102 if (depth
> 0 && did_output
)
3105 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3106 #ifdef DBX_OUTPUT_RBRAC
3107 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3109 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3110 assemble_name (asmfile
, buf
);
3111 #if DBX_BLOCKS_FUNCTION_RELATIVE
3112 putc ('-', asmfile
);
3113 assemble_name (asmfile
, begin_label
);
3115 fprintf (asmfile
, "\n");
3119 block
= BLOCK_CHAIN (block
);
3123 /* Output the information about a function and its arguments and result.
3124 Usually this follows the function's code,
3125 but on some systems, it comes before. */
3127 #if defined (DBX_DEBUGGING_INFO)
3129 dbxout_begin_function (tree decl
)
3131 int saved_tree_used1
= TREE_USED (decl
);
3132 TREE_USED (decl
) = 1;
3133 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3135 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3136 TREE_USED (DECL_RESULT (decl
)) = 1;
3137 dbxout_symbol (decl
, 0);
3138 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3141 dbxout_symbol (decl
, 0);
3142 TREE_USED (decl
) = saved_tree_used1
;
3144 dbxout_parms (DECL_ARGUMENTS (decl
));
3145 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3146 dbxout_symbol (DECL_RESULT (decl
), 1);
3148 #endif /* DBX_DEBUGGING_INFO */
3150 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3152 #include "gt-dbxout.h"