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, 2004 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"
90 #include "langhooks.h"
92 #ifdef XCOFF_DEBUGGING_INFO
96 #define DBXOUT_DECR_NESTING \
97 if (--debug_nesting == 0 && symbol_queue_index > 0) \
98 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
100 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
101 do {--debug_nesting; return (x);} while (0)
104 #define ASM_STABS_OP "\t.stabs\t"
108 #define ASM_STABN_OP "\t.stabn\t"
111 #ifndef DBX_TYPE_DECL_STABS_CODE
112 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
115 #ifndef DBX_STATIC_CONST_VAR_CODE
116 #define DBX_STATIC_CONST_VAR_CODE N_FUN
119 #ifndef DBX_REGPARM_STABS_CODE
120 #define DBX_REGPARM_STABS_CODE N_RSYM
123 #ifndef DBX_REGPARM_STABS_LETTER
124 #define DBX_REGPARM_STABS_LETTER 'P'
127 #ifndef NO_DBX_FUNCTION_END
128 #define NO_DBX_FUNCTION_END 0
131 #ifndef NO_DBX_BNSYM_ENSYM
132 #define NO_DBX_BNSYM_ENSYM 0
135 #ifndef DBX_BLOCKS_FUNCTION_RELATIVE
136 #define DBX_BLOCKS_FUNCTION_RELATIVE 0
139 #ifndef DBX_LINES_FUNCTION_RELATIVE
140 #define DBX_LINES_FUNCTION_RELATIVE 0
143 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
145 /* Structure recording information about a C data type.
146 The status element says whether we have yet output
147 the definition of the type. TYPE_XREF says we have
148 output it as a cross-reference only.
149 The file_number and type_number elements are used if DBX_USE_BINCL
152 struct typeinfo GTY(())
154 enum typestatus status;
159 /* Vector recording information about C data types.
160 When we first notice a data type (a tree node),
161 we assign it a number using next_type_number.
162 That is its index in this vector. */
164 static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
166 /* Number of elements of space allocated in `typevec'. */
168 static GTY(()) int typevec_len;
170 /* In dbx output, each type gets a unique number.
171 This is the number for the next type output.
172 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
174 static GTY(()) int next_type_number;
176 /* The C front end may call dbxout_symbol before dbxout_init runs.
177 We save all such decls in this list and output them when we get
180 static GTY(()) tree preinit_symbols;
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 #ifdef DEBUG_SYMS_TEXT
257 #define FORCE_TEXT function_section (current_function_decl);
264 #define STAB_CODE_TYPE enum __stab_debug_code
266 /* 1 if PARM is passed to this function in memory. */
268 #define PARM_PASSED_IN_MEMORY(PARM) \
269 (MEM_P (DECL_INCOMING_RTL (PARM)))
271 /* A C expression for the integer offset value of an automatic variable
272 (N_LSYM) having address X (an RTX). */
273 #ifndef DEBUGGER_AUTO_OFFSET
274 #define DEBUGGER_AUTO_OFFSET(X) \
275 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
278 /* A C expression for the integer offset value of an argument (N_PSYM)
279 having address X (an RTX). The nominal offset is OFFSET. */
280 #ifndef DEBUGGER_ARG_OFFSET
281 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
284 /* These variables are for dbxout_symbol to communicate to
285 dbxout_finish_symbol.
286 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
287 current_sym_value and current_sym_addr are two ways to address the
288 value to store in the symtab entry.
289 current_sym_addr if nonzero represents the value as an rtx.
290 If that is zero, current_sym_value is used. This is used
291 when the value is an offset (such as for auto variables,
292 register variables and parms). */
294 static STAB_CODE_TYPE current_sym_code;
295 static int current_sym_value;
296 static rtx current_sym_addr;
298 /* Number of chars of symbol-description generated so far for the
299 current symbol. Used by CHARS and CONTIN. */
301 static int current_sym_nchars;
303 /* Report having output N chars of the current symbol-description. */
305 #define CHARS(N) (current_sym_nchars += (N))
307 /* Break the current symbol-description, generating a continuation,
308 if it has become long. */
310 #ifndef DBX_CONTIN_LENGTH
311 #define DBX_CONTIN_LENGTH 80
314 #if DBX_CONTIN_LENGTH > 0
316 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
318 #define CONTIN do { } while (0)
322 static void emit_bincl_stab (const char *c);
323 static void emit_pending_bincls (void);
325 static inline void emit_pending_bincls_if_required (void);
327 static void dbxout_init (const char *);
328 #ifndef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
329 static unsigned int get_lang_number (void);
331 static void dbxout_finish (const char *);
332 static void dbxout_start_source_file (unsigned, const char *);
333 static void dbxout_end_source_file (unsigned);
334 static void dbxout_typedefs (tree);
335 static void dbxout_type_index (tree);
336 #if DBX_CONTIN_LENGTH > 0
337 static void dbxout_continue (void);
339 static void dbxout_args (tree);
340 static void dbxout_type_fields (tree);
341 static void dbxout_type_method_1 (tree, const char *);
342 static void dbxout_type_methods (tree);
343 static void dbxout_range_type (tree);
344 static void dbxout_type (tree, int);
345 static bool print_int_cst_bounds_in_octal_p (tree);
346 static void print_int_cst_octal (tree);
347 static void print_octal (unsigned HOST_WIDE_INT, int);
348 static void print_wide_int (HOST_WIDE_INT);
349 static void dbxout_type_name (tree);
350 static void dbxout_class_name_qualifiers (tree);
351 static int dbxout_symbol_location (tree, tree, const char *, rtx);
352 static void dbxout_symbol_name (tree, const char *, int);
353 static void dbxout_prepare_symbol (tree);
354 static void dbxout_finish_symbol (tree);
355 static void dbxout_block (tree, int, tree);
356 static void dbxout_global_decl (tree);
357 static void dbxout_type_decl (tree, int);
358 static void dbxout_handle_pch (unsigned);
360 /* The debug hooks structure. */
361 #if defined (DBX_DEBUGGING_INFO)
363 static void dbxout_source_line (unsigned int, const char *);
364 static void dbxout_begin_prologue (unsigned int, const char *);
365 static void dbxout_source_file (FILE *, const char *);
366 static void dbxout_function_end (void);
367 static void dbxout_begin_function (tree);
368 static void dbxout_begin_block (unsigned, unsigned);
369 static void dbxout_end_block (unsigned, unsigned);
370 static void dbxout_function_decl (tree);
372 const struct gcc_debug_hooks dbx_debug_hooks =
376 debug_nothing_int_charstar,
377 debug_nothing_int_charstar,
378 dbxout_start_source_file,
379 dbxout_end_source_file,
382 debug_true_tree, /* ignore_block */
383 dbxout_source_line, /* source_line */
384 dbxout_begin_prologue, /* begin_prologue */
385 debug_nothing_int_charstar, /* end_prologue */
386 debug_nothing_int_charstar, /* end_epilogue */
387 #ifdef DBX_FUNCTION_FIRST
388 dbxout_begin_function,
390 debug_nothing_tree, /* begin_function */
392 debug_nothing_int, /* end_function */
393 dbxout_function_decl,
394 dbxout_global_decl, /* global_decl */
395 dbxout_type_decl, /* type_decl */
396 debug_nothing_tree_tree, /* imported_module_or_decl */
397 debug_nothing_tree, /* deferred_inline_function */
398 debug_nothing_tree, /* outlining_inline_function */
399 debug_nothing_rtx, /* label */
400 dbxout_handle_pch, /* handle_pch */
401 debug_nothing_rtx /* var_location */
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 dbxout_type_decl, /* type_decl */
426 debug_nothing_tree_tree, /* imported_module_or_decl */
427 debug_nothing_tree, /* deferred_inline_function */
428 debug_nothing_tree, /* outlining_inline_function */
429 debug_nothing_rtx, /* label */
430 dbxout_handle_pch, /* handle_pch */
431 debug_nothing_rtx /* var_location */
433 #endif /* XCOFF_DEBUGGING_INFO */
435 #if defined (DBX_DEBUGGING_INFO)
437 dbxout_function_end (void)
439 char lscope_label_name[100];
441 /* The Lscope label must be emitted even if we aren't doing anything
442 else; dbxout_block needs it. */
443 function_section (current_function_decl);
445 /* Convert Ltext into the appropriate format for local labels in case
446 the system doesn't insert underscores in front of user generated
448 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
449 targetm.asm_out.internal_label (asm_out_file, "Lscope", scope_labelno);
452 /* The N_FUN tag at the end of the function is a GNU extension,
453 which may be undesirable, and is unnecessary if we do not have
455 if (!use_gnu_debug_info_extensions
456 || NO_DBX_FUNCTION_END
457 || !targetm.have_named_sections)
460 /* By convention, GCC will mark the end of a function with an N_FUN
461 symbol and an empty string. */
462 #ifdef DBX_OUTPUT_NFUN
463 DBX_OUTPUT_NFUN (asm_out_file, lscope_label_name, current_function_decl);
465 fprintf (asm_out_file, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
466 assemble_name (asm_out_file, lscope_label_name);
467 putc ('-', asm_out_file);
468 assemble_name (asm_out_file, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
469 fprintf (asm_out_file, "\n");
472 if (!NO_DBX_BNSYM_ENSYM && !flag_debug_only_used_symbols)
473 fprintf (asm_out_file, "%s%d,0,0\n", ASM_STABD_OP, N_ENSYM);
475 #endif /* DBX_DEBUGGING_INFO */
477 #ifndef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
478 /* Get lang description for N_SO stab. */
481 get_lang_number (void)
483 const char *language_string = lang_hooks.name;
485 if (strcmp (language_string, "GNU C") == 0)
487 else if (strcmp (language_string, "GNU C++") == 0)
489 else if (strcmp (language_string, "GNU F77") == 0)
491 else if (strcmp (language_string, "GNU F95") == 0)
492 return N_SO_FORTRAN90; /* CHECKME */
493 else if (strcmp (language_string, "GNU Pascal") == 0)
495 else if (strcmp (language_string, "GNU Objective-C") == 0)
503 /* At the beginning of compilation, start writing the symbol table.
504 Initialize `typevec' and output the standard data types of C. */
507 dbxout_init (const char *input_file_name)
509 char ltext_label_name[100];
510 tree syms = lang_hooks.decls.getdecls ();
513 typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
515 /* Convert Ltext into the appropriate format for local labels in case
516 the system doesn't insert underscores in front of user generated
518 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
520 /* Put the current working directory in an N_SO symbol. */
521 if (use_gnu_debug_info_extensions)
523 static const char *cwd;
527 cwd = get_src_pwd ();
530 else if (!IS_DIR_SEPARATOR (cwd[strlen (cwd) - 1]))
531 cwd = concat (cwd, "/", NULL);
534 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
535 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file, cwd);
536 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
537 fprintf (asm_out_file, "%s", ASM_STABS_OP);
538 output_quoted_string (asm_out_file, cwd);
539 fprintf (asm_out_file, ",%d,0,%d,", N_SO, get_lang_number ());
540 assemble_name (asm_out_file, ltext_label_name);
541 fputc ('\n', asm_out_file);
542 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
545 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
546 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file, input_file_name);
547 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
548 /* We include outputting `Ltext:' here,
549 because that gives you a way to override it. */
550 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
551 fprintf (asm_out_file, "%s", ASM_STABS_OP);
552 output_quoted_string (asm_out_file, input_file_name);
553 fprintf (asm_out_file, ",%d,0,%d,", N_SO, get_lang_number ());
554 assemble_name (asm_out_file, ltext_label_name);
555 fputc ('\n', asm_out_file);
557 targetm.asm_out.internal_label (asm_out_file, "Ltext", 0);
558 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
560 #ifdef DBX_OUTPUT_GCC_MARKER
561 DBX_OUTPUT_GCC_MARKER (asm_out_file);
563 /* Emit an N_OPT stab to indicate that this file was compiled by GCC.
564 The string used is historical. */
565 fprintf (asm_out_file, "%s\"gcc2_compiled.\",%d,0,0,0\n",
566 ASM_STABS_OP, N_OPT);
569 base_input_file = lastfile = input_file_name;
571 next_type_number = 1;
574 current_file = xmalloc (sizeof *current_file);
575 current_file->next = NULL;
576 current_file->file_number = 0;
577 current_file->next_type_number = 1;
578 next_file_number = 1;
579 current_file->prev = NULL;
580 current_file->bincl_status = BINCL_NOT_REQUIRED;
581 current_file->pending_bincl_name = NULL;
584 /* Get all permanent types that have typedef names, and output them
585 all, except for those already output. Some language front ends
586 put these declarations in the top-level scope; some do not;
587 the latter are responsible for calling debug_hooks->type_decl from
588 their record_builtin_type function. */
589 dbxout_typedefs (syms);
594 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
595 dbxout_symbol (TREE_VALUE (t), 0);
600 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
603 dbxout_typedefs (tree syms)
605 for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
607 if (TREE_CODE (syms) == TYPE_DECL)
609 tree type = TREE_TYPE (syms);
611 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
612 && COMPLETE_OR_VOID_TYPE_P (type)
613 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
614 dbxout_symbol (TYPE_NAME (type), 0);
620 /* Emit BINCL stab using given name. */
622 emit_bincl_stab (const char *name)
624 fprintf (asm_out_file, "%s", ASM_STABS_OP);
625 output_quoted_string (asm_out_file, name);
626 fprintf (asm_out_file, ",%d,0,0,0\n", N_BINCL);
629 /* If there are pending bincls then it is time to emit all of them. */
632 emit_pending_bincls_if_required (void)
635 emit_pending_bincls ();
638 /* Emit all pending bincls. */
641 emit_pending_bincls (void)
643 struct dbx_file *f = current_file;
645 /* Find first pending bincl. */
646 while (f->bincl_status == BINCL_PENDING)
649 /* Now emit all bincls. */
654 if (f->bincl_status == BINCL_PENDING)
656 emit_bincl_stab (f->pending_bincl_name);
658 /* Update file number and status. */
659 f->file_number = next_file_number++;
660 f->bincl_status = BINCL_PROCESSED;
662 if (f == current_file)
667 /* All pending bincls have been emitted. */
674 emit_pending_bincls_if_required (void) {}
677 /* Change to reading from a new source file. Generate a N_BINCL stab. */
680 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
681 const char *filename ATTRIBUTE_UNUSED)
684 struct dbx_file *n = xmalloc (sizeof *n);
686 n->next = current_file;
687 n->next_type_number = 1;
688 /* Do not assign file number now.
689 Delay it until we actually emit BINCL. */
692 current_file->prev = n;
693 n->bincl_status = BINCL_PENDING;
694 n->pending_bincl_name = filename;
700 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
703 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
706 /* Emit EINCL stab only if BINCL is not pending. */
707 if (current_file->bincl_status == BINCL_PROCESSED)
708 fprintf (asm_out_file, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
709 current_file->bincl_status = BINCL_NOT_REQUIRED;
710 current_file = current_file->next;
714 /* Handle a few odd cases that occur when trying to make PCH files work. */
717 dbxout_handle_pch (unsigned at_end)
721 /* When using the PCH, this file will be included, so we need to output
723 dbxout_start_source_file (0, lastfile);
725 /* The base file when using the PCH won't be the same as
726 the base file when it's being generated. */
731 /* ... and an EINCL. */
732 dbxout_end_source_file (0);
734 /* Deal with cases where 'lastfile' was never actually changed. */
735 lastfile_is_base = lastfile == NULL;
739 #if defined (DBX_DEBUGGING_INFO)
740 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
743 dbxout_source_file (FILE *file, const char *filename)
745 if (lastfile == 0 && lastfile_is_base)
747 lastfile = base_input_file;
748 lastfile_is_base = 0;
751 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
753 char ltext_label_name[100];
755 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
756 source_label_number);
757 fprintf (file, "%s", ASM_STABS_OP);
758 output_quoted_string (file, filename);
759 fprintf (asm_out_file, ",%d,0,0,", N_SOL);
760 assemble_name (asm_out_file, ltext_label_name);
761 fputc ('\n', asm_out_file);
762 if (current_function_decl != NULL_TREE)
763 ; /* Don't change section amid function. */
766 targetm.asm_out.internal_label (file, "Ltext", source_label_number);
767 source_label_number++;
772 /* Output N_BNSYM and line number symbol entry. */
775 dbxout_begin_prologue (unsigned int lineno, const char *filename)
777 if (use_gnu_debug_info_extensions
778 && !NO_DBX_FUNCTION_END
779 && !NO_DBX_BNSYM_ENSYM
780 && !flag_debug_only_used_symbols)
781 fprintf (asm_out_file, "%s%d,0,0\n", ASM_STABD_OP, N_BNSYM);
783 dbxout_source_line (lineno, filename);
786 /* Output a line number symbol entry for source file FILENAME and line
790 dbxout_source_line (unsigned int lineno, const char *filename)
792 dbxout_source_file (asm_out_file, filename);
794 #ifdef DBX_OUTPUT_SOURCE_LINE
795 dbxout_source_line_counter += 1;
796 DBX_OUTPUT_SOURCE_LINE (asm_out_file, lineno, dbxout_source_line_counter);
798 if (DBX_LINES_FUNCTION_RELATIVE)
801 dbxout_source_line_counter += 1;
803 ASM_GENERATE_INTERNAL_LABEL (label, "LM", dbxout_source_line_counter);
804 fprintf (asm_out_file, "%s%d,0,%d,", ASM_STABN_OP, N_SLINE, lineno);
805 assemble_name (asm_out_file, label);
806 putc ('-', asm_out_file);
807 assemble_name (asm_out_file,
808 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
809 putc ('\n', asm_out_file);
810 targetm.asm_out.internal_label (asm_out_file, "LM",
811 dbxout_source_line_counter);
814 fprintf (asm_out_file, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
818 /* Describe the beginning of an internal block within a function. */
821 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
823 emit_pending_bincls_if_required ();
824 targetm.asm_out.internal_label (asm_out_file, "LBB", n);
827 /* Describe the end line-number of an internal block within a function. */
830 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
832 emit_pending_bincls_if_required ();
833 targetm.asm_out.internal_label (asm_out_file, "LBE", n);
836 /* Output dbx data for a function definition.
837 This includes a definition of the function name itself (a symbol),
838 definitions of the parameters (locating them in the parameter list)
839 and then output the block that makes up the function's body
840 (including all the auto variables of the function). */
843 dbxout_function_decl (tree decl)
845 emit_pending_bincls_if_required ();
846 #ifndef DBX_FUNCTION_FIRST
847 dbxout_begin_function (decl);
849 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
850 dbxout_function_end ();
853 #endif /* DBX_DEBUGGING_INFO */
855 /* Debug information for a global DECL. Called from toplev.c after
856 compilation proper has finished. */
858 dbxout_global_decl (tree decl)
860 if (TREE_CODE (decl) == VAR_DECL
861 && ! DECL_EXTERNAL (decl)
862 && DECL_RTL_SET_P (decl)) /* Not necessary? */
864 int saved_tree_used = TREE_USED (decl);
865 TREE_USED (decl) = 1;
866 dbxout_symbol (decl, 0);
867 TREE_USED (decl) = saved_tree_used;
871 /* This is just a function-type adapter; dbxout_symbol does exactly
872 what we want but returns an int. */
874 dbxout_type_decl (tree decl, int local)
876 dbxout_symbol (decl, local);
879 /* At the end of compilation, finish writing the symbol table.
880 The default is to call debug_free_queue but do nothing else. */
883 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
885 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
886 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file, filename);
887 #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
889 char letext_label[100];
890 ASM_GENERATE_INTERNAL_LABEL (letext_label, "Letext", 0);
891 fprintf (asm_out_file, "%s\"\",%d,0,0,", ASM_STABS_OP, N_SO);
892 assemble_name (asm_out_file, letext_label);
893 putc ('\n', asm_out_file);
894 targetm.asm_out.internal_label (asm_out_file, "Letext", 0);
900 /* Output the index of a type. */
903 dbxout_type_index (tree type)
905 #ifndef DBX_USE_BINCL
906 fprintf (asm_out_file, "%d", TYPE_SYMTAB_ADDRESS (type));
909 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
910 fprintf (asm_out_file, "(%d,%d)", t->file_number, t->type_number);
915 #if DBX_CONTIN_LENGTH > 0
916 /* Continue a symbol-description that gets too big.
917 End one symbol table entry with a double-backslash
918 and start a new one, eventually producing something like
919 .stabs "start......\\",code,0,value
920 .stabs "...rest",code,0,value */
923 dbxout_continue (void)
925 emit_pending_bincls_if_required ();
926 #ifdef DBX_CONTIN_CHAR
927 fprintf (asm_out_file, "%c", DBX_CONTIN_CHAR);
929 fprintf (asm_out_file, "\\\\");
931 dbxout_finish_symbol (NULL_TREE);
932 fprintf (asm_out_file, "%s\"", ASM_STABS_OP);
933 current_sym_nchars = 0;
935 #endif /* DBX_CONTIN_LENGTH > 0 */
937 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
938 This must be a separate function because anonymous unions require
942 dbxout_type_fields (tree type)
946 /* Output the name, type, position (in bits), size (in bits) of each
947 field that we can support. */
948 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
950 /* If one of the nodes is an error_mark or its type is then
952 if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
955 /* Omit here local type decls until we know how to support them. */
956 if (TREE_CODE (tem) == TYPE_DECL
957 /* Omit fields whose position or size are variable or too large to
959 || (TREE_CODE (tem) == FIELD_DECL
960 && (! host_integerp (bit_position (tem), 0)
962 || ! host_integerp (DECL_SIZE (tem), 1)))
963 /* Omit here the nameless fields that are used to skip bits. */
964 || DECL_IGNORED_P (tem))
967 else if (TREE_CODE (tem) != CONST_DECL)
969 /* Continue the line if necessary,
970 but not before the first field. */
971 if (tem != TYPE_FIELDS (type))
976 fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
977 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
981 fprintf (asm_out_file, ":");
985 if (use_gnu_debug_info_extensions
986 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
987 || TREE_CODE (tem) != FIELD_DECL))
989 have_used_extensions = 1;
990 putc ('/', asm_out_file);
991 putc ((TREE_PRIVATE (tem) ? '0'
992 : TREE_PROTECTED (tem) ? '1' : '2'),
997 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
998 && DECL_BIT_FIELD_TYPE (tem))
999 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
1001 if (TREE_CODE (tem) == VAR_DECL)
1003 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
1005 tree name = DECL_ASSEMBLER_NAME (tem);
1007 have_used_extensions = 1;
1008 fprintf (asm_out_file, ":%s;", IDENTIFIER_POINTER (name));
1009 CHARS (IDENTIFIER_LENGTH (name) + 2);
1013 /* If TEM is non-static, GDB won't understand it. */
1014 fprintf (asm_out_file, ",0,0;");
1020 putc (',', asm_out_file);
1021 print_wide_int (int_bit_position (tem));
1022 putc (',', asm_out_file);
1023 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
1024 putc (';', asm_out_file);
1031 /* Subroutine of `dbxout_type_methods'. Output debug info about the
1032 method described DECL. DEBUG_NAME is an encoding of the method's
1033 type signature. ??? We may be able to do without DEBUG_NAME altogether
1037 dbxout_type_method_1 (tree decl, const char *debug_name)
1041 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
1043 else /* it's a METHOD_TYPE. */
1045 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
1046 /* A for normal functions.
1047 B for `const' member functions.
1048 C for `volatile' member functions.
1049 D for `const volatile' member functions. */
1050 if (TYPE_READONLY (TREE_TYPE (firstarg)))
1052 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
1055 if (DECL_VINDEX (decl))
1061 fprintf (asm_out_file, ":%s;%c%c%c", debug_name,
1062 TREE_PRIVATE (decl) ? '0'
1063 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
1064 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
1065 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
1067 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
1069 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
1070 putc (';', asm_out_file);
1072 dbxout_type (DECL_CONTEXT (decl), 0);
1073 fprintf (asm_out_file, ";");
1078 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1082 dbxout_type_methods (tree type)
1084 /* C++: put out the method names and their parameter lists */
1085 tree methods = TYPE_METHODS (type);
1089 char formatted_type_identifier_length[16];
1090 int type_identifier_length;
1092 if (methods == NULL_TREE)
1095 type_encoding = DECL_NAME (TYPE_NAME (type));
1097 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1099 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1101 if (TREE_CODE (methods) != TREE_VEC)
1103 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1104 fndecl = TREE_VEC_ELT (methods, 0);
1106 fndecl = TREE_VEC_ELT (methods, 1);
1110 int need_prefix = 1;
1112 /* Group together all the methods for the same operation.
1113 These differ in the types of the arguments. */
1114 for (last = NULL_TREE;
1115 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1116 fndecl = TREE_CHAIN (fndecl))
1117 /* Output the name of the field (after overloading), as
1118 well as the name of the field before overloading, along
1119 with its parameter list */
1121 /* This is the "mangled" name of the method.
1122 It encodes the argument types. */
1123 const char *debug_name;
1125 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1126 include TEMPLATE_DECLs.) The debugger doesn't know what
1127 to do with such entities anyhow. */
1128 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1131 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1137 /* Also ignore abstract methods; those are only interesting to
1138 the DWARF backends. */
1139 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1142 /* Redundantly output the plain name, since that's what gdb
1146 tree name = DECL_NAME (fndecl);
1147 fprintf (asm_out_file, "%s::", IDENTIFIER_POINTER (name));
1148 CHARS (IDENTIFIER_LENGTH (name) + 2);
1152 dbxout_type (TREE_TYPE (fndecl), 0);
1154 dbxout_type_method_1 (fndecl, debug_name);
1158 putc (';', asm_out_file);
1164 /* Emit a "range" type specification, which has the form:
1165 "r<index type>;<lower bound>;<upper bound>;".
1166 TYPE is an INTEGER_TYPE. */
1169 dbxout_range_type (tree type)
1171 fprintf (asm_out_file, "r");
1172 if (TREE_TYPE (type))
1173 dbxout_type (TREE_TYPE (type), 0);
1174 else if (TREE_CODE (type) != INTEGER_TYPE)
1175 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1178 /* Traditionally, we made sure 'int' was type 1, and builtin types
1179 were defined to be sub-ranges of int. Unfortunately, this
1180 does not allow us to distinguish true sub-ranges from integer
1181 types. So, instead we define integer (non-sub-range) types as
1182 sub-ranges of themselves. This matters for Chill. If this isn't
1183 a subrange type, then we want to define it in terms of itself.
1184 However, in C, this may be an anonymous integer type, and we don't
1185 want to emit debug info referring to it. Just calling
1186 dbxout_type_index won't work anyways, because the type hasn't been
1187 defined yet. We make this work for both cases by checked to see
1188 whether this is a defined type, referring to it if it is, and using
1190 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1191 dbxout_type_index (type);
1193 dbxout_type_index (integer_type_node);
1196 if (TYPE_MIN_VALUE (type) != 0
1197 && host_integerp (TYPE_MIN_VALUE (type), 0))
1199 putc (';', asm_out_file);
1201 if (print_int_cst_bounds_in_octal_p (type))
1202 print_int_cst_octal (TYPE_MIN_VALUE (type));
1204 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1208 fprintf (asm_out_file, ";0");
1212 if (TYPE_MAX_VALUE (type) != 0
1213 && host_integerp (TYPE_MAX_VALUE (type), 0))
1215 putc (';', asm_out_file);
1217 if (print_int_cst_bounds_in_octal_p (type))
1218 print_int_cst_octal (TYPE_MAX_VALUE (type));
1220 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1221 putc (';', asm_out_file);
1226 fprintf (asm_out_file, ";-1;");
1232 /* Output a reference to a type. If the type has not yet been
1233 described in the dbx output, output its definition now.
1234 For a type already defined, just refer to its definition
1235 using the type number.
1237 If FULL is nonzero, and the type has been described only with
1238 a forward-reference, output the definition now.
1239 If FULL is zero in this case, just refer to the forward-reference
1240 using the number previously allocated. */
1243 dbxout_type (tree type, int full)
1247 static int anonymous_type_number = 0;
1249 if (TREE_CODE (type) == VECTOR_TYPE)
1250 /* The frontend feeds us a representation for the vector as a struct
1251 containing an array. Pull out the array type. */
1252 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1254 /* If there was an input error and we don't really have a type,
1255 avoid crashing and write something that is at least valid
1256 by assuming `int'. */
1257 if (type == error_mark_node)
1258 type = integer_type_node;
1261 if (TYPE_NAME (type)
1262 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1263 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1267 /* Try to find the "main variant" with the same name. */
1268 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1269 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1270 main_variant = TREE_TYPE (TYPE_NAME (type));
1272 main_variant = TYPE_MAIN_VARIANT (type);
1274 /* If we are not using extensions, stabs does not distinguish const and
1275 volatile, so there is no need to make them separate types. */
1276 if (!use_gnu_debug_info_extensions)
1277 type = main_variant;
1279 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1281 /* Type has no dbx number assigned. Assign next available number. */
1282 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1284 /* Make sure type vector is long enough to record about this type. */
1286 if (next_type_number == typevec_len)
1289 = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1290 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1294 #ifdef DBX_USE_BINCL
1295 emit_pending_bincls_if_required ();
1296 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1297 = current_file->file_number;
1298 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1299 = current_file->next_type_number++;
1303 if (flag_debug_only_used_symbols)
1305 if ((TREE_CODE (type) == RECORD_TYPE
1306 || TREE_CODE (type) == UNION_TYPE
1307 || TREE_CODE (type) == QUAL_UNION_TYPE
1308 || TREE_CODE (type) == ENUMERAL_TYPE)
1309 && TYPE_STUB_DECL (type)
1310 && DECL_P (TYPE_STUB_DECL (type))
1311 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1312 debug_queue_symbol (TYPE_STUB_DECL (type));
1313 else if (TYPE_NAME (type)
1314 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1315 debug_queue_symbol (TYPE_NAME (type));
1318 /* Output the number of this type, to refer to it. */
1319 dbxout_type_index (type);
1321 #ifdef DBX_TYPE_DEFINED
1322 if (DBX_TYPE_DEFINED (type))
1326 /* If this type's definition has been output or is now being output,
1329 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1334 /* If we have already had a cross reference,
1335 and either that's all we want or that's the best we could do,
1336 don't repeat the cross reference.
1337 Sun dbx crashes if we do. */
1338 if (! full || !COMPLETE_TYPE_P (type)
1339 /* No way in DBX fmt to describe a variable size. */
1340 || ! host_integerp (TYPE_SIZE (type), 1))
1348 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1349 leave the type-number completely undefined rather than output
1350 a cross-reference. If we have already used GNU debug info extensions,
1351 then it is OK to output a cross reference. This is necessary to get
1352 proper C++ debug output. */
1353 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1354 || TREE_CODE (type) == QUAL_UNION_TYPE
1355 || TREE_CODE (type) == ENUMERAL_TYPE)
1356 && ! use_gnu_debug_info_extensions)
1357 /* We must use the same test here as we use twice below when deciding
1358 whether to emit a cross-reference. */
1359 if ((TYPE_NAME (type) != 0
1360 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1361 && DECL_IGNORED_P (TYPE_NAME (type)))
1363 || !COMPLETE_TYPE_P (type)
1364 /* No way in DBX fmt to describe a variable size. */
1365 || ! host_integerp (TYPE_SIZE (type), 1))
1367 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1372 /* Output a definition now. */
1374 fprintf (asm_out_file, "=");
1377 /* Mark it as defined, so that if it is self-referent
1378 we will not get into an infinite recursion of definitions. */
1380 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1382 /* If this type is a variant of some other, hand off. Types with
1383 different names are usefully distinguished. We only distinguish
1384 cv-qualified types if we're using extensions. */
1385 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1387 putc ('k', asm_out_file);
1389 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1392 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1394 putc ('B', asm_out_file);
1396 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1399 else if (main_variant != TYPE_MAIN_VARIANT (type))
1401 if (flag_debug_only_used_symbols)
1403 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1405 if ((TREE_CODE (orig_type) == RECORD_TYPE
1406 || TREE_CODE (orig_type) == UNION_TYPE
1407 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1408 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1409 && TYPE_STUB_DECL (orig_type)
1410 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1411 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1413 /* 'type' is a typedef; output the type it refers to. */
1414 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1417 /* else continue. */
1419 switch (TREE_CODE (type))
1423 /* For a void type, just define it as itself; i.e., "5=5".
1424 This makes us consider it defined
1425 without saying what it is. The debugger will make it
1426 a void type when the reference is seen, and nothing will
1427 ever override that default. */
1428 dbxout_type_index (type);
1432 if (type == char_type_node && ! TYPE_UNSIGNED (type))
1434 /* Output the type `char' as a subrange of itself!
1435 I don't understand this definition, just copied it
1436 from the output of pcc.
1437 This used to use `r2' explicitly and we used to
1438 take care to make sure that `char' was type number 2. */
1439 fprintf (asm_out_file, "r");
1441 dbxout_type_index (type);
1442 fprintf (asm_out_file, ";0;127;");
1446 /* If this is a subtype of another integer type, always prefer to
1447 write it as a subtype. */
1448 else if (TREE_TYPE (type) != 0
1449 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1451 /* If the size is non-standard, say what it is if we can use
1454 if (use_gnu_debug_info_extensions
1455 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1457 have_used_extensions = 1;
1458 fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type));
1462 dbxout_range_type (type);
1467 /* If the size is non-standard, say what it is if we can use
1470 if (use_gnu_debug_info_extensions
1471 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1473 have_used_extensions = 1;
1474 fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type));
1478 if (print_int_cst_bounds_in_octal_p (type))
1480 fprintf (asm_out_file, "r");
1483 /* If this type derives from another type, output type index of
1484 parent type. This is particularly important when parent type
1485 is an enumerated type, because not generating the parent type
1486 index would transform the definition of this enumerated type
1487 into a plain unsigned type. */
1488 if (TREE_TYPE (type) != 0)
1489 dbxout_type_index (TREE_TYPE (type));
1491 dbxout_type_index (type);
1493 fprintf (asm_out_file, ";");
1495 print_int_cst_octal (TYPE_MIN_VALUE (type));
1496 fprintf (asm_out_file, ";");
1498 print_int_cst_octal (TYPE_MAX_VALUE (type));
1499 fprintf (asm_out_file, ";");
1504 /* Output other integer types as subranges of `int'. */
1505 dbxout_range_type (type);
1511 /* This used to say `r1' and we used to take care
1512 to make sure that `int' was type number 1. */
1513 fprintf (asm_out_file, "r");
1515 dbxout_type_index (integer_type_node);
1516 putc (';', asm_out_file);
1518 print_wide_int (int_size_in_bytes (type));
1519 fputs (";0;", asm_out_file);
1524 if (use_gnu_debug_info_extensions)
1526 have_used_extensions = 1;
1527 fputs ("@s", asm_out_file);
1529 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1530 fputs (";-20;", asm_out_file);
1535 /* Output the type `char' as a subrange of itself.
1536 That is what pcc seems to do. */
1537 fprintf (asm_out_file, "r");
1539 dbxout_type_index (char_type_node);
1540 fprintf (asm_out_file, ";0;%d;", TYPE_UNSIGNED (type) ? 255 : 127);
1546 if (use_gnu_debug_info_extensions)
1548 have_used_extensions = 1;
1549 fputs ("@s", asm_out_file);
1551 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1552 fputs (";-16;", asm_out_file);
1555 else /* Define as enumeral type (False, True) */
1557 fprintf (asm_out_file, "eFalse:0,True:1,;");
1563 putc ('d', asm_out_file);
1565 dbxout_type (TREE_TYPE (type), 0);
1569 /* Differs from the REAL_TYPE by its new data type number.
1570 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1571 codes since gdb doesn't care anyway. */
1573 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1575 fputs ("R3;", asm_out_file);
1577 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1578 fputs (";0;", asm_out_file);
1583 /* Output a complex integer type as a structure,
1584 pending some other way to do it. */
1585 putc ('s', asm_out_file);
1587 print_wide_int (int_size_in_bytes (type));
1588 fprintf (asm_out_file, "real:");
1591 dbxout_type (TREE_TYPE (type), 0);
1592 fprintf (asm_out_file, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1594 fprintf (asm_out_file, "imag:");
1596 dbxout_type (TREE_TYPE (type), 0);
1597 fprintf (asm_out_file, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1598 TYPE_PRECISION (TREE_TYPE (type)));
1604 if (use_gnu_debug_info_extensions)
1606 have_used_extensions = 1;
1607 fputs ("@s", asm_out_file);
1609 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1610 putc (';', asm_out_file);
1613 /* Check if a bitstring type, which in Chill is
1614 different from a [power]set. */
1615 if (TYPE_STRING_FLAG (type))
1617 fprintf (asm_out_file, "@S;");
1621 putc ('S', asm_out_file);
1623 dbxout_type (TYPE_DOMAIN (type), 0);
1627 /* Make arrays of packed bits look like bitstrings for chill. */
1628 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1630 have_used_extensions = 1;
1631 fputs ("@s", asm_out_file);
1633 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1634 fprintf (asm_out_file, ";@S;S");
1636 dbxout_type (TYPE_DOMAIN (type), 0);
1640 /* Output "a" followed by a range type definition
1641 for the index type of the array
1642 followed by a reference to the target-type.
1643 ar1;0;N;M for a C array of type M and size N+1. */
1644 /* Check if a character string type, which in Chill is
1645 different from an array of characters. */
1646 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1648 have_used_extensions = 1;
1649 fprintf (asm_out_file, "@S;");
1652 tem = TYPE_DOMAIN (type);
1655 fprintf (asm_out_file, "ar");
1657 dbxout_type_index (integer_type_node);
1658 fprintf (asm_out_file, ";0;-1;");
1663 fprintf (asm_out_file, "a");
1665 dbxout_range_type (tem);
1668 dbxout_type (TREE_TYPE (type), 0);
1673 case QUAL_UNION_TYPE:
1675 tree binfo = TYPE_BINFO (type);
1677 /* Output a structure type. We must use the same test here as we
1678 use in the DBX_NO_XREFS case above. */
1679 if ((TYPE_NAME (type) != 0
1680 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1681 && DECL_IGNORED_P (TYPE_NAME (type)))
1683 || !COMPLETE_TYPE_P (type)
1684 /* No way in DBX fmt to describe a variable size. */
1685 || ! host_integerp (TYPE_SIZE (type), 1))
1687 /* If the type is just a cross reference, output one
1688 and mark the type as partially described.
1689 If it later becomes defined, we will output
1690 its real definition.
1691 If the type has a name, don't nest its definition within
1692 another type's definition; instead, output an xref
1693 and let the definition come when the name is defined. */
1694 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asm_out_file);
1696 if (TYPE_NAME (type) != 0)
1697 dbxout_type_name (type);
1700 fprintf (asm_out_file, "$$%d", anonymous_type_number++);
1704 fprintf (asm_out_file, ":");
1706 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1710 /* Identify record or union, and print its size. */
1711 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asm_out_file);
1713 print_wide_int (int_size_in_bytes (type));
1719 VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo);
1721 if (use_gnu_debug_info_extensions)
1723 if (BINFO_N_BASE_BINFOS (binfo))
1725 have_used_extensions = 1;
1726 fprintf (asm_out_file, "!%u,", BINFO_N_BASE_BINFOS (binfo));
1730 for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
1732 tree access = (accesses ? VEC_index (tree, accesses, i)
1733 : access_public_node);
1735 if (use_gnu_debug_info_extensions)
1737 have_used_extensions = 1;
1738 putc (BINFO_VIRTUAL_P (child) ? '1' : '0', asm_out_file);
1739 putc (access == access_public_node ? '2' :
1740 (access == access_protected_node ? '1' :'0'),
1743 if (BINFO_VIRTUAL_P (child)
1744 && strcmp (lang_hooks.name, "GNU C++") == 0)
1745 /* For a virtual base, print the (negative)
1746 offset within the vtable where we must look
1747 to find the necessary adjustment. */
1749 (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1752 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1754 putc (',', asm_out_file);
1756 dbxout_type (BINFO_TYPE (child), 0);
1757 putc (';', asm_out_file);
1762 /* Print out the base class information with
1763 fields which have the same names at the types
1765 dbxout_type_name (BINFO_TYPE (child));
1766 putc (':', asm_out_file);
1768 dbxout_type (BINFO_TYPE (child), full);
1769 putc (',', asm_out_file);
1771 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1773 putc (',', asm_out_file);
1776 (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)), 0)
1778 putc (';', asm_out_file);
1785 /* Write out the field declarations. */
1786 dbxout_type_fields (type);
1787 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1789 have_used_extensions = 1;
1790 dbxout_type_methods (type);
1793 putc (';', asm_out_file);
1796 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1797 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1798 && TYPE_VFIELD (type))
1800 have_used_extensions = 1;
1802 /* Tell GDB+ that it may keep reading. */
1803 putc ('~', asm_out_file);
1806 /* We need to write out info about what field this class
1807 uses as its "main" vtable pointer field, because if this
1808 field is inherited from a base class, GDB cannot necessarily
1809 figure out which field it's using in time. */
1810 if (TYPE_VFIELD (type))
1812 putc ('%', asm_out_file);
1814 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1817 putc (';', asm_out_file);
1823 /* We must use the same test here as we use in the DBX_NO_XREFS case
1824 above. We simplify it a bit since an enum will never have a variable
1826 if ((TYPE_NAME (type) != 0
1827 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1828 && DECL_IGNORED_P (TYPE_NAME (type)))
1830 || !COMPLETE_TYPE_P (type))
1832 fprintf (asm_out_file, "xe");
1834 dbxout_type_name (type);
1835 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1836 putc (':', asm_out_file);
1840 if (use_gnu_debug_info_extensions
1841 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1843 fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type));
1847 putc ('e', asm_out_file);
1849 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1851 fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1852 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1853 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1854 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1855 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1856 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1857 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1859 print_int_cst_octal (TREE_VALUE (tem));
1861 putc (',', asm_out_file);
1863 if (TREE_CHAIN (tem) != 0)
1867 putc (';', asm_out_file);
1872 putc ('*', asm_out_file);
1874 dbxout_type (TREE_TYPE (type), 0);
1878 if (use_gnu_debug_info_extensions)
1880 have_used_extensions = 1;
1881 putc ('#', asm_out_file);
1884 /* Write the argument types out longhand. */
1885 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1886 putc (',', asm_out_file);
1888 dbxout_type (TREE_TYPE (type), 0);
1889 dbxout_args (TYPE_ARG_TYPES (type));
1890 putc (';', asm_out_file);
1894 /* Treat it as a function type. */
1895 dbxout_type (TREE_TYPE (type), 0);
1899 if (use_gnu_debug_info_extensions)
1901 have_used_extensions = 1;
1902 putc ('@', asm_out_file);
1904 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1905 putc (',', asm_out_file);
1907 dbxout_type (TREE_TYPE (type), 0);
1910 /* Should print as an int, because it is really just an offset. */
1911 dbxout_type (integer_type_node, 0);
1914 case REFERENCE_TYPE:
1915 if (use_gnu_debug_info_extensions)
1916 have_used_extensions = 1;
1917 putc (use_gnu_debug_info_extensions ? '&' : '*', asm_out_file);
1919 dbxout_type (TREE_TYPE (type), 0);
1923 putc ('f', asm_out_file);
1925 dbxout_type (TREE_TYPE (type), 0);
1933 /* Return nonzero if the given type represents an integer whose bounds
1934 should be printed in octal format. */
1937 print_int_cst_bounds_in_octal_p (tree type)
1939 /* If we can use GDB extensions and the size is wider than a long
1940 (the size used by GDB to read them) or we may have trouble writing
1941 the bounds the usual way, write them in octal. Note the test is for
1942 the *target's* size of "long", not that of the host. The host test
1943 is just to make sure we can write it out in case the host wide int
1944 is narrower than the target "long".
1946 For unsigned types, we use octal if they are the same size or larger.
1947 This is because we print the bounds as signed decimal, and hence they
1948 can't span same size unsigned types. */
1950 if (use_gnu_debug_info_extensions
1951 && TYPE_MIN_VALUE (type) != 0
1952 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1953 && TYPE_MAX_VALUE (type) != 0
1954 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1955 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1956 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1957 && TYPE_UNSIGNED (type))
1958 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1959 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1960 && TYPE_UNSIGNED (type))))
1966 /* Print the value of integer constant C, in octal,
1967 handling double precision. */
1970 print_int_cst_octal (tree c)
1972 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1973 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1974 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1975 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1977 /* GDB wants constants with no extra leading "1" bits, so
1978 we need to remove any sign-extension that might be
1980 if (width == HOST_BITS_PER_WIDE_INT * 2)
1982 else if (width > HOST_BITS_PER_WIDE_INT)
1983 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1984 else if (width == HOST_BITS_PER_WIDE_INT)
1987 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1989 fprintf (asm_out_file, "0");
1994 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1995 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1999 unsigned HOST_WIDE_INT beg = high >> excess;
2000 unsigned HOST_WIDE_INT middle
2001 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
2002 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
2003 unsigned HOST_WIDE_INT end
2004 = low & (((unsigned HOST_WIDE_INT) 1
2005 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
2008 fprintf (asm_out_file, "%o%01o", (int) beg, (int) middle);
2010 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
2015 print_octal (unsigned HOST_WIDE_INT value, int digits)
2019 for (i = digits - 1; i >= 0; i--)
2020 fprintf (asm_out_file, "%01o", (int) ((value >> (3 * i)) & 7));
2025 /* Output C in decimal while adjusting the number of digits written. */
2028 print_wide_int (HOST_WIDE_INT c)
2032 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, c);
2043 /* Output the name of type TYPE, with no punctuation.
2044 Such names can be set up either by typedef declarations
2045 or by struct, enum and union tags. */
2048 dbxout_type_name (tree type)
2050 tree t = TYPE_NAME (type);
2053 switch (TREE_CODE (t))
2055 case IDENTIFIER_NODE:
2064 fprintf (asm_out_file, "%s", IDENTIFIER_POINTER (t));
2065 CHARS (IDENTIFIER_LENGTH (t));
2068 /* Output leading leading struct or class names needed for qualifying
2069 type whose scope is limited to a struct or class. */
2072 dbxout_class_name_qualifiers (tree decl)
2074 tree context = decl_type_context (decl);
2076 if (context != NULL_TREE
2077 && TREE_CODE(context) == RECORD_TYPE
2078 && TYPE_NAME (context) != 0
2079 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2080 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2082 tree name = TYPE_NAME (context);
2084 emit_pending_bincls_if_required ();
2086 if (TREE_CODE (name) == TYPE_DECL)
2088 dbxout_class_name_qualifiers (name);
2089 name = DECL_NAME (name);
2091 fprintf (asm_out_file, "%s::", IDENTIFIER_POINTER (name));
2092 CHARS (IDENTIFIER_LENGTH (name) + 2);
2096 /* Output a .stabs for the symbol defined by DECL,
2097 which must be a ..._DECL node in the normal namespace.
2098 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2099 LOCAL is nonzero if the scope is less than the entire file.
2100 Return 1 if a stabs might have been emitted. */
2103 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2105 tree type = TREE_TYPE (decl);
2106 tree context = NULL_TREE;
2109 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2112 /* Ignore nameless syms, but don't ignore type tags. */
2114 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2115 || DECL_IGNORED_P (decl))
2116 DBXOUT_DECR_NESTING_AND_RETURN (0);
2118 /* If we are to generate only the symbols actually used then such
2119 symbol nodees are flagged with TREE_USED. Ignore any that
2120 aren't flaged as TREE_USED. */
2122 if (flag_debug_only_used_symbols
2123 && (!TREE_USED (decl)
2124 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl))))
2125 DBXOUT_DECR_NESTING_AND_RETURN (0);
2127 /* If dbxout_init has not yet run, queue this symbol for later. */
2130 preinit_symbols = tree_cons (0, decl, preinit_symbols);
2131 DBXOUT_DECR_NESTING_AND_RETURN (0);
2134 if (flag_debug_only_used_symbols)
2138 /* We now have a used symbol. We need to generate the info for
2139 the symbol's type in addition to the symbol itself. These
2140 type symbols are queued to be generated after were done with
2141 the symbol itself (done because the symbol's info is generated
2142 with fprintf's, etc. as it determines what's needed).
2144 Note, because the TREE_TYPE(type) might be something like a
2145 pointer to a named type we need to look for the first name
2146 we see following the TREE_TYPE chain. */
2149 while (POINTER_TYPE_P (t))
2152 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2153 need special treatment. The TYPE_STUB_DECL field in these
2154 types generally represents the tag name type we want to
2155 output. In addition there could be a typedef type with
2156 a different name. In that case we also want to output
2159 if (TREE_CODE (t) == RECORD_TYPE
2160 || TREE_CODE (t) == UNION_TYPE
2161 || TREE_CODE (t) == QUAL_UNION_TYPE
2162 || TREE_CODE (t) == ENUMERAL_TYPE)
2164 if (TYPE_STUB_DECL (t)
2165 && TYPE_STUB_DECL (t) != decl
2166 && DECL_P (TYPE_STUB_DECL (t))
2167 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2169 debug_queue_symbol (TYPE_STUB_DECL (t));
2171 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2172 && TYPE_NAME (t) != decl
2173 && DECL_P (TYPE_NAME (t)))
2174 debug_queue_symbol (TYPE_NAME (t));
2177 else if (TYPE_NAME (t)
2178 && TYPE_NAME (t) != decl
2179 && DECL_P (TYPE_NAME (t)))
2180 debug_queue_symbol (TYPE_NAME (t));
2183 emit_pending_bincls_if_required ();
2185 dbxout_prepare_symbol (decl);
2187 /* The output will always start with the symbol name,
2188 so always count that in the length-output-so-far. */
2190 if (DECL_NAME (decl) != 0)
2191 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2193 switch (TREE_CODE (decl))
2196 /* Enum values are defined by defining the enum type. */
2200 if (DECL_RTL (decl) == 0)
2201 DBXOUT_DECR_NESTING_AND_RETURN (0);
2202 if (DECL_EXTERNAL (decl))
2204 /* Don't mention a nested function under its parent. */
2205 context = decl_function_context (decl);
2206 if (context == current_function_decl)
2208 if (!MEM_P (DECL_RTL (decl))
2209 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2213 fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP,
2214 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2215 TREE_PUBLIC (decl) ? 'F' : 'f');
2218 current_sym_code = N_FUN;
2219 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2221 if (TREE_TYPE (type))
2222 dbxout_type (TREE_TYPE (type), 0);
2224 dbxout_type (void_type_node, 0);
2226 /* For a nested function, when that function is compiled,
2227 mention the containing function name
2228 as well as (since dbx wants it) our own assembler-name. */
2230 fprintf (asm_out_file, ",%s,%s",
2231 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2232 IDENTIFIER_POINTER (DECL_NAME (context)));
2234 dbxout_finish_symbol (decl);
2238 /* Don't output the same typedef twice.
2239 And don't output what language-specific stuff doesn't want output. */
2240 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2241 DBXOUT_DECR_NESTING_AND_RETURN (0);
2243 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2244 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2246 int fundamental_type_number =
2247 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl);
2249 if (fundamental_type_number != 0)
2251 TREE_ASM_WRITTEN (decl) = 1;
2252 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number;
2253 DBXOUT_DECR_NESTING_AND_RETURN (0);
2263 if (DECL_NAME (decl))
2265 /* Nonzero means we must output a tag as well as a typedef. */
2268 /* Handle the case of a C++ structure or union
2269 where the TYPE_NAME is a TYPE_DECL
2270 which gives both a typedef name and a tag. */
2271 /* dbx requires the tag first and the typedef second. */
2272 if ((TREE_CODE (type) == RECORD_TYPE
2273 || TREE_CODE (type) == UNION_TYPE
2274 || TREE_CODE (type) == QUAL_UNION_TYPE)
2275 && TYPE_NAME (type) == decl
2276 && !(use_gnu_debug_info_extensions && have_used_extensions)
2277 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2278 /* Distinguish the implicit typedefs of C++
2279 from explicit ones that might be found in C. */
2280 && DECL_ARTIFICIAL (decl)
2281 /* Do not generate a tag for incomplete records. */
2282 && COMPLETE_TYPE_P (type)
2283 /* Do not generate a tag for records of variable size,
2284 since this type can not be properly described in the
2285 DBX format, and it confuses some tools such as objdump. */
2286 && host_integerp (TYPE_SIZE (type), 1))
2288 tree name = TYPE_NAME (type);
2289 if (TREE_CODE (name) == TYPE_DECL)
2290 name = DECL_NAME (name);
2292 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2293 current_sym_value = 0;
2294 current_sym_addr = 0;
2295 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2297 fprintf (asm_out_file, "%s\"%s:T", ASM_STABS_OP,
2298 IDENTIFIER_POINTER (name));
2299 dbxout_type (type, 1);
2300 dbxout_finish_symbol (NULL_TREE);
2303 /* Output .stabs (or whatever) and leading double quote. */
2304 fprintf (asm_out_file, "%s\"", ASM_STABS_OP);
2306 if (use_gnu_debug_info_extensions)
2308 /* Output leading class/struct qualifiers. */
2309 dbxout_class_name_qualifiers (decl);
2312 /* Output typedef name. */
2313 fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2315 /* Short cut way to output a tag also. */
2316 if ((TREE_CODE (type) == RECORD_TYPE
2317 || TREE_CODE (type) == UNION_TYPE
2318 || TREE_CODE (type) == QUAL_UNION_TYPE)
2319 && TYPE_NAME (type) == decl
2320 /* Distinguish the implicit typedefs of C++
2321 from explicit ones that might be found in C. */
2322 && DECL_ARTIFICIAL (decl))
2324 if (use_gnu_debug_info_extensions && have_used_extensions)
2326 putc ('T', asm_out_file);
2327 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2331 putc ('t', asm_out_file);
2332 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2334 dbxout_type (type, 1);
2335 dbxout_finish_symbol (decl);
2339 /* Don't output a tag if this is an incomplete type. This prevents
2340 the sun4 Sun OS 4.x dbx from crashing. */
2342 if (tag_needed && TYPE_NAME (type) != 0
2343 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2344 || (DECL_NAME (TYPE_NAME (type)) != 0))
2345 && COMPLETE_TYPE_P (type)
2346 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2348 /* For a TYPE_DECL with no name, but the type has a name,
2350 This is what represents `struct foo' with no typedef. */
2351 /* In C++, the name of a type is the corresponding typedef.
2352 In C, it is an IDENTIFIER_NODE. */
2353 tree name = TYPE_NAME (type);
2354 if (TREE_CODE (name) == TYPE_DECL)
2355 name = DECL_NAME (name);
2357 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2358 current_sym_value = 0;
2359 current_sym_addr = 0;
2360 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2362 fprintf (asm_out_file, "%s\"%s:T", ASM_STABS_OP,
2363 IDENTIFIER_POINTER (name));
2364 dbxout_type (type, 1);
2365 dbxout_finish_symbol (NULL_TREE);
2369 /* If an enum type has no name, it cannot be referred to,
2370 but we must output it anyway, since the enumeration constants
2371 can be referred to. */
2372 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2374 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2375 current_sym_value = 0;
2376 current_sym_addr = 0;
2377 current_sym_nchars = 2;
2379 /* Some debuggers fail when given NULL names, so give this a
2380 harmless name of ` '. */
2381 fprintf (asm_out_file, "%s\" :T", ASM_STABS_OP);
2382 dbxout_type (type, 1);
2383 dbxout_finish_symbol (NULL_TREE);
2386 /* Prevent duplicate output of a typedef. */
2387 TREE_ASM_WRITTEN (decl) = 1;
2392 /* Parm decls go in their own separate chains
2393 and are output by dbxout_reg_parms and dbxout_parms. */
2397 /* Named return value, treat like a VAR_DECL. */
2399 if (! DECL_RTL_SET_P (decl))
2400 DBXOUT_DECR_NESTING_AND_RETURN (0);
2401 /* Don't mention a variable that is external.
2402 Let the file that defines it describe it. */
2403 if (DECL_EXTERNAL (decl))
2406 /* If the variable is really a constant
2407 and not written in memory, inform the debugger. */
2408 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2409 && DECL_INITIAL (decl) != 0
2410 && host_integerp (DECL_INITIAL (decl), 0)
2411 && ! TREE_ASM_WRITTEN (decl)
2412 && (DECL_CONTEXT (decl) == NULL_TREE
2413 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2415 if (TREE_PUBLIC (decl) == 0)
2417 /* The sun4 assembler does not grok this. */
2418 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2420 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2421 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2423 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2424 fprintf (asm_out_file, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2426 ASM_STABS_OP, name, ival, N_LSYM);
2427 DBXOUT_DECR_NESTING;
2430 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2432 /* Don't know how to do this yet. */
2436 /* else it is something we handle like a normal variable. */
2439 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2440 #ifdef LEAF_REG_REMAP
2441 if (current_function_uses_only_leaf_regs)
2442 leaf_renumber_regs_insn (DECL_RTL (decl));
2445 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2451 DBXOUT_DECR_NESTING;
2455 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2456 Add SUFFIX to its name, if SUFFIX is not 0.
2457 Describe the variable as residing in HOME
2458 (usually HOME is DECL_RTL (DECL), but not always).
2459 Returns 1 if the stab was really emitted. */
2462 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2467 emit_pending_bincls_if_required ();
2469 /* Don't mention a variable at all
2470 if it was completely optimized into nothingness.
2472 If the decl was from an inline function, then its rtl
2473 is not identically the rtl that was used in this
2474 particular compilation. */
2475 if (GET_CODE (home) == SUBREG)
2479 while (GET_CODE (value) == SUBREG)
2480 value = SUBREG_REG (value);
2483 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2486 home = alter_subreg (&home);
2490 regno = REGNO (home);
2491 if (regno >= FIRST_PSEUDO_REGISTER)
2495 /* The kind-of-variable letter depends on where
2496 the variable is and on the scope of its name:
2497 G and N_GSYM for static storage and global scope,
2498 S for static storage and file scope,
2499 V for static storage and local scope,
2500 for those two, use N_LCSYM if data is in bss segment,
2501 N_STSYM if in data segment, N_FUN otherwise.
2502 (We used N_FUN originally, then changed to N_STSYM
2503 to please GDB. However, it seems that confused ld.
2504 Now GDB has been fixed to like N_FUN, says Kingdon.)
2505 no letter at all, and N_LSYM, for auto variable,
2506 r and N_RSYM for register variable. */
2509 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2511 if (TREE_PUBLIC (decl))
2514 current_sym_code = N_GSYM;
2518 current_sym_addr = XEXP (home, 0);
2520 letter = decl_function_context (decl) ? 'V' : 'S';
2522 /* This should be the same condition as in assemble_variable, but
2523 we don't have access to dont_output_data here. So, instead,
2524 we rely on the fact that error_mark_node initializers always
2525 end up in bss for C++ and never end up in bss for C. */
2526 if (DECL_INITIAL (decl) == 0
2527 || (!strcmp (lang_hooks.name, "GNU C++")
2528 && DECL_INITIAL (decl) == error_mark_node))
2529 current_sym_code = N_LCSYM;
2530 else if (DECL_IN_TEXT_SECTION (decl))
2531 /* This is not quite right, but it's the closest
2532 of all the codes that Unix defines. */
2533 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2536 /* Some ports can transform a symbol ref into a label ref,
2537 because the symbol ref is too far away and has to be
2538 dumped into a constant pool. Alternatively, the symbol
2539 in the constant pool might be referenced by a different
2541 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2542 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2545 rtx tmp = get_pool_constant_mark (current_sym_addr, &marked);
2547 if (GET_CODE (tmp) == SYMBOL_REF)
2549 current_sym_addr = tmp;
2550 if (CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2551 get_pool_constant_mark (current_sym_addr, &marked);
2555 else if (GET_CODE (tmp) == LABEL_REF)
2557 current_sym_addr = tmp;
2561 /* If all references to the constant pool were optimized
2562 out, we just ignore the symbol. */
2567 /* Ultrix `as' seems to need this. */
2568 #ifdef DBX_STATIC_STAB_DATA_SECTION
2571 current_sym_code = N_STSYM;
2575 else if (regno >= 0)
2578 current_sym_code = N_RSYM;
2579 current_sym_value = DBX_REGISTER_NUMBER (regno);
2581 else if (MEM_P (home)
2582 && (MEM_P (XEXP (home, 0))
2583 || (REG_P (XEXP (home, 0))
2584 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2585 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2586 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2587 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2590 /* If the value is indirect by memory or by a register
2591 that isn't the frame pointer
2592 then it means the object is variable-sized and address through
2593 that register or stack slot. DBX has no way to represent this
2594 so all we can do is output the variable as a pointer.
2595 If it's not a parameter, ignore it. */
2597 if (REG_P (XEXP (home, 0)))
2600 current_sym_code = N_RSYM;
2601 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2603 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2607 current_sym_code = N_LSYM;
2608 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2609 We want the value of that CONST_INT. */
2611 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2614 /* Effectively do build_pointer_type, but don't cache this type,
2615 since it might be temporary whereas the type it points to
2616 might have been saved for inlining. */
2617 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2618 type = make_node (POINTER_TYPE);
2619 TREE_TYPE (type) = TREE_TYPE (decl);
2621 else if (MEM_P (home)
2622 && REG_P (XEXP (home, 0)))
2624 current_sym_code = N_LSYM;
2625 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2627 else if (MEM_P (home)
2628 && GET_CODE (XEXP (home, 0)) == PLUS
2629 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2631 current_sym_code = N_LSYM;
2632 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2633 We want the value of that CONST_INT. */
2634 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2636 else if (MEM_P (home)
2637 && GET_CODE (XEXP (home, 0)) == CONST)
2639 /* Handle an obscure case which can arise when optimizing and
2640 when there are few available registers. (This is *always*
2641 the case for i386/i486 targets). The RTL looks like
2642 (MEM (CONST ...)) even though this variable is a local `auto'
2643 or a local `register' variable. In effect, what has happened
2644 is that the reload pass has seen that all assignments and
2645 references for one such a local variable can be replaced by
2646 equivalent assignments and references to some static storage
2647 variable, thereby avoiding the need for a register. In such
2648 cases we're forced to lie to debuggers and tell them that
2649 this variable was itself `static'. */
2650 current_sym_code = N_LCSYM;
2652 current_sym_addr = XEXP (XEXP (home, 0), 0);
2654 else if (GET_CODE (home) == CONCAT)
2658 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2659 for example), then there is no easy way to figure out
2660 what SUBTYPE should be. So, we give up. */
2661 if (TREE_CODE (type) != COMPLEX_TYPE)
2664 subtype = TREE_TYPE (type);
2666 /* If the variable's storage is in two parts,
2667 output each as a separate stab with a modified name. */
2668 if (WORDS_BIG_ENDIAN)
2669 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2671 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2673 dbxout_prepare_symbol (decl);
2675 if (WORDS_BIG_ENDIAN)
2676 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2678 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2682 /* Address might be a MEM, when DECL is a variable-sized object.
2683 Or it might be const0_rtx, meaning previous passes
2684 want us to ignore this variable. */
2687 /* Ok, start a symtab entry and output the variable name. */
2690 #ifdef DBX_STATIC_BLOCK_START
2691 DBX_STATIC_BLOCK_START (asm_out_file, current_sym_code);
2694 dbxout_symbol_name (decl, suffix, letter);
2695 dbxout_type (type, 0);
2696 dbxout_finish_symbol (decl);
2698 #ifdef DBX_STATIC_BLOCK_END
2699 DBX_STATIC_BLOCK_END (asm_out_file, current_sym_code);
2704 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2705 Then output LETTER to indicate the kind of location the symbol has. */
2708 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2712 if (DECL_CONTEXT (decl)
2713 && (TYPE_P (DECL_CONTEXT (decl))
2714 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
2715 /* One slight hitch: if this is a VAR_DECL which is a class member
2716 or a namespace member, we must put out the mangled name instead of the
2717 DECL_NAME. Note also that static member (variable) names DO NOT begin
2718 with underscores in .stabs directives. */
2719 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2721 /* ...but if we're function-local, we don't want to include the junk
2722 added by ASM_FORMAT_PRIVATE_NAME. */
2723 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2727 fprintf (asm_out_file, "%s\"%s%s:", ASM_STABS_OP, name,
2728 (suffix ? suffix : ""));
2731 putc (letter, asm_out_file);
2735 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2737 /* Initialize variables used to communicate each symbol's debug
2738 information to dbxout_finish_symbol with zeroes. */
2740 /* Cast avoids warning in old compilers. */
2741 current_sym_code = (STAB_CODE_TYPE) 0;
2742 current_sym_value = 0;
2743 current_sym_addr = 0;
2747 dbxout_finish_symbol (tree sym)
2749 #ifdef DBX_FINISH_SYMBOL
2750 DBX_FINISH_SYMBOL (asm_out_file, sym);
2753 if (use_gnu_debug_info_extensions && sym != 0)
2754 line = DECL_SOURCE_LINE (sym);
2756 fprintf (asm_out_file, "\",%d,0,%d,", current_sym_code, line);
2757 if (current_sym_addr)
2758 output_addr_const (asm_out_file, current_sym_addr);
2760 fprintf (asm_out_file, "%d", current_sym_value);
2761 putc ('\n', asm_out_file);
2765 /* Output definitions of all the decls in a chain. Return nonzero if
2766 anything was output */
2769 dbxout_syms (tree syms)
2774 result += dbxout_symbol (syms, 1);
2775 syms = TREE_CHAIN (syms);
2780 /* The following two functions output definitions of function parameters.
2781 Each parameter gets a definition locating it in the parameter list.
2782 Each parameter that is a register variable gets a second definition
2783 locating it in the register.
2785 Printing or argument lists in gdb uses the definitions that
2786 locate in the parameter list. But reference to the variable in
2787 expressions uses preferentially the definition as a register. */
2789 /* Output definitions, referring to storage in the parmlist,
2790 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2793 dbxout_parms (tree parms)
2797 emit_pending_bincls_if_required ();
2799 for (; parms; parms = TREE_CHAIN (parms))
2800 if (DECL_NAME (parms)
2801 && TREE_TYPE (parms) != error_mark_node
2802 && DECL_RTL_SET_P (parms)
2803 && DECL_INCOMING_RTL (parms))
2805 dbxout_prepare_symbol (parms);
2807 /* Perform any necessary register eliminations on the parameter's rtl,
2808 so that the debugging output will be accurate. */
2809 DECL_INCOMING_RTL (parms)
2810 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2811 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2812 #ifdef LEAF_REG_REMAP
2813 if (current_function_uses_only_leaf_regs)
2815 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2816 leaf_renumber_regs_insn (DECL_RTL (parms));
2820 if (PARM_PASSED_IN_MEMORY (parms))
2822 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2824 /* ??? Here we assume that the parm address is indexed
2825 off the frame pointer or arg pointer.
2826 If that is not true, we produce meaningless results,
2827 but do not crash. */
2828 if (GET_CODE (addr) == PLUS
2829 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2830 current_sym_value = INTVAL (XEXP (addr, 1));
2832 current_sym_value = 0;
2834 current_sym_code = N_PSYM;
2835 current_sym_addr = 0;
2838 if (DECL_NAME (parms))
2840 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2841 fprintf (asm_out_file, "%s\"%s:p", ASM_STABS_OP,
2842 IDENTIFIER_POINTER (DECL_NAME (parms)));
2846 current_sym_nchars = 8;
2847 fprintf (asm_out_file, "%s\"(anon):p", ASM_STABS_OP);
2850 /* It is quite tempting to use:
2852 dbxout_type (TREE_TYPE (parms), 0);
2854 as the next statement, rather than using DECL_ARG_TYPE(), so
2855 that gcc reports the actual type of the parameter, rather
2856 than the promoted type. This certainly makes GDB's life
2857 easier, at least for some ports. The change is a bad idea
2858 however, since GDB expects to be able access the type without
2859 performing any conversions. So for example, if we were
2860 passing a float to an unprototyped function, gcc will store a
2861 double on the stack, but if we emit a stab saying the type is a
2862 float, then gdb will only read in a single value, and this will
2863 produce an erroneous value. */
2864 dbxout_type (DECL_ARG_TYPE (parms), 0);
2865 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2866 dbxout_finish_symbol (parms);
2868 else if (REG_P (DECL_RTL (parms)))
2871 char regparm_letter;
2873 /* Parm passed in registers and lives in registers or nowhere. */
2875 current_sym_code = DBX_REGPARM_STABS_CODE;
2876 regparm_letter = DBX_REGPARM_STABS_LETTER;
2877 current_sym_addr = 0;
2879 /* If parm lives in a register, use that register;
2880 pretend the parm was passed there. It would be more consistent
2881 to describe the register where the parm was passed,
2882 but in practice that register usually holds something else.
2884 If we use DECL_RTL, then we must use the declared type of
2885 the variable, not the type that it arrived in. */
2886 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2888 best_rtl = DECL_RTL (parms);
2889 parm_type = TREE_TYPE (parms);
2891 /* If the parm lives nowhere, use the register where it was
2892 passed. It is also better to use the declared type here. */
2895 best_rtl = DECL_INCOMING_RTL (parms);
2896 parm_type = TREE_TYPE (parms);
2898 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2901 if (DECL_NAME (parms))
2903 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2904 fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP,
2905 IDENTIFIER_POINTER (DECL_NAME (parms)),
2910 current_sym_nchars = 8;
2911 fprintf (asm_out_file, "%s\"(anon):%c", ASM_STABS_OP,
2915 dbxout_type (parm_type, 0);
2916 dbxout_finish_symbol (parms);
2918 else if (MEM_P (DECL_RTL (parms))
2919 && REG_P (XEXP (DECL_RTL (parms), 0))
2920 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2921 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2922 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2923 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2927 /* Parm was passed via invisible reference.
2928 That is, its address was passed in a register.
2929 Output it as if it lived in that register.
2930 The debugger will know from the type
2931 that it was actually passed by invisible reference. */
2933 char regparm_letter;
2934 /* Parm passed in registers and lives in registers or nowhere. */
2936 current_sym_code = DBX_REGPARM_STABS_CODE;
2938 if (use_gnu_debug_info_extensions)
2939 /* GDB likes this marked with a special letter. */
2940 regparm_letter = 'a';
2942 regparm_letter = DBX_REGPARM_STABS_LETTER;
2944 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2945 If it is an unallocated pseudo-reg, then use the register where
2946 it was passed instead. */
2947 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2948 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2950 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2952 current_sym_addr = 0;
2955 if (DECL_NAME (parms))
2958 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2960 fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP,
2961 IDENTIFIER_POINTER (DECL_NAME (parms)),
2966 current_sym_nchars = 8;
2967 fprintf (asm_out_file, "%s\"(anon):%c", ASM_STABS_OP,
2971 dbxout_type (TREE_TYPE (parms), 0);
2972 dbxout_finish_symbol (parms);
2974 else if (MEM_P (DECL_RTL (parms))
2975 && MEM_P (XEXP (DECL_RTL (parms), 0)))
2977 /* Parm was passed via invisible reference, with the reference
2978 living on the stack. DECL_RTL looks like
2979 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2980 could look like (MEM (MEM (REG))). */
2981 const char *const decl_name = (DECL_NAME (parms)
2982 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2984 if (REG_P (XEXP (XEXP (DECL_RTL (parms), 0), 0)))
2985 current_sym_value = 0;
2988 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2989 current_sym_addr = 0;
2990 current_sym_code = N_PSYM;
2993 fprintf (asm_out_file, "%s\"%s:v", ASM_STABS_OP, decl_name);
2996 = DEBUGGER_ARG_OFFSET (current_sym_value,
2997 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2998 dbxout_type (TREE_TYPE (parms), 0);
2999 dbxout_finish_symbol (parms);
3001 else if (MEM_P (DECL_RTL (parms))
3002 && XEXP (DECL_RTL (parms), 0) != const0_rtx
3003 /* ??? A constant address for a parm can happen
3004 when the reg it lives in is equiv to a constant in memory.
3005 Should make this not happen, after 2.4. */
3006 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
3008 /* Parm was passed in registers but lives on the stack. */
3010 current_sym_code = N_PSYM;
3011 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
3012 in which case we want the value of that CONST_INT,
3014 in which case we use a value of zero. */
3015 if (REG_P (XEXP (DECL_RTL (parms), 0)))
3016 current_sym_value = 0;
3019 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
3021 current_sym_addr = 0;
3023 /* Make a big endian correction if the mode of the type of the
3024 parameter is not the same as the mode of the rtl. */
3025 if (BYTES_BIG_ENDIAN
3026 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
3027 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
3029 current_sym_value +=
3030 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
3031 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
3035 if (DECL_NAME (parms))
3038 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
3040 fprintf (asm_out_file, "%s\"%s:p", ASM_STABS_OP,
3041 IDENTIFIER_POINTER (DECL_NAME (parms)));
3045 current_sym_nchars = 8;
3046 fprintf (asm_out_file, "%s\"(anon):p", ASM_STABS_OP);
3050 = DEBUGGER_ARG_OFFSET (current_sym_value,
3051 XEXP (DECL_RTL (parms), 0));
3052 dbxout_type (TREE_TYPE (parms), 0);
3053 dbxout_finish_symbol (parms);
3056 DBXOUT_DECR_NESTING;
3059 /* Output definitions for the places where parms live during the function,
3060 when different from where they were passed, when the parms were passed
3063 It is not useful to do this for parms passed in registers
3064 that live during the function in different registers, because it is
3065 impossible to look in the passed register for the passed value,
3066 so we use the within-the-function register to begin with.
3068 PARMS is a chain of PARM_DECL nodes. */
3071 dbxout_reg_parms (tree parms)
3075 for (; parms; parms = TREE_CHAIN (parms))
3076 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
3078 dbxout_prepare_symbol (parms);
3080 /* Report parms that live in registers during the function
3081 but were passed in memory. */
3082 if (REG_P (DECL_RTL (parms))
3083 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
3084 dbxout_symbol_location (parms, TREE_TYPE (parms),
3085 0, DECL_RTL (parms));
3086 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3087 dbxout_symbol_location (parms, TREE_TYPE (parms),
3088 0, DECL_RTL (parms));
3089 /* Report parms that live in memory but not where they were passed. */
3090 else if (MEM_P (DECL_RTL (parms))
3091 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3092 dbxout_symbol_location (parms, TREE_TYPE (parms),
3093 0, DECL_RTL (parms));
3095 DBXOUT_DECR_NESTING;
3098 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3099 output definitions of those names, in raw form */
3102 dbxout_args (tree args)
3106 putc (',', asm_out_file);
3107 dbxout_type (TREE_VALUE (args), 0);
3109 args = TREE_CHAIN (args);
3113 /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3114 BEGIN_LABEL is the name of the beginning of the function, which may
3117 dbx_output_lbrac (const char *label,
3118 const char *begin_label ATTRIBUTE_UNUSED)
3120 #ifdef DBX_OUTPUT_LBRAC
3121 DBX_OUTPUT_LBRAC (asm_out_file, label);
3123 fprintf (asm_out_file, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3124 assemble_name (asm_out_file, label);
3125 if (DBX_BLOCKS_FUNCTION_RELATIVE)
3127 putc ('-', asm_out_file);
3128 assemble_name (asm_out_file, begin_label);
3130 fprintf (asm_out_file, "\n");
3134 /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3135 BEGIN_LABEL is the name of the beginning of the function, which may
3138 dbx_output_rbrac (const char *label,
3139 const char *begin_label ATTRIBUTE_UNUSED)
3141 #ifdef DBX_OUTPUT_RBRAC
3142 DBX_OUTPUT_RBRAC (asm_out_file, label);
3144 fprintf (asm_out_file, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3145 assemble_name (asm_out_file, label);
3146 if (DBX_BLOCKS_FUNCTION_RELATIVE)
3148 putc ('-', asm_out_file);
3149 assemble_name (asm_out_file, begin_label);
3151 fprintf (asm_out_file, "\n");
3155 /* Output everything about a symbol block (a BLOCK node
3156 that represents a scope level),
3157 including recursive output of contained blocks.
3159 BLOCK is the BLOCK node.
3160 DEPTH is its depth within containing symbol blocks.
3161 ARGS is usually zero; but for the outermost block of the
3162 body of a function, it is a chain of PARM_DECLs for the function parameters.
3163 We output definitions of all the register parms
3164 as if they were local variables of that block.
3166 If -g1 was used, we count blocks just the same, but output nothing
3167 except for the outermost block.
3169 Actually, BLOCK may be several blocks chained together.
3170 We handle them all in sequence. */
3173 dbxout_block (tree block, int depth, tree args)
3175 const char *begin_label;
3176 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3180 /* Ignore blocks never expanded or otherwise marked as real. */
3181 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3184 int blocknum = BLOCK_NUMBER (block);
3186 /* In dbx format, the syms of a block come before the N_LBRAC.
3187 If nothing is output, we don't need the N_LBRAC, either. */
3189 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3190 did_output = dbxout_syms (BLOCK_VARS (block));
3192 dbxout_reg_parms (args);
3194 /* Now output an N_LBRAC symbol to represent the beginning of
3195 the block. Use the block's tree-walk order to generate
3196 the assembler symbols LBBn and LBEn
3197 that final will define around the code in this block. */
3201 const char *scope_start;
3204 /* The outermost block doesn't get LBB labels; use
3205 the function symbol. */
3206 scope_start = begin_label;
3209 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3213 if (BLOCK_HANDLER_BLOCK (block))
3215 /* A catch block. Must precede N_LBRAC. */
3216 tree decl = BLOCK_VARS (block);
3219 fprintf (asm_out_file, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3220 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3221 assemble_name (asm_out_file, scope_start);
3222 fprintf (asm_out_file, "\n");
3223 decl = TREE_CHAIN (decl);
3226 dbx_output_lbrac (scope_start, begin_label);
3229 /* Output the subblocks. */
3230 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3232 /* Refer to the marker for the end of the block. */
3237 /* The outermost block doesn't get LBE labels;
3238 use the "scope" label which will be emitted
3239 by dbxout_function_end. */
3240 ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno);
3242 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3244 dbx_output_rbrac (buf, begin_label);
3247 block = BLOCK_CHAIN (block);
3251 /* Output the information about a function and its arguments and result.
3252 Usually this follows the function's code,
3253 but on some systems, it comes before. */
3255 #if defined (DBX_DEBUGGING_INFO)
3257 dbxout_begin_function (tree decl)
3259 int saved_tree_used1 = TREE_USED (decl);
3260 TREE_USED (decl) = 1;
3261 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3263 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3264 TREE_USED (DECL_RESULT (decl)) = 1;
3265 dbxout_symbol (decl, 0);
3266 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3269 dbxout_symbol (decl, 0);
3270 TREE_USED (decl) = saved_tree_used1;
3272 dbxout_parms (DECL_ARGUMENTS (decl));
3273 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3274 dbxout_symbol (DECL_RESULT (decl), 1);
3276 #endif /* DBX_DEBUGGING_INFO */
3278 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3280 #include "gt-dbxout.h"