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