* dbxout.c (current_file): Wrap declaration in DBX_USE_BINCL.
[gcc.git] / gcc / dbxout.c
1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22
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.
31
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.
36
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.
43
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".
49
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'.
54
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.
59
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.
65
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
68
69 For more on data type definitions, see `dbxout_type'. */
70
71 #include "config.h"
72 #include "system.h"
73 #include "coretypes.h"
74 #include "tm.h"
75
76 #include "tree.h"
77 #include "rtl.h"
78 #include "flags.h"
79 #include "regs.h"
80 #include "insn-config.h"
81 #include "reload.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
83 #include "dbxout.h"
84 #include "toplev.h"
85 #include "tm_p.h"
86 #include "ggc.h"
87 #include "debug.h"
88 #include "function.h"
89 #include "target.h"
90 #include "langhooks.h"
91
92 #ifdef XCOFF_DEBUGGING_INFO
93 #include "xcoffout.h"
94 #endif
95
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
100
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103 do {--debug_nesting; return (x);} while (0)
104
105 #ifndef ASM_STABS_OP
106 #define ASM_STABS_OP "\t.stabs\t"
107 #endif
108
109 #ifndef ASM_STABN_OP
110 #define ASM_STABN_OP "\t.stabn\t"
111 #endif
112
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
115 #endif
116
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
119 #endif
120
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
123 #endif
124
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
127 #endif
128
129 /* This is used for parameters passed by invisible reference in a register. */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
132 #endif
133
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
136 #endif
137
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
140 #endif
141
142 /* GDB needs to know that the stabs were generated by GCC. We emit an
143 N_OPT stab at the beginning of the source file to indicate this.
144 The string is historical, and different on a very few targets. */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
147 #endif
148
149 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
150
151 /* Structure recording information about a C data type.
152 The status element says whether we have yet output
153 the definition of the type. TYPE_XREF says we have
154 output it as a cross-reference only.
155 The file_number and type_number elements are used if DBX_USE_BINCL
156 is defined. */
157
158 struct typeinfo GTY(())
159 {
160 enum typestatus status;
161 int file_number;
162 int type_number;
163 };
164
165 /* Vector recording information about C data types.
166 When we first notice a data type (a tree node),
167 we assign it a number using next_type_number.
168 That is its index in this vector. */
169
170 static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
171
172 /* Number of elements of space allocated in `typevec'. */
173
174 static GTY(()) int typevec_len;
175
176 /* In dbx output, each type gets a unique number.
177 This is the number for the next type output.
178 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
179
180 static GTY(()) int next_type_number;
181
182 enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED};
183
184 /* When using N_BINCL in dbx output, each type number is actually a
185 pair of the file number and the type number within the file.
186 This is a stack of input files. */
187
188 struct dbx_file
189 {
190 struct dbx_file *next;
191 int file_number;
192 int next_type_number;
193 enum binclstatus bincl_status; /* Keep track of lazy bincl. */
194 const char *pending_bincl_name; /* Name of bincl. */
195 struct dbx_file *prev; /* Chain to traverse all pending bincls. */
196 };
197
198 /* This is the top of the stack.
199
200 This is not saved for PCH, because restoring a PCH should not change it.
201 next_file_number does have to be saved, because the PCH may use some
202 file numbers; however, just before restoring a PCH, next_file_number
203 should always be 0 because we should not have needed any file numbers
204 yet. */
205
206 #ifdef DBX_USE_BINCL
207 static struct dbx_file *current_file;
208 #endif
209
210 /* This is the next file number to use. */
211
212 static GTY(()) int next_file_number;
213
214 /* A counter for dbxout_function_end. */
215
216 static GTY(()) int scope_labelno;
217
218 /* A counter for dbxout_source_line. */
219
220 static GTY(()) int dbxout_source_line_counter;
221
222 /* Nonzero if we have actually used any of the GDB extensions
223 to the debugging format. The idea is that we use them for the
224 first time only if there's a strong reason, but once we have done that,
225 we use them whenever convenient. */
226
227 static GTY(()) int have_used_extensions = 0;
228
229 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
230 for the N_SO filename stabs label. */
231
232 static GTY(()) int source_label_number = 1;
233
234 /* Last source file name mentioned in a NOTE insn. */
235
236 static GTY(()) const char *lastfile;
237
238 /* Used by PCH machinery to detect if 'lastfile' should be reset to
239 base_input_file. */
240 static GTY(()) int lastfile_is_base;
241
242 /* Typical USG systems don't have stab.h, and they also have
243 no use for DBX-format debugging info. */
244
245 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
246
247 #ifdef DBX_USE_BINCL
248 /* If zero then there is no pending BINCL. */
249 static int pending_bincls = 0;
250 #endif
251
252 /* The original input file name. */
253 static const char *base_input_file;
254
255 /* Current working directory. */
256
257 static const char *cwd;
258
259 #ifdef DEBUG_SYMS_TEXT
260 #define FORCE_TEXT function_section (current_function_decl);
261 #else
262 #define FORCE_TEXT
263 #endif
264
265 #include "gstab.h"
266
267 #define STAB_CODE_TYPE enum __stab_debug_code
268
269 /* 1 if PARM is passed to this function in memory. */
270
271 #define PARM_PASSED_IN_MEMORY(PARM) \
272 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
273
274 /* A C expression for the integer offset value of an automatic variable
275 (N_LSYM) having address X (an RTX). */
276 #ifndef DEBUGGER_AUTO_OFFSET
277 #define DEBUGGER_AUTO_OFFSET(X) \
278 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
279 #endif
280
281 /* A C expression for the integer offset value of an argument (N_PSYM)
282 having address X (an RTX). The nominal offset is OFFSET. */
283 #ifndef DEBUGGER_ARG_OFFSET
284 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
285 #endif
286
287 /* Stream for writing to assembler file. */
288
289 static FILE *asmfile;
290
291 /* These variables are for dbxout_symbol to communicate to
292 dbxout_finish_symbol.
293 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
294 current_sym_value and current_sym_addr are two ways to address the
295 value to store in the symtab entry.
296 current_sym_addr if nonzero represents the value as an rtx.
297 If that is zero, current_sym_value is used. This is used
298 when the value is an offset (such as for auto variables,
299 register variables and parms). */
300
301 static STAB_CODE_TYPE current_sym_code;
302 static int current_sym_value;
303 static rtx current_sym_addr;
304
305 /* Number of chars of symbol-description generated so far for the
306 current symbol. Used by CHARS and CONTIN. */
307
308 static int current_sym_nchars;
309
310 /* Report having output N chars of the current symbol-description. */
311
312 #define CHARS(N) (current_sym_nchars += (N))
313
314 /* Break the current symbol-description, generating a continuation,
315 if it has become long. */
316
317 #ifndef DBX_CONTIN_LENGTH
318 #define DBX_CONTIN_LENGTH 80
319 #endif
320
321 #if DBX_CONTIN_LENGTH > 0
322 #define CONTIN \
323 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
324 #else
325 #define CONTIN do { } while (0)
326 #endif
327
328 #ifdef DBX_USE_BINCL
329 static void emit_bincl_stab (const char *c);
330 static void emit_pending_bincls (void);
331 #endif
332 static inline void emit_pending_bincls_if_required (void);
333
334 static void dbxout_init (const char *);
335 static void dbxout_finish (const char *);
336 static void dbxout_start_source_file (unsigned, const char *);
337 static void dbxout_end_source_file (unsigned);
338 static void dbxout_typedefs (tree);
339 static void dbxout_type_index (tree);
340 #if DBX_CONTIN_LENGTH > 0
341 static void dbxout_continue (void);
342 #endif
343 static void dbxout_args (tree);
344 static void dbxout_type_fields (tree);
345 static void dbxout_type_method_1 (tree, const char *);
346 static void dbxout_type_methods (tree);
347 static void dbxout_range_type (tree);
348 static void dbxout_type (tree, int);
349 static bool print_int_cst_bounds_in_octal_p (tree);
350 static void print_int_cst_octal (tree);
351 static void print_octal (unsigned HOST_WIDE_INT, int);
352 static void print_wide_int (HOST_WIDE_INT);
353 static void dbxout_type_name (tree);
354 static void dbxout_class_name_qualifiers (tree);
355 static int dbxout_symbol_location (tree, tree, const char *, rtx);
356 static void dbxout_symbol_name (tree, const char *, int);
357 static void dbxout_prepare_symbol (tree);
358 static void dbxout_finish_symbol (tree);
359 static void dbxout_block (tree, int, tree);
360 static void dbxout_global_decl (tree);
361 static void dbxout_handle_pch (unsigned);
362 \f
363 /* The debug hooks structure. */
364 #if defined (DBX_DEBUGGING_INFO)
365
366 static void dbxout_source_line (unsigned int, const char *);
367 static void dbxout_source_file (FILE *, const char *);
368 static void dbxout_function_end (void);
369 static void dbxout_begin_function (tree);
370 static void dbxout_begin_block (unsigned, unsigned);
371 static void dbxout_end_block (unsigned, unsigned);
372 static void dbxout_function_decl (tree);
373
374 const struct gcc_debug_hooks dbx_debug_hooks =
375 {
376 dbxout_init,
377 dbxout_finish,
378 debug_nothing_int_charstar,
379 debug_nothing_int_charstar,
380 dbxout_start_source_file,
381 dbxout_end_source_file,
382 dbxout_begin_block,
383 dbxout_end_block,
384 debug_true_tree, /* ignore_block */
385 dbxout_source_line, /* source_line */
386 dbxout_source_line, /* begin_prologue: just output line info */
387 debug_nothing_int_charstar, /* end_prologue */
388 debug_nothing_int_charstar, /* end_epilogue */
389 #ifdef DBX_FUNCTION_FIRST
390 dbxout_begin_function,
391 #else
392 debug_nothing_tree, /* begin_function */
393 #endif
394 debug_nothing_int, /* end_function */
395 dbxout_function_decl,
396 dbxout_global_decl, /* global_decl */
397 debug_nothing_tree, /* deferred_inline_function */
398 debug_nothing_tree, /* outlining_inline_function */
399 debug_nothing_rtx, /* label */
400 dbxout_handle_pch /* handle_pch */
401 };
402 #endif /* DBX_DEBUGGING_INFO */
403
404 #if defined (XCOFF_DEBUGGING_INFO)
405 const struct gcc_debug_hooks xcoff_debug_hooks =
406 {
407 dbxout_init,
408 dbxout_finish,
409 debug_nothing_int_charstar,
410 debug_nothing_int_charstar,
411 dbxout_start_source_file,
412 dbxout_end_source_file,
413 xcoffout_begin_block,
414 xcoffout_end_block,
415 debug_true_tree, /* ignore_block */
416 xcoffout_source_line,
417 xcoffout_begin_prologue, /* begin_prologue */
418 debug_nothing_int_charstar, /* end_prologue */
419 xcoffout_end_epilogue,
420 debug_nothing_tree, /* begin_function */
421 xcoffout_end_function,
422 debug_nothing_tree, /* function_decl */
423 dbxout_global_decl, /* global_decl */
424 debug_nothing_tree, /* deferred_inline_function */
425 debug_nothing_tree, /* outlining_inline_function */
426 debug_nothing_rtx, /* label */
427 dbxout_handle_pch /* handle_pch */
428 };
429 #endif /* XCOFF_DEBUGGING_INFO */
430 \f
431 #if defined (DBX_DEBUGGING_INFO)
432 static void
433 dbxout_function_end (void)
434 {
435 char lscope_label_name[100];
436 /* Convert Ltext into the appropriate format for local labels in case
437 the system doesn't insert underscores in front of user generated
438 labels. */
439 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
440 (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
441 scope_labelno++;
442
443 /* By convention, GCC will mark the end of a function with an N_FUN
444 symbol and an empty string. */
445 #ifdef DBX_OUTPUT_NFUN
446 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
447 #else
448 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
449 assemble_name (asmfile, lscope_label_name);
450 putc ('-', asmfile);
451 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
452 fprintf (asmfile, "\n");
453 #endif
454 }
455 #endif /* DBX_DEBUGGING_INFO */
456
457 /* At the beginning of compilation, start writing the symbol table.
458 Initialize `typevec' and output the standard data types of C. */
459
460 static void
461 dbxout_init (const char *input_file_name)
462 {
463 char ltext_label_name[100];
464 tree syms = (*lang_hooks.decls.getdecls) ();
465
466 asmfile = asm_out_file;
467
468 typevec_len = 100;
469 typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
470
471 /* Convert Ltext into the appropriate format for local labels in case
472 the system doesn't insert underscores in front of user generated
473 labels. */
474 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
475
476 /* Put the current working directory in an N_SO symbol. */
477 if (use_gnu_debug_info_extensions)
478 {
479 if (!cwd && (cwd = get_src_pwd ())
480 && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
481 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
482 if (cwd)
483 {
484 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
485 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
486 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
487 fprintf (asmfile, "%s", ASM_STABS_OP);
488 output_quoted_string (asmfile, cwd);
489 fprintf (asmfile, ",%d,0,0,", N_SO);
490 assemble_name (asmfile, ltext_label_name);
491 fputc ('\n', asmfile);
492 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
493 }
494 }
495
496 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
497 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
498 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
499 /* We include outputting `Ltext:' here,
500 because that gives you a way to override it. */
501 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
502 fprintf (asmfile, "%s", ASM_STABS_OP);
503 output_quoted_string (asmfile, input_file_name);
504 fprintf (asmfile, ",%d,0,0,", N_SO);
505 assemble_name (asmfile, ltext_label_name);
506 fputc ('\n', asmfile);
507 text_section ();
508 (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
509 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
510
511 #ifdef DBX_OUTPUT_GCC_MARKER
512 DBX_OUTPUT_GCC_MARKER (asmfile);
513 #else
514 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
515 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
516 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
517 #endif
518
519 base_input_file = lastfile = input_file_name;
520
521 next_type_number = 1;
522
523 #ifdef DBX_USE_BINCL
524 current_file = xmalloc (sizeof *current_file);
525 current_file->next = NULL;
526 current_file->file_number = 0;
527 current_file->next_type_number = 1;
528 next_file_number = 1;
529 current_file->prev = NULL;
530 current_file->bincl_status = BINCL_NOT_REQUIRED;
531 current_file->pending_bincl_name = NULL;
532 #endif
533
534 /* Make sure that types `int' and `char' have numbers 1 and 2.
535 Definitions of other integer types will refer to those numbers.
536 (Actually it should no longer matter what their numbers are.
537 Also, if any types with tags have been defined, dbxout_symbol
538 will output them first, so the numbers won't be 1 and 2. That
539 happens in C++. So it's a good thing it should no longer matter). */
540
541 #ifdef DBX_OUTPUT_STANDARD_TYPES
542 DBX_OUTPUT_STANDARD_TYPES (syms);
543 #endif
544
545 /* Get all permanent types that have typedef names, and output them
546 all, except for those already output. Some language front ends
547 put these declarations in the top-level scope; some do not. */
548 dbxout_typedefs ((*lang_hooks.decls.builtin_type_decls) ());
549 dbxout_typedefs (syms);
550 }
551
552 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
553
554 static void
555 dbxout_typedefs (tree syms)
556 {
557 for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
558 {
559 if (TREE_CODE (syms) == TYPE_DECL)
560 {
561 tree type = TREE_TYPE (syms);
562 if (TYPE_NAME (type)
563 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
564 && COMPLETE_OR_VOID_TYPE_P (type)
565 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
566 dbxout_symbol (TYPE_NAME (type), 0);
567 }
568 }
569 }
570
571 #ifdef DBX_USE_BINCL
572 /* Emit BINCL stab using given name. */
573 static void
574 emit_bincl_stab (const char *name)
575 {
576 fprintf (asmfile, "%s", ASM_STABS_OP);
577 output_quoted_string (asmfile, name);
578 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
579 }
580
581 /* If there are pending bincls then it is time to emit all of them. */
582
583 static inline void
584 emit_pending_bincls_if_required (void)
585 {
586 if (pending_bincls)
587 emit_pending_bincls ();
588 }
589
590 /* Emit all pending bincls. */
591
592 static void
593 emit_pending_bincls (void)
594 {
595 struct dbx_file *f = current_file;
596
597 /* Find first pending bincl. */
598 while (f->bincl_status == BINCL_PENDING)
599 f = f->next;
600
601 /* Now emit all bincls. */
602 f = f->prev;
603
604 while (f)
605 {
606 if (f->bincl_status == BINCL_PENDING)
607 {
608 emit_bincl_stab (f->pending_bincl_name);
609
610 /* Update file number and status. */
611 f->file_number = next_file_number++;
612 f->bincl_status = BINCL_PROCESSED;
613 }
614 if (f == current_file)
615 break;
616 f = f->prev;
617 }
618
619 /* All pending bincls have been emitted. */
620 pending_bincls = 0;
621 }
622
623 #else
624
625 static inline void
626 emit_pending_bincls_if_required (void) {}
627 #endif
628
629 /* Change to reading from a new source file. Generate a N_BINCL stab. */
630
631 static void
632 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
633 const char *filename ATTRIBUTE_UNUSED)
634 {
635 #ifdef DBX_USE_BINCL
636 struct dbx_file *n = xmalloc (sizeof *n);
637
638 n->next = current_file;
639 n->next_type_number = 1;
640 /* Do not assign file number now.
641 Delay it until we actually emit BINCL. */
642 n->file_number = 0;
643 n->prev = NULL;
644 current_file->prev = n;
645 n->bincl_status = BINCL_PENDING;
646 n->pending_bincl_name = filename;
647 pending_bincls = 1;
648 current_file = n;
649 #endif
650 }
651
652 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
653
654 static void
655 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
656 {
657 #ifdef DBX_USE_BINCL
658 /* Emit EINCL stab only if BINCL is not pending. */
659 if (current_file->bincl_status == BINCL_PROCESSED)
660 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
661 current_file->bincl_status = BINCL_NOT_REQUIRED;
662 current_file = current_file->next;
663 #endif
664 }
665
666 /* Handle a few odd cases that occur when trying to make PCH files work. */
667
668 static void
669 dbxout_handle_pch (unsigned at_end)
670 {
671 if (! at_end)
672 {
673 /* When using the PCH, this file will be included, so we need to output
674 a BINCL. */
675 dbxout_start_source_file (0, lastfile);
676
677 /* The base file when using the PCH won't be the same as
678 the base file when it's being generated. */
679 lastfile = NULL;
680 }
681 else
682 {
683 /* ... and an EINCL. */
684 dbxout_end_source_file (0);
685
686 /* Deal with cases where 'lastfile' was never actually changed. */
687 lastfile_is_base = lastfile == NULL;
688 }
689 }
690
691 #if defined (DBX_DEBUGGING_INFO)
692 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
693
694 static void
695 dbxout_source_file (FILE *file, const char *filename)
696 {
697 if (lastfile == 0 && lastfile_is_base)
698 {
699 lastfile = base_input_file;
700 lastfile_is_base = 0;
701 }
702
703 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
704 {
705 char ltext_label_name[100];
706
707 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
708 source_label_number);
709 fprintf (file, "%s", ASM_STABS_OP);
710 output_quoted_string (file, filename);
711 fprintf (asmfile, ",%d,0,0,", N_SOL);
712 assemble_name (asmfile, ltext_label_name);
713 fputc ('\n', asmfile);
714 if (current_function_decl != NULL_TREE
715 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
716 ; /* Don't change section amid function. */
717 else
718 text_section ();
719 (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
720 source_label_number++;
721 lastfile = filename;
722 }
723 }
724
725 /* Output a line number symbol entry for source file FILENAME and line
726 number LINENO. */
727
728 static void
729 dbxout_source_line (unsigned int lineno, const char *filename)
730 {
731 dbxout_source_file (asmfile, filename);
732
733 #ifdef ASM_OUTPUT_SOURCE_LINE
734 dbxout_source_line_counter += 1;
735 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
736 #else
737 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
738 #endif
739 }
740
741 /* Describe the beginning of an internal block within a function. */
742
743 static void
744 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
745 {
746 emit_pending_bincls_if_required ();
747 (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
748 }
749
750 /* Describe the end line-number of an internal block within a function. */
751
752 static void
753 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
754 {
755 emit_pending_bincls_if_required ();
756 (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
757 }
758
759 /* Output dbx data for a function definition.
760 This includes a definition of the function name itself (a symbol),
761 definitions of the parameters (locating them in the parameter list)
762 and then output the block that makes up the function's body
763 (including all the auto variables of the function). */
764
765 static void
766 dbxout_function_decl (tree decl)
767 {
768 emit_pending_bincls_if_required ();
769 #ifndef DBX_FUNCTION_FIRST
770 dbxout_begin_function (decl);
771 #endif
772 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
773 #ifdef DBX_OUTPUT_FUNCTION_END
774 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
775 #endif
776 if (use_gnu_debug_info_extensions
777 #if defined(NO_DBX_FUNCTION_END)
778 && ! NO_DBX_FUNCTION_END
779 #endif
780 && targetm.have_named_sections)
781 dbxout_function_end ();
782 }
783
784 #endif /* DBX_DEBUGGING_INFO */
785
786 /* Debug information for a global DECL. Called from toplev.c after
787 compilation proper has finished. */
788 static void
789 dbxout_global_decl (tree decl)
790 {
791 if (TREE_CODE (decl) == VAR_DECL
792 && ! DECL_EXTERNAL (decl)
793 && DECL_RTL_SET_P (decl)) /* Not necessary? */
794 {
795 int saved_tree_used = TREE_USED (decl);
796 TREE_USED (decl) = 1;
797 dbxout_symbol (decl, 0);
798 TREE_USED (decl) = saved_tree_used;
799 }
800 }
801
802 /* At the end of compilation, finish writing the symbol table.
803 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
804 to do nothing. */
805
806 static void
807 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
808 {
809 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
810 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
811 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
812
813 debug_free_queue ();
814 }
815
816 /* Output the index of a type. */
817
818 static void
819 dbxout_type_index (tree type)
820 {
821 #ifndef DBX_USE_BINCL
822 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
823 CHARS (3);
824 #else
825 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
826 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
827 CHARS (9);
828 #endif
829 }
830
831 #if DBX_CONTIN_LENGTH > 0
832 /* Continue a symbol-description that gets too big.
833 End one symbol table entry with a double-backslash
834 and start a new one, eventually producing something like
835 .stabs "start......\\",code,0,value
836 .stabs "...rest",code,0,value */
837
838 static void
839 dbxout_continue (void)
840 {
841 emit_pending_bincls_if_required ();
842 #ifdef DBX_CONTIN_CHAR
843 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
844 #else
845 fprintf (asmfile, "\\\\");
846 #endif
847 dbxout_finish_symbol (NULL_TREE);
848 fprintf (asmfile, "%s\"", ASM_STABS_OP);
849 current_sym_nchars = 0;
850 }
851 #endif /* DBX_CONTIN_LENGTH > 0 */
852 \f
853 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
854 This must be a separate function because anonymous unions require
855 recursive calls. */
856
857 static void
858 dbxout_type_fields (tree type)
859 {
860 tree tem;
861
862 /* Output the name, type, position (in bits), size (in bits) of each
863 field that we can support. */
864 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
865 {
866 /* Omit here local type decls until we know how to support them. */
867 if (TREE_CODE (tem) == TYPE_DECL
868 /* Omit fields whose position or size are variable or too large to
869 represent. */
870 || (TREE_CODE (tem) == FIELD_DECL
871 && (! host_integerp (bit_position (tem), 0)
872 || ! DECL_SIZE (tem)
873 || ! host_integerp (DECL_SIZE (tem), 1)))
874 /* Omit here the nameless fields that are used to skip bits. */
875 || DECL_IGNORED_P (tem))
876 continue;
877
878 else if (TREE_CODE (tem) != CONST_DECL)
879 {
880 /* Continue the line if necessary,
881 but not before the first field. */
882 if (tem != TYPE_FIELDS (type))
883 CONTIN;
884
885 if (DECL_NAME (tem))
886 {
887 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
888 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
889 }
890 else
891 {
892 fprintf (asmfile, ":");
893 CHARS (1);
894 }
895
896 if (use_gnu_debug_info_extensions
897 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
898 || TREE_CODE (tem) != FIELD_DECL))
899 {
900 have_used_extensions = 1;
901 putc ('/', asmfile);
902 putc ((TREE_PRIVATE (tem) ? '0'
903 : TREE_PROTECTED (tem) ? '1' : '2'),
904 asmfile);
905 CHARS (2);
906 }
907
908 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
909 && DECL_BIT_FIELD_TYPE (tem))
910 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
911
912 if (TREE_CODE (tem) == VAR_DECL)
913 {
914 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
915 {
916 tree name = DECL_ASSEMBLER_NAME (tem);
917
918 have_used_extensions = 1;
919 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
920 CHARS (IDENTIFIER_LENGTH (name) + 2);
921 }
922 else
923 {
924 /* If TEM is non-static, GDB won't understand it. */
925 fprintf (asmfile, ",0,0;");
926 CHARS (5);
927 }
928 }
929 else
930 {
931 putc (',', asmfile);
932 print_wide_int (int_bit_position (tem));
933 putc (',', asmfile);
934 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
935 putc (';', asmfile);
936 CHARS (3);
937 }
938 }
939 }
940 }
941 \f
942 /* Subroutine of `dbxout_type_methods'. Output debug info about the
943 method described DECL. DEBUG_NAME is an encoding of the method's
944 type signature. ??? We may be able to do without DEBUG_NAME altogether
945 now. */
946
947 static void
948 dbxout_type_method_1 (tree decl, const char *debug_name)
949 {
950 char c1 = 'A', c2;
951
952 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
953 c2 = '?';
954 else /* it's a METHOD_TYPE. */
955 {
956 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
957 /* A for normal functions.
958 B for `const' member functions.
959 C for `volatile' member functions.
960 D for `const volatile' member functions. */
961 if (TYPE_READONLY (TREE_TYPE (firstarg)))
962 c1 += 1;
963 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
964 c1 += 2;
965
966 if (DECL_VINDEX (decl))
967 c2 = '*';
968 else
969 c2 = '.';
970 }
971
972 fprintf (asmfile, ":%s;%c%c%c", debug_name,
973 TREE_PRIVATE (decl) ? '0'
974 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
975 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
976 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
977
978 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
979 {
980 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
981 putc (';', asmfile);
982 CHARS (1);
983 dbxout_type (DECL_CONTEXT (decl), 0);
984 fprintf (asmfile, ";");
985 CHARS (1);
986 }
987 }
988 \f
989 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
990 in TYPE. */
991
992 static void
993 dbxout_type_methods (tree type)
994 {
995 /* C++: put out the method names and their parameter lists */
996 tree methods = TYPE_METHODS (type);
997 tree type_encoding;
998 tree fndecl;
999 tree last;
1000 char formatted_type_identifier_length[16];
1001 int type_identifier_length;
1002
1003 if (methods == NULL_TREE)
1004 return;
1005
1006 type_encoding = DECL_NAME (TYPE_NAME (type));
1007
1008 #if 0
1009 /* C++: Template classes break some assumptions made by this code about
1010 the class names, constructor names, and encodings for assembler
1011 label names. For now, disable output of dbx info for them. */
1012 {
1013 const char *ptr = IDENTIFIER_POINTER (type_encoding);
1014 /* This should use index. (mrs) */
1015 while (*ptr && *ptr != '<') ptr++;
1016 if (*ptr != 0)
1017 {
1018 static int warned;
1019 if (!warned)
1020 warned = 1;
1021 return;
1022 }
1023 }
1024 #endif
1025
1026 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1027
1028 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1029
1030 if (TREE_CODE (methods) != TREE_VEC)
1031 fndecl = methods;
1032 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1033 fndecl = TREE_VEC_ELT (methods, 0);
1034 else
1035 fndecl = TREE_VEC_ELT (methods, 1);
1036
1037 while (fndecl)
1038 {
1039 int need_prefix = 1;
1040
1041 /* Group together all the methods for the same operation.
1042 These differ in the types of the arguments. */
1043 for (last = NULL_TREE;
1044 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1045 fndecl = TREE_CHAIN (fndecl))
1046 /* Output the name of the field (after overloading), as
1047 well as the name of the field before overloading, along
1048 with its parameter list */
1049 {
1050 /* This is the "mangled" name of the method.
1051 It encodes the argument types. */
1052 const char *debug_name;
1053
1054 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1055 include TEMPLATE_DECLs.) The debugger doesn't know what
1056 to do with such entities anyhow. */
1057 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1058 continue;
1059
1060 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1061
1062 CONTIN;
1063
1064 last = fndecl;
1065
1066 /* Also ignore abstract methods; those are only interesting to
1067 the DWARF backends. */
1068 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1069 continue;
1070
1071 /* Redundantly output the plain name, since that's what gdb
1072 expects. */
1073 if (need_prefix)
1074 {
1075 tree name = DECL_NAME (fndecl);
1076 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1077 CHARS (IDENTIFIER_LENGTH (name) + 2);
1078 need_prefix = 0;
1079 }
1080
1081 dbxout_type (TREE_TYPE (fndecl), 0);
1082
1083 dbxout_type_method_1 (fndecl, debug_name);
1084 }
1085 if (!need_prefix)
1086 {
1087 putc (';', asmfile);
1088 CHARS (1);
1089 }
1090 }
1091 }
1092
1093 /* Emit a "range" type specification, which has the form:
1094 "r<index type>;<lower bound>;<upper bound>;".
1095 TYPE is an INTEGER_TYPE. */
1096
1097 static void
1098 dbxout_range_type (tree type)
1099 {
1100 fprintf (asmfile, "r");
1101 if (TREE_TYPE (type))
1102 dbxout_type (TREE_TYPE (type), 0);
1103 else if (TREE_CODE (type) != INTEGER_TYPE)
1104 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1105 else
1106 {
1107 /* Traditionally, we made sure 'int' was type 1, and builtin types
1108 were defined to be sub-ranges of int. Unfortunately, this
1109 does not allow us to distinguish true sub-ranges from integer
1110 types. So, instead we define integer (non-sub-range) types as
1111 sub-ranges of themselves. This matters for Chill. If this isn't
1112 a subrange type, then we want to define it in terms of itself.
1113 However, in C, this may be an anonymous integer type, and we don't
1114 want to emit debug info referring to it. Just calling
1115 dbxout_type_index won't work anyways, because the type hasn't been
1116 defined yet. We make this work for both cases by checked to see
1117 whether this is a defined type, referring to it if it is, and using
1118 'int' otherwise. */
1119 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1120 dbxout_type_index (type);
1121 else
1122 dbxout_type_index (integer_type_node);
1123 }
1124
1125 if (TYPE_MIN_VALUE (type) != 0
1126 && host_integerp (TYPE_MIN_VALUE (type), 0))
1127 {
1128 putc (';', asmfile);
1129 CHARS (1);
1130 if (print_int_cst_bounds_in_octal_p (type))
1131 print_int_cst_octal (TYPE_MIN_VALUE (type));
1132 else
1133 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1134 }
1135 else
1136 {
1137 fprintf (asmfile, ";0");
1138 CHARS (2);
1139 }
1140
1141 if (TYPE_MAX_VALUE (type) != 0
1142 && host_integerp (TYPE_MAX_VALUE (type), 0))
1143 {
1144 putc (';', asmfile);
1145 CHARS (1);
1146 if (print_int_cst_bounds_in_octal_p (type))
1147 print_int_cst_octal (TYPE_MAX_VALUE (type));
1148 else
1149 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1150 putc (';', asmfile);
1151 CHARS (1);
1152 }
1153 else
1154 {
1155 fprintf (asmfile, ";-1;");
1156 CHARS (4);
1157 }
1158 }
1159 \f
1160
1161 /* Output a reference to a type. If the type has not yet been
1162 described in the dbx output, output its definition now.
1163 For a type already defined, just refer to its definition
1164 using the type number.
1165
1166 If FULL is nonzero, and the type has been described only with
1167 a forward-reference, output the definition now.
1168 If FULL is zero in this case, just refer to the forward-reference
1169 using the number previously allocated. */
1170
1171 static void
1172 dbxout_type (tree type, int full)
1173 {
1174 tree tem;
1175 tree main_variant;
1176 static int anonymous_type_number = 0;
1177
1178 if (TREE_CODE (type) == VECTOR_TYPE)
1179 /* The frontend feeds us a representation for the vector as a struct
1180 containing an array. Pull out the array type. */
1181 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1182
1183 /* If there was an input error and we don't really have a type,
1184 avoid crashing and write something that is at least valid
1185 by assuming `int'. */
1186 if (type == error_mark_node)
1187 type = integer_type_node;
1188 else
1189 {
1190 if (TYPE_NAME (type)
1191 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1192 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1193 full = 0;
1194 }
1195
1196 /* Try to find the "main variant" with the same name. */
1197 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1198 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1199 main_variant = TREE_TYPE (TYPE_NAME (type));
1200 else
1201 main_variant = TYPE_MAIN_VARIANT (type);
1202
1203 /* If we are not using extensions, stabs does not distinguish const and
1204 volatile, so there is no need to make them separate types. */
1205 if (!use_gnu_debug_info_extensions)
1206 type = main_variant;
1207
1208 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1209 {
1210 /* Type has no dbx number assigned. Assign next available number. */
1211 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1212
1213 /* Make sure type vector is long enough to record about this type. */
1214
1215 if (next_type_number == typevec_len)
1216 {
1217 typevec
1218 = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1219 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1220 typevec_len *= 2;
1221 }
1222
1223 #ifdef DBX_USE_BINCL
1224 emit_pending_bincls_if_required ();
1225 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1226 = current_file->file_number;
1227 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1228 = current_file->next_type_number++;
1229 #endif
1230 }
1231
1232 if (flag_debug_only_used_symbols)
1233 {
1234 if ((TREE_CODE (type) == RECORD_TYPE
1235 || TREE_CODE (type) == UNION_TYPE
1236 || TREE_CODE (type) == QUAL_UNION_TYPE
1237 || TREE_CODE (type) == ENUMERAL_TYPE)
1238 && TYPE_STUB_DECL (type)
1239 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1240 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1241 debug_queue_symbol (TYPE_STUB_DECL (type));
1242 else if (TYPE_NAME (type)
1243 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1244 debug_queue_symbol (TYPE_NAME (type));
1245 }
1246
1247 /* Output the number of this type, to refer to it. */
1248 dbxout_type_index (type);
1249
1250 #ifdef DBX_TYPE_DEFINED
1251 if (DBX_TYPE_DEFINED (type))
1252 return;
1253 #endif
1254
1255 /* If this type's definition has been output or is now being output,
1256 that is all. */
1257
1258 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1259 {
1260 case TYPE_UNSEEN:
1261 break;
1262 case TYPE_XREF:
1263 /* If we have already had a cross reference,
1264 and either that's all we want or that's the best we could do,
1265 don't repeat the cross reference.
1266 Sun dbx crashes if we do. */
1267 if (! full || !COMPLETE_TYPE_P (type)
1268 /* No way in DBX fmt to describe a variable size. */
1269 || ! host_integerp (TYPE_SIZE (type), 1))
1270 return;
1271 break;
1272 case TYPE_DEFINED:
1273 return;
1274 }
1275
1276 #ifdef DBX_NO_XREFS
1277 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1278 leave the type-number completely undefined rather than output
1279 a cross-reference. If we have already used GNU debug info extensions,
1280 then it is OK to output a cross reference. This is necessary to get
1281 proper C++ debug output. */
1282 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1283 || TREE_CODE (type) == QUAL_UNION_TYPE
1284 || TREE_CODE (type) == ENUMERAL_TYPE)
1285 && ! use_gnu_debug_info_extensions)
1286 /* We must use the same test here as we use twice below when deciding
1287 whether to emit a cross-reference. */
1288 if ((TYPE_NAME (type) != 0
1289 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1290 && DECL_IGNORED_P (TYPE_NAME (type)))
1291 && !full)
1292 || !COMPLETE_TYPE_P (type)
1293 /* No way in DBX fmt to describe a variable size. */
1294 || ! host_integerp (TYPE_SIZE (type), 1))
1295 {
1296 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1297 return;
1298 }
1299 #endif
1300
1301 /* Output a definition now. */
1302
1303 fprintf (asmfile, "=");
1304 CHARS (1);
1305
1306 /* Mark it as defined, so that if it is self-referent
1307 we will not get into an infinite recursion of definitions. */
1308
1309 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1310
1311 /* If this type is a variant of some other, hand off. Types with
1312 different names are usefully distinguished. We only distinguish
1313 cv-qualified types if we're using extensions. */
1314 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1315 {
1316 putc ('k', asmfile);
1317 CHARS (1);
1318 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1319 return;
1320 }
1321 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1322 {
1323 putc ('B', asmfile);
1324 CHARS (1);
1325 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1326 return;
1327 }
1328 else if (main_variant != TYPE_MAIN_VARIANT (type))
1329 {
1330 if (flag_debug_only_used_symbols)
1331 {
1332 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1333
1334 if ((TREE_CODE (orig_type) == RECORD_TYPE
1335 || TREE_CODE (orig_type) == UNION_TYPE
1336 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1337 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1338 && TYPE_STUB_DECL (orig_type)
1339 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1340 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1341 }
1342 /* 'type' is a typedef; output the type it refers to. */
1343 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1344 return;
1345 }
1346 /* else continue. */
1347
1348 switch (TREE_CODE (type))
1349 {
1350 case VOID_TYPE:
1351 case LANG_TYPE:
1352 /* For a void type, just define it as itself; ie, "5=5".
1353 This makes us consider it defined
1354 without saying what it is. The debugger will make it
1355 a void type when the reference is seen, and nothing will
1356 ever override that default. */
1357 dbxout_type_index (type);
1358 break;
1359
1360 case INTEGER_TYPE:
1361 if (type == char_type_node && ! TREE_UNSIGNED (type))
1362 {
1363 /* Output the type `char' as a subrange of itself!
1364 I don't understand this definition, just copied it
1365 from the output of pcc.
1366 This used to use `r2' explicitly and we used to
1367 take care to make sure that `char' was type number 2. */
1368 fprintf (asmfile, "r");
1369 CHARS (1);
1370 dbxout_type_index (type);
1371 fprintf (asmfile, ";0;127;");
1372 CHARS (7);
1373 }
1374
1375 /* If this is a subtype of another integer type, always prefer to
1376 write it as a subtype. */
1377 else if (TREE_TYPE (type) != 0
1378 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1379 {
1380 /* If the size is non-standard, say what it is if we can use
1381 GDB extensions. */
1382
1383 if (use_gnu_debug_info_extensions
1384 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1385 {
1386 have_used_extensions = 1;
1387 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1388 CHARS (5);
1389 }
1390
1391 dbxout_range_type (type);
1392 }
1393
1394 else
1395 {
1396 /* If the size is non-standard, say what it is if we can use
1397 GDB extensions. */
1398
1399 if (use_gnu_debug_info_extensions
1400 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1401 {
1402 have_used_extensions = 1;
1403 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1404 CHARS (5);
1405 }
1406
1407 if (print_int_cst_bounds_in_octal_p (type))
1408 {
1409 fprintf (asmfile, "r");
1410 CHARS (1);
1411
1412 /* If this type derives from another type, output type index of
1413 parent type. This is particularly important when parent type
1414 is an enumerated type, because not generating the parent type
1415 index would transform the definition of this enumerated type
1416 into a plain unsigned type. */
1417 if (TREE_TYPE (type) != 0)
1418 dbxout_type_index (TREE_TYPE (type));
1419 else
1420 dbxout_type_index (type);
1421
1422 fprintf (asmfile, ";");
1423 CHARS (1);
1424 print_int_cst_octal (TYPE_MIN_VALUE (type));
1425 fprintf (asmfile, ";");
1426 CHARS (1);
1427 print_int_cst_octal (TYPE_MAX_VALUE (type));
1428 fprintf (asmfile, ";");
1429 CHARS (1);
1430 }
1431
1432 else
1433 /* Output other integer types as subranges of `int'. */
1434 dbxout_range_type (type);
1435 }
1436
1437 break;
1438
1439 case REAL_TYPE:
1440 /* This used to say `r1' and we used to take care
1441 to make sure that `int' was type number 1. */
1442 fprintf (asmfile, "r");
1443 CHARS (1);
1444 dbxout_type_index (integer_type_node);
1445 putc (';', asmfile);
1446 CHARS (1);
1447 print_wide_int (int_size_in_bytes (type));
1448 fputs (";0;", asmfile);
1449 CHARS (3);
1450 break;
1451
1452 case CHAR_TYPE:
1453 if (use_gnu_debug_info_extensions)
1454 {
1455 have_used_extensions = 1;
1456 fputs ("@s", asmfile);
1457 CHARS (2);
1458 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1459 fputs (";-20;", asmfile);
1460 CHARS (4);
1461 }
1462 else
1463 {
1464 /* Output the type `char' as a subrange of itself.
1465 That is what pcc seems to do. */
1466 fprintf (asmfile, "r");
1467 CHARS (1);
1468 dbxout_type_index (char_type_node);
1469 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1470 CHARS (7);
1471 }
1472 break;
1473
1474 case BOOLEAN_TYPE:
1475 if (use_gnu_debug_info_extensions)
1476 {
1477 have_used_extensions = 1;
1478 fputs ("@s", asmfile);
1479 CHARS (2);
1480 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1481 fputs (";-16;", asmfile);
1482 CHARS (4);
1483 }
1484 else /* Define as enumeral type (False, True) */
1485 {
1486 fprintf (asmfile, "eFalse:0,True:1,;");
1487 CHARS (17);
1488 }
1489 break;
1490
1491 case FILE_TYPE:
1492 putc ('d', asmfile);
1493 CHARS (1);
1494 dbxout_type (TREE_TYPE (type), 0);
1495 break;
1496
1497 case COMPLEX_TYPE:
1498 /* Differs from the REAL_TYPE by its new data type number.
1499 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1500 codes since gdb doesn't care anyway. */
1501
1502 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1503 {
1504 fputs ("R3;", asmfile);
1505 CHARS (3);
1506 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1507 fputs (";0;", asmfile);
1508 CHARS (3);
1509 }
1510 else
1511 {
1512 /* Output a complex integer type as a structure,
1513 pending some other way to do it. */
1514 putc ('s', asmfile);
1515 CHARS (1);
1516 print_wide_int (int_size_in_bytes (type));
1517 fprintf (asmfile, "real:");
1518 CHARS (5);
1519
1520 dbxout_type (TREE_TYPE (type), 0);
1521 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1522 CHARS (7);
1523 fprintf (asmfile, "imag:");
1524 CHARS (5);
1525 dbxout_type (TREE_TYPE (type), 0);
1526 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1527 TYPE_PRECISION (TREE_TYPE (type)));
1528 CHARS (10);
1529 }
1530 break;
1531
1532 case SET_TYPE:
1533 if (use_gnu_debug_info_extensions)
1534 {
1535 have_used_extensions = 1;
1536 fputs ("@s", asmfile);
1537 CHARS (2);
1538 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1539 putc (';', asmfile);
1540 CHARS (1);
1541
1542 /* Check if a bitstring type, which in Chill is
1543 different from a [power]set. */
1544 if (TYPE_STRING_FLAG (type))
1545 {
1546 fprintf (asmfile, "@S;");
1547 CHARS (3);
1548 }
1549 }
1550 putc ('S', asmfile);
1551 CHARS (1);
1552 dbxout_type (TYPE_DOMAIN (type), 0);
1553 break;
1554
1555 case ARRAY_TYPE:
1556 /* Make arrays of packed bits look like bitstrings for chill. */
1557 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1558 {
1559 have_used_extensions = 1;
1560 fputs ("@s", asmfile);
1561 CHARS (2);
1562 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1563 fprintf (asmfile, ";@S;S");
1564 CHARS (5);
1565 dbxout_type (TYPE_DOMAIN (type), 0);
1566 break;
1567 }
1568
1569 /* Output "a" followed by a range type definition
1570 for the index type of the array
1571 followed by a reference to the target-type.
1572 ar1;0;N;M for a C array of type M and size N+1. */
1573 /* Check if a character string type, which in Chill is
1574 different from an array of characters. */
1575 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1576 {
1577 have_used_extensions = 1;
1578 fprintf (asmfile, "@S;");
1579 CHARS (3);
1580 }
1581 tem = TYPE_DOMAIN (type);
1582 if (tem == NULL)
1583 {
1584 fprintf (asmfile, "ar");
1585 CHARS (2);
1586 dbxout_type_index (integer_type_node);
1587 fprintf (asmfile, ";0;-1;");
1588 CHARS (6);
1589 }
1590 else
1591 {
1592 fprintf (asmfile, "a");
1593 CHARS (1);
1594 dbxout_range_type (tem);
1595 }
1596
1597 dbxout_type (TREE_TYPE (type), 0);
1598 break;
1599
1600 case RECORD_TYPE:
1601 case UNION_TYPE:
1602 case QUAL_UNION_TYPE:
1603 {
1604 int i, n_baseclasses = 0;
1605
1606 if (TYPE_BINFO (type) != 0
1607 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1608 && TYPE_BINFO_BASETYPES (type) != 0)
1609 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1610
1611 /* Output a structure type. We must use the same test here as we
1612 use in the DBX_NO_XREFS case above. */
1613 if ((TYPE_NAME (type) != 0
1614 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1615 && DECL_IGNORED_P (TYPE_NAME (type)))
1616 && !full)
1617 || !COMPLETE_TYPE_P (type)
1618 /* No way in DBX fmt to describe a variable size. */
1619 || ! host_integerp (TYPE_SIZE (type), 1))
1620 {
1621 /* If the type is just a cross reference, output one
1622 and mark the type as partially described.
1623 If it later becomes defined, we will output
1624 its real definition.
1625 If the type has a name, don't nest its definition within
1626 another type's definition; instead, output an xref
1627 and let the definition come when the name is defined. */
1628 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1629 CHARS (2);
1630 #if 0 /* This assertion is legitimately false in C++. */
1631 /* We shouldn't be outputting a reference to a type before its
1632 definition unless the type has a tag name.
1633 A typedef name without a tag name should be impossible. */
1634 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1635 abort ();
1636 #endif
1637 if (TYPE_NAME (type) != 0)
1638 dbxout_type_name (type);
1639 else
1640 {
1641 fprintf (asmfile, "$$%d", anonymous_type_number++);
1642 CHARS (5);
1643 }
1644
1645 fprintf (asmfile, ":");
1646 CHARS (1);
1647 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1648 break;
1649 }
1650
1651 /* Identify record or union, and print its size. */
1652 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1653 CHARS (1);
1654 print_wide_int (int_size_in_bytes (type));
1655
1656 if (use_gnu_debug_info_extensions)
1657 {
1658 if (n_baseclasses)
1659 {
1660 have_used_extensions = 1;
1661 fprintf (asmfile, "!%d,", n_baseclasses);
1662 CHARS (8);
1663 }
1664 }
1665 for (i = 0; i < n_baseclasses; i++)
1666 {
1667 tree binfo = TYPE_BINFO (type);
1668 tree child = BINFO_BASETYPE (binfo, i);
1669 tree access = (BINFO_BASEACCESSES (binfo)
1670 ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1671
1672 if (use_gnu_debug_info_extensions)
1673 {
1674 have_used_extensions = 1;
1675 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1676 putc (access == access_public_node ? '2' : '0', asmfile);
1677 CHARS (2);
1678 if (TREE_VIA_VIRTUAL (child)
1679 && strcmp (lang_hooks.name, "GNU C++") == 0)
1680 /* For a virtual base, print the (negative) offset within
1681 the vtable where we must look to find the necessary
1682 adjustment. */
1683 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1684 * BITS_PER_UNIT);
1685 else
1686 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1687 * BITS_PER_UNIT);
1688 putc (',', asmfile);
1689 CHARS (1);
1690 dbxout_type (BINFO_TYPE (child), 0);
1691 putc (';', asmfile);
1692 CHARS (1);
1693 }
1694 else
1695 {
1696 /* Print out the base class information with fields
1697 which have the same names at the types they hold. */
1698 dbxout_type_name (BINFO_TYPE (child));
1699 putc (':', asmfile);
1700 CHARS (1);
1701 dbxout_type (BINFO_TYPE (child), full);
1702 putc (',', asmfile);
1703 CHARS (1);
1704 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1705 * BITS_PER_UNIT);
1706 putc (',', asmfile);
1707 CHARS (1);
1708 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
1709 0)
1710 * BITS_PER_UNIT);
1711 putc (';', asmfile);
1712 CHARS (1);
1713 }
1714 }
1715 }
1716
1717 /* Write out the field declarations. */
1718 dbxout_type_fields (type);
1719 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1720 {
1721 have_used_extensions = 1;
1722 dbxout_type_methods (type);
1723 }
1724
1725 putc (';', asmfile);
1726 CHARS (1);
1727
1728 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1729 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1730 && TYPE_VFIELD (type))
1731 {
1732 have_used_extensions = 1;
1733
1734 /* Tell GDB+ that it may keep reading. */
1735 putc ('~', asmfile);
1736 CHARS (1);
1737
1738 /* We need to write out info about what field this class
1739 uses as its "main" vtable pointer field, because if this
1740 field is inherited from a base class, GDB cannot necessarily
1741 figure out which field it's using in time. */
1742 if (TYPE_VFIELD (type))
1743 {
1744 putc ('%', asmfile);
1745 CHARS (1);
1746 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1747 }
1748
1749 putc (';', asmfile);
1750 CHARS (1);
1751 }
1752 break;
1753
1754 case ENUMERAL_TYPE:
1755 /* We must use the same test here as we use in the DBX_NO_XREFS case
1756 above. We simplify it a bit since an enum will never have a variable
1757 size. */
1758 if ((TYPE_NAME (type) != 0
1759 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1760 && DECL_IGNORED_P (TYPE_NAME (type)))
1761 && !full)
1762 || !COMPLETE_TYPE_P (type))
1763 {
1764 fprintf (asmfile, "xe");
1765 CHARS (2);
1766 dbxout_type_name (type);
1767 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1768 putc (':', asmfile);
1769 CHARS (1);
1770 return;
1771 }
1772 if (use_gnu_debug_info_extensions
1773 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1774 {
1775 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1776 CHARS (5);
1777 }
1778
1779 putc ('e', asmfile);
1780 CHARS (1);
1781 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1782 {
1783 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1784 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1785 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1786 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1787 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1788 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1789 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1790 else
1791 print_int_cst_octal (TREE_VALUE (tem));
1792
1793 putc (',', asmfile);
1794 CHARS (1);
1795 if (TREE_CHAIN (tem) != 0)
1796 CONTIN;
1797 }
1798
1799 putc (';', asmfile);
1800 CHARS (1);
1801 break;
1802
1803 case POINTER_TYPE:
1804 putc ('*', asmfile);
1805 CHARS (1);
1806 dbxout_type (TREE_TYPE (type), 0);
1807 break;
1808
1809 case METHOD_TYPE:
1810 if (use_gnu_debug_info_extensions)
1811 {
1812 have_used_extensions = 1;
1813 putc ('#', asmfile);
1814 CHARS (1);
1815
1816 /* Write the argument types out longhand. */
1817 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1818 putc (',', asmfile);
1819 CHARS (1);
1820 dbxout_type (TREE_TYPE (type), 0);
1821 dbxout_args (TYPE_ARG_TYPES (type));
1822 putc (';', asmfile);
1823 CHARS (1);
1824 }
1825 else
1826 /* Treat it as a function type. */
1827 dbxout_type (TREE_TYPE (type), 0);
1828 break;
1829
1830 case OFFSET_TYPE:
1831 if (use_gnu_debug_info_extensions)
1832 {
1833 have_used_extensions = 1;
1834 putc ('@', asmfile);
1835 CHARS (1);
1836 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1837 putc (',', asmfile);
1838 CHARS (1);
1839 dbxout_type (TREE_TYPE (type), 0);
1840 }
1841 else
1842 /* Should print as an int, because it is really just an offset. */
1843 dbxout_type (integer_type_node, 0);
1844 break;
1845
1846 case REFERENCE_TYPE:
1847 if (use_gnu_debug_info_extensions)
1848 have_used_extensions = 1;
1849 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1850 CHARS (1);
1851 dbxout_type (TREE_TYPE (type), 0);
1852 break;
1853
1854 case FUNCTION_TYPE:
1855 putc ('f', asmfile);
1856 CHARS (1);
1857 dbxout_type (TREE_TYPE (type), 0);
1858 break;
1859
1860 default:
1861 abort ();
1862 }
1863 }
1864
1865 /* Return nonzero if the given type represents an integer whose bounds
1866 should be printed in octal format. */
1867
1868 static bool
1869 print_int_cst_bounds_in_octal_p (tree type)
1870 {
1871 /* If we can use GDB extensions and the size is wider than a long
1872 (the size used by GDB to read them) or we may have trouble writing
1873 the bounds the usual way, write them in octal. Note the test is for
1874 the *target's* size of "long", not that of the host. The host test
1875 is just to make sure we can write it out in case the host wide int
1876 is narrower than the target "long".
1877
1878 For unsigned types, we use octal if they are the same size or larger.
1879 This is because we print the bounds as signed decimal, and hence they
1880 can't span same size unsigned types. */
1881
1882 if (use_gnu_debug_info_extensions
1883 && TYPE_MIN_VALUE (type) != 0
1884 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1885 && TYPE_MAX_VALUE (type) != 0
1886 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1887 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1888 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1889 && TREE_UNSIGNED (type))
1890 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1891 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1892 && TREE_UNSIGNED (type))))
1893 return TRUE;
1894 else
1895 return FALSE;
1896 }
1897
1898 /* Print the value of integer constant C, in octal,
1899 handling double precision. */
1900
1901 static void
1902 print_int_cst_octal (tree c)
1903 {
1904 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1905 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1906 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1907 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1908
1909 /* GDB wants constants with no extra leading "1" bits, so
1910 we need to remove any sign-extension that might be
1911 present. */
1912 if (width == HOST_BITS_PER_WIDE_INT * 2)
1913 ;
1914 else if (width > HOST_BITS_PER_WIDE_INT)
1915 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1916 else if (width == HOST_BITS_PER_WIDE_INT)
1917 high = 0;
1918 else
1919 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1920
1921 fprintf (asmfile, "0");
1922 CHARS (1);
1923
1924 if (excess == 3)
1925 {
1926 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1927 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1928 }
1929 else
1930 {
1931 unsigned HOST_WIDE_INT beg = high >> excess;
1932 unsigned HOST_WIDE_INT middle
1933 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1934 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1935 unsigned HOST_WIDE_INT end
1936 = low & (((unsigned HOST_WIDE_INT) 1
1937 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1938 - 1);
1939
1940 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1941 CHARS (2);
1942 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1943 }
1944 }
1945
1946 static void
1947 print_octal (unsigned HOST_WIDE_INT value, int digits)
1948 {
1949 int i;
1950
1951 for (i = digits - 1; i >= 0; i--)
1952 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1953
1954 CHARS (digits);
1955 }
1956
1957 /* Output C in decimal while adjusting the number of digits written. */
1958
1959 static void
1960 print_wide_int (HOST_WIDE_INT c)
1961 {
1962 int digs = 0;
1963
1964 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1965
1966 if (c < 0)
1967 digs++, c = -c;
1968
1969 while (c > 0)
1970 c /= 10; digs++;
1971
1972 CHARS (digs);
1973 }
1974
1975 /* Output the name of type TYPE, with no punctuation.
1976 Such names can be set up either by typedef declarations
1977 or by struct, enum and union tags. */
1978
1979 static void
1980 dbxout_type_name (tree type)
1981 {
1982 tree t;
1983 if (TYPE_NAME (type) == 0)
1984 abort ();
1985 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1986 {
1987 t = TYPE_NAME (type);
1988 }
1989 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1990 {
1991 t = DECL_NAME (TYPE_NAME (type));
1992 }
1993 else
1994 abort ();
1995
1996 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1997 CHARS (IDENTIFIER_LENGTH (t));
1998 }
1999
2000 /* Output leading leading struct or class names needed for qualifying
2001 type whose scope is limited to a struct or class. */
2002
2003 static void
2004 dbxout_class_name_qualifiers (tree decl)
2005 {
2006 tree context = decl_type_context (decl);
2007
2008 if (context != NULL_TREE
2009 && TREE_CODE(context) == RECORD_TYPE
2010 && TYPE_NAME (context) != 0
2011 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2012 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2013 {
2014 tree name = TYPE_NAME (context);
2015
2016 emit_pending_bincls_if_required ();
2017
2018 if (TREE_CODE (name) == TYPE_DECL)
2019 {
2020 dbxout_class_name_qualifiers (name);
2021 name = DECL_NAME (name);
2022 }
2023 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2024 CHARS (IDENTIFIER_LENGTH (name) + 2);
2025 }
2026 }
2027 \f
2028 /* Output a .stabs for the symbol defined by DECL,
2029 which must be a ..._DECL node in the normal namespace.
2030 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2031 LOCAL is nonzero if the scope is less than the entire file.
2032 Return 1 if a stabs might have been emitted. */
2033
2034 int
2035 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2036 {
2037 tree type = TREE_TYPE (decl);
2038 tree context = NULL_TREE;
2039 int result = 0;
2040
2041 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2042 ++debug_nesting;
2043
2044 /* Cast avoids warning in old compilers. */
2045 current_sym_code = (STAB_CODE_TYPE) 0;
2046 current_sym_value = 0;
2047 current_sym_addr = 0;
2048
2049 /* Ignore nameless syms, but don't ignore type tags. */
2050
2051 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2052 || DECL_IGNORED_P (decl))
2053 DBXOUT_DECR_NESTING_AND_RETURN (0);
2054
2055 /* If we are to generate only the symbols actually used then such
2056 symbol nodees are flagged with TREE_USED. Ignore any that
2057 aren't flaged as TREE_USED. */
2058
2059 if (flag_debug_only_used_symbols)
2060 {
2061 tree t;
2062
2063 if (!TREE_USED (decl)
2064 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
2065 DBXOUT_DECR_NESTING_AND_RETURN (0);
2066
2067 /* We now have a used symbol. We need to generate the info for
2068 the symbol's type in addition to the symbol itself. These
2069 type symbols are queued to be generated after were done with
2070 the symbol itself (done because the symbol's info is generated
2071 with fprintf's, etc. as it determines what's needed).
2072
2073 Note, because the TREE_TYPE(type) might be something like a
2074 pointer to a named type we need to look for the first name
2075 we see following the TREE_TYPE chain. */
2076
2077 t = type;
2078 while (POINTER_TYPE_P (t))
2079 t = TREE_TYPE (t);
2080
2081 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2082 need special treatment. The TYPE_STUB_DECL field in these
2083 types generally represents the tag name type we want to
2084 output. In addition there could be a typedef type with
2085 a different name. In that case we also want to output
2086 that. */
2087
2088 if ((TREE_CODE (t) == RECORD_TYPE
2089 || TREE_CODE (t) == UNION_TYPE
2090 || TREE_CODE (t) == QUAL_UNION_TYPE
2091 || TREE_CODE (t) == ENUMERAL_TYPE)
2092 && TYPE_STUB_DECL (t)
2093 && TYPE_STUB_DECL (t) != decl
2094 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2095 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2096 {
2097 debug_queue_symbol (TYPE_STUB_DECL (t));
2098 if (TYPE_NAME (t)
2099 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2100 && TYPE_NAME (t) != decl
2101 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2102 debug_queue_symbol (TYPE_NAME (t));
2103 }
2104 else if (TYPE_NAME (t)
2105 && TYPE_NAME (t) != decl
2106 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2107 debug_queue_symbol (TYPE_NAME (t));
2108 }
2109
2110 emit_pending_bincls_if_required ();
2111
2112 dbxout_prepare_symbol (decl);
2113
2114 /* The output will always start with the symbol name,
2115 so always count that in the length-output-so-far. */
2116
2117 if (DECL_NAME (decl) != 0)
2118 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2119
2120 switch (TREE_CODE (decl))
2121 {
2122 case CONST_DECL:
2123 /* Enum values are defined by defining the enum type. */
2124 break;
2125
2126 case FUNCTION_DECL:
2127 if (DECL_RTL (decl) == 0)
2128 DBXOUT_DECR_NESTING_AND_RETURN (0);
2129 if (DECL_EXTERNAL (decl))
2130 break;
2131 /* Don't mention a nested function under its parent. */
2132 context = decl_function_context (decl);
2133 if (context == current_function_decl)
2134 break;
2135 if (GET_CODE (DECL_RTL (decl)) != MEM
2136 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2137 break;
2138 FORCE_TEXT;
2139
2140 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2141 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2142 TREE_PUBLIC (decl) ? 'F' : 'f');
2143 result = 1;
2144
2145 current_sym_code = N_FUN;
2146 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2147
2148 if (TREE_TYPE (type))
2149 dbxout_type (TREE_TYPE (type), 0);
2150 else
2151 dbxout_type (void_type_node, 0);
2152
2153 /* For a nested function, when that function is compiled,
2154 mention the containing function name
2155 as well as (since dbx wants it) our own assembler-name. */
2156 if (context != 0)
2157 fprintf (asmfile, ",%s,%s",
2158 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2159 IDENTIFIER_POINTER (DECL_NAME (context)));
2160
2161 dbxout_finish_symbol (decl);
2162 break;
2163
2164 case TYPE_DECL:
2165 /* Don't output the same typedef twice.
2166 And don't output what language-specific stuff doesn't want output. */
2167 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2168 DBXOUT_DECR_NESTING_AND_RETURN (0);
2169
2170 FORCE_TEXT;
2171 result = 1;
2172 {
2173 int tag_needed = 1;
2174 int did_output = 0;
2175
2176 if (DECL_NAME (decl))
2177 {
2178 /* Nonzero means we must output a tag as well as a typedef. */
2179 tag_needed = 0;
2180
2181 /* Handle the case of a C++ structure or union
2182 where the TYPE_NAME is a TYPE_DECL
2183 which gives both a typedef name and a tag. */
2184 /* dbx requires the tag first and the typedef second. */
2185 if ((TREE_CODE (type) == RECORD_TYPE
2186 || TREE_CODE (type) == UNION_TYPE
2187 || TREE_CODE (type) == QUAL_UNION_TYPE)
2188 && TYPE_NAME (type) == decl
2189 && !(use_gnu_debug_info_extensions && have_used_extensions)
2190 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2191 /* Distinguish the implicit typedefs of C++
2192 from explicit ones that might be found in C. */
2193 && DECL_ARTIFICIAL (decl)
2194 /* Do not generate a tag for incomplete records. */
2195 && COMPLETE_TYPE_P (type)
2196 /* Do not generate a tag for records of variable size,
2197 since this type can not be properly described in the
2198 DBX format, and it confuses some tools such as objdump. */
2199 && host_integerp (TYPE_SIZE (type), 1))
2200 {
2201 tree name = TYPE_NAME (type);
2202 if (TREE_CODE (name) == TYPE_DECL)
2203 name = DECL_NAME (name);
2204
2205 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2206 current_sym_value = 0;
2207 current_sym_addr = 0;
2208 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2209
2210 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2211 IDENTIFIER_POINTER (name));
2212 dbxout_type (type, 1);
2213 dbxout_finish_symbol (NULL_TREE);
2214 }
2215
2216 /* Output .stabs (or whatever) and leading double quote. */
2217 fprintf (asmfile, "%s\"", ASM_STABS_OP);
2218
2219 if (use_gnu_debug_info_extensions)
2220 {
2221 /* Output leading class/struct qualifiers. */
2222 dbxout_class_name_qualifiers (decl);
2223 }
2224
2225 /* Output typedef name. */
2226 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2227
2228 /* Short cut way to output a tag also. */
2229 if ((TREE_CODE (type) == RECORD_TYPE
2230 || TREE_CODE (type) == UNION_TYPE
2231 || TREE_CODE (type) == QUAL_UNION_TYPE)
2232 && TYPE_NAME (type) == decl
2233 /* Distinguish the implicit typedefs of C++
2234 from explicit ones that might be found in C. */
2235 && DECL_ARTIFICIAL (decl))
2236 {
2237 if (use_gnu_debug_info_extensions && have_used_extensions)
2238 {
2239 putc ('T', asmfile);
2240 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2241 }
2242 #if 0 /* Now we generate the tag for this case up above. */
2243 else
2244 tag_needed = 1;
2245 #endif
2246 }
2247
2248 putc ('t', asmfile);
2249 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2250
2251 dbxout_type (type, 1);
2252 dbxout_finish_symbol (decl);
2253 did_output = 1;
2254 }
2255
2256 /* Don't output a tag if this is an incomplete type. This prevents
2257 the sun4 Sun OS 4.x dbx from crashing. */
2258
2259 if (tag_needed && TYPE_NAME (type) != 0
2260 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2261 || (DECL_NAME (TYPE_NAME (type)) != 0))
2262 && COMPLETE_TYPE_P (type)
2263 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2264 {
2265 /* For a TYPE_DECL with no name, but the type has a name,
2266 output a tag.
2267 This is what represents `struct foo' with no typedef. */
2268 /* In C++, the name of a type is the corresponding typedef.
2269 In C, it is an IDENTIFIER_NODE. */
2270 tree name = TYPE_NAME (type);
2271 if (TREE_CODE (name) == TYPE_DECL)
2272 name = DECL_NAME (name);
2273
2274 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2275 current_sym_value = 0;
2276 current_sym_addr = 0;
2277 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2278
2279 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2280 IDENTIFIER_POINTER (name));
2281 dbxout_type (type, 1);
2282 dbxout_finish_symbol (NULL_TREE);
2283 did_output = 1;
2284 }
2285
2286 /* If an enum type has no name, it cannot be referred to,
2287 but we must output it anyway, since the enumeration constants
2288 can be referred to. */
2289 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2290 {
2291 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2292 current_sym_value = 0;
2293 current_sym_addr = 0;
2294 current_sym_nchars = 2;
2295
2296 /* Some debuggers fail when given NULL names, so give this a
2297 harmless name of ` '. */
2298 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2299 dbxout_type (type, 1);
2300 dbxout_finish_symbol (NULL_TREE);
2301 }
2302
2303 /* Prevent duplicate output of a typedef. */
2304 TREE_ASM_WRITTEN (decl) = 1;
2305 break;
2306 }
2307
2308 case PARM_DECL:
2309 /* Parm decls go in their own separate chains
2310 and are output by dbxout_reg_parms and dbxout_parms. */
2311 abort ();
2312
2313 case RESULT_DECL:
2314 /* Named return value, treat like a VAR_DECL. */
2315 case VAR_DECL:
2316 if (! DECL_RTL_SET_P (decl))
2317 DBXOUT_DECR_NESTING_AND_RETURN (0);
2318 /* Don't mention a variable that is external.
2319 Let the file that defines it describe it. */
2320 if (DECL_EXTERNAL (decl))
2321 break;
2322
2323 /* If the variable is really a constant
2324 and not written in memory, inform the debugger. */
2325 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2326 && DECL_INITIAL (decl) != 0
2327 && host_integerp (DECL_INITIAL (decl), 0)
2328 && ! TREE_ASM_WRITTEN (decl)
2329 && (DECL_CONTEXT (decl) == NULL_TREE
2330 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2331 {
2332 if (TREE_PUBLIC (decl) == 0)
2333 {
2334 /* The sun4 assembler does not grok this. */
2335 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2336
2337 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2338 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2339 {
2340 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2341 fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2342 "\",0x%x,0,0,0\n",
2343 ASM_STABS_OP, name, ival, N_LSYM);
2344 DBXOUT_DECR_NESTING;
2345 return 1;
2346 }
2347 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2348 {
2349 /* don't know how to do this yet. */
2350 }
2351 break;
2352 }
2353 /* else it is something we handle like a normal variable. */
2354 }
2355
2356 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2357 #ifdef LEAF_REG_REMAP
2358 if (current_function_uses_only_leaf_regs)
2359 leaf_renumber_regs_insn (DECL_RTL (decl));
2360 #endif
2361
2362 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2363 break;
2364
2365 default:
2366 break;
2367 }
2368 DBXOUT_DECR_NESTING;
2369 return result;
2370 }
2371 \f
2372 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2373 Add SUFFIX to its name, if SUFFIX is not 0.
2374 Describe the variable as residing in HOME
2375 (usually HOME is DECL_RTL (DECL), but not always).
2376 Returns 1 if the stab was really emitted. */
2377
2378 static int
2379 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2380 {
2381 int letter = 0;
2382 int regno = -1;
2383
2384 emit_pending_bincls_if_required ();
2385
2386 /* Don't mention a variable at all
2387 if it was completely optimized into nothingness.
2388
2389 If the decl was from an inline function, then its rtl
2390 is not identically the rtl that was used in this
2391 particular compilation. */
2392 if (GET_CODE (home) == SUBREG)
2393 {
2394 rtx value = home;
2395
2396 while (GET_CODE (value) == SUBREG)
2397 value = SUBREG_REG (value);
2398 if (GET_CODE (value) == REG)
2399 {
2400 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2401 return 0;
2402 }
2403 home = alter_subreg (&home);
2404 }
2405 if (GET_CODE (home) == REG)
2406 {
2407 regno = REGNO (home);
2408 if (regno >= FIRST_PSEUDO_REGISTER)
2409 return 0;
2410 }
2411
2412 /* The kind-of-variable letter depends on where
2413 the variable is and on the scope of its name:
2414 G and N_GSYM for static storage and global scope,
2415 S for static storage and file scope,
2416 V for static storage and local scope,
2417 for those two, use N_LCSYM if data is in bss segment,
2418 N_STSYM if in data segment, N_FUN otherwise.
2419 (We used N_FUN originally, then changed to N_STSYM
2420 to please GDB. However, it seems that confused ld.
2421 Now GDB has been fixed to like N_FUN, says Kingdon.)
2422 no letter at all, and N_LSYM, for auto variable,
2423 r and N_RSYM for register variable. */
2424
2425 if (GET_CODE (home) == MEM
2426 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2427 {
2428 if (TREE_PUBLIC (decl))
2429 {
2430 letter = 'G';
2431 current_sym_code = N_GSYM;
2432 }
2433 else
2434 {
2435 current_sym_addr = XEXP (home, 0);
2436
2437 letter = decl_function_context (decl) ? 'V' : 'S';
2438
2439 /* This should be the same condition as in assemble_variable, but
2440 we don't have access to dont_output_data here. So, instead,
2441 we rely on the fact that error_mark_node initializers always
2442 end up in bss for C++ and never end up in bss for C. */
2443 if (DECL_INITIAL (decl) == 0
2444 || (!strcmp (lang_hooks.name, "GNU C++")
2445 && DECL_INITIAL (decl) == error_mark_node))
2446 current_sym_code = N_LCSYM;
2447 else if (DECL_IN_TEXT_SECTION (decl))
2448 /* This is not quite right, but it's the closest
2449 of all the codes that Unix defines. */
2450 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2451 else
2452 {
2453 /* Some ports can transform a symbol ref into a label ref,
2454 because the symbol ref is too far away and has to be
2455 dumped into a constant pool. Alternatively, the symbol
2456 in the constant pool might be referenced by a different
2457 symbol. */
2458 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2459 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2460 {
2461 rtx tmp = get_pool_constant (current_sym_addr);
2462
2463 if (GET_CODE (tmp) == SYMBOL_REF
2464 || GET_CODE (tmp) == LABEL_REF)
2465 current_sym_addr = tmp;
2466 }
2467
2468 /* Ultrix `as' seems to need this. */
2469 #ifdef DBX_STATIC_STAB_DATA_SECTION
2470 data_section ();
2471 #endif
2472 current_sym_code = N_STSYM;
2473 }
2474 }
2475 }
2476 else if (regno >= 0)
2477 {
2478 letter = 'r';
2479 current_sym_code = N_RSYM;
2480 current_sym_value = DBX_REGISTER_NUMBER (regno);
2481 }
2482 else if (GET_CODE (home) == MEM
2483 && (GET_CODE (XEXP (home, 0)) == MEM
2484 || (GET_CODE (XEXP (home, 0)) == REG
2485 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2486 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2487 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2488 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2489 #endif
2490 )))
2491 /* If the value is indirect by memory or by a register
2492 that isn't the frame pointer
2493 then it means the object is variable-sized and address through
2494 that register or stack slot. DBX has no way to represent this
2495 so all we can do is output the variable as a pointer.
2496 If it's not a parameter, ignore it.
2497 (VAR_DECLs like this can be made by integrate.c.) */
2498 {
2499 if (GET_CODE (XEXP (home, 0)) == REG)
2500 {
2501 letter = 'r';
2502 current_sym_code = N_RSYM;
2503 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2504 return 0;
2505 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2506 }
2507 else
2508 {
2509 current_sym_code = N_LSYM;
2510 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2511 We want the value of that CONST_INT. */
2512 current_sym_value
2513 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2514 }
2515
2516 /* Effectively do build_pointer_type, but don't cache this type,
2517 since it might be temporary whereas the type it points to
2518 might have been saved for inlining. */
2519 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2520 type = make_node (POINTER_TYPE);
2521 TREE_TYPE (type) = TREE_TYPE (decl);
2522 }
2523 else if (GET_CODE (home) == MEM
2524 && GET_CODE (XEXP (home, 0)) == REG)
2525 {
2526 current_sym_code = N_LSYM;
2527 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2528 }
2529 else if (GET_CODE (home) == MEM
2530 && GET_CODE (XEXP (home, 0)) == PLUS
2531 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2532 {
2533 current_sym_code = N_LSYM;
2534 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2535 We want the value of that CONST_INT. */
2536 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2537 }
2538 else if (GET_CODE (home) == MEM
2539 && GET_CODE (XEXP (home, 0)) == CONST)
2540 {
2541 /* Handle an obscure case which can arise when optimizing and
2542 when there are few available registers. (This is *always*
2543 the case for i386/i486 targets). The RTL looks like
2544 (MEM (CONST ...)) even though this variable is a local `auto'
2545 or a local `register' variable. In effect, what has happened
2546 is that the reload pass has seen that all assignments and
2547 references for one such a local variable can be replaced by
2548 equivalent assignments and references to some static storage
2549 variable, thereby avoiding the need for a register. In such
2550 cases we're forced to lie to debuggers and tell them that
2551 this variable was itself `static'. */
2552 current_sym_code = N_LCSYM;
2553 letter = 'V';
2554 current_sym_addr = XEXP (XEXP (home, 0), 0);
2555 }
2556 else if (GET_CODE (home) == CONCAT)
2557 {
2558 tree subtype;
2559
2560 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2561 for example), then there is no easy way to figure out
2562 what SUBTYPE should be. So, we give up. */
2563 if (TREE_CODE (type) != COMPLEX_TYPE)
2564 return 0;
2565
2566 subtype = TREE_TYPE (type);
2567
2568 /* If the variable's storage is in two parts,
2569 output each as a separate stab with a modified name. */
2570 if (WORDS_BIG_ENDIAN)
2571 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2572 else
2573 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2574
2575 /* Cast avoids warning in old compilers. */
2576 current_sym_code = (STAB_CODE_TYPE) 0;
2577 current_sym_value = 0;
2578 current_sym_addr = 0;
2579 dbxout_prepare_symbol (decl);
2580
2581 if (WORDS_BIG_ENDIAN)
2582 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2583 else
2584 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2585 return 1;
2586 }
2587 else
2588 /* Address might be a MEM, when DECL is a variable-sized object.
2589 Or it might be const0_rtx, meaning previous passes
2590 want us to ignore this variable. */
2591 return 0;
2592
2593 /* Ok, start a symtab entry and output the variable name. */
2594 FORCE_TEXT;
2595
2596 #ifdef DBX_STATIC_BLOCK_START
2597 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2598 #endif
2599
2600 dbxout_symbol_name (decl, suffix, letter);
2601 dbxout_type (type, 0);
2602 dbxout_finish_symbol (decl);
2603
2604 #ifdef DBX_STATIC_BLOCK_END
2605 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2606 #endif
2607 return 1;
2608 }
2609 \f
2610 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2611 Then output LETTER to indicate the kind of location the symbol has. */
2612
2613 static void
2614 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2615 {
2616 const char *name;
2617
2618 if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2619 /* One slight hitch: if this is a VAR_DECL which is a static
2620 class member, we must put out the mangled name instead of the
2621 DECL_NAME. Note also that static member (variable) names DO NOT begin
2622 with underscores in .stabs directives. */
2623 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2624 else
2625 /* ...but if we're function-local, we don't want to include the junk
2626 added by ASM_FORMAT_PRIVATE_NAME. */
2627 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2628
2629 if (name == 0)
2630 name = "(anon)";
2631 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2632 (suffix ? suffix : ""));
2633
2634 if (letter)
2635 putc (letter, asmfile);
2636 }
2637
2638 static void
2639 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2640 {
2641 #ifdef WINNING_GDB
2642 const char *filename = DECL_SOURCE_FILE (decl);
2643
2644 dbxout_source_file (asmfile, filename);
2645 #endif
2646 }
2647
2648 static void
2649 dbxout_finish_symbol (tree sym)
2650 {
2651 #ifdef DBX_FINISH_SYMBOL
2652 DBX_FINISH_SYMBOL (sym);
2653 #else
2654 int line = 0;
2655 if (use_gnu_debug_info_extensions && sym != 0)
2656 line = DECL_SOURCE_LINE (sym);
2657
2658 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2659 if (current_sym_addr)
2660 output_addr_const (asmfile, current_sym_addr);
2661 else
2662 fprintf (asmfile, "%d", current_sym_value);
2663 putc ('\n', asmfile);
2664 #endif
2665 }
2666
2667 /* Output definitions of all the decls in a chain. Return nonzero if
2668 anything was output */
2669
2670 int
2671 dbxout_syms (tree syms)
2672 {
2673 int result = 0;
2674 while (syms)
2675 {
2676 result += dbxout_symbol (syms, 1);
2677 syms = TREE_CHAIN (syms);
2678 }
2679 return result;
2680 }
2681 \f
2682 /* The following two functions output definitions of function parameters.
2683 Each parameter gets a definition locating it in the parameter list.
2684 Each parameter that is a register variable gets a second definition
2685 locating it in the register.
2686
2687 Printing or argument lists in gdb uses the definitions that
2688 locate in the parameter list. But reference to the variable in
2689 expressions uses preferentially the definition as a register. */
2690
2691 /* Output definitions, referring to storage in the parmlist,
2692 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2693
2694 void
2695 dbxout_parms (tree parms)
2696 {
2697 ++debug_nesting;
2698
2699 emit_pending_bincls_if_required ();
2700
2701 for (; parms; parms = TREE_CHAIN (parms))
2702 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2703 {
2704 dbxout_prepare_symbol (parms);
2705
2706 /* Perform any necessary register eliminations on the parameter's rtl,
2707 so that the debugging output will be accurate. */
2708 DECL_INCOMING_RTL (parms)
2709 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2710 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2711 #ifdef LEAF_REG_REMAP
2712 if (current_function_uses_only_leaf_regs)
2713 {
2714 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2715 leaf_renumber_regs_insn (DECL_RTL (parms));
2716 }
2717 #endif
2718
2719 if (PARM_PASSED_IN_MEMORY (parms))
2720 {
2721 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2722
2723 /* ??? Here we assume that the parm address is indexed
2724 off the frame pointer or arg pointer.
2725 If that is not true, we produce meaningless results,
2726 but do not crash. */
2727 if (GET_CODE (addr) == PLUS
2728 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2729 current_sym_value = INTVAL (XEXP (addr, 1));
2730 else
2731 current_sym_value = 0;
2732
2733 current_sym_code = N_PSYM;
2734 current_sym_addr = 0;
2735
2736 FORCE_TEXT;
2737 if (DECL_NAME (parms))
2738 {
2739 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2740
2741 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2742 IDENTIFIER_POINTER (DECL_NAME (parms)),
2743 DBX_MEMPARM_STABS_LETTER);
2744 }
2745 else
2746 {
2747 current_sym_nchars = 8;
2748 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2749 DBX_MEMPARM_STABS_LETTER);
2750 }
2751
2752 /* It is quite tempting to use:
2753
2754 dbxout_type (TREE_TYPE (parms), 0);
2755
2756 as the next statement, rather than using DECL_ARG_TYPE(), so
2757 that gcc reports the actual type of the parameter, rather
2758 than the promoted type. This certainly makes GDB's life
2759 easier, at least for some ports. The change is a bad idea
2760 however, since GDB expects to be able access the type without
2761 performing any conversions. So for example, if we were
2762 passing a float to an unprototyped function, gcc will store a
2763 double on the stack, but if we emit a stab saying the type is a
2764 float, then gdb will only read in a single value, and this will
2765 produce an erroneous value. */
2766 dbxout_type (DECL_ARG_TYPE (parms), 0);
2767 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2768 dbxout_finish_symbol (parms);
2769 }
2770 else if (GET_CODE (DECL_RTL (parms)) == REG)
2771 {
2772 rtx best_rtl;
2773 char regparm_letter;
2774 tree parm_type;
2775 /* Parm passed in registers and lives in registers or nowhere. */
2776
2777 current_sym_code = DBX_REGPARM_STABS_CODE;
2778 regparm_letter = DBX_REGPARM_STABS_LETTER;
2779 current_sym_addr = 0;
2780
2781 /* If parm lives in a register, use that register;
2782 pretend the parm was passed there. It would be more consistent
2783 to describe the register where the parm was passed,
2784 but in practice that register usually holds something else.
2785
2786 If we use DECL_RTL, then we must use the declared type of
2787 the variable, not the type that it arrived in. */
2788 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2789 {
2790 best_rtl = DECL_RTL (parms);
2791 parm_type = TREE_TYPE (parms);
2792 }
2793 /* If the parm lives nowhere, use the register where it was
2794 passed. It is also better to use the declared type here. */
2795 else
2796 {
2797 best_rtl = DECL_INCOMING_RTL (parms);
2798 parm_type = TREE_TYPE (parms);
2799 }
2800 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2801
2802 FORCE_TEXT;
2803 if (DECL_NAME (parms))
2804 {
2805 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2806 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2807 IDENTIFIER_POINTER (DECL_NAME (parms)),
2808 regparm_letter);
2809 }
2810 else
2811 {
2812 current_sym_nchars = 8;
2813 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2814 regparm_letter);
2815 }
2816
2817 dbxout_type (parm_type, 0);
2818 dbxout_finish_symbol (parms);
2819 }
2820 else if (GET_CODE (DECL_RTL (parms)) == MEM
2821 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2822 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2823 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2824 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2825 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2826 #endif
2827 )
2828 {
2829 /* Parm was passed via invisible reference.
2830 That is, its address was passed in a register.
2831 Output it as if it lived in that register.
2832 The debugger will know from the type
2833 that it was actually passed by invisible reference. */
2834
2835 char regparm_letter;
2836 /* Parm passed in registers and lives in registers or nowhere. */
2837
2838 current_sym_code = DBX_REGPARM_STABS_CODE;
2839 if (use_gnu_debug_info_extensions)
2840 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2841 else
2842 regparm_letter = DBX_REGPARM_STABS_LETTER;
2843
2844 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2845 If it is an unallocated pseudo-reg, then use the register where
2846 it was passed instead. */
2847 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2848 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2849 else
2850 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2851
2852 current_sym_addr = 0;
2853
2854 FORCE_TEXT;
2855 if (DECL_NAME (parms))
2856 {
2857 current_sym_nchars
2858 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2859
2860 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2861 IDENTIFIER_POINTER (DECL_NAME (parms)),
2862 regparm_letter);
2863 }
2864 else
2865 {
2866 current_sym_nchars = 8;
2867 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2868 regparm_letter);
2869 }
2870
2871 dbxout_type (TREE_TYPE (parms), 0);
2872 dbxout_finish_symbol (parms);
2873 }
2874 else if (GET_CODE (DECL_RTL (parms)) == MEM
2875 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2876 {
2877 /* Parm was passed via invisible reference, with the reference
2878 living on the stack. DECL_RTL looks like
2879 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2880 could look like (MEM (MEM (REG))). */
2881 const char *const decl_name = (DECL_NAME (parms)
2882 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2883 : "(anon)");
2884 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2885 current_sym_value = 0;
2886 else
2887 current_sym_value
2888 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2889 current_sym_addr = 0;
2890 current_sym_code = N_PSYM;
2891
2892 FORCE_TEXT;
2893 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2894
2895 current_sym_value
2896 = DEBUGGER_ARG_OFFSET (current_sym_value,
2897 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2898 dbxout_type (TREE_TYPE (parms), 0);
2899 dbxout_finish_symbol (parms);
2900 }
2901 else if (GET_CODE (DECL_RTL (parms)) == MEM
2902 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2903 /* ??? A constant address for a parm can happen
2904 when the reg it lives in is equiv to a constant in memory.
2905 Should make this not happen, after 2.4. */
2906 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2907 {
2908 /* Parm was passed in registers but lives on the stack. */
2909
2910 current_sym_code = N_PSYM;
2911 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2912 in which case we want the value of that CONST_INT,
2913 or (MEM (REG ...)),
2914 in which case we use a value of zero. */
2915 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2916 current_sym_value = 0;
2917 else
2918 current_sym_value
2919 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2920
2921 current_sym_addr = 0;
2922
2923 /* Make a big endian correction if the mode of the type of the
2924 parameter is not the same as the mode of the rtl. */
2925 if (BYTES_BIG_ENDIAN
2926 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2927 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2928 {
2929 current_sym_value +=
2930 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2931 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2932 }
2933
2934 FORCE_TEXT;
2935 if (DECL_NAME (parms))
2936 {
2937 current_sym_nchars
2938 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2939
2940 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2941 IDENTIFIER_POINTER (DECL_NAME (parms)),
2942 DBX_MEMPARM_STABS_LETTER);
2943 }
2944 else
2945 {
2946 current_sym_nchars = 8;
2947 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2948 DBX_MEMPARM_STABS_LETTER);
2949 }
2950
2951 current_sym_value
2952 = DEBUGGER_ARG_OFFSET (current_sym_value,
2953 XEXP (DECL_RTL (parms), 0));
2954 dbxout_type (TREE_TYPE (parms), 0);
2955 dbxout_finish_symbol (parms);
2956 }
2957 }
2958 DBXOUT_DECR_NESTING;
2959 }
2960
2961 /* Output definitions for the places where parms live during the function,
2962 when different from where they were passed, when the parms were passed
2963 in memory.
2964
2965 It is not useful to do this for parms passed in registers
2966 that live during the function in different registers, because it is
2967 impossible to look in the passed register for the passed value,
2968 so we use the within-the-function register to begin with.
2969
2970 PARMS is a chain of PARM_DECL nodes. */
2971
2972 void
2973 dbxout_reg_parms (tree parms)
2974 {
2975 ++debug_nesting;
2976
2977 for (; parms; parms = TREE_CHAIN (parms))
2978 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2979 {
2980 dbxout_prepare_symbol (parms);
2981
2982 /* Report parms that live in registers during the function
2983 but were passed in memory. */
2984 if (GET_CODE (DECL_RTL (parms)) == REG
2985 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2986 dbxout_symbol_location (parms, TREE_TYPE (parms),
2987 0, DECL_RTL (parms));
2988 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2989 dbxout_symbol_location (parms, TREE_TYPE (parms),
2990 0, DECL_RTL (parms));
2991 /* Report parms that live in memory but not where they were passed. */
2992 else if (GET_CODE (DECL_RTL (parms)) == MEM
2993 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2994 dbxout_symbol_location (parms, TREE_TYPE (parms),
2995 0, DECL_RTL (parms));
2996 }
2997 DBXOUT_DECR_NESTING;
2998 }
2999 \f
3000 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3001 output definitions of those names, in raw form */
3002
3003 static void
3004 dbxout_args (tree args)
3005 {
3006 while (args)
3007 {
3008 putc (',', asmfile);
3009 dbxout_type (TREE_VALUE (args), 0);
3010 CHARS (1);
3011 args = TREE_CHAIN (args);
3012 }
3013 }
3014 \f
3015 /* Output everything about a symbol block (a BLOCK node
3016 that represents a scope level),
3017 including recursive output of contained blocks.
3018
3019 BLOCK is the BLOCK node.
3020 DEPTH is its depth within containing symbol blocks.
3021 ARGS is usually zero; but for the outermost block of the
3022 body of a function, it is a chain of PARM_DECLs for the function parameters.
3023 We output definitions of all the register parms
3024 as if they were local variables of that block.
3025
3026 If -g1 was used, we count blocks just the same, but output nothing
3027 except for the outermost block.
3028
3029 Actually, BLOCK may be several blocks chained together.
3030 We handle them all in sequence. */
3031
3032 static void
3033 dbxout_block (tree block, int depth, tree args)
3034 {
3035 int blocknum = -1;
3036
3037 #if DBX_BLOCKS_FUNCTION_RELATIVE
3038 const char *begin_label;
3039 if (current_function_func_begin_label != NULL_TREE)
3040 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3041 else
3042 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3043 #endif
3044
3045 while (block)
3046 {
3047 /* Ignore blocks never expanded or otherwise marked as real. */
3048 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3049 {
3050 int did_output;
3051
3052 /* In dbx format, the syms of a block come before the N_LBRAC.
3053 If nothing is output, we don't need the N_LBRAC, either. */
3054 did_output = 0;
3055 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3056 did_output = dbxout_syms (BLOCK_VARS (block));
3057 if (args)
3058 dbxout_reg_parms (args);
3059
3060 /* Now output an N_LBRAC symbol to represent the beginning of
3061 the block. Use the block's tree-walk order to generate
3062 the assembler symbols LBBn and LBEn
3063 that final will define around the code in this block. */
3064 if (depth > 0 && did_output)
3065 {
3066 char buf[20];
3067 blocknum = BLOCK_NUMBER (block);
3068 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3069
3070 if (BLOCK_HANDLER_BLOCK (block))
3071 {
3072 /* A catch block. Must precede N_LBRAC. */
3073 tree decl = BLOCK_VARS (block);
3074 while (decl)
3075 {
3076 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3077 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3078 assemble_name (asmfile, buf);
3079 fprintf (asmfile, "\n");
3080 decl = TREE_CHAIN (decl);
3081 }
3082 }
3083
3084 #ifdef DBX_OUTPUT_LBRAC
3085 DBX_OUTPUT_LBRAC (asmfile, buf);
3086 #else
3087 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3088 assemble_name (asmfile, buf);
3089 #if DBX_BLOCKS_FUNCTION_RELATIVE
3090 putc ('-', asmfile);
3091 assemble_name (asmfile, begin_label);
3092 #endif
3093 fprintf (asmfile, "\n");
3094 #endif
3095 }
3096
3097 /* Output the subblocks. */
3098 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3099
3100 /* Refer to the marker for the end of the block. */
3101 if (depth > 0 && did_output)
3102 {
3103 char buf[20];
3104 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3105 #ifdef DBX_OUTPUT_RBRAC
3106 DBX_OUTPUT_RBRAC (asmfile, buf);
3107 #else
3108 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3109 assemble_name (asmfile, buf);
3110 #if DBX_BLOCKS_FUNCTION_RELATIVE
3111 putc ('-', asmfile);
3112 assemble_name (asmfile, begin_label);
3113 #endif
3114 fprintf (asmfile, "\n");
3115 #endif
3116 }
3117 }
3118 block = BLOCK_CHAIN (block);
3119 }
3120 }
3121
3122 /* Output the information about a function and its arguments and result.
3123 Usually this follows the function's code,
3124 but on some systems, it comes before. */
3125
3126 #if defined (DBX_DEBUGGING_INFO)
3127 static void
3128 dbxout_begin_function (tree decl)
3129 {
3130 int saved_tree_used1 = TREE_USED (decl);
3131 TREE_USED (decl) = 1;
3132 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3133 {
3134 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3135 TREE_USED (DECL_RESULT (decl)) = 1;
3136 dbxout_symbol (decl, 0);
3137 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3138 }
3139 else
3140 dbxout_symbol (decl, 0);
3141 TREE_USED (decl) = saved_tree_used1;
3142
3143 dbxout_parms (DECL_ARGUMENTS (decl));
3144 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3145 dbxout_symbol (DECL_RESULT (decl), 1);
3146 }
3147 #endif /* DBX_DEBUGGING_INFO */
3148
3149 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3150
3151 #include "gt-dbxout.h"