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