Mark ChangeLog
[official-gcc.git] / gcc / dbxout.c
blob1b04d0eb1631a3710f8893333774da6820d51ca4
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 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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
48 end of its "name".
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.
53 See `dbxout_symbol'.
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'. */
71 #include "config.h"
72 #include "system.h"
74 #include "tree.h"
75 #include "rtl.h"
76 #include "flags.h"
77 #include "regs.h"
78 #include "insn-config.h"
79 #include "reload.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
81 #include "dbxout.h"
82 #include "toplev.h"
83 #include "tm_p.h"
84 #include "ggc.h"
86 #ifdef XCOFF_DEBUGGING_INFO
87 #include "xcoffout.h"
88 #endif
90 #ifndef ASM_STABS_OP
91 #define ASM_STABS_OP "\t.stabs\t"
92 #endif
94 #ifndef ASM_STABN_OP
95 #define ASM_STABN_OP "\t.stabn\t"
96 #endif
98 #ifndef DBX_TYPE_DECL_STABS_CODE
99 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
100 #endif
102 #ifndef DBX_STATIC_CONST_VAR_CODE
103 #define DBX_STATIC_CONST_VAR_CODE N_FUN
104 #endif
106 #ifndef DBX_REGPARM_STABS_CODE
107 #define DBX_REGPARM_STABS_CODE N_RSYM
108 #endif
110 #ifndef DBX_REGPARM_STABS_LETTER
111 #define DBX_REGPARM_STABS_LETTER 'P'
112 #endif
114 /* This is used for parameters passed by invisible reference in a register. */
115 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
116 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
117 #endif
119 #ifndef DBX_MEMPARM_STABS_LETTER
120 #define DBX_MEMPARM_STABS_LETTER 'p'
121 #endif
123 #ifndef FILE_NAME_JOINER
124 #define FILE_NAME_JOINER "/"
125 #endif
127 /* GDB needs to know that the stabs were generated by GCC. We emit an
128 N_OPT stab at the beginning of the source file to indicate this.
129 The string is historical, and different on a very few targets. */
130 #ifndef STABS_GCC_MARKER
131 #define STABS_GCC_MARKER "gcc2_compiled."
132 #endif
134 /* Nonzero means if the type has methods, only output debugging
135 information if methods are actually written to the asm file. This
136 optimization only works if the debugger can detect the special C++
137 marker. */
139 #define MINIMAL_DEBUG 1
141 #ifdef NO_DOLLAR_IN_LABEL
142 #ifdef NO_DOT_IN_LABEL
143 #undef MINIMAL_DEBUG
144 #define MINIMAL_DEBUG 0
145 #endif
146 #endif
148 /* Typical USG systems don't have stab.h, and they also have
149 no use for DBX-format debugging info. */
151 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
153 static int flag_minimal_debug = MINIMAL_DEBUG;
155 /* Nonzero if we have actually used any of the GDB extensions
156 to the debugging format. The idea is that we use them for the
157 first time only if there's a strong reason, but once we have done that,
158 we use them whenever convenient. */
160 static int have_used_extensions = 0;
162 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
163 for the N_SO filename stabs label. */
165 static int source_label_number = 1;
167 #ifdef DEBUG_SYMS_TEXT
168 #define FORCE_TEXT text_section ();
169 #else
170 #define FORCE_TEXT
171 #endif
173 /* If there is a system stab.h, use it. Otherwise, use our own. */
174 /* ??? This is supposed to describe the target's stab format, so using
175 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
176 when cross compiling. */
177 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
178 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
179 #else
180 #include <stab.h>
182 /* This is a GNU extension we need to reference in this file. */
183 #ifndef N_CATCH
184 #define N_CATCH 0x54
185 #endif
187 /* This is a Solaris extension we need to reference in this file. */
188 #ifndef N_OPT
189 #define N_OPT 0x3c
190 #endif
191 #endif
193 #ifdef __GNU_STAB__
194 #define STAB_CODE_TYPE enum __stab_debug_code
195 #else
196 #define STAB_CODE_TYPE int
197 #endif
199 /* 1 if PARM is passed to this function in memory. */
201 #define PARM_PASSED_IN_MEMORY(PARM) \
202 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
204 /* A C expression for the integer offset value of an automatic variable
205 (N_LSYM) having address X (an RTX). */
206 #ifndef DEBUGGER_AUTO_OFFSET
207 #define DEBUGGER_AUTO_OFFSET(X) \
208 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
209 #endif
211 /* A C expression for the integer offset value of an argument (N_PSYM)
212 having address X (an RTX). The nominal offset is OFFSET. */
213 #ifndef DEBUGGER_ARG_OFFSET
214 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
215 #endif
217 /* Stream for writing to assembler file. */
219 static FILE *asmfile;
221 /* Last source file name mentioned in a NOTE insn. */
223 static const char *lastfile;
225 /* Current working directory. */
227 static const char *cwd;
229 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
231 /* Structure recording information about a C data type.
232 The status element says whether we have yet output
233 the definition of the type. TYPE_XREF says we have
234 output it as a cross-reference only.
235 The file_number and type_number elements are used if DBX_USE_BINCL
236 is defined. */
238 struct typeinfo
240 enum typestatus status;
241 #ifdef DBX_USE_BINCL
242 int file_number;
243 int type_number;
244 #endif
247 /* Vector recording information about C data types.
248 When we first notice a data type (a tree node),
249 we assign it a number using next_type_number.
250 That is its index in this vector. */
252 struct typeinfo *typevec;
254 /* Number of elements of space allocated in `typevec'. */
256 static int typevec_len;
258 /* In dbx output, each type gets a unique number.
259 This is the number for the next type output.
260 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
262 static int next_type_number;
264 #ifdef DBX_USE_BINCL
266 /* When using N_BINCL in dbx output, each type number is actually a
267 pair of the file number and the type number within the file.
268 This is a stack of input files. */
270 struct dbx_file
272 struct dbx_file *next;
273 int file_number;
274 int next_type_number;
277 /* This is the top of the stack. */
279 static struct dbx_file *current_file;
281 /* This is the next file number to use. */
283 static int next_file_number;
285 #endif /* DBX_USE_BINCL */
287 /* These variables are for dbxout_symbol to communicate to
288 dbxout_finish_symbol.
289 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
290 current_sym_value and current_sym_addr are two ways to address the
291 value to store in the symtab entry.
292 current_sym_addr if nonzero represents the value as an rtx.
293 If that is zero, current_sym_value is used. This is used
294 when the value is an offset (such as for auto variables,
295 register variables and parms). */
297 static STAB_CODE_TYPE current_sym_code;
298 static int current_sym_value;
299 static rtx current_sym_addr;
301 /* Number of chars of symbol-description generated so far for the
302 current symbol. Used by CHARS and CONTIN. */
304 static int current_sym_nchars;
306 /* Report having output N chars of the current symbol-description. */
308 #define CHARS(N) (current_sym_nchars += (N))
310 /* Break the current symbol-description, generating a continuation,
311 if it has become long. */
313 #ifndef DBX_CONTIN_LENGTH
314 #define DBX_CONTIN_LENGTH 80
315 #endif
317 #if DBX_CONTIN_LENGTH > 0
318 #define CONTIN \
319 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
320 #else
321 #define CONTIN do { } while (0)
322 #endif
324 #if defined(ASM_OUTPUT_SECTION_NAME)
325 static void dbxout_function_end PARAMS ((void));
326 #endif
327 static void dbxout_typedefs PARAMS ((tree));
328 static void dbxout_type_index PARAMS ((tree));
329 #if DBX_CONTIN_LENGTH > 0
330 static void dbxout_continue PARAMS ((void));
331 #endif
332 static void dbxout_type_fields PARAMS ((tree));
333 static void dbxout_type_method_1 PARAMS ((tree, const char *));
334 static void dbxout_type_methods PARAMS ((tree));
335 static void dbxout_range_type PARAMS ((tree));
336 static void dbxout_type PARAMS ((tree, int, int));
337 static void print_int_cst_octal PARAMS ((tree));
338 static void print_octal PARAMS ((unsigned HOST_WIDE_INT, int));
339 static void dbxout_type_name PARAMS ((tree));
340 static int dbxout_symbol_location PARAMS ((tree, tree, const char *, rtx));
341 static void dbxout_symbol_name PARAMS ((tree, const char *, int));
342 static void dbxout_prepare_symbol PARAMS ((tree));
343 static void dbxout_finish_symbol PARAMS ((tree));
344 static void dbxout_block PARAMS ((tree, int, tree));
345 static void dbxout_really_begin_function PARAMS ((tree));
347 #if defined(ASM_OUTPUT_SECTION_NAME)
348 static void
349 dbxout_function_end ()
351 static int scope_labelno = 0;
352 char lscope_label_name[100];
353 /* Convert Ltext into the appropriate format for local labels in case
354 the system doesn't insert underscores in front of user generated
355 labels. */
356 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
357 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
358 scope_labelno++;
360 /* By convention, GCC will mark the end of a function with an N_FUN
361 symbol and an empty string. */
362 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
363 assemble_name (asmfile, lscope_label_name);
364 fputc ('-', asmfile);
365 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
366 fprintf (asmfile, "\n");
368 #endif /* ! NO_DBX_FUNCTION_END */
370 /* At the beginning of compilation, start writing the symbol table.
371 Initialize `typevec' and output the standard data types of C. */
373 void
374 dbxout_init (asm_file, input_file_name, syms)
375 FILE *asm_file;
376 const char *input_file_name;
377 tree syms;
379 char ltext_label_name[100];
381 asmfile = asm_file;
383 typevec_len = 100;
384 typevec = (struct typeinfo *) xcalloc (typevec_len, sizeof typevec[0]);
386 /* Convert Ltext into the appropriate format for local labels in case
387 the system doesn't insert underscores in front of user generated
388 labels. */
389 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
391 /* Put the current working directory in an N_SO symbol. */
392 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
393 but GDB always does. */
394 if (use_gnu_debug_info_extensions)
395 #endif
397 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
399 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
400 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
401 cwd = wdslash;
403 if (cwd)
405 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
406 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
407 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
408 fprintf (asmfile, "%s", ASM_STABS_OP);
409 output_quoted_string (asmfile, cwd);
410 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, &ltext_label_name[1]);
411 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
415 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
416 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
417 would give us an N_SOL, and we want an N_SO. */
418 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
419 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
420 /* We include outputting `Ltext:' here,
421 because that gives you a way to override it. */
422 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
423 fprintf (asmfile, "%s", ASM_STABS_OP);
424 output_quoted_string (asmfile, input_file_name);
425 fprintf (asmfile, ",%d,0,0,%s\n",
426 N_SO, &ltext_label_name[1]);
427 text_section ();
428 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
429 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
431 #ifdef DBX_OUTPUT_GCC_MARKER
432 DBX_OUTPUT_GCC_MARKER (asmfile);
433 #else
434 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
435 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
436 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
437 #endif
439 lastfile = input_file_name;
441 next_type_number = 1;
443 #ifdef DBX_USE_BINCL
444 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
445 current_file->next = NULL;
446 current_file->file_number = 0;
447 current_file->next_type_number = 1;
448 next_file_number = 1;
449 #endif
451 /* Make sure that types `int' and `char' have numbers 1 and 2.
452 Definitions of other integer types will refer to those numbers.
453 (Actually it should no longer matter what their numbers are.
454 Also, if any types with tags have been defined, dbxout_symbol
455 will output them first, so the numbers won't be 1 and 2. That
456 happens in C++. So it's a good thing it should no longer matter). */
458 #ifdef DBX_OUTPUT_STANDARD_TYPES
459 DBX_OUTPUT_STANDARD_TYPES (syms);
460 #else
461 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
462 dbxout_symbol (TYPE_NAME (char_type_node), 0);
463 #endif
465 /* Get all permanent types that have typedef names,
466 and output them all, except for those already output. */
468 dbxout_typedefs (syms);
471 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
472 in the reverse order from that which is found in SYMS. */
474 static void
475 dbxout_typedefs (syms)
476 tree syms;
478 if (syms)
480 dbxout_typedefs (TREE_CHAIN (syms));
481 if (TREE_CODE (syms) == TYPE_DECL)
483 tree type = TREE_TYPE (syms);
484 if (TYPE_NAME (type)
485 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
486 && COMPLETE_TYPE_P (type)
487 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
488 dbxout_symbol (TYPE_NAME (type), 0);
493 /* Change to reading from a new source file. Generate a N_BINCL stab. */
495 void
496 dbxout_start_new_source_file (filename)
497 const char *filename ATTRIBUTE_UNUSED;
499 #ifdef DBX_USE_BINCL
500 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
502 n->next = current_file;
503 n->file_number = next_file_number++;
504 n->next_type_number = 1;
505 current_file = n;
506 fprintf (asmfile, "%s", ASM_STABS_OP);
507 output_quoted_string (asmfile, filename);
508 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
509 #endif
512 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
514 void
515 dbxout_resume_previous_source_file ()
517 #ifdef DBX_USE_BINCL
518 struct dbx_file *next;
520 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
521 next = current_file->next;
522 free (current_file);
523 current_file = next;
524 #endif
527 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
529 void
530 dbxout_source_file (file, filename)
531 FILE *file;
532 const char *filename;
534 char ltext_label_name[100];
536 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
538 #ifdef DBX_OUTPUT_SOURCE_FILENAME
539 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
540 #else
541 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
542 source_label_number);
543 fprintf (file, "%s", ASM_STABS_OP);
544 output_quoted_string (file, filename);
545 fprintf (file, ",%d,0,0,%s\n", N_SOL, &ltext_label_name[1]);
546 if (current_function_decl != NULL_TREE
547 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
548 ; /* Don't change section amid function. */
549 else
550 text_section ();
551 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
552 source_label_number++;
553 #endif
554 lastfile = filename;
558 /* Output a line number symbol entry into output stream FILE,
559 for source file FILENAME and line number LINENO. */
561 void
562 dbxout_source_line (file, filename, lineno)
563 FILE *file;
564 const char *filename;
565 int lineno;
567 dbxout_source_file (file, filename);
569 #ifdef ASM_OUTPUT_SOURCE_LINE
570 ASM_OUTPUT_SOURCE_LINE (file, lineno);
571 #else
572 fprintf (file, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
573 #endif
576 /* At the end of compilation, finish writing the symbol table.
577 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
578 to do nothing. */
580 void
581 dbxout_finish (file, filename)
582 FILE *file ATTRIBUTE_UNUSED;
583 const char *filename ATTRIBUTE_UNUSED;
585 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
586 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
587 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
590 /* Output the index of a type. */
592 static void
593 dbxout_type_index (type)
594 tree type;
596 #ifndef DBX_USE_BINCL
597 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
598 CHARS (3);
599 #else
600 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
601 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
602 CHARS (7);
603 #endif
606 #if DBX_CONTIN_LENGTH > 0
607 /* Continue a symbol-description that gets too big.
608 End one symbol table entry with a double-backslash
609 and start a new one, eventually producing something like
610 .stabs "start......\\",code,0,value
611 .stabs "...rest",code,0,value */
613 static void
614 dbxout_continue ()
616 #ifdef DBX_CONTIN_CHAR
617 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
618 #else
619 fprintf (asmfile, "\\\\");
620 #endif
621 dbxout_finish_symbol (NULL_TREE);
622 fprintf (asmfile, "%s\"", ASM_STABS_OP);
623 current_sym_nchars = 0;
625 #endif /* DBX_CONTIN_LENGTH > 0 */
627 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
628 This must be a separate function because anonymous unions require
629 recursive calls. */
631 static void
632 dbxout_type_fields (type)
633 tree type;
635 tree tem;
637 /* Output the name, type, position (in bits), size (in bits) of each
638 field that we can support. */
639 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
641 /* Omit here local type decls until we know how to support them. */
642 if (TREE_CODE (tem) == TYPE_DECL
643 /* Omit fields whose position or size are variable or too large to
644 represent. */
645 || (TREE_CODE (tem) == FIELD_DECL
646 && (! host_integerp (bit_position (tem), 0)
647 || ! DECL_SIZE (tem)
648 || ! host_integerp (DECL_SIZE (tem), 1)))
649 /* Omit here the nameless fields that are used to skip bits. */
650 || DECL_IGNORED_P (tem))
651 continue;
653 else if (TREE_CODE (tem) != CONST_DECL)
655 /* Continue the line if necessary,
656 but not before the first field. */
657 if (tem != TYPE_FIELDS (type))
658 CONTIN;
660 if (use_gnu_debug_info_extensions
661 && flag_minimal_debug
662 && TREE_CODE (tem) == FIELD_DECL
663 && DECL_VIRTUAL_P (tem)
664 && DECL_ASSEMBLER_NAME (tem))
666 have_used_extensions = 1;
667 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
668 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
669 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
670 fprintf (asmfile, ":");
671 dbxout_type (TREE_TYPE (tem), 0, 0);
672 fputc (',', asmfile);
673 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
674 int_bit_position (tem));
675 fputc (';', asmfile);
676 continue;
679 if (DECL_NAME (tem))
681 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
682 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
684 else
686 fprintf (asmfile, ":");
687 CHARS (2);
690 if (use_gnu_debug_info_extensions
691 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
692 || TREE_CODE (tem) != FIELD_DECL))
694 have_used_extensions = 1;
695 putc ('/', asmfile);
696 putc ((TREE_PRIVATE (tem) ? '0'
697 : TREE_PROTECTED (tem) ? '1' : '2'),
698 asmfile);
699 CHARS (2);
702 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
703 && DECL_BIT_FIELD_TYPE (tem))
704 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0, 0);
706 if (TREE_CODE (tem) == VAR_DECL)
708 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
710 const char *name =
711 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
712 have_used_extensions = 1;
713 fprintf (asmfile, ":%s;", name);
714 CHARS (strlen (name));
716 else
717 /* If TEM is non-static, GDB won't understand it. */
718 fprintf (asmfile, ",0,0;");
720 else
722 fputc (',', asmfile);
723 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
724 int_bit_position (tem));
725 fputc (',', asmfile);
726 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
727 tree_low_cst (DECL_SIZE (tem), 1));
728 fputc (';', asmfile);
729 CHARS (23);
735 /* Subroutine of `dbxout_type_methods'. Output debug info about the
736 method described DECL. DEBUG_NAME is an encoding of the method's
737 type signature. ??? We may be able to do without DEBUG_NAME altogether
738 now. */
740 static void
741 dbxout_type_method_1 (decl, debug_name)
742 tree decl;
743 const char *debug_name;
745 char c1 = 'A', c2;
747 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
748 c2 = '?';
749 else /* it's a METHOD_TYPE. */
751 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
752 /* A for normal functions.
753 B for `const' member functions.
754 C for `volatile' member functions.
755 D for `const volatile' member functions. */
756 if (TYPE_READONLY (TREE_TYPE (firstarg)))
757 c1 += 1;
758 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
759 c1 += 2;
761 if (DECL_VINDEX (decl))
762 c2 = '*';
763 else
764 c2 = '.';
767 fprintf (asmfile, ":%s;%c%c%c", debug_name,
768 TREE_PRIVATE (decl) ? '0'
769 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
770 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
771 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
773 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
775 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
776 tree_low_cst (DECL_VINDEX (decl), 0));
777 fputc (';', asmfile);
778 dbxout_type (DECL_CONTEXT (decl), 0, 0);
779 fprintf (asmfile, ";");
780 CHARS (8);
784 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
785 in TYPE. */
787 static void
788 dbxout_type_methods (type)
789 register tree type;
791 /* C++: put out the method names and their parameter lists */
792 tree methods = TYPE_METHODS (type);
793 tree type_encoding;
794 register tree fndecl;
795 register tree last;
796 char formatted_type_identifier_length[16];
797 register int type_identifier_length;
799 if (methods == NULL_TREE)
800 return;
802 type_encoding = DECL_NAME (TYPE_NAME (type));
804 #if 0
805 /* C++: Template classes break some assumptions made by this code about
806 the class names, constructor names, and encodings for assembler
807 label names. For now, disable output of dbx info for them. */
809 const char *ptr = IDENTIFIER_POINTER (type_encoding);
810 /* This should use index. (mrs) */
811 while (*ptr && *ptr != '<') ptr++;
812 if (*ptr != 0)
814 static int warned;
815 if (!warned)
816 warned = 1;
817 return;
820 #endif
822 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
824 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
826 if (TREE_CODE (methods) != TREE_VEC)
827 fndecl = methods;
828 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
829 fndecl = TREE_VEC_ELT (methods, 0);
830 else
831 fndecl = TREE_VEC_ELT (methods, 1);
833 while (fndecl)
835 tree name = DECL_NAME (fndecl);
836 int need_prefix = 1;
838 /* Group together all the methods for the same operation.
839 These differ in the types of the arguments. */
840 for (last = NULL_TREE;
841 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
842 fndecl = TREE_CHAIN (fndecl))
843 /* Output the name of the field (after overloading), as
844 well as the name of the field before overloading, along
845 with its parameter list */
847 /* This is the "mangled" name of the method.
848 It encodes the argument types. */
849 const char *debug_name;
850 int show_arg_types = 0;
852 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
853 include TEMPLATE_DECLs.) The debugger doesn't know what
854 to do with such entities anyhow. */
855 if (TREE_CODE (fndecl) != FUNCTION_DECL)
856 continue;
858 debug_name =
859 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
861 CONTIN;
863 last = fndecl;
865 /* Also ignore abstract methods; those are only interesting to
866 the DWARF backends. */
867 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
868 continue;
870 if (flag_minimal_debug)
872 char marker;
874 /* We can't optimize a method which uses an anonymous
875 class, because the debugger will not be able to
876 associate the arbitrary class name with the actual
877 class. */
878 #ifndef NO_DOLLAR_IN_LABEL
879 marker = '$';
880 #else
881 marker = '.';
882 #endif
883 if (strchr (debug_name, marker))
884 show_arg_types = 1;
885 /* Detect ordinary methods because their mangled names
886 start with the operation name. */
887 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
888 IDENTIFIER_LENGTH (name)))
890 debug_name += IDENTIFIER_LENGTH (name);
891 if (debug_name[0] == '_' && debug_name[1] == '_')
893 const char *method_name = debug_name + 2;
894 const char *length_ptr =
895 formatted_type_identifier_length;
896 /* Get past const and volatile qualifiers. */
897 while (*method_name == 'C' || *method_name == 'V')
898 method_name++;
899 /* Skip digits for length of type_encoding. */
900 while (*method_name == *length_ptr && *length_ptr)
901 length_ptr++, method_name++;
902 if (! strncmp (method_name,
903 IDENTIFIER_POINTER (type_encoding),
904 type_identifier_length))
905 method_name += type_identifier_length;
906 debug_name = method_name;
909 /* Detect constructors by their style of name mangling. */
910 else if (debug_name[0] == '_' && debug_name[1] == '_')
912 const char *ctor_name = debug_name + 2;
913 const char *length_ptr = formatted_type_identifier_length;
914 while (*ctor_name == 'C' || *ctor_name == 'V')
915 ctor_name++;
916 /* Skip digits for length of type_encoding. */
917 while (*ctor_name == *length_ptr && *length_ptr)
918 length_ptr++, ctor_name++;
919 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
920 type_identifier_length))
921 debug_name = ctor_name + type_identifier_length;
923 /* The other alternative is a destructor. */
924 else
925 show_arg_types = 1;
927 /* Output the operation name just once, for the first method
928 that we output. */
929 if (need_prefix)
931 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
932 CHARS (IDENTIFIER_LENGTH (name) + 2);
933 need_prefix = 0;
937 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
939 dbxout_type_method_1 (fndecl, debug_name);
941 if (!need_prefix)
943 putc (';', asmfile);
944 CHARS (1);
949 /* Emit a "range" type specification, which has the form:
950 "r<index type>;<lower bound>;<upper bound>;".
951 TYPE is an INTEGER_TYPE. */
953 static void
954 dbxout_range_type (type)
955 tree type;
957 fprintf (asmfile, "r");
958 if (TREE_TYPE (type))
959 dbxout_type (TREE_TYPE (type), 0, 0);
960 else if (TREE_CODE (type) != INTEGER_TYPE)
961 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
962 else
964 /* Traditionally, we made sure 'int' was type 1, and builtin types
965 were defined to be sub-ranges of int. Unfortunately, this
966 does not allow us to distinguish true sub-ranges from integer
967 types. So, instead we define integer (non-sub-range) types as
968 sub-ranges of themselves. This matters for Chill. If this isn't
969 a subrange type, then we want to define it in terms of itself.
970 However, in C, this may be an anonymous integer type, and we don't
971 want to emit debug info referring to it. Just calling
972 dbxout_type_index won't work anyways, because the type hasn't been
973 defined yet. We make this work for both cases by checked to see
974 whether this is a defined type, referring to it if it is, and using
975 'int' otherwise. */
976 if (TYPE_SYMTAB_ADDRESS (type) != 0)
977 dbxout_type_index (type);
978 else
979 dbxout_type_index (integer_type_node);
982 if (TYPE_MIN_VALUE (type) != 0
983 && host_integerp (TYPE_MIN_VALUE (type), 0))
985 fputc (';', asmfile);
986 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
987 tree_low_cst (TYPE_MIN_VALUE (type), 0));
989 else
990 fprintf (asmfile, ";0");
992 if (TYPE_MAX_VALUE (type) != 0
993 && host_integerp (TYPE_MAX_VALUE (type), 0))
995 fputc (';', asmfile);
996 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
997 tree_low_cst (TYPE_MAX_VALUE (type), 0));
998 fputc (';', asmfile);
1000 else
1001 fprintf (asmfile, ";-1;");
1004 /* Output a reference to a type. If the type has not yet been
1005 described in the dbx output, output its definition now.
1006 For a type already defined, just refer to its definition
1007 using the type number.
1009 If FULL is nonzero, and the type has been described only with
1010 a forward-reference, output the definition now.
1011 If FULL is zero in this case, just refer to the forward-reference
1012 using the number previously allocated.
1014 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1015 types for a METHOD_TYPE. */
1017 static void
1018 dbxout_type (type, full, show_arg_types)
1019 tree type;
1020 int full;
1021 int show_arg_types;
1023 register tree tem;
1024 static int anonymous_type_number = 0;
1026 if (TREE_CODE (type) == VECTOR_TYPE)
1027 type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
1029 /* If there was an input error and we don't really have a type,
1030 avoid crashing and write something that is at least valid
1031 by assuming `int'. */
1032 if (type == error_mark_node)
1033 type = integer_type_node;
1034 else
1036 /* Try to find the "main variant" with the same name but not const
1037 or volatile. (Since stabs does not distinguish const and volatile,
1038 there is no need to make them separate types. But types with
1039 different names are usefully distinguished.) */
1041 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1042 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1043 && TYPE_NAME (tem) == TYPE_NAME (type))
1045 type = tem;
1046 break;
1048 if (TYPE_NAME (type)
1049 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1050 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1051 full = 0;
1054 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1056 /* Type has no dbx number assigned. Assign next available number. */
1057 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1059 /* Make sure type vector is long enough to record about this type. */
1061 if (next_type_number == typevec_len)
1063 typevec
1064 = (struct typeinfo *) xrealloc (typevec,
1065 typevec_len * 2 * sizeof typevec[0]);
1066 memset ((char *) (typevec + typevec_len), 0,
1067 typevec_len * sizeof typevec[0]);
1068 typevec_len *= 2;
1071 #ifdef DBX_USE_BINCL
1072 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1073 = current_file->file_number;
1074 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1075 = current_file->next_type_number++;
1076 #endif
1079 /* Output the number of this type, to refer to it. */
1080 dbxout_type_index (type);
1082 #ifdef DBX_TYPE_DEFINED
1083 if (DBX_TYPE_DEFINED (type))
1084 return;
1085 #endif
1087 /* If this type's definition has been output or is now being output,
1088 that is all. */
1090 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1092 case TYPE_UNSEEN:
1093 break;
1094 case TYPE_XREF:
1095 /* If we have already had a cross reference,
1096 and either that's all we want or that's the best we could do,
1097 don't repeat the cross reference.
1098 Sun dbx crashes if we do. */
1099 if (! full || !COMPLETE_TYPE_P (type)
1100 /* No way in DBX fmt to describe a variable size. */
1101 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1102 return;
1103 break;
1104 case TYPE_DEFINED:
1105 return;
1108 #ifdef DBX_NO_XREFS
1109 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1110 leave the type-number completely undefined rather than output
1111 a cross-reference. If we have already used GNU debug info extensions,
1112 then it is OK to output a cross reference. This is necessary to get
1113 proper C++ debug output. */
1114 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1115 || TREE_CODE (type) == QUAL_UNION_TYPE
1116 || TREE_CODE (type) == ENUMERAL_TYPE)
1117 && ! use_gnu_debug_info_extensions)
1118 /* We must use the same test here as we use twice below when deciding
1119 whether to emit a cross-reference. */
1120 if ((TYPE_NAME (type) != 0
1121 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1122 && DECL_IGNORED_P (TYPE_NAME (type)))
1123 && !full)
1124 || !COMPLETE_TYPE_P (type)
1125 /* No way in DBX fmt to describe a variable size. */
1126 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1128 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1129 return;
1131 #endif
1133 /* Output a definition now. */
1135 fprintf (asmfile, "=");
1136 CHARS (1);
1138 /* Mark it as defined, so that if it is self-referent
1139 we will not get into an infinite recursion of definitions. */
1141 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1143 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1144 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1146 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1147 return;
1150 switch (TREE_CODE (type))
1152 case VOID_TYPE:
1153 case LANG_TYPE:
1154 /* For a void type, just define it as itself; ie, "5=5".
1155 This makes us consider it defined
1156 without saying what it is. The debugger will make it
1157 a void type when the reference is seen, and nothing will
1158 ever override that default. */
1159 dbxout_type_index (type);
1160 break;
1162 case INTEGER_TYPE:
1163 if (type == char_type_node && ! TREE_UNSIGNED (type))
1165 /* Output the type `char' as a subrange of itself!
1166 I don't understand this definition, just copied it
1167 from the output of pcc.
1168 This used to use `r2' explicitly and we used to
1169 take care to make sure that `char' was type number 2. */
1170 fprintf (asmfile, "r");
1171 dbxout_type_index (type);
1172 fprintf (asmfile, ";0;127;");
1175 /* If this is a subtype of another integer type, always prefer to
1176 write it as a subtype. */
1177 else if (TREE_TYPE (type) != 0
1178 && TREE_CODE (TREE_TYPE (type)) == INTEGER_CST)
1179 dbxout_range_type (type);
1181 else
1183 /* If the size is non-standard, say what it is if we can use
1184 GDB extensions. */
1186 if (use_gnu_debug_info_extensions
1187 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1188 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1190 /* If we can use GDB extensions and the size is wider than a
1191 long (the size used by GDB to read them) or we may have
1192 trouble writing the bounds the usual way, write them in
1193 octal. Note the test is for the *target's* size of "long",
1194 not that of the host. The host test is just to make sure we
1195 can write it out in case the host wide int is narrower than the
1196 target "long". */
1198 /* For unsigned types, we use octal if they are the same size or
1199 larger. This is because we print the bounds as signed decimal,
1200 and hence they can't span same size unsigned types. */
1202 if (use_gnu_debug_info_extensions
1203 && TYPE_MIN_VALUE (type) != 0
1204 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1205 && TYPE_MAX_VALUE (type) != 0
1206 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1207 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1208 || (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
1209 && TREE_UNSIGNED (type))
1210 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1211 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1212 && TREE_UNSIGNED (type))))
1214 fprintf (asmfile, "r");
1215 dbxout_type_index (type);
1216 fprintf (asmfile, ";");
1217 print_int_cst_octal (TYPE_MIN_VALUE (type));
1218 fprintf (asmfile, ";");
1219 print_int_cst_octal (TYPE_MAX_VALUE (type));
1220 fprintf (asmfile, ";");
1223 else
1224 /* Output other integer types as subranges of `int'. */
1225 dbxout_range_type (type);
1228 CHARS (22);
1229 break;
1231 case REAL_TYPE:
1232 /* This used to say `r1' and we used to take care
1233 to make sure that `int' was type number 1. */
1234 fprintf (asmfile, "r");
1235 dbxout_type_index (integer_type_node);
1236 fputc (';', asmfile);
1237 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1238 fputs (";0;", asmfile);
1239 CHARS (13);
1240 break;
1242 case CHAR_TYPE:
1243 if (use_gnu_debug_info_extensions)
1245 fputs ("@s", asmfile);
1246 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1247 BITS_PER_UNIT * int_size_in_bytes (type));
1248 fputs (";-20;", asmfile);
1250 else
1252 /* Output the type `char' as a subrange of itself.
1253 That is what pcc seems to do. */
1254 fprintf (asmfile, "r");
1255 dbxout_type_index (char_type_node);
1256 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1258 CHARS (9);
1259 break;
1261 case BOOLEAN_TYPE:
1262 if (use_gnu_debug_info_extensions)
1264 fputs ("@s", asmfile);
1265 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1266 BITS_PER_UNIT * int_size_in_bytes (type));
1267 fputs (";-16;", asmfile);
1269 else /* Define as enumeral type (False, True) */
1270 fprintf (asmfile, "eFalse:0,True:1,;");
1271 CHARS (17);
1272 break;
1274 case FILE_TYPE:
1275 putc ('d', asmfile);
1276 CHARS (1);
1277 dbxout_type (TREE_TYPE (type), 0, 0);
1278 break;
1280 case COMPLEX_TYPE:
1281 /* Differs from the REAL_TYPE by its new data type number */
1283 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1285 fprintf (asmfile, "r");
1286 dbxout_type_index (type);
1287 fputc (';', asmfile);
1288 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1289 2 * int_size_in_bytes (TREE_TYPE (type)));
1290 fputs (";0;", asmfile);
1291 CHARS (12); /* The number is probably incorrect here. */
1293 else
1295 /* Output a complex integer type as a structure,
1296 pending some other way to do it. */
1297 fputc ('s', asmfile);
1298 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1300 fprintf (asmfile, "real:");
1301 CHARS (10);
1302 dbxout_type (TREE_TYPE (type), 0, 0);
1303 fprintf (asmfile, ",%d,%d;",
1304 0, TYPE_PRECISION (TREE_TYPE (type)));
1305 CHARS (8);
1306 fprintf (asmfile, "imag:");
1307 CHARS (5);
1308 dbxout_type (TREE_TYPE (type), 0, 0);
1309 fprintf (asmfile, ",%d,%d;;",
1310 TYPE_PRECISION (TREE_TYPE (type)),
1311 TYPE_PRECISION (TREE_TYPE (type)));
1312 CHARS (9);
1314 break;
1316 case SET_TYPE:
1317 if (use_gnu_debug_info_extensions)
1319 have_used_extensions = 1;
1320 fputs ("@s", asmfile);
1321 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1322 BITS_PER_UNIT * int_size_in_bytes (type));
1323 fputc (';', asmfile);
1324 /* Check if a bitstring type, which in Chill is
1325 different from a [power]set. */
1326 if (TYPE_STRING_FLAG (type))
1327 fprintf (asmfile, "@S;");
1329 putc ('S', asmfile);
1330 CHARS (1);
1331 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1332 break;
1334 case ARRAY_TYPE:
1335 /* Make arrays of packed bits look like bitstrings for chill. */
1336 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1338 have_used_extensions = 1;
1339 fputs ("@s", asmfile);
1340 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1341 BITS_PER_UNIT * int_size_in_bytes (type));
1342 fputc (';', asmfile);
1343 fprintf (asmfile, "@S;");
1344 putc ('S', asmfile);
1345 CHARS (1);
1346 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1347 break;
1349 /* Output "a" followed by a range type definition
1350 for the index type of the array
1351 followed by a reference to the target-type.
1352 ar1;0;N;M for a C array of type M and size N+1. */
1353 /* Check if a character string type, which in Chill is
1354 different from an array of characters. */
1355 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1357 have_used_extensions = 1;
1358 fprintf (asmfile, "@S;");
1360 tem = TYPE_DOMAIN (type);
1361 if (tem == NULL)
1363 fprintf (asmfile, "ar");
1364 dbxout_type_index (integer_type_node);
1365 fprintf (asmfile, ";0;-1;");
1367 else
1369 fprintf (asmfile, "a");
1370 dbxout_range_type (tem);
1372 CHARS (14);
1373 dbxout_type (TREE_TYPE (type), 0, 0);
1374 break;
1376 case RECORD_TYPE:
1377 case UNION_TYPE:
1378 case QUAL_UNION_TYPE:
1380 int i, n_baseclasses = 0;
1382 if (TYPE_BINFO (type) != 0
1383 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1384 && TYPE_BINFO_BASETYPES (type) != 0)
1385 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1387 /* Output a structure type. We must use the same test here as we
1388 use in the DBX_NO_XREFS case above. */
1389 if ((TYPE_NAME (type) != 0
1390 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1391 && DECL_IGNORED_P (TYPE_NAME (type)))
1392 && !full)
1393 || !COMPLETE_TYPE_P (type)
1394 /* No way in DBX fmt to describe a variable size. */
1395 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1397 /* If the type is just a cross reference, output one
1398 and mark the type as partially described.
1399 If it later becomes defined, we will output
1400 its real definition.
1401 If the type has a name, don't nest its definition within
1402 another type's definition; instead, output an xref
1403 and let the definition come when the name is defined. */
1404 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1405 CHARS (3);
1406 #if 0 /* This assertion is legitimately false in C++. */
1407 /* We shouldn't be outputting a reference to a type before its
1408 definition unless the type has a tag name.
1409 A typedef name without a tag name should be impossible. */
1410 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1411 abort ();
1412 #endif
1413 if (TYPE_NAME (type) != 0)
1414 dbxout_type_name (type);
1415 else
1416 fprintf (asmfile, "$$%d", anonymous_type_number++);
1417 fprintf (asmfile, ":");
1418 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1419 break;
1422 /* Identify record or union, and print its size. */
1423 fputc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1424 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1425 int_size_in_bytes (type));
1427 if (use_gnu_debug_info_extensions)
1429 if (n_baseclasses)
1431 have_used_extensions = 1;
1432 fprintf (asmfile, "!%d,", n_baseclasses);
1433 CHARS (8);
1436 for (i = 0; i < n_baseclasses; i++)
1438 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1440 if (use_gnu_debug_info_extensions)
1442 have_used_extensions = 1;
1443 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1444 putc (TREE_VIA_PUBLIC (child) ? '2' : '0', asmfile);
1445 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1446 (tree_low_cst (BINFO_OFFSET (child), 0)
1447 * BITS_PER_UNIT));
1448 fputc (',', asmfile);
1449 CHARS (15);
1450 dbxout_type (BINFO_TYPE (child), 0, 0);
1451 putc (';', asmfile);
1453 else
1455 /* Print out the base class information with fields
1456 which have the same names at the types they hold. */
1457 dbxout_type_name (BINFO_TYPE (child));
1458 putc (':', asmfile);
1459 dbxout_type (BINFO_TYPE (child), full, 0);
1460 fputc (',', asmfile);
1461 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1462 tree_low_cst (BINFO_OFFSET (child), 0)
1463 * BITS_PER_UNIT);
1464 fputc (',', asmfile);
1465 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1466 (tree_low_cst (DECL_SIZE (TYPE_NAME
1467 (BINFO_TYPE (child))), 0)
1468 * BITS_PER_UNIT));
1469 fputc (';', asmfile);
1470 CHARS (20);
1475 CHARS (11);
1477 /* Write out the field declarations. */
1478 dbxout_type_fields (type);
1479 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1481 have_used_extensions = 1;
1482 dbxout_type_methods (type);
1485 putc (';', asmfile);
1487 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1488 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1489 && TYPE_VFIELD (type))
1491 have_used_extensions = 1;
1493 /* Tell GDB+ that it may keep reading. */
1494 putc ('~', asmfile);
1496 /* We need to write out info about what field this class
1497 uses as its "main" vtable pointer field, because if this
1498 field is inherited from a base class, GDB cannot necessarily
1499 figure out which field it's using in time. */
1500 if (TYPE_VFIELD (type))
1502 putc ('%', asmfile);
1503 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1505 putc (';', asmfile);
1506 CHARS (3);
1508 break;
1510 case ENUMERAL_TYPE:
1511 /* We must use the same test here as we use in the DBX_NO_XREFS case
1512 above. We simplify it a bit since an enum will never have a variable
1513 size. */
1514 if ((TYPE_NAME (type) != 0
1515 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1516 && DECL_IGNORED_P (TYPE_NAME (type)))
1517 && !full)
1518 || !COMPLETE_TYPE_P (type))
1520 fprintf (asmfile, "xe");
1521 CHARS (3);
1522 dbxout_type_name (type);
1523 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1524 fprintf (asmfile, ":");
1525 return;
1527 #ifdef DBX_OUTPUT_ENUM
1528 DBX_OUTPUT_ENUM (asmfile, type);
1529 #else
1530 if (use_gnu_debug_info_extensions
1531 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1532 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1533 putc ('e', asmfile);
1534 CHARS (1);
1535 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1537 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1538 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1539 fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED,
1540 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1541 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1542 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1543 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1544 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1545 else
1546 print_int_cst_octal (TREE_VALUE (tem));
1547 fprintf (asmfile, ",");
1548 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1549 if (TREE_CHAIN (tem) != 0)
1551 CONTIN;
1554 putc (';', asmfile);
1555 CHARS (1);
1556 #endif
1557 break;
1559 case POINTER_TYPE:
1560 putc ('*', asmfile);
1561 CHARS (1);
1562 dbxout_type (TREE_TYPE (type), 0, 0);
1563 break;
1565 case METHOD_TYPE:
1566 if (use_gnu_debug_info_extensions)
1568 have_used_extensions = 1;
1569 putc ('#', asmfile);
1570 CHARS (1);
1571 if (flag_minimal_debug && !show_arg_types)
1573 /* Normally, just output the return type.
1574 The argument types are encoded in the method name. */
1575 putc ('#', asmfile);
1576 CHARS (1);
1577 dbxout_type (TREE_TYPE (type), 0, 0);
1578 putc (';', asmfile);
1579 CHARS (1);
1581 else
1583 /* When outputting destructors, we need to write
1584 the argument types out longhand. */
1585 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1586 putc (',', asmfile);
1587 CHARS (1);
1588 dbxout_type (TREE_TYPE (type), 0, 0);
1589 dbxout_args (TYPE_ARG_TYPES (type));
1590 putc (';', asmfile);
1591 CHARS (1);
1594 else
1596 /* Treat it as a function type. */
1597 dbxout_type (TREE_TYPE (type), 0, 0);
1599 break;
1601 case OFFSET_TYPE:
1602 if (use_gnu_debug_info_extensions)
1604 have_used_extensions = 1;
1605 putc ('@', asmfile);
1606 CHARS (1);
1607 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1608 putc (',', asmfile);
1609 CHARS (1);
1610 dbxout_type (TREE_TYPE (type), 0, 0);
1612 else
1614 /* Should print as an int, because it is really
1615 just an offset. */
1616 dbxout_type (integer_type_node, 0, 0);
1618 break;
1620 case REFERENCE_TYPE:
1621 if (use_gnu_debug_info_extensions)
1622 have_used_extensions = 1;
1623 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1624 CHARS (1);
1625 dbxout_type (TREE_TYPE (type), 0, 0);
1626 break;
1628 case FUNCTION_TYPE:
1629 putc ('f', asmfile);
1630 CHARS (1);
1631 dbxout_type (TREE_TYPE (type), 0, 0);
1632 break;
1634 default:
1635 abort ();
1639 /* Print the value of integer constant C, in octal,
1640 handling double precision. */
1642 static void
1643 print_int_cst_octal (c)
1644 tree c;
1646 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1647 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1648 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1649 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1651 /* GDB wants constants with no extra leading "1" bits, so
1652 we need to remove any sign-extension that might be
1653 present. */
1654 if (width == HOST_BITS_PER_WIDE_INT * 2)
1656 else if (width > HOST_BITS_PER_WIDE_INT)
1657 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1658 else if (width == HOST_BITS_PER_WIDE_INT)
1659 high = 0;
1660 else
1661 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1663 fprintf (asmfile, "0");
1665 if (excess == 3)
1667 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1668 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1670 else
1672 unsigned HOST_WIDE_INT beg = high >> excess;
1673 unsigned HOST_WIDE_INT middle
1674 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1675 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1676 unsigned HOST_WIDE_INT end
1677 = low & (((unsigned HOST_WIDE_INT) 1
1678 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1679 - 1);
1681 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1682 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1686 static void
1687 print_octal (value, digits)
1688 unsigned HOST_WIDE_INT value;
1689 int digits;
1691 int i;
1693 for (i = digits - 1; i >= 0; i--)
1694 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1697 /* Output the name of type TYPE, with no punctuation.
1698 Such names can be set up either by typedef declarations
1699 or by struct, enum and union tags. */
1701 static void
1702 dbxout_type_name (type)
1703 register tree type;
1705 tree t;
1706 if (TYPE_NAME (type) == 0)
1707 abort ();
1708 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1710 t = TYPE_NAME (type);
1712 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1714 t = DECL_NAME (TYPE_NAME (type));
1716 else
1717 abort ();
1719 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1720 CHARS (IDENTIFIER_LENGTH (t));
1723 /* Output a .stabs for the symbol defined by DECL,
1724 which must be a ..._DECL node in the normal namespace.
1725 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1726 LOCAL is nonzero if the scope is less than the entire file.
1727 Return 1 if a stabs might have been emitted. */
1730 dbxout_symbol (decl, local)
1731 tree decl;
1732 int local ATTRIBUTE_UNUSED;
1734 tree type = TREE_TYPE (decl);
1735 tree context = NULL_TREE;
1736 int result = 0;
1738 /* Cast avoids warning in old compilers. */
1739 current_sym_code = (STAB_CODE_TYPE) 0;
1740 current_sym_value = 0;
1741 current_sym_addr = 0;
1743 /* Ignore nameless syms, but don't ignore type tags. */
1745 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1746 || DECL_IGNORED_P (decl))
1747 return 0;
1749 dbxout_prepare_symbol (decl);
1751 /* The output will always start with the symbol name,
1752 so always count that in the length-output-so-far. */
1754 if (DECL_NAME (decl) != 0)
1755 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1757 switch (TREE_CODE (decl))
1759 case CONST_DECL:
1760 /* Enum values are defined by defining the enum type. */
1761 break;
1763 case FUNCTION_DECL:
1764 if (DECL_RTL (decl) == 0)
1765 return 0;
1766 if (DECL_EXTERNAL (decl))
1767 break;
1768 /* Don't mention a nested function under its parent. */
1769 context = decl_function_context (decl);
1770 if (context == current_function_decl)
1771 break;
1772 if (GET_CODE (DECL_RTL (decl)) != MEM
1773 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1774 break;
1775 FORCE_TEXT;
1777 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
1778 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1779 TREE_PUBLIC (decl) ? 'F' : 'f');
1780 result = 1;
1782 current_sym_code = N_FUN;
1783 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1785 if (TREE_TYPE (type))
1786 dbxout_type (TREE_TYPE (type), 0, 0);
1787 else
1788 dbxout_type (void_type_node, 0, 0);
1790 /* For a nested function, when that function is compiled,
1791 mention the containing function name
1792 as well as (since dbx wants it) our own assembler-name. */
1793 if (context != 0)
1794 fprintf (asmfile, ",%s,%s",
1795 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1796 IDENTIFIER_POINTER (DECL_NAME (context)));
1798 dbxout_finish_symbol (decl);
1799 break;
1801 case TYPE_DECL:
1802 #if 0
1803 /* This seems all wrong. Outputting most kinds of types gives no name
1804 at all. A true definition gives no name; a cross-ref for a
1805 structure can give the tag name, but not a type name.
1806 It seems that no typedef name is defined by outputting a type. */
1808 /* If this typedef name was defined by outputting the type,
1809 don't duplicate it. */
1810 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1811 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1812 return 0;
1813 #endif
1814 /* Don't output the same typedef twice.
1815 And don't output what language-specific stuff doesn't want output. */
1816 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1817 return 0;
1819 FORCE_TEXT;
1820 result = 1;
1822 int tag_needed = 1;
1823 int did_output = 0;
1825 if (DECL_NAME (decl))
1827 /* Nonzero means we must output a tag as well as a typedef. */
1828 tag_needed = 0;
1830 /* Handle the case of a C++ structure or union
1831 where the TYPE_NAME is a TYPE_DECL
1832 which gives both a typedef name and a tag. */
1833 /* dbx requires the tag first and the typedef second. */
1834 if ((TREE_CODE (type) == RECORD_TYPE
1835 || TREE_CODE (type) == UNION_TYPE
1836 || TREE_CODE (type) == QUAL_UNION_TYPE)
1837 && TYPE_NAME (type) == decl
1838 && !(use_gnu_debug_info_extensions && have_used_extensions)
1839 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1840 /* Distinguish the implicit typedefs of C++
1841 from explicit ones that might be found in C. */
1842 && DECL_ARTIFICIAL (decl))
1844 tree name = TYPE_NAME (type);
1845 if (TREE_CODE (name) == TYPE_DECL)
1846 name = DECL_NAME (name);
1848 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1849 current_sym_value = 0;
1850 current_sym_addr = 0;
1851 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1853 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
1854 IDENTIFIER_POINTER (name));
1855 dbxout_type (type, 1, 0);
1856 dbxout_finish_symbol (NULL_TREE);
1859 /* Output typedef name. */
1860 fprintf (asmfile, "%s\"%s:", ASM_STABS_OP,
1861 IDENTIFIER_POINTER (DECL_NAME (decl)));
1863 /* Short cut way to output a tag also. */
1864 if ((TREE_CODE (type) == RECORD_TYPE
1865 || TREE_CODE (type) == UNION_TYPE
1866 || TREE_CODE (type) == QUAL_UNION_TYPE)
1867 && TYPE_NAME (type) == decl
1868 /* Distinguish the implicit typedefs of C++
1869 from explicit ones that might be found in C. */
1870 && DECL_ARTIFICIAL (decl))
1872 if (use_gnu_debug_info_extensions && have_used_extensions)
1874 putc ('T', asmfile);
1875 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1877 #if 0 /* Now we generate the tag for this case up above. */
1878 else
1879 tag_needed = 1;
1880 #endif
1883 putc ('t', asmfile);
1884 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1886 dbxout_type (type, 1, 0);
1887 dbxout_finish_symbol (decl);
1888 did_output = 1;
1891 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1892 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1894 if (tag_needed && TYPE_NAME (type) != 0
1895 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1896 || (DECL_NAME (TYPE_NAME (type)) != 0))
1897 && COMPLETE_TYPE_P (type)
1898 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1900 /* For a TYPE_DECL with no name, but the type has a name,
1901 output a tag.
1902 This is what represents `struct foo' with no typedef. */
1903 /* In C++, the name of a type is the corresponding typedef.
1904 In C, it is an IDENTIFIER_NODE. */
1905 tree name = TYPE_NAME (type);
1906 if (TREE_CODE (name) == TYPE_DECL)
1907 name = DECL_NAME (name);
1909 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1910 current_sym_value = 0;
1911 current_sym_addr = 0;
1912 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1914 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
1915 IDENTIFIER_POINTER (name));
1916 dbxout_type (type, 1, 0);
1917 dbxout_finish_symbol (NULL_TREE);
1918 did_output = 1;
1921 /* If an enum type has no name, it cannot be referred to,
1922 but we must output it anyway, since the enumeration constants
1923 can be referred to. */
1924 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1926 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1927 current_sym_value = 0;
1928 current_sym_addr = 0;
1929 current_sym_nchars = 2;
1931 /* Some debuggers fail when given NULL names, so give this a
1932 harmless name of ` '. */
1933 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
1934 dbxout_type (type, 1, 0);
1935 dbxout_finish_symbol (NULL_TREE);
1938 /* Prevent duplicate output of a typedef. */
1939 TREE_ASM_WRITTEN (decl) = 1;
1940 break;
1943 case PARM_DECL:
1944 /* Parm decls go in their own separate chains
1945 and are output by dbxout_reg_parms and dbxout_parms. */
1946 abort ();
1948 case RESULT_DECL:
1949 /* Named return value, treat like a VAR_DECL. */
1950 case VAR_DECL:
1951 if (! DECL_RTL_SET_P (decl))
1952 return 0;
1953 /* Don't mention a variable that is external.
1954 Let the file that defines it describe it. */
1955 if (DECL_EXTERNAL (decl))
1956 break;
1958 /* If the variable is really a constant
1959 and not written in memory, inform the debugger. */
1960 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1961 && DECL_INITIAL (decl) != 0
1962 && host_integerp (DECL_INITIAL (decl), 0)
1963 && ! TREE_ASM_WRITTEN (decl)
1964 && (DECL_CONTEXT (decl) == NULL_TREE
1965 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
1967 if (TREE_PUBLIC (decl) == 0)
1969 /* The sun4 assembler does not grok this. */
1970 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1972 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1973 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1975 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
1976 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1977 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1978 #else
1979 fprintf (asmfile, "%s\"%s:c=i", ASM_STABS_OP, name);
1981 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
1982 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
1983 #endif
1984 return 1;
1986 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1988 /* don't know how to do this yet. */
1990 break;
1992 /* else it is something we handle like a normal variable. */
1995 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
1996 #ifdef LEAF_REG_REMAP
1997 if (current_function_uses_only_leaf_regs)
1998 leaf_renumber_regs_insn (DECL_RTL (decl));
1999 #endif
2001 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2002 break;
2004 default:
2005 break;
2007 return result;
2010 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2011 Add SUFFIX to its name, if SUFFIX is not 0.
2012 Describe the variable as residing in HOME
2013 (usually HOME is DECL_RTL (DECL), but not always).
2014 Returns 1 if the stab was really emitted. */
2016 static int
2017 dbxout_symbol_location (decl, type, suffix, home)
2018 tree decl, type;
2019 const char *suffix;
2020 rtx home;
2022 int letter = 0;
2023 int regno = -1;
2025 /* Don't mention a variable at all
2026 if it was completely optimized into nothingness.
2028 If the decl was from an inline function, then its rtl
2029 is not identically the rtl that was used in this
2030 particular compilation. */
2031 if (GET_CODE (home) == REG)
2033 regno = REGNO (home);
2034 if (regno >= FIRST_PSEUDO_REGISTER)
2035 return 0;
2037 else if (GET_CODE (home) == SUBREG)
2039 rtx value = home;
2040 int offset = 0;
2041 while (GET_CODE (value) == SUBREG)
2043 offset += SUBREG_WORD (value);
2044 value = SUBREG_REG (value);
2046 if (GET_CODE (value) == REG)
2048 regno = REGNO (value);
2049 if (regno >= FIRST_PSEUDO_REGISTER)
2050 return 0;
2051 regno += offset;
2053 alter_subreg (home);
2056 /* The kind-of-variable letter depends on where
2057 the variable is and on the scope of its name:
2058 G and N_GSYM for static storage and global scope,
2059 S for static storage and file scope,
2060 V for static storage and local scope,
2061 for those two, use N_LCSYM if data is in bss segment,
2062 N_STSYM if in data segment, N_FUN otherwise.
2063 (We used N_FUN originally, then changed to N_STSYM
2064 to please GDB. However, it seems that confused ld.
2065 Now GDB has been fixed to like N_FUN, says Kingdon.)
2066 no letter at all, and N_LSYM, for auto variable,
2067 r and N_RSYM for register variable. */
2069 if (GET_CODE (home) == MEM
2070 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2072 if (TREE_PUBLIC (decl))
2074 letter = 'G';
2075 current_sym_code = N_GSYM;
2077 else
2079 current_sym_addr = XEXP (home, 0);
2081 letter = decl_function_context (decl) ? 'V' : 'S';
2083 /* This should be the same condition as in assemble_variable, but
2084 we don't have access to dont_output_data here. So, instead,
2085 we rely on the fact that error_mark_node initializers always
2086 end up in bss for C++ and never end up in bss for C. */
2087 if (DECL_INITIAL (decl) == 0
2088 || (!strcmp (lang_identify (), "cplusplus")
2089 && DECL_INITIAL (decl) == error_mark_node))
2090 current_sym_code = N_LCSYM;
2091 else if (DECL_IN_TEXT_SECTION (decl))
2092 /* This is not quite right, but it's the closest
2093 of all the codes that Unix defines. */
2094 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2095 else
2097 /* Ultrix `as' seems to need this. */
2098 #ifdef DBX_STATIC_STAB_DATA_SECTION
2099 data_section ();
2100 #endif
2101 current_sym_code = N_STSYM;
2105 else if (regno >= 0)
2107 letter = 'r';
2108 current_sym_code = N_RSYM;
2109 current_sym_value = DBX_REGISTER_NUMBER (regno);
2111 else if (GET_CODE (home) == MEM
2112 && (GET_CODE (XEXP (home, 0)) == MEM
2113 || (GET_CODE (XEXP (home, 0)) == REG
2114 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2115 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2116 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2117 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2118 #endif
2120 /* If the value is indirect by memory or by a register
2121 that isn't the frame pointer
2122 then it means the object is variable-sized and address through
2123 that register or stack slot. DBX has no way to represent this
2124 so all we can do is output the variable as a pointer.
2125 If it's not a parameter, ignore it.
2126 (VAR_DECLs like this can be made by integrate.c.) */
2128 if (GET_CODE (XEXP (home, 0)) == REG)
2130 letter = 'r';
2131 current_sym_code = N_RSYM;
2132 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2134 else
2136 current_sym_code = N_LSYM;
2137 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2138 We want the value of that CONST_INT. */
2139 current_sym_value
2140 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2143 /* Effectively do build_pointer_type, but don't cache this type,
2144 since it might be temporary whereas the type it points to
2145 might have been saved for inlining. */
2146 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2147 type = make_node (POINTER_TYPE);
2148 TREE_TYPE (type) = TREE_TYPE (decl);
2150 else if (GET_CODE (home) == MEM
2151 && GET_CODE (XEXP (home, 0)) == REG)
2153 current_sym_code = N_LSYM;
2154 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2156 else if (GET_CODE (home) == MEM
2157 && GET_CODE (XEXP (home, 0)) == PLUS
2158 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2160 current_sym_code = N_LSYM;
2161 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2162 We want the value of that CONST_INT. */
2163 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2165 else if (GET_CODE (home) == MEM
2166 && GET_CODE (XEXP (home, 0)) == CONST)
2168 /* Handle an obscure case which can arise when optimizing and
2169 when there are few available registers. (This is *always*
2170 the case for i386/i486 targets). The RTL looks like
2171 (MEM (CONST ...)) even though this variable is a local `auto'
2172 or a local `register' variable. In effect, what has happened
2173 is that the reload pass has seen that all assignments and
2174 references for one such a local variable can be replaced by
2175 equivalent assignments and references to some static storage
2176 variable, thereby avoiding the need for a register. In such
2177 cases we're forced to lie to debuggers and tell them that
2178 this variable was itself `static'. */
2179 current_sym_code = N_LCSYM;
2180 letter = 'V';
2181 current_sym_addr = XEXP (XEXP (home, 0), 0);
2183 else if (GET_CODE (home) == CONCAT)
2185 tree subtype;
2187 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2188 for example), then there is no easy way to figure out
2189 what SUBTYPE should be. So, we give up. */
2190 if (TREE_CODE (type) != COMPLEX_TYPE)
2191 return 0;
2193 subtype = TREE_TYPE (type);
2195 /* If the variable's storage is in two parts,
2196 output each as a separate stab with a modified name. */
2197 if (WORDS_BIG_ENDIAN)
2198 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2199 else
2200 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2202 /* Cast avoids warning in old compilers. */
2203 current_sym_code = (STAB_CODE_TYPE) 0;
2204 current_sym_value = 0;
2205 current_sym_addr = 0;
2206 dbxout_prepare_symbol (decl);
2208 if (WORDS_BIG_ENDIAN)
2209 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2210 else
2211 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2212 return 1;
2214 else
2215 /* Address might be a MEM, when DECL is a variable-sized object.
2216 Or it might be const0_rtx, meaning previous passes
2217 want us to ignore this variable. */
2218 return 0;
2220 /* Ok, start a symtab entry and output the variable name. */
2221 FORCE_TEXT;
2223 #ifdef DBX_STATIC_BLOCK_START
2224 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2225 #endif
2227 dbxout_symbol_name (decl, suffix, letter);
2228 dbxout_type (type, 0, 0);
2229 dbxout_finish_symbol (decl);
2231 #ifdef DBX_STATIC_BLOCK_END
2232 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2233 #endif
2234 return 1;
2237 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2238 Then output LETTER to indicate the kind of location the symbol has. */
2240 static void
2241 dbxout_symbol_name (decl, suffix, letter)
2242 tree decl;
2243 const char *suffix;
2244 int letter;
2246 const char *name;
2248 if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2249 /* One slight hitch: if this is a VAR_DECL which is a static
2250 class member, we must put out the mangled name instead of the
2251 DECL_NAME. Note also that static member (variable) names DO NOT begin
2252 with underscores in .stabs directives. */
2253 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2254 else
2255 /* ...but if we're function-local, we don't want to include the junk
2256 added by ASM_FORMAT_PRIVATE_NAME. */
2257 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2259 if (name == 0)
2260 name = "(anon)";
2261 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2262 (suffix ? suffix : ""));
2264 if (letter) putc (letter, asmfile);
2267 static void
2268 dbxout_prepare_symbol (decl)
2269 tree decl ATTRIBUTE_UNUSED;
2271 #ifdef WINNING_GDB
2272 const char *filename = DECL_SOURCE_FILE (decl);
2274 dbxout_source_file (asmfile, filename);
2275 #endif
2278 static void
2279 dbxout_finish_symbol (sym)
2280 tree sym;
2282 #ifdef DBX_FINISH_SYMBOL
2283 DBX_FINISH_SYMBOL (sym);
2284 #else
2285 int line = 0;
2286 if (use_gnu_debug_info_extensions && sym != 0)
2287 line = DECL_SOURCE_LINE (sym);
2289 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2290 if (current_sym_addr)
2291 output_addr_const (asmfile, current_sym_addr);
2292 else
2293 fprintf (asmfile, "%d", current_sym_value);
2294 putc ('\n', asmfile);
2295 #endif
2298 /* Output definitions of all the decls in a chain. Return non-zero if
2299 anything was output */
2302 dbxout_syms (syms)
2303 tree syms;
2305 int result = 0;
2306 while (syms)
2308 result += dbxout_symbol (syms, 1);
2309 syms = TREE_CHAIN (syms);
2311 return result;
2314 /* The following two functions output definitions of function parameters.
2315 Each parameter gets a definition locating it in the parameter list.
2316 Each parameter that is a register variable gets a second definition
2317 locating it in the register.
2319 Printing or argument lists in gdb uses the definitions that
2320 locate in the parameter list. But reference to the variable in
2321 expressions uses preferentially the definition as a register. */
2323 /* Output definitions, referring to storage in the parmlist,
2324 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2326 void
2327 dbxout_parms (parms)
2328 tree parms;
2330 for (; parms; parms = TREE_CHAIN (parms))
2331 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2333 dbxout_prepare_symbol (parms);
2335 /* Perform any necessary register eliminations on the parameter's rtl,
2336 so that the debugging output will be accurate. */
2337 DECL_INCOMING_RTL (parms)
2338 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2339 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2340 #ifdef LEAF_REG_REMAP
2341 if (current_function_uses_only_leaf_regs)
2343 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2344 leaf_renumber_regs_insn (DECL_RTL (parms));
2346 #endif
2348 if (PARM_PASSED_IN_MEMORY (parms))
2350 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2352 /* ??? Here we assume that the parm address is indexed
2353 off the frame pointer or arg pointer.
2354 If that is not true, we produce meaningless results,
2355 but do not crash. */
2356 if (GET_CODE (addr) == PLUS
2357 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2358 current_sym_value = INTVAL (XEXP (addr, 1));
2359 else
2360 current_sym_value = 0;
2362 current_sym_code = N_PSYM;
2363 current_sym_addr = 0;
2365 FORCE_TEXT;
2366 if (DECL_NAME (parms))
2368 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2370 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2371 IDENTIFIER_POINTER (DECL_NAME (parms)),
2372 DBX_MEMPARM_STABS_LETTER);
2374 else
2376 current_sym_nchars = 8;
2377 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2378 DBX_MEMPARM_STABS_LETTER);
2381 /* It is quite tempting to use:
2383 dbxout_type (TREE_TYPE (parms), 0, 0);
2385 as the next statement, rather than using DECL_ARG_TYPE(), so
2386 that gcc reports the actual type of the parameter, rather
2387 than the promoted type. This certainly makes GDB's life
2388 easier, at least for some ports. The change is a bad idea
2389 however, since GDB expects to be able access the type without
2390 performing any conversions. So for example, if we were
2391 passing a float to an unprototyped function, gcc will store a
2392 double on the stack, but if we emit a stab saying the type is a
2393 float, then gdb will only read in a single value, and this will
2394 produce an erropneous value. */
2395 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2396 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2397 dbxout_finish_symbol (parms);
2399 else if (GET_CODE (DECL_RTL (parms)) == REG)
2401 rtx best_rtl;
2402 char regparm_letter;
2403 tree parm_type;
2404 /* Parm passed in registers and lives in registers or nowhere. */
2406 current_sym_code = DBX_REGPARM_STABS_CODE;
2407 regparm_letter = DBX_REGPARM_STABS_LETTER;
2408 current_sym_addr = 0;
2410 /* If parm lives in a register, use that register;
2411 pretend the parm was passed there. It would be more consistent
2412 to describe the register where the parm was passed,
2413 but in practice that register usually holds something else.
2415 If we use DECL_RTL, then we must use the declared type of
2416 the variable, not the type that it arrived in. */
2417 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2419 best_rtl = DECL_RTL (parms);
2420 parm_type = TREE_TYPE (parms);
2422 /* If the parm lives nowhere, use the register where it was
2423 passed. It is also better to use the declared type here. */
2424 else
2426 best_rtl = DECL_INCOMING_RTL (parms);
2427 parm_type = TREE_TYPE (parms);
2429 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2431 FORCE_TEXT;
2432 if (DECL_NAME (parms))
2434 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2435 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2436 IDENTIFIER_POINTER (DECL_NAME (parms)),
2437 regparm_letter);
2439 else
2441 current_sym_nchars = 8;
2442 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2443 regparm_letter);
2446 dbxout_type (parm_type, 0, 0);
2447 dbxout_finish_symbol (parms);
2449 else if (GET_CODE (DECL_RTL (parms)) == MEM
2450 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2451 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2452 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2453 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2454 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2455 #endif
2458 /* Parm was passed via invisible reference.
2459 That is, its address was passed in a register.
2460 Output it as if it lived in that register.
2461 The debugger will know from the type
2462 that it was actually passed by invisible reference. */
2464 char regparm_letter;
2465 /* Parm passed in registers and lives in registers or nowhere. */
2467 current_sym_code = DBX_REGPARM_STABS_CODE;
2468 if (use_gnu_debug_info_extensions)
2469 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2470 else
2471 regparm_letter = DBX_REGPARM_STABS_LETTER;
2473 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2474 If it is an unallocated pseudo-reg, then use the register where
2475 it was passed instead. */
2476 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2477 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2478 else
2479 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2481 current_sym_addr = 0;
2483 FORCE_TEXT;
2484 if (DECL_NAME (parms))
2486 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2488 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2489 IDENTIFIER_POINTER (DECL_NAME (parms)),
2490 regparm_letter);
2492 else
2494 current_sym_nchars = 8;
2495 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2496 regparm_letter);
2499 dbxout_type (TREE_TYPE (parms), 0, 0);
2500 dbxout_finish_symbol (parms);
2502 else if (GET_CODE (DECL_RTL (parms)) == MEM
2503 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2505 /* Parm was passed via invisible reference, with the reference
2506 living on the stack. DECL_RTL looks like
2507 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2508 could look like (MEM (MEM (REG))). */
2509 const char *decl_name = (DECL_NAME (parms)
2510 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2511 : "(anon)");
2512 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2513 current_sym_value = 0;
2514 else
2515 current_sym_value
2516 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2517 current_sym_addr = 0;
2519 FORCE_TEXT;
2520 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2521 dbxout_type (TREE_TYPE (parms), 0, 0);
2522 dbxout_finish_symbol (parms);
2524 else if (GET_CODE (DECL_RTL (parms)) == MEM
2525 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2526 /* ??? A constant address for a parm can happen
2527 when the reg it lives in is equiv to a constant in memory.
2528 Should make this not happen, after 2.4. */
2529 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2531 /* Parm was passed in registers but lives on the stack. */
2533 current_sym_code = N_PSYM;
2534 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2535 in which case we want the value of that CONST_INT,
2536 or (MEM (REG ...)),
2537 in which case we use a value of zero. */
2538 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2539 current_sym_value = 0;
2540 else
2541 current_sym_value
2542 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2544 current_sym_addr = 0;
2546 /* Make a big endian correction if the mode of the type of the
2547 parameter is not the same as the mode of the rtl. */
2548 if (BYTES_BIG_ENDIAN
2549 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2550 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2552 current_sym_value +=
2553 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2554 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2557 FORCE_TEXT;
2558 if (DECL_NAME (parms))
2560 current_sym_nchars
2561 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2563 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2564 IDENTIFIER_POINTER (DECL_NAME (parms)),
2565 DBX_MEMPARM_STABS_LETTER);
2567 else
2569 current_sym_nchars = 8;
2570 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2571 DBX_MEMPARM_STABS_LETTER);
2574 current_sym_value
2575 = DEBUGGER_ARG_OFFSET (current_sym_value,
2576 XEXP (DECL_RTL (parms), 0));
2577 dbxout_type (TREE_TYPE (parms), 0, 0);
2578 dbxout_finish_symbol (parms);
2583 /* Output definitions for the places where parms live during the function,
2584 when different from where they were passed, when the parms were passed
2585 in memory.
2587 It is not useful to do this for parms passed in registers
2588 that live during the function in different registers, because it is
2589 impossible to look in the passed register for the passed value,
2590 so we use the within-the-function register to begin with.
2592 PARMS is a chain of PARM_DECL nodes. */
2594 void
2595 dbxout_reg_parms (parms)
2596 tree parms;
2598 for (; parms; parms = TREE_CHAIN (parms))
2599 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2601 dbxout_prepare_symbol (parms);
2603 /* Report parms that live in registers during the function
2604 but were passed in memory. */
2605 if (GET_CODE (DECL_RTL (parms)) == REG
2606 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2607 dbxout_symbol_location (parms, TREE_TYPE (parms),
2608 0, DECL_RTL (parms));
2609 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2610 dbxout_symbol_location (parms, TREE_TYPE (parms),
2611 0, DECL_RTL (parms));
2612 /* Report parms that live in memory but not where they were passed. */
2613 else if (GET_CODE (DECL_RTL (parms)) == MEM
2614 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2615 dbxout_symbol_location (parms, TREE_TYPE (parms),
2616 0, DECL_RTL (parms));
2620 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2621 output definitions of those names, in raw form */
2623 void
2624 dbxout_args (args)
2625 tree args;
2627 while (args)
2629 putc (',', asmfile);
2630 dbxout_type (TREE_VALUE (args), 0, 0);
2631 CHARS (1);
2632 args = TREE_CHAIN (args);
2636 /* Given a chain of ..._TYPE nodes,
2637 find those which have typedef names and output those names.
2638 This is to ensure those types get output. */
2640 void
2641 dbxout_types (types)
2642 register tree types;
2644 while (types)
2646 if (TYPE_NAME (types)
2647 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2648 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2649 dbxout_symbol (TYPE_NAME (types), 1);
2650 types = TREE_CHAIN (types);
2654 /* Output everything about a symbol block (a BLOCK node
2655 that represents a scope level),
2656 including recursive output of contained blocks.
2658 BLOCK is the BLOCK node.
2659 DEPTH is its depth within containing symbol blocks.
2660 ARGS is usually zero; but for the outermost block of the
2661 body of a function, it is a chain of PARM_DECLs for the function parameters.
2662 We output definitions of all the register parms
2663 as if they were local variables of that block.
2665 If -g1 was used, we count blocks just the same, but output nothing
2666 except for the outermost block.
2668 Actually, BLOCK may be several blocks chained together.
2669 We handle them all in sequence. */
2671 static void
2672 dbxout_block (block, depth, args)
2673 register tree block;
2674 int depth;
2675 tree args;
2677 int blocknum = -1;
2679 #if DBX_BLOCKS_FUNCTION_RELATIVE
2680 const char *begin_label;
2681 if (current_function_func_begin_label != NULL_TREE)
2682 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
2683 else
2684 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
2685 #endif
2687 while (block)
2689 /* Ignore blocks never expanded or otherwise marked as real. */
2690 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
2692 int did_output;
2694 #ifdef DBX_LBRAC_FIRST
2695 did_output = 1;
2696 #else
2697 /* In dbx format, the syms of a block come before the N_LBRAC.
2698 If nothing is output, we don't need the N_LBRAC, either. */
2699 did_output = 0;
2700 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2701 did_output = dbxout_syms (BLOCK_VARS (block));
2702 if (args)
2703 dbxout_reg_parms (args);
2704 #endif
2706 /* Now output an N_LBRAC symbol to represent the beginning of
2707 the block. Use the block's tree-walk order to generate
2708 the assembler symbols LBBn and LBEn
2709 that final will define around the code in this block. */
2710 if (depth > 0 && did_output)
2712 char buf[20];
2713 blocknum = BLOCK_NUMBER (block);
2714 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2716 if (BLOCK_HANDLER_BLOCK (block))
2718 /* A catch block. Must precede N_LBRAC. */
2719 tree decl = BLOCK_VARS (block);
2720 while (decl)
2722 #ifdef DBX_OUTPUT_CATCH
2723 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2724 #else
2725 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
2726 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2727 assemble_name (asmfile, buf);
2728 fprintf (asmfile, "\n");
2729 #endif
2730 decl = TREE_CHAIN (decl);
2734 #ifdef DBX_OUTPUT_LBRAC
2735 DBX_OUTPUT_LBRAC (asmfile, buf);
2736 #else
2737 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
2738 assemble_name (asmfile, buf);
2739 #if DBX_BLOCKS_FUNCTION_RELATIVE
2740 fputc ('-', asmfile);
2741 assemble_name (asmfile, begin_label);
2742 #endif
2743 fprintf (asmfile, "\n");
2744 #endif
2747 #ifdef DBX_LBRAC_FIRST
2748 /* On some weird machines, the syms of a block
2749 come after the N_LBRAC. */
2750 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2751 dbxout_syms (BLOCK_VARS (block));
2752 if (args)
2753 dbxout_reg_parms (args);
2754 #endif
2756 /* Output the subblocks. */
2757 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2759 /* Refer to the marker for the end of the block. */
2760 if (depth > 0 && did_output)
2762 char buf[20];
2763 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2764 #ifdef DBX_OUTPUT_RBRAC
2765 DBX_OUTPUT_RBRAC (asmfile, buf);
2766 #else
2767 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
2768 assemble_name (asmfile, buf);
2769 #if DBX_BLOCKS_FUNCTION_RELATIVE
2770 fputc ('-', asmfile);
2771 assemble_name (asmfile, begin_label);
2772 #endif
2773 fprintf (asmfile, "\n");
2774 #endif
2777 block = BLOCK_CHAIN (block);
2781 /* Output the information about a function and its arguments and result.
2782 Usually this follows the function's code,
2783 but on some systems, it comes before. */
2785 static void
2786 dbxout_really_begin_function (decl)
2787 tree decl;
2789 dbxout_symbol (decl, 0);
2790 dbxout_parms (DECL_ARGUMENTS (decl));
2791 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2792 dbxout_symbol (DECL_RESULT (decl), 1);
2795 /* Called at beginning of output of function definition. */
2797 void
2798 dbxout_begin_function (decl)
2799 tree decl ATTRIBUTE_UNUSED;
2801 #ifdef DBX_FUNCTION_FIRST
2802 dbxout_really_begin_function (decl);
2803 #endif
2806 /* Output dbx data for a function definition.
2807 This includes a definition of the function name itself (a symbol),
2808 definitions of the parameters (locating them in the parameter list)
2809 and then output the block that makes up the function's body
2810 (including all the auto variables of the function). */
2812 void
2813 dbxout_function (decl)
2814 tree decl;
2816 #ifndef DBX_FUNCTION_FIRST
2817 dbxout_really_begin_function (decl);
2818 #endif
2819 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2820 #ifdef DBX_OUTPUT_FUNCTION_END
2821 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2822 #endif
2823 #if defined(ASM_OUTPUT_SECTION_NAME)
2824 if (use_gnu_debug_info_extensions
2825 #if defined(NO_DBX_FUNCTION_END)
2826 && ! NO_DBX_FUNCTION_END
2827 #endif
2829 dbxout_function_end ();
2830 #endif
2832 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */