allow all arm targets to use -mstructure-size-boundary=XX
[official-gcc.git] / gcc / dbxout.c
blobaf77dcaf9fc3463bfde6ba2620ceab6fc6438f15
1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* Output dbx-format symbol table data.
23 This consists of many symbol table entries, each of them
24 a .stabs assembler pseudo-op with four operands:
25 a "name" which is really a description of one symbol and its type,
26 a "code", which is a symbol defined in stab.h whose name starts with N_,
27 an unused operand always 0,
28 and a "value" which is an address or an offset.
29 The name is enclosed in doublequote characters.
31 Each function, variable, typedef, and structure tag
32 has a symbol table entry to define it.
33 The beginning and end of each level of name scoping within
34 a function are also marked by special symbol table entries.
36 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
37 and a data type number. The data type number may be followed by
38 "=" and a type definition; normally this will happen the first time
39 the type number is mentioned. The type definition may refer to
40 other types by number, and those type numbers may be followed
41 by "=" and nested definitions.
43 This can make the "name" quite long.
44 When a name is more than 80 characters, we split the .stabs pseudo-op
45 into two .stabs pseudo-ops, both sharing the same "code" and "value".
46 The first one is marked as continued with a double-backslash at the
47 end of its "name".
49 The kind-of-symbol letter distinguished function names from global
50 variables from file-scope variables from parameters from auto
51 variables in memory from typedef names from register variables.
52 See `dbxout_symbol'.
54 The "code" is mostly redundant with the kind-of-symbol letter
55 that goes in the "name", but not entirely: for symbols located
56 in static storage, the "code" says which segment the address is in,
57 which controls how it is relocated.
59 The "value" for a symbol in static storage
60 is the core address of the symbol (actually, the assembler
61 label for the symbol). For a symbol located in a stack slot
62 it is the stack offset; for one in a register, the register number.
63 For a typedef symbol, it is zero.
65 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
66 output while in the text section.
68 For more on data type definitions, see `dbxout_type'. */
70 #include "config.h"
71 #include "system.h"
73 #include "tree.h"
74 #include "rtl.h"
75 #include "flags.h"
76 #include "regs.h"
77 #include "insn-config.h"
78 #include "reload.h"
79 #include "defaults.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"
85 #ifdef XCOFF_DEBUGGING_INFO
86 #include "xcoffout.h"
87 #endif
89 #ifndef ASM_STABS_OP
90 #define ASM_STABS_OP ".stabs"
91 #endif
93 #ifndef ASM_STABN_OP
94 #define ASM_STABN_OP ".stabn"
95 #endif
97 #ifndef DBX_TYPE_DECL_STABS_CODE
98 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
99 #endif
101 #ifndef DBX_STATIC_CONST_VAR_CODE
102 #define DBX_STATIC_CONST_VAR_CODE N_FUN
103 #endif
105 #ifndef DBX_REGPARM_STABS_CODE
106 #define DBX_REGPARM_STABS_CODE N_RSYM
107 #endif
109 #ifndef DBX_REGPARM_STABS_LETTER
110 #define DBX_REGPARM_STABS_LETTER 'P'
111 #endif
113 /* This is used for parameters passed by invisible reference in a register. */
114 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
115 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
116 #endif
118 #ifndef DBX_MEMPARM_STABS_LETTER
119 #define DBX_MEMPARM_STABS_LETTER 'p'
120 #endif
122 #ifndef FILE_NAME_JOINER
123 #define FILE_NAME_JOINER "/"
124 #endif
126 /* Nonzero means if the type has methods, only output debugging
127 information if methods are actually written to the asm file. This
128 optimization only works if the debugger can detect the special C++
129 marker. */
131 #define MINIMAL_DEBUG 1
133 #ifdef NO_DOLLAR_IN_LABEL
134 #ifdef NO_DOT_IN_LABEL
135 #undef MINIMAL_DEBUG
136 #define MINIMAL_DEBUG 0
137 #endif
138 #endif
140 /* Typical USG systems don't have stab.h, and they also have
141 no use for DBX-format debugging info. */
143 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
145 static int flag_minimal_debug = MINIMAL_DEBUG;
147 /* Nonzero if we have actually used any of the GDB extensions
148 to the debugging format. The idea is that we use them for the
149 first time only if there's a strong reason, but once we have done that,
150 we use them whenever convenient. */
152 static int have_used_extensions = 0;
154 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
155 for the N_SO filename stabs label. */
157 static int source_label_number = 1;
159 #ifdef DEBUG_SYMS_TEXT
160 #define FORCE_TEXT text_section ();
161 #else
162 #define FORCE_TEXT
163 #endif
165 /* If there is a system stab.h, use it. Otherwise, use our own. */
166 /* ??? This is supposed to describe the target's stab format, so using
167 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
168 when cross compiling. */
169 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
170 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
171 #else
172 #include <stab.h>
174 /* This is a GNU extension we need to reference in this file. */
175 #ifndef N_CATCH
176 #define N_CATCH 0x54
177 #endif
178 #endif
180 #ifdef __GNU_STAB__
181 #define STAB_CODE_TYPE enum __stab_debug_code
182 #else
183 #define STAB_CODE_TYPE int
184 #endif
186 /* 1 if PARM is passed to this function in memory. */
188 #define PARM_PASSED_IN_MEMORY(PARM) \
189 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
191 /* A C expression for the integer offset value of an automatic variable
192 (N_LSYM) having address X (an RTX). */
193 #ifndef DEBUGGER_AUTO_OFFSET
194 #define DEBUGGER_AUTO_OFFSET(X) \
195 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
196 #endif
198 /* A C expression for the integer offset value of an argument (N_PSYM)
199 having address X (an RTX). The nominal offset is OFFSET. */
200 #ifndef DEBUGGER_ARG_OFFSET
201 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
202 #endif
204 /* Stream for writing to assembler file. */
206 static FILE *asmfile;
208 /* Last source file name mentioned in a NOTE insn. */
210 static const char *lastfile;
212 /* Current working directory. */
214 static const char *cwd;
216 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
218 /* Structure recording information about a C data type.
219 The status element says whether we have yet output
220 the definition of the type. TYPE_XREF says we have
221 output it as a cross-reference only.
222 The file_number and type_number elements are used if DBX_USE_BINCL
223 is defined. */
225 struct typeinfo
227 enum typestatus status;
228 #ifdef DBX_USE_BINCL
229 int file_number;
230 int type_number;
231 #endif
234 /* Vector recording information about C data types.
235 When we first notice a data type (a tree node),
236 we assign it a number using next_type_number.
237 That is its index in this vector. */
239 struct typeinfo *typevec;
241 /* Number of elements of space allocated in `typevec'. */
243 static int typevec_len;
245 /* In dbx output, each type gets a unique number.
246 This is the number for the next type output.
247 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
249 static int next_type_number;
251 #ifdef DBX_USE_BINCL
253 /* When using N_BINCL in dbx output, each type number is actually a
254 pair of the file number and the type number within the file.
255 This is a stack of input files. */
257 struct dbx_file
259 struct dbx_file *next;
260 int file_number;
261 int next_type_number;
264 /* This is the top of the stack. */
266 static struct dbx_file *current_file;
268 /* This is the next file number to use. */
270 static int next_file_number;
272 #endif /* DBX_USE_BINCL */
274 /* In dbx output, we must assign symbol-blocks id numbers
275 in the order in which their beginnings are encountered.
276 We output debugging info that refers to the beginning and
277 end of the ranges of code in each block
278 with assembler labels LBBn and LBEn, where n is the block number.
279 The labels are generated in final, which assigns numbers to the
280 blocks in the same way. */
282 static int next_block_number;
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
312 #endif
314 #if DBX_CONTIN_LENGTH > 0
315 #define CONTIN \
316 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
317 #else
318 #define CONTIN
319 #endif
321 #if defined(ASM_OUTPUT_SECTION_NAME)
322 static void dbxout_function_end PROTO((void));
323 #endif
324 static void dbxout_typedefs PROTO((tree));
325 static void dbxout_type_index PROTO((tree));
326 #if DBX_CONTIN_LENGTH > 0
327 static void dbxout_continue PROTO((void));
328 #endif
329 static void dbxout_type_fields PROTO((tree));
330 static void dbxout_type_method_1 PROTO((tree, const char *));
331 static void dbxout_type_methods PROTO((tree));
332 static void dbxout_range_type PROTO((tree));
333 static void dbxout_type PROTO((tree, int, int));
334 static void print_int_cst_octal PROTO((tree));
335 static void print_octal PROTO((unsigned HOST_WIDE_INT, int));
336 static void dbxout_type_name PROTO((tree));
337 static void dbxout_symbol_location PROTO((tree, tree, const char *, rtx));
338 static void dbxout_symbol_name PROTO((tree, const char *, int));
339 static void dbxout_prepare_symbol PROTO((tree));
340 static void dbxout_finish_symbol PROTO((tree));
341 static void dbxout_block PROTO((tree, int, tree));
342 static void dbxout_really_begin_function PROTO((tree));
344 #if defined(ASM_OUTPUT_SECTION_NAME)
345 static void
346 dbxout_function_end ()
348 static int scope_labelno = 0;
349 char lscope_label_name[100];
350 /* Convert Ltext into the appropriate format for local labels in case
351 the system doesn't insert underscores in front of user generated
352 labels. */
353 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
354 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
355 scope_labelno++;
357 /* By convention, GCC will mark the end of a function with an N_FUN
358 symbol and an empty string. */
359 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
360 assemble_name (asmfile, lscope_label_name);
361 fputc ('-', asmfile);
362 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
363 fprintf (asmfile, "\n");
365 #endif /* ! NO_DBX_FUNCTION_END */
367 /* At the beginning of compilation, start writing the symbol table.
368 Initialize `typevec' and output the standard data types of C. */
370 void
371 dbxout_init (asm_file, input_file_name, syms)
372 FILE *asm_file;
373 const char *input_file_name;
374 tree syms;
376 char ltext_label_name[100];
378 asmfile = asm_file;
380 typevec_len = 100;
381 typevec = (struct typeinfo *) xcalloc (typevec_len, sizeof typevec[0]);
383 /* Convert Ltext into the appropriate format for local labels in case
384 the system doesn't insert underscores in front of user generated
385 labels. */
386 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
388 /* Put the current working directory in an N_SO symbol. */
389 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
390 but GDB always does. */
391 if (use_gnu_debug_info_extensions)
392 #endif
394 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
396 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
397 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
398 cwd = wdslash;
400 if (cwd)
402 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
403 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
404 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
405 fprintf (asmfile, "%s ", ASM_STABS_OP);
406 output_quoted_string (asmfile, cwd);
407 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, &ltext_label_name[1]);
408 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
412 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
413 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
414 would give us an N_SOL, and we want an N_SO. */
415 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
416 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
417 /* We include outputting `Ltext:' here,
418 because that gives you a way to override it. */
419 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
420 fprintf (asmfile, "%s ", ASM_STABS_OP);
421 output_quoted_string (asmfile, input_file_name);
422 fprintf (asmfile, ",%d,0,0,%s\n",
423 N_SO, &ltext_label_name[1]);
424 text_section ();
425 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
426 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
428 /* Possibly output something to inform GDB that this compilation was by
429 GCC. It's easier for GDB to parse it when after the N_SO's. This
430 is used in Solaris 2. */
431 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
432 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
433 #endif
435 lastfile = input_file_name;
437 next_type_number = 1;
438 next_block_number = 2;
440 #ifdef DBX_USE_BINCL
441 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
442 current_file->next = NULL;
443 current_file->file_number = 0;
444 current_file->next_type_number = 1;
445 next_file_number = 1;
446 #endif
448 /* Make sure that types `int' and `char' have numbers 1 and 2.
449 Definitions of other integer types will refer to those numbers.
450 (Actually it should no longer matter what their numbers are.
451 Also, if any types with tags have been defined, dbxout_symbol
452 will output them first, so the numbers won't be 1 and 2. That
453 happens in C++. So it's a good thing it should no longer matter). */
455 #ifdef DBX_OUTPUT_STANDARD_TYPES
456 DBX_OUTPUT_STANDARD_TYPES (syms);
457 #else
458 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
459 dbxout_symbol (TYPE_NAME (char_type_node), 0);
460 #endif
462 /* Get all permanent types that have typedef names,
463 and output them all, except for those already output. */
465 dbxout_typedefs (syms);
468 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
469 in the reverse order from that which is found in SYMS. */
471 static void
472 dbxout_typedefs (syms)
473 tree syms;
475 if (syms)
477 dbxout_typedefs (TREE_CHAIN (syms));
478 if (TREE_CODE (syms) == TYPE_DECL)
480 tree type = TREE_TYPE (syms);
481 if (TYPE_NAME (type)
482 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
483 && TYPE_SIZE (type) != NULL_TREE
484 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
485 dbxout_symbol (TYPE_NAME (type), 0);
490 /* Change to reading from a new source file. Generate a N_BINCL stab. */
492 void
493 dbxout_start_new_source_file (filename)
494 const char *filename ATTRIBUTE_UNUSED;
496 #ifdef DBX_USE_BINCL
497 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
499 n->next = current_file;
500 n->file_number = next_file_number++;
501 n->next_type_number = 1;
502 current_file = n;
503 fprintf (asmfile, "%s ", ASM_STABS_OP);
504 output_quoted_string (asmfile, filename);
505 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
506 #endif
509 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
511 void
512 dbxout_resume_previous_source_file ()
514 #ifdef DBX_USE_BINCL
515 struct dbx_file *next;
517 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
518 next = current_file->next;
519 free (current_file);
520 current_file = next;
521 #endif
524 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
526 void
527 dbxout_source_file (file, filename)
528 FILE *file;
529 const char *filename;
531 char ltext_label_name[100];
533 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
535 #ifdef DBX_OUTPUT_SOURCE_FILENAME
536 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
537 #else
538 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
539 source_label_number);
540 fprintf (file, "%s ", ASM_STABS_OP);
541 output_quoted_string (file, filename);
542 fprintf (file, ",%d,0,0,%s\n", N_SOL, &ltext_label_name[1]);
543 if (current_function_decl != NULL_TREE
544 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
545 ; /* Don't change section amid function. */
546 else
547 text_section ();
548 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
549 source_label_number++;
550 #endif
551 lastfile = filename;
555 /* Output a line number symbol entry into output stream FILE,
556 for source file FILENAME and line number LINENO. */
558 void
559 dbxout_source_line (file, filename, lineno)
560 FILE *file;
561 const char *filename;
562 int lineno;
564 dbxout_source_file (file, filename);
566 #ifdef ASM_OUTPUT_SOURCE_LINE
567 ASM_OUTPUT_SOURCE_LINE (file, lineno);
568 #else
569 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
570 #endif
573 /* At the end of compilation, finish writing the symbol table.
574 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
575 to do nothing. */
577 void
578 dbxout_finish (file, filename)
579 FILE *file ATTRIBUTE_UNUSED;
580 const char *filename ATTRIBUTE_UNUSED;
582 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
583 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
584 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
587 /* Output the index of a type. */
589 static void
590 dbxout_type_index (type)
591 tree type;
593 #ifndef DBX_USE_BINCL
594 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
595 CHARS (3);
596 #else
597 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
598 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
599 CHARS (7);
600 #endif
603 #if DBX_CONTIN_LENGTH > 0
604 /* Continue a symbol-description that gets too big.
605 End one symbol table entry with a double-backslash
606 and start a new one, eventually producing something like
607 .stabs "start......\\",code,0,value
608 .stabs "...rest",code,0,value */
610 static void
611 dbxout_continue ()
613 #ifdef DBX_CONTIN_CHAR
614 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
615 #else
616 fprintf (asmfile, "\\\\");
617 #endif
618 dbxout_finish_symbol (NULL_TREE);
619 fprintf (asmfile, "%s \"", ASM_STABS_OP);
620 current_sym_nchars = 0;
622 #endif /* DBX_CONTIN_LENGTH > 0 */
624 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
625 This must be a separate function because anonymous unions require
626 recursive calls. */
628 static void
629 dbxout_type_fields (type)
630 tree type;
632 tree tem;
633 /* Output the name, type, position (in bits), size (in bits) of each
634 field. */
635 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
637 /* Omit here local type decls until we know how to support them. */
638 if (TREE_CODE (tem) == TYPE_DECL)
639 continue;
640 /* Omit fields whose position or size are variable. */
641 else if (TREE_CODE (tem) == FIELD_DECL
642 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
643 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
644 continue;
645 /* Omit here the nameless fields that are used to skip bits. */
646 else if (DECL_IGNORED_P (tem))
647 continue;
648 else if (TREE_CODE (tem) != CONST_DECL)
650 /* Continue the line if necessary,
651 but not before the first field. */
652 if (tem != TYPE_FIELDS (type))
654 CONTIN;
657 if (use_gnu_debug_info_extensions
658 && flag_minimal_debug
659 && TREE_CODE (tem) == FIELD_DECL
660 && DECL_VIRTUAL_P (tem)
661 && DECL_ASSEMBLER_NAME (tem))
663 have_used_extensions = 1;
664 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
665 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
666 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
667 fprintf (asmfile, ":");
668 dbxout_type (TREE_TYPE (tem), 0, 0);
669 fputc (',', asmfile);
670 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
671 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
672 fputc (';', asmfile);
673 continue;
676 if (DECL_NAME (tem))
678 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
679 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
681 else
683 fprintf (asmfile, ":");
684 CHARS (2);
687 if (use_gnu_debug_info_extensions
688 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
689 || TREE_CODE (tem) != FIELD_DECL))
691 have_used_extensions = 1;
692 putc ('/', asmfile);
693 putc ((TREE_PRIVATE (tem) ? '0'
694 : TREE_PROTECTED (tem) ? '1' : '2'),
695 asmfile);
696 CHARS (2);
699 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
700 && DECL_BIT_FIELD_TYPE (tem))
701 ? DECL_BIT_FIELD_TYPE (tem)
702 : TREE_TYPE (tem), 0, 0);
704 if (TREE_CODE (tem) == VAR_DECL)
706 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
708 const char *name =
709 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
710 have_used_extensions = 1;
711 fprintf (asmfile, ":%s;", name);
712 CHARS (strlen (name));
714 else
716 /* If TEM is non-static, GDB won't understand it. */
717 fprintf (asmfile, ",0,0;");
720 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
722 fputc (',', asmfile);
723 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
724 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
725 fputc (',', asmfile);
726 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
727 TREE_INT_CST_LOW (DECL_SIZE (tem)));
728 fputc (';', asmfile);
730 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' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
769 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
770 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
771 if (DECL_VINDEX (decl))
773 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
774 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
775 fputc (';', asmfile);
776 dbxout_type (DECL_CONTEXT (decl), 0, 0);
777 fprintf (asmfile, ";");
778 CHARS (8);
782 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
783 in TYPE. */
785 static void
786 dbxout_type_methods (type)
787 register tree type;
789 /* C++: put out the method names and their parameter lists */
790 tree methods = TYPE_METHODS (type);
791 tree type_encoding;
792 register tree fndecl;
793 register tree last;
794 char formatted_type_identifier_length[16];
795 register int type_identifier_length;
797 if (methods == NULL_TREE)
798 return;
800 type_encoding = DECL_NAME (TYPE_NAME (type));
802 #if 0
803 /* C++: Template classes break some assumptions made by this code about
804 the class names, constructor names, and encodings for assembler
805 label names. For now, disable output of dbx info for them. */
807 const char *ptr = IDENTIFIER_POINTER (type_encoding);
808 /* This should use index. (mrs) */
809 while (*ptr && *ptr != '<') ptr++;
810 if (*ptr != 0)
812 static int warned;
813 if (!warned)
814 warned = 1;
815 return;
818 #endif
820 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
822 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
824 if (TREE_CODE (methods) != TREE_VEC)
825 fndecl = methods;
826 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
827 fndecl = TREE_VEC_ELT (methods, 0);
828 else
829 fndecl = TREE_VEC_ELT (methods, 1);
831 while (fndecl)
833 tree name = DECL_NAME (fndecl);
834 int need_prefix = 1;
836 /* Group together all the methods for the same operation.
837 These differ in the types of the arguments. */
838 for (last = NULL_TREE;
839 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
840 fndecl = TREE_CHAIN (fndecl))
841 /* Output the name of the field (after overloading), as
842 well as the name of the field before overloading, along
843 with its parameter list */
845 /* This is the "mangled" name of the method.
846 It encodes the argument types. */
847 const char *debug_name =
848 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
849 int show_arg_types = 0;
851 CONTIN;
853 last = fndecl;
855 if (DECL_IGNORED_P (fndecl))
856 continue;
858 if (flag_minimal_debug)
860 char marker;
862 /* We can't optimize a method which uses an anonymous
863 class, because the debugger will not be able to
864 associate the arbitrary class name with the actual
865 class. */
866 #ifndef NO_DOLLAR_IN_LABEL
867 marker = '$';
868 #else
869 marker = '.';
870 #endif
871 if (strchr (debug_name, marker))
872 show_arg_types = 1;
873 /* Detect ordinary methods because their mangled names
874 start with the operation name. */
875 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
876 IDENTIFIER_LENGTH (name)))
878 debug_name += IDENTIFIER_LENGTH (name);
879 if (debug_name[0] == '_' && debug_name[1] == '_')
881 const char *method_name = debug_name + 2;
882 const char *length_ptr =
883 formatted_type_identifier_length;
884 /* Get past const and volatile qualifiers. */
885 while (*method_name == 'C' || *method_name == 'V')
886 method_name++;
887 /* Skip digits for length of type_encoding. */
888 while (*method_name == *length_ptr && *length_ptr)
889 length_ptr++, method_name++;
890 if (! strncmp (method_name,
891 IDENTIFIER_POINTER (type_encoding),
892 type_identifier_length))
893 method_name += type_identifier_length;
894 debug_name = method_name;
897 /* Detect constructors by their style of name mangling. */
898 else if (debug_name[0] == '_' && debug_name[1] == '_')
900 const char *ctor_name = debug_name + 2;
901 const char *length_ptr = formatted_type_identifier_length;
902 while (*ctor_name == 'C' || *ctor_name == 'V')
903 ctor_name++;
904 /* Skip digits for length of type_encoding. */
905 while (*ctor_name == *length_ptr && *length_ptr)
906 length_ptr++, ctor_name++;
907 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
908 type_identifier_length))
909 debug_name = ctor_name + type_identifier_length;
911 /* The other alternative is a destructor. */
912 else
913 show_arg_types = 1;
915 /* Output the operation name just once, for the first method
916 that we output. */
917 if (need_prefix)
919 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
920 CHARS (IDENTIFIER_LENGTH (name) + 2);
921 need_prefix = 0;
925 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
927 dbxout_type_method_1 (fndecl, debug_name);
929 if (!need_prefix)
931 putc (';', asmfile);
932 CHARS (1);
937 /* Emit a "range" type specification, which has the form:
938 "r<index type>;<lower bound>;<upper bound>;".
939 TYPE is an INTEGER_TYPE. */
941 static void
942 dbxout_range_type (type)
943 tree type;
945 fprintf (asmfile, "r");
946 if (TREE_TYPE (type))
947 dbxout_type (TREE_TYPE (type), 0, 0);
948 else if (TREE_CODE (type) != INTEGER_TYPE)
949 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
950 else
952 /* Traditionally, we made sure 'int' was type 1, and builtin types
953 were defined to be sub-ranges of int. Unfortunately, this
954 does not allow us to distinguish true sub-ranges from integer
955 types. So, instead we define integer (non-sub-range) types as
956 sub-ranges of themselves. This matters for Chill. If this isn't
957 a subrange type, then we want to define it in terms of itself.
958 However, in C, this may be an anonymous integer type, and we don't
959 want to emit debug info referring to it. Just calling
960 dbxout_type_index won't work anyways, because the type hasn't been
961 defined yet. We make this work for both cases by checked to see
962 whether this is a defined type, referring to it if it is, and using
963 'int' otherwise. */
964 if (TYPE_SYMTAB_ADDRESS (type) != 0)
965 dbxout_type_index (type);
966 else
967 dbxout_type_index (integer_type_node);
969 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
971 fputc (';', asmfile);
972 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
973 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
975 else
976 fprintf (asmfile, ";0");
977 if (TYPE_MAX_VALUE (type)
978 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
980 fputc (';', asmfile);
981 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
982 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
983 fputc (';', asmfile);
985 else
986 fprintf (asmfile, ";-1;");
989 /* Output a reference to a type. If the type has not yet been
990 described in the dbx output, output its definition now.
991 For a type already defined, just refer to its definition
992 using the type number.
994 If FULL is nonzero, and the type has been described only with
995 a forward-reference, output the definition now.
996 If FULL is zero in this case, just refer to the forward-reference
997 using the number previously allocated.
999 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1000 types for a METHOD_TYPE. */
1002 static void
1003 dbxout_type (type, full, show_arg_types)
1004 tree type;
1005 int full;
1006 int show_arg_types;
1008 register tree tem;
1009 static int anonymous_type_number = 0;
1011 /* If there was an input error and we don't really have a type,
1012 avoid crashing and write something that is at least valid
1013 by assuming `int'. */
1014 if (type == error_mark_node)
1015 type = integer_type_node;
1016 else
1018 /* Try to find the "main variant" with the same name but not const
1019 or volatile. (Since stabs does not distinguish const and volatile,
1020 there is no need to make them separate types. But types with
1021 different names are usefully distinguished.) */
1023 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1024 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1025 && TYPE_NAME (tem) == TYPE_NAME (type))
1027 type = tem;
1028 break;
1030 if (TYPE_NAME (type)
1031 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1032 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1033 full = 0;
1036 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1038 /* Type has no dbx number assigned. Assign next available number. */
1039 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1041 /* Make sure type vector is long enough to record about this type. */
1043 if (next_type_number == typevec_len)
1045 typevec
1046 = (struct typeinfo *) xrealloc (typevec,
1047 typevec_len * 2 * sizeof typevec[0]);
1048 bzero ((char *) (typevec + typevec_len),
1049 typevec_len * sizeof typevec[0]);
1050 typevec_len *= 2;
1053 #ifdef DBX_USE_BINCL
1054 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1055 = current_file->file_number;
1056 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1057 = current_file->next_type_number++;
1058 #endif
1061 /* Output the number of this type, to refer to it. */
1062 dbxout_type_index (type);
1064 #ifdef DBX_TYPE_DEFINED
1065 if (DBX_TYPE_DEFINED (type))
1066 return;
1067 #endif
1069 /* If this type's definition has been output or is now being output,
1070 that is all. */
1072 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1074 case TYPE_UNSEEN:
1075 break;
1076 case TYPE_XREF:
1077 /* If we have already had a cross reference,
1078 and either that's all we want or that's the best we could do,
1079 don't repeat the cross reference.
1080 Sun dbx crashes if we do. */
1081 if (! full || TYPE_SIZE (type) == 0
1082 /* No way in DBX fmt to describe a variable size. */
1083 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1084 return;
1085 break;
1086 case TYPE_DEFINED:
1087 return;
1090 #ifdef DBX_NO_XREFS
1091 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1092 leave the type-number completely undefined rather than output
1093 a cross-reference. If we have already used GNU debug info extensions,
1094 then it is OK to output a cross reference. This is necessary to get
1095 proper C++ debug output. */
1096 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1097 || TREE_CODE (type) == QUAL_UNION_TYPE
1098 || TREE_CODE (type) == ENUMERAL_TYPE)
1099 && ! use_gnu_debug_info_extensions)
1100 /* We must use the same test here as we use twice below when deciding
1101 whether to emit a cross-reference. */
1102 if ((TYPE_NAME (type) != 0
1103 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1104 && DECL_IGNORED_P (TYPE_NAME (type)))
1105 && !full)
1106 || TYPE_SIZE (type) == 0
1107 /* No way in DBX fmt to describe a variable size. */
1108 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1110 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1111 return;
1113 #endif
1115 /* Output a definition now. */
1117 fprintf (asmfile, "=");
1118 CHARS (1);
1120 /* Mark it as defined, so that if it is self-referent
1121 we will not get into an infinite recursion of definitions. */
1123 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1125 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1126 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1128 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1129 return;
1132 switch (TREE_CODE (type))
1134 case VOID_TYPE:
1135 case LANG_TYPE:
1136 /* For a void type, just define it as itself; ie, "5=5".
1137 This makes us consider it defined
1138 without saying what it is. The debugger will make it
1139 a void type when the reference is seen, and nothing will
1140 ever override that default. */
1141 dbxout_type_index (type);
1142 break;
1144 case INTEGER_TYPE:
1145 if (type == char_type_node && ! TREE_UNSIGNED (type))
1147 /* Output the type `char' as a subrange of itself!
1148 I don't understand this definition, just copied it
1149 from the output of pcc.
1150 This used to use `r2' explicitly and we used to
1151 take care to make sure that `char' was type number 2. */
1152 fprintf (asmfile, "r");
1153 dbxout_type_index (type);
1154 fprintf (asmfile, ";0;127;");
1156 /* This used to check if the type's precision was more than
1157 HOST_BITS_PER_WIDE_INT. That is wrong since gdb uses a
1158 long (it has no concept of HOST_BITS_PER_WIDE_INT). */
1159 else if (use_gnu_debug_info_extensions
1160 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1161 || TYPE_PRECISION (type) >= HOST_BITS_PER_LONG))
1163 /* This used to say `r1' and we used to take care
1164 to make sure that `int' was type number 1. */
1165 fprintf (asmfile, "r");
1166 dbxout_type_index (integer_type_node);
1167 fprintf (asmfile, ";");
1168 print_int_cst_octal (TYPE_MIN_VALUE (type));
1169 fprintf (asmfile, ";");
1170 print_int_cst_octal (TYPE_MAX_VALUE (type));
1171 fprintf (asmfile, ";");
1173 else /* Output other integer types as subranges of `int'. */
1174 dbxout_range_type (type);
1175 CHARS (22);
1176 break;
1178 case REAL_TYPE:
1179 /* This used to say `r1' and we used to take care
1180 to make sure that `int' was type number 1. */
1181 fprintf (asmfile, "r");
1182 dbxout_type_index (integer_type_node);
1183 fputc (';', asmfile);
1184 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1185 fputs (";0;", asmfile);
1186 CHARS (13);
1187 break;
1189 case CHAR_TYPE:
1190 if (use_gnu_debug_info_extensions)
1192 fputs ("@s", asmfile);
1193 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1194 BITS_PER_UNIT * int_size_in_bytes (type));
1195 fputs (";-20;", asmfile);
1197 else
1199 /* Output the type `char' as a subrange of itself.
1200 That is what pcc seems to do. */
1201 fprintf (asmfile, "r");
1202 dbxout_type_index (char_type_node);
1203 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1205 CHARS (9);
1206 break;
1208 case BOOLEAN_TYPE:
1209 if (use_gnu_debug_info_extensions)
1211 fputs ("@s", asmfile);
1212 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1213 BITS_PER_UNIT * int_size_in_bytes (type));
1214 fputs (";-16;", asmfile);
1216 else /* Define as enumeral type (False, True) */
1217 fprintf (asmfile, "eFalse:0,True:1,;");
1218 CHARS (17);
1219 break;
1221 case FILE_TYPE:
1222 putc ('d', asmfile);
1223 CHARS (1);
1224 dbxout_type (TREE_TYPE (type), 0, 0);
1225 break;
1227 case COMPLEX_TYPE:
1228 /* Differs from the REAL_TYPE by its new data type number */
1230 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1232 fprintf (asmfile, "r");
1233 dbxout_type_index (type);
1234 fputc (';', asmfile);
1235 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1236 int_size_in_bytes (TREE_TYPE (type)));
1237 fputs (";0;", asmfile);
1238 CHARS (12); /* The number is probably incorrect here. */
1240 else
1242 /* Output a complex integer type as a structure,
1243 pending some other way to do it. */
1244 fputc ('s', asmfile);
1245 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1247 fprintf (asmfile, "real:");
1248 CHARS (10);
1249 dbxout_type (TREE_TYPE (type), 0, 0);
1250 fprintf (asmfile, ",%d,%d;",
1251 0, TYPE_PRECISION (TREE_TYPE (type)));
1252 CHARS (8);
1253 fprintf (asmfile, "imag:");
1254 CHARS (5);
1255 dbxout_type (TREE_TYPE (type), 0, 0);
1256 fprintf (asmfile, ",%d,%d;;",
1257 TYPE_PRECISION (TREE_TYPE (type)),
1258 TYPE_PRECISION (TREE_TYPE (type)));
1259 CHARS (9);
1261 break;
1263 case SET_TYPE:
1264 if (use_gnu_debug_info_extensions)
1266 have_used_extensions = 1;
1267 fputs ("@s", asmfile);
1268 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1269 BITS_PER_UNIT * int_size_in_bytes (type));
1270 fputc (';', asmfile);
1271 /* Check if a bitstring type, which in Chill is
1272 different from a [power]set. */
1273 if (TYPE_STRING_FLAG (type))
1274 fprintf (asmfile, "@S;");
1276 putc ('S', asmfile);
1277 CHARS (1);
1278 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1279 break;
1281 case ARRAY_TYPE:
1282 /* Make arrays of packed bits look like bitstrings for chill. */
1283 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1285 have_used_extensions = 1;
1286 fputs ("@s", asmfile);
1287 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1288 BITS_PER_UNIT * int_size_in_bytes (type));
1289 fputc (';', asmfile);
1290 fprintf (asmfile, "@S;");
1291 putc ('S', asmfile);
1292 CHARS (1);
1293 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1294 break;
1296 /* Output "a" followed by a range type definition
1297 for the index type of the array
1298 followed by a reference to the target-type.
1299 ar1;0;N;M for a C array of type M and size N+1. */
1300 /* Check if a character string type, which in Chill is
1301 different from an array of characters. */
1302 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1304 have_used_extensions = 1;
1305 fprintf (asmfile, "@S;");
1307 tem = TYPE_DOMAIN (type);
1308 if (tem == NULL)
1310 fprintf (asmfile, "ar");
1311 dbxout_type_index (integer_type_node);
1312 fprintf (asmfile, ";0;-1;");
1314 else
1316 fprintf (asmfile, "a");
1317 dbxout_range_type (tem);
1319 CHARS (14);
1320 dbxout_type (TREE_TYPE (type), 0, 0);
1321 break;
1323 case RECORD_TYPE:
1324 case UNION_TYPE:
1325 case QUAL_UNION_TYPE:
1327 int i, n_baseclasses = 0;
1329 if (TYPE_BINFO (type) != 0
1330 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1331 && TYPE_BINFO_BASETYPES (type) != 0)
1332 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1334 /* Output a structure type. We must use the same test here as we
1335 use in the DBX_NO_XREFS case above. */
1336 if ((TYPE_NAME (type) != 0
1337 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1338 && DECL_IGNORED_P (TYPE_NAME (type)))
1339 && !full)
1340 || TYPE_SIZE (type) == 0
1341 /* No way in DBX fmt to describe a variable size. */
1342 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1344 /* If the type is just a cross reference, output one
1345 and mark the type as partially described.
1346 If it later becomes defined, we will output
1347 its real definition.
1348 If the type has a name, don't nest its definition within
1349 another type's definition; instead, output an xref
1350 and let the definition come when the name is defined. */
1351 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1352 CHARS (3);
1353 #if 0 /* This assertion is legitimately false in C++. */
1354 /* We shouldn't be outputting a reference to a type before its
1355 definition unless the type has a tag name.
1356 A typedef name without a tag name should be impossible. */
1357 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1358 abort ();
1359 #endif
1360 if (TYPE_NAME (type) != 0)
1361 dbxout_type_name (type);
1362 else
1363 fprintf (asmfile, "$$%d", anonymous_type_number++);
1364 fprintf (asmfile, ":");
1365 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1366 break;
1369 /* Identify record or union, and print its size. */
1370 fputc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1371 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1372 int_size_in_bytes (type));
1374 if (use_gnu_debug_info_extensions)
1376 if (n_baseclasses)
1378 have_used_extensions = 1;
1379 fprintf (asmfile, "!%d,", n_baseclasses);
1380 CHARS (8);
1383 for (i = 0; i < n_baseclasses; i++)
1385 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1386 if (use_gnu_debug_info_extensions)
1388 have_used_extensions = 1;
1389 putc (TREE_VIA_VIRTUAL (child) ? '1'
1390 : '0',
1391 asmfile);
1392 putc (TREE_VIA_PUBLIC (child) ? '2'
1393 : '0',
1394 asmfile);
1395 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1396 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1397 fputc (',', asmfile);
1398 CHARS (15);
1399 dbxout_type (BINFO_TYPE (child), 0, 0);
1400 putc (';', asmfile);
1402 else
1404 /* Print out the base class information with fields
1405 which have the same names at the types they hold. */
1406 dbxout_type_name (BINFO_TYPE (child));
1407 putc (':', asmfile);
1408 dbxout_type (BINFO_TYPE (child), full, 0);
1409 fputc (',', asmfile);
1410 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1411 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1412 fputc (',', asmfile);
1413 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1414 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1415 fputc (';', asmfile);
1416 CHARS (20);
1421 CHARS (11);
1423 /* Write out the field declarations. */
1424 dbxout_type_fields (type);
1425 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1427 have_used_extensions = 1;
1428 dbxout_type_methods (type);
1430 putc (';', asmfile);
1432 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1433 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1434 && TYPE_VFIELD (type))
1436 have_used_extensions = 1;
1438 /* Tell GDB+ that it may keep reading. */
1439 putc ('~', asmfile);
1441 /* We need to write out info about what field this class
1442 uses as its "main" vtable pointer field, because if this
1443 field is inherited from a base class, GDB cannot necessarily
1444 figure out which field it's using in time. */
1445 if (TYPE_VFIELD (type))
1447 putc ('%', asmfile);
1448 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1450 putc (';', asmfile);
1451 CHARS (3);
1453 break;
1455 case ENUMERAL_TYPE:
1456 /* We must use the same test here as we use in the DBX_NO_XREFS case
1457 above. We simplify it a bit since an enum will never have a variable
1458 size. */
1459 if ((TYPE_NAME (type) != 0
1460 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1461 && DECL_IGNORED_P (TYPE_NAME (type)))
1462 && !full)
1463 || TYPE_SIZE (type) == 0)
1465 fprintf (asmfile, "xe");
1466 CHARS (3);
1467 dbxout_type_name (type);
1468 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1469 fprintf (asmfile, ":");
1470 return;
1472 #ifdef DBX_OUTPUT_ENUM
1473 DBX_OUTPUT_ENUM (asmfile, type);
1474 #else
1475 if (use_gnu_debug_info_extensions
1476 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1477 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1478 putc ('e', asmfile);
1479 CHARS (1);
1480 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1482 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1483 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1484 fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED,
1485 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1486 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1487 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1488 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1489 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1490 else
1491 print_int_cst_octal (TREE_VALUE (tem));
1492 fprintf (asmfile, ",");
1493 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1494 if (TREE_CHAIN (tem) != 0)
1496 CONTIN;
1499 putc (';', asmfile);
1500 CHARS (1);
1501 #endif
1502 break;
1504 case POINTER_TYPE:
1505 putc ('*', asmfile);
1506 CHARS (1);
1507 dbxout_type (TREE_TYPE (type), 0, 0);
1508 break;
1510 case METHOD_TYPE:
1511 if (use_gnu_debug_info_extensions)
1513 have_used_extensions = 1;
1514 putc ('#', asmfile);
1515 CHARS (1);
1516 if (flag_minimal_debug && !show_arg_types)
1518 /* Normally, just output the return type.
1519 The argument types are encoded in the method name. */
1520 putc ('#', asmfile);
1521 CHARS (1);
1522 dbxout_type (TREE_TYPE (type), 0, 0);
1523 putc (';', asmfile);
1524 CHARS (1);
1526 else
1528 /* When outputting destructors, we need to write
1529 the argument types out longhand. */
1530 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1531 putc (',', asmfile);
1532 CHARS (1);
1533 dbxout_type (TREE_TYPE (type), 0, 0);
1534 dbxout_args (TYPE_ARG_TYPES (type));
1535 putc (';', asmfile);
1536 CHARS (1);
1539 else
1541 /* Treat it as a function type. */
1542 dbxout_type (TREE_TYPE (type), 0, 0);
1544 break;
1546 case OFFSET_TYPE:
1547 if (use_gnu_debug_info_extensions)
1549 have_used_extensions = 1;
1550 putc ('@', asmfile);
1551 CHARS (1);
1552 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1553 putc (',', asmfile);
1554 CHARS (1);
1555 dbxout_type (TREE_TYPE (type), 0, 0);
1557 else
1559 /* Should print as an int, because it is really
1560 just an offset. */
1561 dbxout_type (integer_type_node, 0, 0);
1563 break;
1565 case REFERENCE_TYPE:
1566 if (use_gnu_debug_info_extensions)
1567 have_used_extensions = 1;
1568 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1569 CHARS (1);
1570 dbxout_type (TREE_TYPE (type), 0, 0);
1571 break;
1573 case FUNCTION_TYPE:
1574 putc ('f', asmfile);
1575 CHARS (1);
1576 dbxout_type (TREE_TYPE (type), 0, 0);
1577 break;
1579 default:
1580 abort ();
1584 /* Print the value of integer constant C, in octal,
1585 handling double precision. */
1587 static void
1588 print_int_cst_octal (c)
1589 tree c;
1591 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1592 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1593 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1594 int width = TYPE_PRECISION (TREE_TYPE (c));
1596 /* GDB wants constants with no extra leading "1" bits, so
1597 we need to remove any sign-extension that might be
1598 present. */
1599 if (width == HOST_BITS_PER_WIDE_INT * 2)
1601 else if (width > HOST_BITS_PER_WIDE_INT)
1602 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1603 else if (width == HOST_BITS_PER_WIDE_INT)
1604 high = 0;
1605 else
1606 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1608 fprintf (asmfile, "0");
1610 if (excess == 3)
1612 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1613 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1615 else
1617 unsigned HOST_WIDE_INT beg = high >> excess;
1618 unsigned HOST_WIDE_INT middle
1619 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1620 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1621 unsigned HOST_WIDE_INT end
1622 = low & (((unsigned HOST_WIDE_INT) 1
1623 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1624 - 1);
1626 fprintf (asmfile, "%o%01o", (int)beg, (int)middle);
1627 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1631 static void
1632 print_octal (value, digits)
1633 unsigned HOST_WIDE_INT value;
1634 int digits;
1636 int i;
1638 for (i = digits - 1; i >= 0; i--)
1639 fprintf (asmfile, "%01o", (int)((value >> (3 * i)) & 7));
1642 /* Output the name of type TYPE, with no punctuation.
1643 Such names can be set up either by typedef declarations
1644 or by struct, enum and union tags. */
1646 static void
1647 dbxout_type_name (type)
1648 register tree type;
1650 tree t;
1651 if (TYPE_NAME (type) == 0)
1652 abort ();
1653 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1655 t = TYPE_NAME (type);
1657 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1659 t = DECL_NAME (TYPE_NAME (type));
1661 else
1662 abort ();
1664 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1665 CHARS (IDENTIFIER_LENGTH (t));
1668 /* Output a .stabs for the symbol defined by DECL,
1669 which must be a ..._DECL node in the normal namespace.
1670 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1671 LOCAL is nonzero if the scope is less than the entire file. */
1673 void
1674 dbxout_symbol (decl, local)
1675 tree decl;
1676 int local ATTRIBUTE_UNUSED;
1678 tree type = TREE_TYPE (decl);
1679 tree context = NULL_TREE;
1681 /* Cast avoids warning in old compilers. */
1682 current_sym_code = (STAB_CODE_TYPE) 0;
1683 current_sym_value = 0;
1684 current_sym_addr = 0;
1686 /* Ignore nameless syms, but don't ignore type tags. */
1688 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1689 || DECL_IGNORED_P (decl))
1690 return;
1692 dbxout_prepare_symbol (decl);
1694 /* The output will always start with the symbol name,
1695 so always count that in the length-output-so-far. */
1697 if (DECL_NAME (decl) != 0)
1698 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1700 switch (TREE_CODE (decl))
1702 case CONST_DECL:
1703 /* Enum values are defined by defining the enum type. */
1704 break;
1706 case FUNCTION_DECL:
1707 if (DECL_RTL (decl) == 0)
1708 return;
1709 if (DECL_EXTERNAL (decl))
1710 break;
1711 /* Don't mention a nested function under its parent. */
1712 context = decl_function_context (decl);
1713 if (context == current_function_decl)
1714 break;
1715 if (GET_CODE (DECL_RTL (decl)) != MEM
1716 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1717 break;
1718 FORCE_TEXT;
1720 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1721 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1722 TREE_PUBLIC (decl) ? 'F' : 'f');
1724 current_sym_code = N_FUN;
1725 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1727 if (TREE_TYPE (type))
1728 dbxout_type (TREE_TYPE (type), 0, 0);
1729 else
1730 dbxout_type (void_type_node, 0, 0);
1732 /* For a nested function, when that function is compiled,
1733 mention the containing function name
1734 as well as (since dbx wants it) our own assembler-name. */
1735 if (context != 0)
1736 fprintf (asmfile, ",%s,%s",
1737 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1738 IDENTIFIER_POINTER (DECL_NAME (context)));
1740 dbxout_finish_symbol (decl);
1741 break;
1743 case TYPE_DECL:
1744 #if 0
1745 /* This seems all wrong. Outputting most kinds of types gives no name
1746 at all. A true definition gives no name; a cross-ref for a
1747 structure can give the tag name, but not a type name.
1748 It seems that no typedef name is defined by outputting a type. */
1750 /* If this typedef name was defined by outputting the type,
1751 don't duplicate it. */
1752 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1753 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1754 return;
1755 #endif
1756 /* Don't output the same typedef twice.
1757 And don't output what language-specific stuff doesn't want output. */
1758 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1759 return;
1761 FORCE_TEXT;
1764 int tag_needed = 1;
1765 int did_output = 0;
1767 if (DECL_NAME (decl))
1769 /* Nonzero means we must output a tag as well as a typedef. */
1770 tag_needed = 0;
1772 /* Handle the case of a C++ structure or union
1773 where the TYPE_NAME is a TYPE_DECL
1774 which gives both a typedef name and a tag. */
1775 /* dbx requires the tag first and the typedef second. */
1776 if ((TREE_CODE (type) == RECORD_TYPE
1777 || TREE_CODE (type) == UNION_TYPE
1778 || TREE_CODE (type) == QUAL_UNION_TYPE)
1779 && TYPE_NAME (type) == decl
1780 && !(use_gnu_debug_info_extensions && have_used_extensions)
1781 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1782 /* Distinguish the implicit typedefs of C++
1783 from explicit ones that might be found in C. */
1784 && DECL_ARTIFICIAL (decl))
1786 tree name = TYPE_NAME (type);
1787 if (TREE_CODE (name) == TYPE_DECL)
1788 name = DECL_NAME (name);
1790 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1791 current_sym_value = 0;
1792 current_sym_addr = 0;
1793 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1795 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1796 IDENTIFIER_POINTER (name));
1797 dbxout_type (type, 1, 0);
1798 dbxout_finish_symbol (NULL_TREE);
1801 /* Output typedef name. */
1802 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1803 IDENTIFIER_POINTER (DECL_NAME (decl)));
1805 /* Short cut way to output a tag also. */
1806 if ((TREE_CODE (type) == RECORD_TYPE
1807 || TREE_CODE (type) == UNION_TYPE
1808 || TREE_CODE (type) == QUAL_UNION_TYPE)
1809 && TYPE_NAME (type) == decl
1810 /* Distinguish the implicit typedefs of C++
1811 from explicit ones that might be found in C. */
1812 && DECL_ARTIFICIAL (decl))
1814 if (use_gnu_debug_info_extensions && have_used_extensions)
1816 putc ('T', asmfile);
1817 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1819 #if 0 /* Now we generate the tag for this case up above. */
1820 else
1821 tag_needed = 1;
1822 #endif
1825 putc ('t', asmfile);
1826 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1828 dbxout_type (type, 1, 0);
1829 dbxout_finish_symbol (decl);
1830 did_output = 1;
1833 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1834 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1836 if (tag_needed && TYPE_NAME (type) != 0
1837 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1838 || (DECL_NAME (TYPE_NAME (type)) != 0))
1839 && TYPE_SIZE (type) != 0
1840 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1842 /* For a TYPE_DECL with no name, but the type has a name,
1843 output a tag.
1844 This is what represents `struct foo' with no typedef. */
1845 /* In C++, the name of a type is the corresponding typedef.
1846 In C, it is an IDENTIFIER_NODE. */
1847 tree name = TYPE_NAME (type);
1848 if (TREE_CODE (name) == TYPE_DECL)
1849 name = DECL_NAME (name);
1851 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1852 current_sym_value = 0;
1853 current_sym_addr = 0;
1854 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1856 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1857 IDENTIFIER_POINTER (name));
1858 dbxout_type (type, 1, 0);
1859 dbxout_finish_symbol (NULL_TREE);
1860 did_output = 1;
1863 /* If an enum type has no name, it cannot be referred to,
1864 but we must output it anyway, since the enumeration constants
1865 can be referred to. */
1866 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1868 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1869 current_sym_value = 0;
1870 current_sym_addr = 0;
1871 current_sym_nchars = 2;
1873 /* Some debuggers fail when given NULL names, so give this a
1874 harmless name of ` '. */
1875 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1876 dbxout_type (type, 1, 0);
1877 dbxout_finish_symbol (NULL_TREE);
1880 /* Prevent duplicate output of a typedef. */
1881 TREE_ASM_WRITTEN (decl) = 1;
1882 break;
1885 case PARM_DECL:
1886 /* Parm decls go in their own separate chains
1887 and are output by dbxout_reg_parms and dbxout_parms. */
1888 abort ();
1890 case RESULT_DECL:
1891 /* Named return value, treat like a VAR_DECL. */
1892 case VAR_DECL:
1893 if (DECL_RTL (decl) == 0)
1894 return;
1895 /* Don't mention a variable that is external.
1896 Let the file that defines it describe it. */
1897 if (DECL_EXTERNAL (decl))
1898 break;
1900 /* If the variable is really a constant
1901 and not written in memory, inform the debugger. */
1902 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1903 && DECL_INITIAL (decl) != 0
1904 && ! TREE_ASM_WRITTEN (decl)
1905 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1906 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1908 if (TREE_PUBLIC (decl) == 0)
1910 /* The sun4 assembler does not grok this. */
1911 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1912 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1913 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1915 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1916 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1917 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1918 #else
1919 fprintf (asmfile, "%s \"%s:c=i", ASM_STABS_OP, name);
1921 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
1922 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
1923 #endif
1924 return;
1926 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1928 /* don't know how to do this yet. */
1930 break;
1932 /* else it is something we handle like a normal variable. */
1935 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1936 #ifdef LEAF_REG_REMAP
1937 if (current_function_uses_only_leaf_regs)
1938 leaf_renumber_regs_insn (DECL_RTL (decl));
1939 #endif
1941 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1942 break;
1944 default:
1945 break;
1949 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1950 Add SUFFIX to its name, if SUFFIX is not 0.
1951 Describe the variable as residing in HOME
1952 (usually HOME is DECL_RTL (DECL), but not always). */
1954 static void
1955 dbxout_symbol_location (decl, type, suffix, home)
1956 tree decl, type;
1957 const char *suffix;
1958 rtx home;
1960 int letter = 0;
1961 int regno = -1;
1963 /* Don't mention a variable at all
1964 if it was completely optimized into nothingness.
1966 If the decl was from an inline function, then its rtl
1967 is not identically the rtl that was used in this
1968 particular compilation. */
1969 if (GET_CODE (home) == REG)
1971 regno = REGNO (home);
1972 if (regno >= FIRST_PSEUDO_REGISTER)
1973 return;
1975 else if (GET_CODE (home) == SUBREG)
1977 rtx value = home;
1978 int offset = 0;
1979 while (GET_CODE (value) == SUBREG)
1981 offset += SUBREG_WORD (value);
1982 value = SUBREG_REG (value);
1984 if (GET_CODE (value) == REG)
1986 regno = REGNO (value);
1987 if (regno >= FIRST_PSEUDO_REGISTER)
1988 return;
1989 regno += offset;
1991 alter_subreg (home);
1994 /* The kind-of-variable letter depends on where
1995 the variable is and on the scope of its name:
1996 G and N_GSYM for static storage and global scope,
1997 S for static storage and file scope,
1998 V for static storage and local scope,
1999 for those two, use N_LCSYM if data is in bss segment,
2000 N_STSYM if in data segment, N_FUN otherwise.
2001 (We used N_FUN originally, then changed to N_STSYM
2002 to please GDB. However, it seems that confused ld.
2003 Now GDB has been fixed to like N_FUN, says Kingdon.)
2004 no letter at all, and N_LSYM, for auto variable,
2005 r and N_RSYM for register variable. */
2007 if (GET_CODE (home) == MEM
2008 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2010 if (TREE_PUBLIC (decl))
2012 letter = 'G';
2013 current_sym_code = N_GSYM;
2015 else
2017 current_sym_addr = XEXP (home, 0);
2019 letter = decl_function_context (decl) ? 'V' : 'S';
2021 /* This should be the same condition as in assemble_variable, but
2022 we don't have access to dont_output_data here. So, instead,
2023 we rely on the fact that error_mark_node initializers always
2024 end up in bss for C++ and never end up in bss for C. */
2025 if (DECL_INITIAL (decl) == 0
2026 || (!strcmp (lang_identify (), "cplusplus")
2027 && DECL_INITIAL (decl) == error_mark_node))
2028 current_sym_code = N_LCSYM;
2029 else if (DECL_IN_TEXT_SECTION (decl))
2030 /* This is not quite right, but it's the closest
2031 of all the codes that Unix defines. */
2032 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2033 else
2035 /* Ultrix `as' seems to need this. */
2036 #ifdef DBX_STATIC_STAB_DATA_SECTION
2037 data_section ();
2038 #endif
2039 current_sym_code = N_STSYM;
2043 else if (regno >= 0)
2045 letter = 'r';
2046 current_sym_code = N_RSYM;
2047 current_sym_value = DBX_REGISTER_NUMBER (regno);
2049 else if (GET_CODE (home) == MEM
2050 && (GET_CODE (XEXP (home, 0)) == MEM
2051 || (GET_CODE (XEXP (home, 0)) == REG
2052 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2053 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2054 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2055 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2056 #endif
2058 /* If the value is indirect by memory or by a register
2059 that isn't the frame pointer
2060 then it means the object is variable-sized and address through
2061 that register or stack slot. DBX has no way to represent this
2062 so all we can do is output the variable as a pointer.
2063 If it's not a parameter, ignore it.
2064 (VAR_DECLs like this can be made by integrate.c.) */
2066 if (GET_CODE (XEXP (home, 0)) == REG)
2068 letter = 'r';
2069 current_sym_code = N_RSYM;
2070 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2072 else
2074 current_sym_code = N_LSYM;
2075 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2076 We want the value of that CONST_INT. */
2077 current_sym_value
2078 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2081 /* Effectively do build_pointer_type, but don't cache this type,
2082 since it might be temporary whereas the type it points to
2083 might have been saved for inlining. */
2084 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2085 type = make_node (POINTER_TYPE);
2086 TREE_TYPE (type) = TREE_TYPE (decl);
2088 else if (GET_CODE (home) == MEM
2089 && GET_CODE (XEXP (home, 0)) == REG)
2091 current_sym_code = N_LSYM;
2092 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2094 else if (GET_CODE (home) == MEM
2095 && GET_CODE (XEXP (home, 0)) == PLUS
2096 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2098 current_sym_code = N_LSYM;
2099 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2100 We want the value of that CONST_INT. */
2101 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2103 else if (GET_CODE (home) == MEM
2104 && GET_CODE (XEXP (home, 0)) == CONST)
2106 /* Handle an obscure case which can arise when optimizing and
2107 when there are few available registers. (This is *always*
2108 the case for i386/i486 targets). The RTL looks like
2109 (MEM (CONST ...)) even though this variable is a local `auto'
2110 or a local `register' variable. In effect, what has happened
2111 is that the reload pass has seen that all assignments and
2112 references for one such a local variable can be replaced by
2113 equivalent assignments and references to some static storage
2114 variable, thereby avoiding the need for a register. In such
2115 cases we're forced to lie to debuggers and tell them that
2116 this variable was itself `static'. */
2117 current_sym_code = N_LCSYM;
2118 letter = 'V';
2119 current_sym_addr = XEXP (XEXP (home, 0), 0);
2121 else if (GET_CODE (home) == CONCAT)
2123 tree subtype = TREE_TYPE (type);
2125 /* If the variable's storage is in two parts,
2126 output each as a separate stab with a modified name. */
2127 if (WORDS_BIG_ENDIAN)
2128 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2129 else
2130 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2132 /* Cast avoids warning in old compilers. */
2133 current_sym_code = (STAB_CODE_TYPE) 0;
2134 current_sym_value = 0;
2135 current_sym_addr = 0;
2136 dbxout_prepare_symbol (decl);
2138 if (WORDS_BIG_ENDIAN)
2139 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2140 else
2141 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2142 return;
2144 else
2145 /* Address might be a MEM, when DECL is a variable-sized object.
2146 Or it might be const0_rtx, meaning previous passes
2147 want us to ignore this variable. */
2148 return;
2150 /* Ok, start a symtab entry and output the variable name. */
2151 FORCE_TEXT;
2153 #ifdef DBX_STATIC_BLOCK_START
2154 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2155 #endif
2157 dbxout_symbol_name (decl, suffix, letter);
2158 dbxout_type (type, 0, 0);
2159 dbxout_finish_symbol (decl);
2161 #ifdef DBX_STATIC_BLOCK_END
2162 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2163 #endif
2166 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2167 Then output LETTER to indicate the kind of location the symbol has. */
2169 static void
2170 dbxout_symbol_name (decl, suffix, letter)
2171 tree decl;
2172 const char *suffix;
2173 int letter;
2175 /* One slight hitch: if this is a VAR_DECL which is a static
2176 class member, we must put out the mangled name instead of the
2177 DECL_NAME. Note also that static member (variable) names DO NOT begin
2178 with underscores in .stabs directives. */
2179 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2180 if (name == 0)
2181 name = "(anon)";
2182 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2183 (suffix ? suffix : ""));
2185 if (letter) putc (letter, asmfile);
2188 static void
2189 dbxout_prepare_symbol (decl)
2190 tree decl ATTRIBUTE_UNUSED;
2192 #ifdef WINNING_GDB
2193 const char *filename = DECL_SOURCE_FILE (decl);
2195 dbxout_source_file (asmfile, filename);
2196 #endif
2199 static void
2200 dbxout_finish_symbol (sym)
2201 tree sym;
2203 #ifdef DBX_FINISH_SYMBOL
2204 DBX_FINISH_SYMBOL (sym);
2205 #else
2206 int line = 0;
2207 if (use_gnu_debug_info_extensions && sym != 0)
2208 line = DECL_SOURCE_LINE (sym);
2210 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2211 if (current_sym_addr)
2212 output_addr_const (asmfile, current_sym_addr);
2213 else
2214 fprintf (asmfile, "%d", current_sym_value);
2215 putc ('\n', asmfile);
2216 #endif
2219 /* Output definitions of all the decls in a chain. */
2221 void
2222 dbxout_syms (syms)
2223 tree syms;
2225 while (syms)
2227 dbxout_symbol (syms, 1);
2228 syms = TREE_CHAIN (syms);
2232 /* The following two functions output definitions of function parameters.
2233 Each parameter gets a definition locating it in the parameter list.
2234 Each parameter that is a register variable gets a second definition
2235 locating it in the register.
2237 Printing or argument lists in gdb uses the definitions that
2238 locate in the parameter list. But reference to the variable in
2239 expressions uses preferentially the definition as a register. */
2241 /* Output definitions, referring to storage in the parmlist,
2242 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2244 void
2245 dbxout_parms (parms)
2246 tree parms;
2248 for (; parms; parms = TREE_CHAIN (parms))
2249 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2251 dbxout_prepare_symbol (parms);
2253 /* Perform any necessary register eliminations on the parameter's rtl,
2254 so that the debugging output will be accurate. */
2255 DECL_INCOMING_RTL (parms)
2256 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2257 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2258 #ifdef LEAF_REG_REMAP
2259 if (current_function_uses_only_leaf_regs)
2261 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2262 leaf_renumber_regs_insn (DECL_RTL (parms));
2264 #endif
2266 if (PARM_PASSED_IN_MEMORY (parms))
2268 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2270 /* ??? Here we assume that the parm address is indexed
2271 off the frame pointer or arg pointer.
2272 If that is not true, we produce meaningless results,
2273 but do not crash. */
2274 if (GET_CODE (addr) == PLUS
2275 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2276 current_sym_value = INTVAL (XEXP (addr, 1));
2277 else
2278 current_sym_value = 0;
2280 current_sym_code = N_PSYM;
2281 current_sym_addr = 0;
2283 FORCE_TEXT;
2284 if (DECL_NAME (parms))
2286 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2288 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2289 IDENTIFIER_POINTER (DECL_NAME (parms)),
2290 DBX_MEMPARM_STABS_LETTER);
2292 else
2294 current_sym_nchars = 8;
2295 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2296 DBX_MEMPARM_STABS_LETTER);
2299 /* It is quite tempting to use:
2301 dbxout_type (TREE_TYPE (parms), 0, 0);
2303 as the next statement, rather than using DECL_ARG_TYPE(), so
2304 that gcc reports the actual type of the parameter, rather
2305 than the promoted type. This certainly makes GDB's life
2306 easier, at least for some ports. The change is a bad idea
2307 however, since GDB expects to be able access the type without
2308 performing any conversions. So for example, if we were
2309 passing a float to an unprototyped function, gcc will store a
2310 double on the stack, but if we emit a stab saying the type is a
2311 float, then gdb will only read in a single value, and this will
2312 produce an erropneous value. */
2313 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2314 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2315 dbxout_finish_symbol (parms);
2317 else if (GET_CODE (DECL_RTL (parms)) == REG)
2319 rtx best_rtl;
2320 char regparm_letter;
2321 tree parm_type;
2322 /* Parm passed in registers and lives in registers or nowhere. */
2324 current_sym_code = DBX_REGPARM_STABS_CODE;
2325 regparm_letter = DBX_REGPARM_STABS_LETTER;
2326 current_sym_addr = 0;
2328 /* If parm lives in a register, use that register;
2329 pretend the parm was passed there. It would be more consistent
2330 to describe the register where the parm was passed,
2331 but in practice that register usually holds something else.
2333 If we use DECL_RTL, then we must use the declared type of
2334 the variable, not the type that it arrived in. */
2335 if (REGNO (DECL_RTL (parms)) >= 0
2336 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2338 best_rtl = DECL_RTL (parms);
2339 parm_type = TREE_TYPE (parms);
2341 /* If the parm lives nowhere, use the register where it was
2342 passed. It is also better to use the declared type here. */
2343 else
2345 best_rtl = DECL_INCOMING_RTL (parms);
2346 parm_type = TREE_TYPE (parms);
2348 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2350 FORCE_TEXT;
2351 if (DECL_NAME (parms))
2353 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2354 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2355 IDENTIFIER_POINTER (DECL_NAME (parms)),
2356 regparm_letter);
2358 else
2360 current_sym_nchars = 8;
2361 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2362 regparm_letter);
2365 dbxout_type (parm_type, 0, 0);
2366 dbxout_finish_symbol (parms);
2368 else if (GET_CODE (DECL_RTL (parms)) == MEM
2369 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2370 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2371 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2372 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2373 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2374 #endif
2377 /* Parm was passed via invisible reference.
2378 That is, its address was passed in a register.
2379 Output it as if it lived in that register.
2380 The debugger will know from the type
2381 that it was actually passed by invisible reference. */
2383 char regparm_letter;
2384 /* Parm passed in registers and lives in registers or nowhere. */
2386 current_sym_code = DBX_REGPARM_STABS_CODE;
2387 if (use_gnu_debug_info_extensions)
2388 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2389 else
2390 regparm_letter = DBX_REGPARM_STABS_LETTER;
2392 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2393 If it is an unallocated pseudo-reg, then use the register where
2394 it was passed instead. */
2395 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2396 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2397 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2398 else
2399 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2401 current_sym_addr = 0;
2403 FORCE_TEXT;
2404 if (DECL_NAME (parms))
2406 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2408 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2409 IDENTIFIER_POINTER (DECL_NAME (parms)),
2410 regparm_letter);
2412 else
2414 current_sym_nchars = 8;
2415 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2416 regparm_letter);
2419 dbxout_type (TREE_TYPE (parms), 0, 0);
2420 dbxout_finish_symbol (parms);
2422 else if (GET_CODE (DECL_RTL (parms)) == MEM
2423 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2424 /* ??? A constant address for a parm can happen
2425 when the reg it lives in is equiv to a constant in memory.
2426 Should make this not happen, after 2.4. */
2427 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2429 /* Parm was passed in registers but lives on the stack. */
2431 current_sym_code = N_PSYM;
2432 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2433 in which case we want the value of that CONST_INT,
2434 or (MEM (REG ...)) or (MEM (MEM ...)),
2435 in which case we use a value of zero. */
2436 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2437 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2438 current_sym_value = 0;
2439 else
2440 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2441 current_sym_addr = 0;
2443 /* Make a big endian correction if the mode of the type of the
2444 parameter is not the same as the mode of the rtl. */
2445 if (BYTES_BIG_ENDIAN
2446 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2447 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2449 current_sym_value += UNITS_PER_WORD - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2452 FORCE_TEXT;
2453 if (DECL_NAME (parms))
2455 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2457 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2458 IDENTIFIER_POINTER (DECL_NAME (parms)),
2459 DBX_MEMPARM_STABS_LETTER);
2461 else
2463 current_sym_nchars = 8;
2464 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2465 DBX_MEMPARM_STABS_LETTER);
2468 current_sym_value
2469 = DEBUGGER_ARG_OFFSET (current_sym_value,
2470 XEXP (DECL_RTL (parms), 0));
2471 dbxout_type (TREE_TYPE (parms), 0, 0);
2472 dbxout_finish_symbol (parms);
2477 /* Output definitions for the places where parms live during the function,
2478 when different from where they were passed, when the parms were passed
2479 in memory.
2481 It is not useful to do this for parms passed in registers
2482 that live during the function in different registers, because it is
2483 impossible to look in the passed register for the passed value,
2484 so we use the within-the-function register to begin with.
2486 PARMS is a chain of PARM_DECL nodes. */
2488 void
2489 dbxout_reg_parms (parms)
2490 tree parms;
2492 for (; parms; parms = TREE_CHAIN (parms))
2493 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2495 dbxout_prepare_symbol (parms);
2497 /* Report parms that live in registers during the function
2498 but were passed in memory. */
2499 if (GET_CODE (DECL_RTL (parms)) == REG
2500 && REGNO (DECL_RTL (parms)) >= 0
2501 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2502 dbxout_symbol_location (parms, TREE_TYPE (parms),
2503 0, DECL_RTL (parms));
2504 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2505 dbxout_symbol_location (parms, TREE_TYPE (parms),
2506 0, DECL_RTL (parms));
2507 /* Report parms that live in memory but not where they were passed. */
2508 else if (GET_CODE (DECL_RTL (parms)) == MEM
2509 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2510 dbxout_symbol_location (parms, TREE_TYPE (parms),
2511 0, DECL_RTL (parms));
2515 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2516 output definitions of those names, in raw form */
2518 void
2519 dbxout_args (args)
2520 tree args;
2522 while (args)
2524 putc (',', asmfile);
2525 dbxout_type (TREE_VALUE (args), 0, 0);
2526 CHARS (1);
2527 args = TREE_CHAIN (args);
2531 /* Given a chain of ..._TYPE nodes,
2532 find those which have typedef names and output those names.
2533 This is to ensure those types get output. */
2535 void
2536 dbxout_types (types)
2537 register tree types;
2539 while (types)
2541 if (TYPE_NAME (types)
2542 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2543 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2544 dbxout_symbol (TYPE_NAME (types), 1);
2545 types = TREE_CHAIN (types);
2549 /* Output everything about a symbol block (a BLOCK node
2550 that represents a scope level),
2551 including recursive output of contained blocks.
2553 BLOCK is the BLOCK node.
2554 DEPTH is its depth within containing symbol blocks.
2555 ARGS is usually zero; but for the outermost block of the
2556 body of a function, it is a chain of PARM_DECLs for the function parameters.
2557 We output definitions of all the register parms
2558 as if they were local variables of that block.
2560 If -g1 was used, we count blocks just the same, but output nothing
2561 except for the outermost block.
2563 Actually, BLOCK may be several blocks chained together.
2564 We handle them all in sequence. */
2566 static void
2567 dbxout_block (block, depth, args)
2568 register tree block;
2569 int depth;
2570 tree args;
2572 int blocknum = -1;
2574 while (block)
2576 /* Ignore blocks never expanded or otherwise marked as real. */
2577 if (TREE_USED (block))
2579 #ifndef DBX_LBRAC_FIRST
2580 /* In dbx format, the syms of a block come before the N_LBRAC. */
2581 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2582 dbxout_syms (BLOCK_VARS (block));
2583 if (args)
2584 dbxout_reg_parms (args);
2585 #endif
2587 /* Now output an N_LBRAC symbol to represent the beginning of
2588 the block. Use the block's tree-walk order to generate
2589 the assembler symbols LBBn and LBEn
2590 that final will define around the code in this block. */
2591 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2593 char buf[20];
2594 blocknum = next_block_number++;
2595 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2597 if (BLOCK_HANDLER_BLOCK (block))
2599 /* A catch block. Must precede N_LBRAC. */
2600 tree decl = BLOCK_VARS (block);
2601 while (decl)
2603 #ifdef DBX_OUTPUT_CATCH
2604 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2605 #else
2606 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2607 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2608 assemble_name (asmfile, buf);
2609 fprintf (asmfile, "\n");
2610 #endif
2611 decl = TREE_CHAIN (decl);
2615 #ifdef DBX_OUTPUT_LBRAC
2616 DBX_OUTPUT_LBRAC (asmfile, buf);
2617 #else
2618 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2619 assemble_name (asmfile, buf);
2620 #if DBX_BLOCKS_FUNCTION_RELATIVE
2621 fputc ('-', asmfile);
2622 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2623 #endif
2624 fprintf (asmfile, "\n");
2625 #endif
2627 else if (depth > 0)
2628 /* Count blocks the same way regardless of debug_info_level. */
2629 next_block_number++;
2631 #ifdef DBX_LBRAC_FIRST
2632 /* On some weird machines, the syms of a block
2633 come after the N_LBRAC. */
2634 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2635 dbxout_syms (BLOCK_VARS (block));
2636 if (args)
2637 dbxout_reg_parms (args);
2638 #endif
2640 /* Output the subblocks. */
2641 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2643 /* Refer to the marker for the end of the block. */
2644 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2646 char buf[20];
2647 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2648 #ifdef DBX_OUTPUT_RBRAC
2649 DBX_OUTPUT_RBRAC (asmfile, buf);
2650 #else
2651 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2652 assemble_name (asmfile, buf);
2653 #if DBX_BLOCKS_FUNCTION_RELATIVE
2654 fputc ('-', asmfile);
2655 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2656 #endif
2657 fprintf (asmfile, "\n");
2658 #endif
2661 block = BLOCK_CHAIN (block);
2665 /* Output the information about a function and its arguments and result.
2666 Usually this follows the function's code,
2667 but on some systems, it comes before. */
2669 static void
2670 dbxout_really_begin_function (decl)
2671 tree decl;
2673 dbxout_symbol (decl, 0);
2674 dbxout_parms (DECL_ARGUMENTS (decl));
2675 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2676 dbxout_symbol (DECL_RESULT (decl), 1);
2679 /* Called at beginning of output of function definition. */
2681 void
2682 dbxout_begin_function (decl)
2683 tree decl ATTRIBUTE_UNUSED;
2685 #ifdef DBX_FUNCTION_FIRST
2686 dbxout_really_begin_function (decl);
2687 #endif
2690 /* Output dbx data for a function definition.
2691 This includes a definition of the function name itself (a symbol),
2692 definitions of the parameters (locating them in the parameter list)
2693 and then output the block that makes up the function's body
2694 (including all the auto variables of the function). */
2696 void
2697 dbxout_function (decl)
2698 tree decl;
2700 #ifndef DBX_FUNCTION_FIRST
2701 dbxout_really_begin_function (decl);
2702 #endif
2703 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2704 #ifdef DBX_OUTPUT_FUNCTION_END
2705 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2706 #endif
2707 #if defined(ASM_OUTPUT_SECTION_NAME)
2708 if (use_gnu_debug_info_extensions
2709 #if defined(NO_DBX_FUNCTION_END)
2710 && ! NO_DBX_FUNCTION_END
2711 #endif
2713 dbxout_function_end ();
2714 #endif
2716 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */