]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/dbxout.c
Update copyright years in gcc/
[thirdparty/gcc.git] / gcc / dbxout.c
CommitLineData
00fe048c 1/* Output dbx-format symbol table information from GNU compiler.
23a5b65a 2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
00fe048c 3
1322177d 4This file is part of GCC.
00fe048c 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
00fe048c 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
00fe048c
RS
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
00fe048c
RS
19
20
21/* Output dbx-format symbol table data.
22 This consists of many symbol table entries, each of them
23 a .stabs assembler pseudo-op with four operands:
24 a "name" which is really a description of one symbol and its type,
25 a "code", which is a symbol defined in stab.h whose name starts with N_,
26 an unused operand always 0,
27 and a "value" which is an address or an offset.
28 The name is enclosed in doublequote characters.
29
30 Each function, variable, typedef, and structure tag
31 has a symbol table entry to define it.
32 The beginning and end of each level of name scoping within
33 a function are also marked by special symbol table entries.
34
35 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
36 and a data type number. The data type number may be followed by
37 "=" and a type definition; normally this will happen the first time
38 the type number is mentioned. The type definition may refer to
39 other types by number, and those type numbers may be followed
40 by "=" and nested definitions.
41
42 This can make the "name" quite long.
43 When a name is more than 80 characters, we split the .stabs pseudo-op
44 into two .stabs pseudo-ops, both sharing the same "code" and "value".
45 The first one is marked as continued with a double-backslash at the
46 end of its "name".
47
48 The kind-of-symbol letter distinguished function names from global
49 variables from file-scope variables from parameters from auto
50 variables in memory from typedef names from register variables.
51 See `dbxout_symbol'.
52
53 The "code" is mostly redundant with the kind-of-symbol letter
54 that goes in the "name", but not entirely: for symbols located
55 in static storage, the "code" says which segment the address is in,
56 which controls how it is relocated.
57
58 The "value" for a symbol in static storage
59 is the core address of the symbol (actually, the assembler
60 label for the symbol). For a symbol located in a stack slot
61 it is the stack offset; for one in a register, the register number.
62 For a typedef symbol, it is zero.
63
64 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
65 output while in the text section.
66
67 For more on data type definitions, see `dbxout_type'. */
68
e9a25f70 69#include "config.h"
670ee920 70#include "system.h"
4977bab6
ZW
71#include "coretypes.h"
72#include "tm.h"
ccd043a9 73
00fe048c 74#include "tree.h"
d8a2d370
DN
75#include "varasm.h"
76#include "stor-layout.h"
00fe048c
RS
77#include "rtl.h"
78#include "flags.h"
79#include "regs.h"
80#include "insn-config.h"
81#include "reload.h"
3e487b21 82#include "output.h"
76ead72b 83#include "dbxout.h"
718f9c0f 84#include "diagnostic-core.h"
487a6e06 85#include "toplev.h"
aa388f29 86#include "tm_p.h"
951a525f 87#include "ggc.h"
a51d908e 88#include "debug.h"
c3fb23f4 89#include "function.h"
7c262518 90#include "target.h"
677f3fa8 91#include "common/common-target.h"
3ac88239 92#include "langhooks.h"
93a27b7b 93#include "obstack.h"
9bfa80fb 94#include "expr.h"
9166988f 95#include "cgraph.h"
00fe048c 96
b372168c 97#ifdef XCOFF_DEBUGGING_INFO
95f2ba07 98#include "xcoffout.h"
b372168c
MM
99#endif
100
00fe048c 101#ifndef ASM_STABS_OP
93a27b7b
ZW
102# ifdef XCOFF_DEBUGGING_INFO
103# define ASM_STABS_OP "\t.stabx\t"
104# else
105# define ASM_STABS_OP "\t.stabs\t"
106# endif
00fe048c
RS
107#endif
108
109#ifndef ASM_STABN_OP
0a3e1f45 110#define ASM_STABN_OP "\t.stabn\t"
00fe048c
RS
111#endif
112
93a27b7b
ZW
113#ifndef ASM_STABD_OP
114#define ASM_STABD_OP "\t.stabd\t"
115#endif
116
01e2750c
RS
117#ifndef DBX_TYPE_DECL_STABS_CODE
118#define DBX_TYPE_DECL_STABS_CODE N_LSYM
b372168c
MM
119#endif
120
121#ifndef DBX_STATIC_CONST_VAR_CODE
122#define DBX_STATIC_CONST_VAR_CODE N_FUN
123#endif
124
125#ifndef DBX_REGPARM_STABS_CODE
126#define DBX_REGPARM_STABS_CODE N_RSYM
127#endif
128
129#ifndef DBX_REGPARM_STABS_LETTER
130#define DBX_REGPARM_STABS_LETTER 'P'
131#endif
132
8768c655
RH
133#ifndef NO_DBX_FUNCTION_END
134#define NO_DBX_FUNCTION_END 0
135#endif
136
5d865dac
EB
137#ifndef NO_DBX_BNSYM_ENSYM
138#define NO_DBX_BNSYM_ENSYM 0
139#endif
140
93a27b7b
ZW
141#ifndef NO_DBX_MAIN_SOURCE_DIRECTORY
142#define NO_DBX_MAIN_SOURCE_DIRECTORY 0
143#endif
144
3e487b21
ZW
145#ifndef DBX_BLOCKS_FUNCTION_RELATIVE
146#define DBX_BLOCKS_FUNCTION_RELATIVE 0
147#endif
148
149#ifndef DBX_LINES_FUNCTION_RELATIVE
150#define DBX_LINES_FUNCTION_RELATIVE 0
151#endif
152
93a27b7b
ZW
153#ifndef DBX_CONTIN_LENGTH
154#define DBX_CONTIN_LENGTH 80
155#endif
156
157#ifndef DBX_CONTIN_CHAR
158#define DBX_CONTIN_CHAR '\\'
159#endif
160
00fe048c
RS
161enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
162
4bcaafd9
ILT
163/* Structure recording information about a C data type.
164 The status element says whether we have yet output
165 the definition of the type. TYPE_XREF says we have
166 output it as a cross-reference only.
167 The file_number and type_number elements are used if DBX_USE_BINCL
168 is defined. */
169
d1b38208 170struct GTY(()) typeinfo {
4bcaafd9 171 enum typestatus status;
4bcaafd9
ILT
172 int file_number;
173 int type_number;
4bcaafd9
ILT
174};
175
176/* Vector recording information about C data types.
00fe048c
RS
177 When we first notice a data type (a tree node),
178 we assign it a number using next_type_number.
4bcaafd9 179 That is its index in this vector. */
00fe048c 180
17211ab5 181static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
00fe048c
RS
182
183/* Number of elements of space allocated in `typevec'. */
184
17211ab5 185static GTY(()) int typevec_len;
00fe048c
RS
186
187/* In dbx output, each type gets a unique number.
188 This is the number for the next type output.
189 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
190
17211ab5 191static GTY(()) int next_type_number;
4bcaafd9 192
21d13d83
ZW
193/* The C front end may call dbxout_symbol before dbxout_init runs.
194 We save all such decls in this list and output them when we get
195 to dbxout_init. */
196
197static GTY(()) tree preinit_symbols;
198
33e9d2aa
DP
199enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED};
200
4bcaafd9
ILT
201/* When using N_BINCL in dbx output, each type number is actually a
202 pair of the file number and the type number within the file.
203 This is a stack of input files. */
204
047c6eac 205struct dbx_file
4bcaafd9
ILT
206{
207 struct dbx_file *next;
208 int file_number;
209 int next_type_number;
047c6eac
GK
210 enum binclstatus bincl_status; /* Keep track of lazy bincl. */
211 const char *pending_bincl_name; /* Name of bincl. */
212 struct dbx_file *prev; /* Chain to traverse all pending bincls. */
4bcaafd9
ILT
213};
214
b8698a0f
L
215/* This is the top of the stack.
216
047c6eac
GK
217 This is not saved for PCH, because restoring a PCH should not change it.
218 next_file_number does have to be saved, because the PCH may use some
219 file numbers; however, just before restoring a PCH, next_file_number
220 should always be 0 because we should not have needed any file numbers
221 yet. */
4bcaafd9 222
e139ff5b
AS
223#if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
224 && defined (DBX_USE_BINCL)
047c6eac 225static struct dbx_file *current_file;
a37336cf 226#endif
4bcaafd9
ILT
227
228/* This is the next file number to use. */
229
17211ab5
GK
230static GTY(()) int next_file_number;
231
33b49800 232/* A counter for dbxout_function_end. */
c1b50e49 233
33b49800 234static GTY(()) int scope_labelno;
c1b50e49 235
a8d0467e
EB
236/* A counter for dbxout_source_line. */
237
238static GTY(()) int dbxout_source_line_counter;
239
17211ab5
GK
240/* Number for the next N_SOL filename stabs label. The number 0 is reserved
241 for the N_SO filename stabs label. */
242
33b49800
GK
243static GTY(()) int source_label_number = 1;
244
245/* Last source file name mentioned in a NOTE insn. */
246
247static GTY(()) const char *lastfile;
248
249/* Used by PCH machinery to detect if 'lastfile' should be reset to
250 base_input_file. */
251static GTY(()) int lastfile_is_base;
252
253/* Typical USG systems don't have stab.h, and they also have
254 no use for DBX-format debugging info. */
255
256#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
257
8837d828
AS
258#ifdef DBX_USE_BINCL
259/* If zero then there is no pending BINCL. */
260static int pending_bincls = 0;
261#endif
262
33b49800
GK
263/* The original input file name. */
264static const char *base_input_file;
265
17211ab5 266#ifdef DEBUG_SYMS_TEXT
d6b5193b 267#define FORCE_TEXT switch_to_section (current_function_section ())
17211ab5
GK
268#else
269#define FORCE_TEXT
270#endif
271
272#include "gstab.h"
273
17211ab5
GK
274/* 1 if PARM is passed to this function in memory. */
275
276#define PARM_PASSED_IN_MEMORY(PARM) \
3c0cb5de 277 (MEM_P (DECL_INCOMING_RTL (PARM)))
4bcaafd9 278
17211ab5
GK
279/* A C expression for the integer offset value of an automatic variable
280 (N_LSYM) having address X (an RTX). */
281#ifndef DEBUGGER_AUTO_OFFSET
282#define DEBUGGER_AUTO_OFFSET(X) \
283 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
284#endif
285
286/* A C expression for the integer offset value of an argument (N_PSYM)
3d07b7cd
LCW
287 having address X (an RTX). The nominal offset is OFFSET.
288 Note that we use OFFSET + 0 here to avoid the self-assign warning
289 when the macro is called in a context like
290 number = DEBUGGER_ARG_OFFSET(number, X) */
17211ab5 291#ifndef DEBUGGER_ARG_OFFSET
3d07b7cd 292#define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET + 0)
17211ab5
GK
293#endif
294
93a27b7b
ZW
295/* This obstack holds the stab string currently being constructed. We
296 build it up here, then write it out, so we can split long lines up
297 properly (see dbxout_finish_complex_stabs). */
298static struct obstack stabstr_ob;
299static size_t stabstr_last_contin_point;
00fe048c 300
5ec3a5a7 301#ifdef DBX_USE_BINCL
33e9d2aa
DP
302static void emit_bincl_stab (const char *c);
303static void emit_pending_bincls (void);
f23b9d52 304#endif
33e9d2aa
DP
305static inline void emit_pending_bincls_if_required (void);
306
7080f735 307static void dbxout_init (const char *);
b8698a0f 308
7080f735
AJ
309static void dbxout_finish (const char *);
310static void dbxout_start_source_file (unsigned, const char *);
311static void dbxout_end_source_file (unsigned);
312static void dbxout_typedefs (tree);
7080f735 313static void dbxout_type_index (tree);
7080f735
AJ
314static void dbxout_args (tree);
315static void dbxout_type_fields (tree);
93a27b7b 316static void dbxout_type_method_1 (tree);
7080f735 317static void dbxout_type_methods (tree);
84fb43a1 318static void dbxout_range_type (tree, tree, tree);
7080f735 319static void dbxout_type (tree, int);
84fb43a1 320static bool print_int_cst_bounds_in_octal_p (tree, tree, tree);
7151ffbe 321static bool is_fortran (void);
7080f735
AJ
322static void dbxout_type_name (tree);
323static void dbxout_class_name_qualifiers (tree);
324static int dbxout_symbol_location (tree, tree, const char *, rtx);
325static void dbxout_symbol_name (tree, const char *, int);
dbb6088f 326static void dbxout_common_name (tree, const char *, stab_code_type);
7151ffbe 327static const char *dbxout_common_check (tree, int *);
7080f735 328static void dbxout_global_decl (tree);
8507c40a 329static void dbxout_type_decl (tree, int);
7080f735 330static void dbxout_handle_pch (unsigned);
1ed13f83 331static void debug_free_queue (void);
00fe048c 332\f
7f905405 333/* The debug hooks structure. */
a5a42b92
NB
334#if defined (DBX_DEBUGGING_INFO)
335
ed5ef2e4 336static void dbxout_source_line (unsigned int, const char *, int, bool);
8fa5469d 337static void dbxout_begin_prologue (unsigned int, const char *);
93a27b7b 338static void dbxout_source_file (const char *);
847d0c08 339static void dbxout_function_end (tree);
7080f735
AJ
340static void dbxout_begin_function (tree);
341static void dbxout_begin_block (unsigned, unsigned);
342static void dbxout_end_block (unsigned, unsigned);
343static void dbxout_function_decl (tree);
a5a42b92 344
54b6670a 345const struct gcc_debug_hooks dbx_debug_hooks =
a51d908e
NB
346{
347 dbxout_init,
7f905405 348 dbxout_finish,
3df9609a 349 debug_nothing_void,
7f905405
NB
350 debug_nothing_int_charstar,
351 debug_nothing_int_charstar,
352 dbxout_start_source_file,
a5a42b92
NB
353 dbxout_end_source_file,
354 dbxout_begin_block,
e2a12aca 355 dbxout_end_block,
9678086d 356 debug_true_const_tree, /* ignore_block */
6097b0c3 357 dbxout_source_line, /* source_line */
8fa5469d 358 dbxout_begin_prologue, /* begin_prologue */
6097b0c3 359 debug_nothing_int_charstar, /* end_prologue */
67ad2ae7 360 debug_nothing_int_charstar, /* begin_epilogue */
6097b0c3 361 debug_nothing_int_charstar, /* end_epilogue */
653e276c
NB
362#ifdef DBX_FUNCTION_FIRST
363 dbxout_begin_function,
364#else
6097b0c3 365 debug_nothing_tree, /* begin_function */
653e276c 366#endif
6097b0c3 367 debug_nothing_int, /* end_function */
2b85879e 368 dbxout_function_decl,
6097b0c3 369 dbxout_global_decl, /* global_decl */
21d13d83 370 dbxout_type_decl, /* type_decl */
a64f5186 371 debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */
6097b0c3
DP
372 debug_nothing_tree, /* deferred_inline_function */
373 debug_nothing_tree, /* outlining_inline_function */
374 debug_nothing_rtx, /* label */
014a1138 375 dbxout_handle_pch, /* handle_pch */
9e9945c5 376 debug_nothing_rtx, /* var_location */
87c8b4be 377 debug_nothing_void, /* switch_text_section */
a417cdd9 378 debug_nothing_tree_tree, /* set_name */
c6a13190
ILT
379 0, /* start_end_main_source_file */
380 TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */
a51d908e 381};
a5a42b92
NB
382#endif /* DBX_DEBUGGING_INFO */
383
384#if defined (XCOFF_DEBUGGING_INFO)
54b6670a 385const struct gcc_debug_hooks xcoff_debug_hooks =
a5a42b92
NB
386{
387 dbxout_init,
388 dbxout_finish,
3df9609a 389 debug_nothing_void,
a5a42b92
NB
390 debug_nothing_int_charstar,
391 debug_nothing_int_charstar,
392 dbxout_start_source_file,
393 dbxout_end_source_file,
394 xcoffout_begin_block,
e2a12aca 395 xcoffout_end_block,
9678086d 396 debug_true_const_tree, /* ignore_block */
e2a12aca 397 xcoffout_source_line,
6097b0c3
DP
398 xcoffout_begin_prologue, /* begin_prologue */
399 debug_nothing_int_charstar, /* end_prologue */
67ad2ae7 400 debug_nothing_int_charstar, /* begin_epilogue */
e2a12aca 401 xcoffout_end_epilogue,
6097b0c3 402 debug_nothing_tree, /* begin_function */
2b85879e 403 xcoffout_end_function,
6097b0c3
DP
404 debug_nothing_tree, /* function_decl */
405 dbxout_global_decl, /* global_decl */
21d13d83 406 dbxout_type_decl, /* type_decl */
a64f5186 407 debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */
6097b0c3
DP
408 debug_nothing_tree, /* deferred_inline_function */
409 debug_nothing_tree, /* outlining_inline_function */
410 debug_nothing_rtx, /* label */
014a1138 411 dbxout_handle_pch, /* handle_pch */
9e9945c5 412 debug_nothing_rtx, /* var_location */
87c8b4be 413 debug_nothing_void, /* switch_text_section */
58298177 414 debug_nothing_tree_tree, /* set_name */
c6a13190
ILT
415 0, /* start_end_main_source_file */
416 TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */
a5a42b92
NB
417};
418#endif /* XCOFF_DEBUGGING_INFO */
a51d908e 419\f
93a27b7b
ZW
420/* Numeric formatting helper macro. Note that this does not handle
421 hexadecimal. */
422#define NUMBER_FMT_LOOP(P, NUM, BASE) \
423 do \
424 { \
425 int digit = NUM % BASE; \
426 NUM /= BASE; \
427 *--P = digit + '0'; \
428 } \
429 while (NUM > 0)
430
431/* Utility: write a decimal integer NUM to asm_out_file. */
432void
433dbxout_int (int num)
434{
435 char buf[64];
436 char *p = buf + sizeof buf;
437 unsigned int unum;
438
439 if (num == 0)
440 {
441 putc ('0', asm_out_file);
442 return;
443 }
444 if (num < 0)
445 {
446 putc ('-', asm_out_file);
447 unum = -num;
448 }
449 else
450 unum = num;
451
452 NUMBER_FMT_LOOP (p, unum, 10);
453
454 while (p < buf + sizeof buf)
455 {
456 putc (*p, asm_out_file);
457 p++;
458 }
459}
460
461\f
462/* Primitives for emitting simple stabs directives. All other stabs
463 routines should use these functions instead of directly emitting
464 stabs. They are exported because machine-dependent code may need
465 to invoke them, e.g. in a DBX_OUTPUT_* macro whose definition
466 forwards to code in CPU.c. */
467
468/* The following functions should all be called immediately after one
469 of the dbxout_begin_stab* functions (below). They write out
470 various things as the value of a stab. */
471
472/* Write out a literal zero as the value of a stab. */
473void
474dbxout_stab_value_zero (void)
475{
476 fputs ("0\n", asm_out_file);
477}
478
479/* Write out the label LABEL as the value of a stab. */
480void
481dbxout_stab_value_label (const char *label)
482{
483 assemble_name (asm_out_file, label);
484 putc ('\n', asm_out_file);
485}
486
487/* Write out the difference of two labels, LABEL - BASE, as the value
488 of a stab. */
489void
490dbxout_stab_value_label_diff (const char *label, const char *base)
491{
492 assemble_name (asm_out_file, label);
493 putc ('-', asm_out_file);
494 assemble_name (asm_out_file, base);
495 putc ('\n', asm_out_file);
496}
497
498/* Write out an internal label as the value of a stab, and immediately
499 emit that internal label. This should be used only when
500 dbxout_stabd will not work. STEM is the name stem of the label,
501 COUNTERP is a pointer to a counter variable which will be used to
502 guarantee label uniqueness. */
503void
504dbxout_stab_value_internal_label (const char *stem, int *counterp)
505{
506 char label[100];
507 int counter = counterp ? (*counterp)++ : 0;
508
509 ASM_GENERATE_INTERNAL_LABEL (label, stem, counter);
510 dbxout_stab_value_label (label);
511 targetm.asm_out.internal_label (asm_out_file, stem, counter);
512}
513
514/* Write out the difference between BASE and an internal label as the
515 value of a stab, and immediately emit that internal label. STEM and
516 COUNTERP are as for dbxout_stab_value_internal_label. */
517void
518dbxout_stab_value_internal_label_diff (const char *stem, int *counterp,
519 const char *base)
520{
521 char label[100];
522 int counter = counterp ? (*counterp)++ : 0;
523
524 ASM_GENERATE_INTERNAL_LABEL (label, stem, counter);
525 dbxout_stab_value_label_diff (label, base);
526 targetm.asm_out.internal_label (asm_out_file, stem, counter);
527}
528
529/* The following functions produce specific kinds of stab directives. */
530
531/* Write a .stabd directive with type STYPE and desc SDESC to asm_out_file. */
532void
533dbxout_stabd (int stype, int sdesc)
534{
535 fputs (ASM_STABD_OP, asm_out_file);
536 dbxout_int (stype);
537 fputs (",0,", asm_out_file);
538 dbxout_int (sdesc);
539 putc ('\n', asm_out_file);
540}
541
542/* Write a .stabn directive with type STYPE. This function stops
543 short of emitting the value field, which is the responsibility of
544 the caller (normally it will be either a symbol or the difference
545 of two symbols). */
546
547void
548dbxout_begin_stabn (int stype)
549{
550 fputs (ASM_STABN_OP, asm_out_file);
551 dbxout_int (stype);
552 fputs (",0,0,", asm_out_file);
553}
554
555/* Write a .stabn directive with type N_SLINE and desc LINE. As above,
556 the value field is the responsibility of the caller. */
557void
558dbxout_begin_stabn_sline (int lineno)
559{
560 fputs (ASM_STABN_OP, asm_out_file);
561 dbxout_int (N_SLINE);
562 fputs (",0,", asm_out_file);
563 dbxout_int (lineno);
564 putc (',', asm_out_file);
565}
566
567/* Begin a .stabs directive with string "", type STYPE, and desc and
568 other fields 0. The value field is the responsibility of the
569 caller. This function cannot be used for .stabx directives. */
570void
571dbxout_begin_empty_stabs (int stype)
572{
573 fputs (ASM_STABS_OP, asm_out_file);
574 fputs ("\"\",", asm_out_file);
575 dbxout_int (stype);
576 fputs (",0,0,", asm_out_file);
577}
578
579/* Begin a .stabs directive with string STR, type STYPE, and desc 0.
580 The value field is the responsibility of the caller. */
581void
582dbxout_begin_simple_stabs (const char *str, int stype)
583{
584 fputs (ASM_STABS_OP, asm_out_file);
585 output_quoted_string (asm_out_file, str);
586 putc (',', asm_out_file);
587 dbxout_int (stype);
588 fputs (",0,0,", asm_out_file);
589}
590
591/* As above but use SDESC for the desc field. */
592void
593dbxout_begin_simple_stabs_desc (const char *str, int stype, int sdesc)
594{
595 fputs (ASM_STABS_OP, asm_out_file);
596 output_quoted_string (asm_out_file, str);
597 putc (',', asm_out_file);
598 dbxout_int (stype);
599 fputs (",0,", asm_out_file);
600 dbxout_int (sdesc);
601 putc (',', asm_out_file);
602}
603
604/* The next set of functions are entirely concerned with production of
605 "complex" .stabs directives: that is, .stabs directives whose
606 strings have to be constructed piecemeal. dbxout_type,
607 dbxout_symbol, etc. use these routines heavily. The string is queued
608 up in an obstack, then written out by dbxout_finish_complex_stabs, which
609 is also responsible for splitting it up if it exceeds DBX_CONTIN_LENGTH.
610 (You might think it would be more efficient to go straight to stdio
611 when DBX_CONTIN_LENGTH is 0 (i.e. no length limit) but that turns
612 out not to be the case, and anyway this needs fewer #ifdefs.) */
613
614/* Begin a complex .stabs directive. If we can, write the initial
615 ASM_STABS_OP to the asm_out_file. */
616
617static void
618dbxout_begin_complex_stabs (void)
619{
620 emit_pending_bincls_if_required ();
621 FORCE_TEXT;
622 fputs (ASM_STABS_OP, asm_out_file);
623 putc ('"', asm_out_file);
624 gcc_assert (stabstr_last_contin_point == 0);
625}
626
859ee18f
ZW
627/* As above, but do not force text or emit pending bincls. This is
628 used by dbxout_symbol_location, which needs to do something else. */
629static void
630dbxout_begin_complex_stabs_noforcetext (void)
631{
632 fputs (ASM_STABS_OP, asm_out_file);
633 putc ('"', asm_out_file);
634 gcc_assert (stabstr_last_contin_point == 0);
635}
636
93a27b7b
ZW
637/* Add CHR, a single character, to the string being built. */
638#define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
639
640/* Add STR, a normal C string, to the string being built. */
c3284718 641#define stabstr_S(str) obstack_grow (&stabstr_ob, str, strlen (str))
93a27b7b
ZW
642
643/* Add the text of ID, an IDENTIFIER_NODE, to the string being built. */
644#define stabstr_I(id) obstack_grow (&stabstr_ob, \
645 IDENTIFIER_POINTER (id), \
646 IDENTIFIER_LENGTH (id))
647
648/* Add NUM, a signed decimal number, to the string being built. */
649static void
650stabstr_D (HOST_WIDE_INT num)
651{
652 char buf[64];
653 char *p = buf + sizeof buf;
654 unsigned int unum;
655
656 if (num == 0)
657 {
658 stabstr_C ('0');
659 return;
660 }
661 if (num < 0)
662 {
663 stabstr_C ('-');
664 unum = -num;
665 }
666 else
667 unum = num;
668
669 NUMBER_FMT_LOOP (p, unum, 10);
670
671 obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
672}
673
674/* Add NUM, an unsigned decimal number, to the string being built. */
675static void
676stabstr_U (unsigned HOST_WIDE_INT num)
677{
678 char buf[64];
679 char *p = buf + sizeof buf;
680 if (num == 0)
681 {
682 stabstr_C ('0');
683 return;
684 }
685 NUMBER_FMT_LOOP (p, num, 10);
686 obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
687}
688
689/* Add CST, an INTEGER_CST tree, to the string being built as an
690 unsigned octal number. This routine handles values which are
691 larger than a single HOST_WIDE_INT. */
692static void
693stabstr_O (tree cst)
694{
695 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (cst);
696 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (cst);
697
698 char buf[128];
699 char *p = buf + sizeof buf;
700
701 /* GDB wants constants with no extra leading "1" bits, so
702 we need to remove any sign-extension that might be
703 present. */
704 {
705 const unsigned int width = TYPE_PRECISION (TREE_TYPE (cst));
49ab6098 706 if (width == HOST_BITS_PER_DOUBLE_INT)
93a27b7b
ZW
707 ;
708 else if (width > HOST_BITS_PER_WIDE_INT)
709 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
710 else if (width == HOST_BITS_PER_WIDE_INT)
711 high = 0;
712 else
713 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
714 }
715
716 /* Leading zero for base indicator. */
717 stabstr_C ('0');
718
719 /* If the value is zero, the base indicator will serve as the value
720 all by itself. */
721 if (high == 0 && low == 0)
722 return;
723
724 /* If the high half is zero, we need only print the low half normally. */
725 if (high == 0)
726 NUMBER_FMT_LOOP (p, low, 8);
727 else
728 {
729 /* When high != 0, we need to print enough zeroes from low to
730 give the digits from high their proper place-values. Hence
731 NUMBER_FMT_LOOP cannot be used. */
732 const int n_digits = HOST_BITS_PER_WIDE_INT / 3;
733 int i;
734
735 for (i = 1; i <= n_digits; i++)
736 {
737 unsigned int digit = low % 8;
738 low /= 8;
739 *--p = '0' + digit;
740 }
741
742 /* Octal digits carry exactly three bits of information. The
743 width of a HOST_WIDE_INT is not normally a multiple of three.
744 Therefore, the next digit printed probably needs to carry
745 information from both low and high. */
746 if (HOST_BITS_PER_WIDE_INT % 3 != 0)
747 {
748 const int n_leftover_bits = HOST_BITS_PER_WIDE_INT % 3;
749 const int n_bits_from_high = 3 - n_leftover_bits;
750
751 const unsigned HOST_WIDE_INT
752 low_mask = (((unsigned HOST_WIDE_INT)1) << n_leftover_bits) - 1;
753 const unsigned HOST_WIDE_INT
754 high_mask = (((unsigned HOST_WIDE_INT)1) << n_bits_from_high) - 1;
755
756 unsigned int digit;
757
758 /* At this point, only the bottom n_leftover_bits bits of low
759 should be set. */
760 gcc_assert (!(low & ~low_mask));
761
762 digit = (low | ((high & high_mask) << n_leftover_bits));
763 high >>= n_bits_from_high;
764
765 *--p = '0' + digit;
766 }
767
768 /* Now we can format high in the normal manner. However, if
769 the only bits of high that were set were handled by the
770 digit split between low and high, high will now be zero, and
771 we don't want to print extra digits in that case. */
772 if (high)
773 NUMBER_FMT_LOOP (p, high, 8);
774 }
775
776 obstack_grow (&stabstr_ob, p, (buf + sizeof buf) - p);
777}
778
779/* Called whenever it is safe to break a stabs string into multiple
780 .stabs directives. If the current string has exceeded the limit
781 set by DBX_CONTIN_LENGTH, mark the current position in the buffer
782 as a continuation point by inserting DBX_CONTIN_CHAR (doubled if
783 it is a backslash) and a null character. */
784static inline void
785stabstr_continue (void)
786{
787 if (DBX_CONTIN_LENGTH > 0
788 && obstack_object_size (&stabstr_ob) - stabstr_last_contin_point
789 > DBX_CONTIN_LENGTH)
790 {
791 if (DBX_CONTIN_CHAR == '\\')
792 obstack_1grow (&stabstr_ob, '\\');
793 obstack_1grow (&stabstr_ob, DBX_CONTIN_CHAR);
794 obstack_1grow (&stabstr_ob, '\0');
795 stabstr_last_contin_point = obstack_object_size (&stabstr_ob);
796 }
797}
798#define CONTIN stabstr_continue ()
799
800/* Macro subroutine of dbxout_finish_complex_stabs, which emits
801 all of the arguments to the .stabs directive after the string.
802 Overridden by xcoffout.h. CODE is the stabs code for this symbol;
803 LINE is the source line to write into the desc field (in extended
859ee18f 804 mode); SYM is the symbol itself.
93a27b7b
ZW
805
806 ADDR, LABEL, and NUMBER are three different ways to represent the
807 stabs value field. At most one of these should be nonzero.
808
809 ADDR is used most of the time; it represents the value as an
810 RTL address constant.
811
812 LABEL is used (currently) only for N_CATCH stabs; it represents
813 the value as a string suitable for assemble_name.
814
815 NUMBER is used when the value is an offset from an implicit base
816 pointer (e.g. for a stack variable), or an index (e.g. for a
817 register variable). It represents the value as a decimal integer. */
818
819#ifndef DBX_FINISH_STABS
859ee18f
ZW
820#define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
821do { \
93a27b7b
ZW
822 int line_ = use_gnu_debug_info_extensions ? LINE : 0; \
823 \
824 dbxout_int (CODE); \
825 fputs (",0,", asm_out_file); \
826 dbxout_int (line_); \
827 putc (',', asm_out_file); \
828 if (ADDR) \
829 output_addr_const (asm_out_file, ADDR); \
830 else if (LABEL) \
831 assemble_name (asm_out_file, LABEL); \
832 else \
833 dbxout_int (NUMBER); \
834 putc ('\n', asm_out_file); \
835} while (0)
836#endif
837
838/* Finish the emission of a complex .stabs directive. When DBX_CONTIN_LENGTH
839 is zero, this has only to emit the close quote and the remainder of
840 the arguments. When it is nonzero, the string has been marshalled in
841 stabstr_ob, and this routine is responsible for breaking it up into
842 DBX_CONTIN_LENGTH-sized chunks.
843
844 SYM is the DECL of the symbol under consideration; it is used only
845 for its DECL_SOURCE_LINE. The other arguments are all passed directly
846 to DBX_FINISH_STABS; see above for details. */
b8698a0f 847
93a27b7b 848static void
dbb6088f 849dbxout_finish_complex_stabs (tree sym, stab_code_type code,
93a27b7b
ZW
850 rtx addr, const char *label, int number)
851{
12126025 852 int line ATTRIBUTE_UNUSED;
93a27b7b
ZW
853 char *str;
854 size_t len;
855
12126025 856 line = sym ? DECL_SOURCE_LINE (sym) : 0;
93a27b7b
ZW
857 if (DBX_CONTIN_LENGTH > 0)
858 {
859 char *chunk;
860 size_t chunklen;
861
862 /* Nul-terminate the growing string, then get its size and
863 address. */
864 obstack_1grow (&stabstr_ob, '\0');
865
866 len = obstack_object_size (&stabstr_ob);
7973fd2a 867 chunk = str = XOBFINISH (&stabstr_ob, char *);
93a27b7b
ZW
868
869 /* Within the buffer are a sequence of NUL-separated strings,
870 each of which is to be written out as a separate stab
871 directive. */
872 for (;;)
873 {
874 chunklen = strlen (chunk);
875 fwrite (chunk, 1, chunklen, asm_out_file);
876 fputs ("\",", asm_out_file);
877
878 /* Must add an extra byte to account for the NUL separator. */
879 chunk += chunklen + 1;
880 len -= chunklen + 1;
881
882 /* Only put a line number on the last stab in the sequence. */
859ee18f
ZW
883 DBX_FINISH_STABS (sym, code, len == 0 ? line : 0,
884 addr, label, number);
93a27b7b
ZW
885 if (len == 0)
886 break;
887
888 fputs (ASM_STABS_OP, asm_out_file);
889 putc ('"', asm_out_file);
890 }
891 stabstr_last_contin_point = 0;
892 }
893 else
894 {
895 /* No continuations - we can put the whole string out at once.
896 It is faster to augment the string with the close quote and
897 comma than to do a two-character fputs. */
898 obstack_grow (&stabstr_ob, "\",", 2);
899 len = obstack_object_size (&stabstr_ob);
7973fd2a 900 str = XOBFINISH (&stabstr_ob, char *);
b8698a0f 901
93a27b7b 902 fwrite (str, 1, len, asm_out_file);
859ee18f 903 DBX_FINISH_STABS (sym, code, line, addr, label, number);
93a27b7b
ZW
904 }
905 obstack_free (&stabstr_ob, str);
906}
907
96621ebf 908#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
93a27b7b 909
f55dfa2f
NF
910/* When -gused is used, emit debug info for only used symbols. But in
911 addition to the standard intercepted debug_hooks there are some
912 direct calls into this file, i.e., dbxout_symbol, dbxout_parms, and
913 dbxout_reg_params. Those routines may also be called from a higher
914 level intercepted routine. So to prevent recording data for an inner
915 call to one of these for an intercept, we maintain an intercept
916 nesting counter (debug_nesting). We only save the intercepted
917 arguments if the nesting is 1. */
918static int debug_nesting = 0;
919
920static tree *symbol_queue;
921static int symbol_queue_index = 0;
922static int symbol_queue_size = 0;
923
924#define DBXOUT_DECR_NESTING \
925 if (--debug_nesting == 0 && symbol_queue_index > 0) \
926 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
927
928#define DBXOUT_DECR_NESTING_AND_RETURN(x) \
929 do {--debug_nesting; return (x);} while (0)
930
96621ebf
TG
931#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
932
933#if defined (DBX_DEBUGGING_INFO)
934
cf440348 935static void
725730f2 936dbxout_function_end (tree decl ATTRIBUTE_UNUSED)
cf440348
JL
937{
938 char lscope_label_name[100];
750054a2 939
403f8503
ZW
940 /* The Lscope label must be emitted even if we aren't doing anything
941 else; dbxout_block needs it. */
d6b5193b 942 switch_to_section (function_section (current_function_decl));
b8698a0f 943
93a27b7b 944 /* Convert Lscope into the appropriate format for local labels in case
cf440348
JL
945 the system doesn't insert underscores in front of user generated
946 labels. */
e098f3a5
CD
947 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
948 targetm.asm_out.internal_label (asm_out_file, "Lscope", scope_labelno);
cf440348 949
4a22dcdd
UW
950 /* The N_FUN tag at the end of the function is a GNU extension,
951 which may be undesirable, and is unnecessary if we do not have
952 named sections. */
953 if (!use_gnu_debug_info_extensions
954 || NO_DBX_FUNCTION_END
677f3fa8 955 || !targetm_common.have_named_sections)
4a22dcdd
UW
956 return;
957
cf440348
JL
958 /* By convention, GCC will mark the end of a function with an N_FUN
959 symbol and an empty string. */
87c8b4be
CT
960 if (flag_reorder_blocks_and_partition)
961 {
962 dbxout_begin_empty_stabs (N_FUN);
b8698a0f 963 dbxout_stab_value_label_diff (crtl->subsections.hot_section_end_label,
38173d38 964 crtl->subsections.hot_section_label);
87c8b4be 965 dbxout_begin_empty_stabs (N_FUN);
b8698a0f 966 dbxout_stab_value_label_diff (crtl->subsections.cold_section_end_label,
38173d38 967 crtl->subsections.cold_section_label);
87c8b4be
CT
968 }
969 else
970 {
03471b3f
CD
971 char begin_label[20];
972 /* Reference current function start using LFBB. */
e098f3a5 973 ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
87c8b4be 974 dbxout_begin_empty_stabs (N_FUN);
03471b3f 975 dbxout_stab_value_label_diff (lscope_label_name, begin_label);
87c8b4be 976 }
8fa5469d 977
5d865dac 978 if (!NO_DBX_BNSYM_ENSYM && !flag_debug_only_used_symbols)
93a27b7b 979 dbxout_stabd (N_ENSYM, 0);
cf440348 980}
c3fb23f4 981#endif /* DBX_DEBUGGING_INFO */
cf440348 982
0456cbf6 983/* Get lang description for N_SO stab. */
93a27b7b 984static unsigned int ATTRIBUTE_UNUSED
0456cbf6
DP
985get_lang_number (void)
986{
987 const char *language_string = lang_hooks.name;
988
989 if (strcmp (language_string, "GNU C") == 0)
990 return N_SO_C;
991 else if (strcmp (language_string, "GNU C++") == 0)
992 return N_SO_CC;
993 else if (strcmp (language_string, "GNU F77") == 0)
994 return N_SO_FORTRAN;
3135ce84 995 else if (strcmp (language_string, "GNU Fortran") == 0)
0456cbf6
DP
996 return N_SO_FORTRAN90; /* CHECKME */
997 else if (strcmp (language_string, "GNU Pascal") == 0)
998 return N_SO_PASCAL;
999 else if (strcmp (language_string, "GNU Objective-C") == 0)
1000 return N_SO_OBJC;
6e955430
ZL
1001 else if (strcmp (language_string, "GNU Objective-C++") == 0)
1002 return N_SO_OBJCPLUS;
0456cbf6
DP
1003 else
1004 return 0;
1005
1006}
1007
7151ffbe
GH
1008static bool
1009is_fortran (void)
1010{
1011 unsigned int lang = get_lang_number ();
1012
1013 return (lang == N_SO_FORTRAN) || (lang == N_SO_FORTRAN90);
1014}
1015
00fe048c
RS
1016/* At the beginning of compilation, start writing the symbol table.
1017 Initialize `typevec' and output the standard data types of C. */
1018
a51d908e 1019static void
7080f735 1020dbxout_init (const char *input_file_name)
00fe048c
RS
1021{
1022 char ltext_label_name[100];
93a27b7b 1023 bool used_ltext_label_name = false;
ae2bcd98 1024 tree syms = lang_hooks.decls.getdecls ();
c8aea42c 1025 const char *mapped_name;
00fe048c 1026
00fe048c 1027 typevec_len = 100;
a9429e29 1028 typevec = ggc_alloc_cleared_vec_typeinfo (typevec_len);
00fe048c 1029
93a27b7b
ZW
1030 /* stabstr_ob contains one string, which will be just fine with
1031 1-byte alignment. */
1032 obstack_specify_allocation (&stabstr_ob, 0, 1, xmalloc, free);
1033
00fe048c
RS
1034 /* Convert Ltext into the appropriate format for local labels in case
1035 the system doesn't insert underscores in front of user generated
1036 labels. */
1037 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
1038
1039 /* Put the current working directory in an N_SO symbol. */
93a27b7b 1040 if (use_gnu_debug_info_extensions && !NO_DBX_MAIN_SOURCE_DIRECTORY)
b372168c 1041 {
ac746f1d
ZW
1042 static const char *cwd;
1043
1044 if (!cwd)
b372168c 1045 {
ac746f1d
ZW
1046 cwd = get_src_pwd ();
1047 if (cwd[0] == '\0')
1048 cwd = "/";
1049 else if (!IS_DIR_SEPARATOR (cwd[strlen (cwd) - 1]))
1050 cwd = concat (cwd, "/", NULL);
c8aea42c 1051 cwd = remap_debug_filename (cwd);
ac746f1d 1052 }
00fe048c 1053#ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
ac746f1d 1054 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file, cwd);
00fe048c 1055#else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
93a27b7b
ZW
1056 dbxout_begin_simple_stabs_desc (cwd, N_SO, get_lang_number ());
1057 dbxout_stab_value_label (ltext_label_name);
1058 used_ltext_label_name = true;
00fe048c 1059#endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
b372168c 1060 }
00fe048c 1061
c8aea42c 1062 mapped_name = remap_debug_filename (input_file_name);
00fe048c 1063#ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
c8aea42c 1064 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file, mapped_name);
ad087b92 1065#else
c8aea42c 1066 dbxout_begin_simple_stabs_desc (mapped_name, N_SO, get_lang_number ());
93a27b7b
ZW
1067 dbxout_stab_value_label (ltext_label_name);
1068 used_ltext_label_name = true;
1069#endif
1070
1071 if (used_ltext_label_name)
1072 {
d6b5193b 1073 switch_to_section (text_section);
93a27b7b
ZW
1074 targetm.asm_out.internal_label (asm_out_file, "Ltext", 0);
1075 }
1076
ac746f1d
ZW
1077 /* Emit an N_OPT stab to indicate that this file was compiled by GCC.
1078 The string used is historical. */
93a27b7b
ZW
1079#ifndef NO_DBX_GCC_MARKER
1080 dbxout_begin_simple_stabs ("gcc2_compiled.", N_OPT);
1081 dbxout_stab_value_zero ();
ad087b92 1082#endif
01571284 1083
33b49800 1084 base_input_file = lastfile = input_file_name;
00fe048c
RS
1085
1086 next_type_number = 1;
00fe048c 1087
4bcaafd9 1088#ifdef DBX_USE_BINCL
5ed6ace5 1089 current_file = XNEW (struct dbx_file);
4bcaafd9
ILT
1090 current_file->next = NULL;
1091 current_file->file_number = 0;
1092 current_file->next_type_number = 1;
1093 next_file_number = 1;
33e9d2aa
DP
1094 current_file->prev = NULL;
1095 current_file->bincl_status = BINCL_NOT_REQUIRED;
1096 current_file->pending_bincl_name = NULL;
4bcaafd9
ILT
1097#endif
1098
47aa0df4
MM
1099 /* Get all permanent types that have typedef names, and output them
1100 all, except for those already output. Some language front ends
21d13d83
ZW
1101 put these declarations in the top-level scope; some do not;
1102 the latter are responsible for calling debug_hooks->type_decl from
1103 their record_builtin_type function. */
00fe048c 1104 dbxout_typedefs (syms);
21d13d83
ZW
1105
1106 if (preinit_symbols)
1107 {
1108 tree t;
1109 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
1110 dbxout_symbol (TREE_VALUE (t), 0);
1111 preinit_symbols = 0;
1112 }
00fe048c
RS
1113}
1114
0ee55ad8 1115/* Output any typedef names for types described by TYPE_DECLs in SYMS. */
00fe048c
RS
1116
1117static void
7080f735 1118dbxout_typedefs (tree syms)
00fe048c 1119{
910ad8de 1120 for (; syms != NULL_TREE; syms = DECL_CHAIN (syms))
00fe048c 1121 {
00fe048c
RS
1122 if (TREE_CODE (syms) == TYPE_DECL)
1123 {
1124 tree type = TREE_TYPE (syms);
1125 if (TYPE_NAME (type)
1126 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
a354c7d6 1127 && COMPLETE_OR_VOID_TYPE_P (type)
00fe048c
RS
1128 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
1129 dbxout_symbol (TYPE_NAME (type), 0);
1130 }
1131 }
1132}
1133
f23b9d52 1134#ifdef DBX_USE_BINCL
4ed43216 1135/* Emit BINCL stab using given name. */
33e9d2aa
DP
1136static void
1137emit_bincl_stab (const char *name)
1138{
93a27b7b
ZW
1139 dbxout_begin_simple_stabs (name, N_BINCL);
1140 dbxout_stab_value_zero ();
33e9d2aa
DP
1141}
1142
1143/* If there are pending bincls then it is time to emit all of them. */
1144
1145static inline void
7e51717c 1146emit_pending_bincls_if_required (void)
33e9d2aa 1147{
33e9d2aa
DP
1148 if (pending_bincls)
1149 emit_pending_bincls ();
33e9d2aa
DP
1150}
1151
1152/* Emit all pending bincls. */
1153
1154static void
7e51717c 1155emit_pending_bincls (void)
33e9d2aa
DP
1156{
1157 struct dbx_file *f = current_file;
1158
1159 /* Find first pending bincl. */
1160 while (f->bincl_status == BINCL_PENDING)
1161 f = f->next;
1162
1163 /* Now emit all bincls. */
1164 f = f->prev;
1165
1166 while (f)
1167 {
1168 if (f->bincl_status == BINCL_PENDING)
1169 {
1170 emit_bincl_stab (f->pending_bincl_name);
1171
1172 /* Update file number and status. */
1173 f->file_number = next_file_number++;
1174 f->bincl_status = BINCL_PROCESSED;
1175 }
1176 if (f == current_file)
1177 break;
1178 f = f->prev;
1179 }
1180
1181 /* All pending bincls have been emitted. */
1182 pending_bincls = 0;
1183}
1184
f23b9d52
DE
1185#else
1186
1187static inline void
7e51717c 1188emit_pending_bincls_if_required (void) {}
f23b9d52
DE
1189#endif
1190
4bcaafd9
ILT
1191/* Change to reading from a new source file. Generate a N_BINCL stab. */
1192
7f905405 1193static void
7080f735
AJ
1194dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
1195 const char *filename ATTRIBUTE_UNUSED)
4bcaafd9
ILT
1196{
1197#ifdef DBX_USE_BINCL
5ed6ace5 1198 struct dbx_file *n = XNEW (struct dbx_file);
4bcaafd9
ILT
1199
1200 n->next = current_file;
4bcaafd9 1201 n->next_type_number = 1;
b8698a0f 1202 /* Do not assign file number now.
33e9d2aa
DP
1203 Delay it until we actually emit BINCL. */
1204 n->file_number = 0;
1205 n->prev = NULL;
1206 current_file->prev = n;
1207 n->bincl_status = BINCL_PENDING;
c8aea42c 1208 n->pending_bincl_name = remap_debug_filename (filename);
33e9d2aa 1209 pending_bincls = 1;
4bcaafd9 1210 current_file = n;
4bcaafd9
ILT
1211#endif
1212}
1213
1214/* Revert to reading a previous source file. Generate a N_EINCL stab. */
1215
7f905405 1216static void
7080f735 1217dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
4bcaafd9
ILT
1218{
1219#ifdef DBX_USE_BINCL
33e9d2aa
DP
1220 /* Emit EINCL stab only if BINCL is not pending. */
1221 if (current_file->bincl_status == BINCL_PROCESSED)
93a27b7b
ZW
1222 {
1223 dbxout_begin_stabn (N_EINCL);
1224 dbxout_stab_value_zero ();
1225 }
33e9d2aa 1226 current_file->bincl_status = BINCL_NOT_REQUIRED;
17211ab5 1227 current_file = current_file->next;
4bcaafd9
ILT
1228#endif
1229}
1230
33b49800
GK
1231/* Handle a few odd cases that occur when trying to make PCH files work. */
1232
1233static void
1234dbxout_handle_pch (unsigned at_end)
1235{
1236 if (! at_end)
1237 {
1238 /* When using the PCH, this file will be included, so we need to output
1239 a BINCL. */
1240 dbxout_start_source_file (0, lastfile);
1241
1242 /* The base file when using the PCH won't be the same as
1243 the base file when it's being generated. */
1244 lastfile = NULL;
1245 }
1246 else
1247 {
71c0e7fc 1248 /* ... and an EINCL. */
33b49800
GK
1249 dbxout_end_source_file (0);
1250
1251 /* Deal with cases where 'lastfile' was never actually changed. */
1252 lastfile_is_base = lastfile == NULL;
1253 }
1254}
1255
c3fb23f4 1256#if defined (DBX_DEBUGGING_INFO)
b420396f
OH
1257
1258static void dbxout_block (tree, int, tree);
1259
00fe048c
RS
1260/* Output debugging info to FILE to switch to sourcefile FILENAME. */
1261
e1772ac0 1262static void
93a27b7b 1263dbxout_source_file (const char *filename)
00fe048c 1264{
33b49800
GK
1265 if (lastfile == 0 && lastfile_is_base)
1266 {
1267 lastfile = base_input_file;
1268 lastfile_is_base = 0;
1269 }
1270
00fe048c
RS
1271 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
1272 {
93a27b7b
ZW
1273 /* Don't change section amid function. */
1274 if (current_function_decl == NULL_TREE)
d6b5193b 1275 switch_to_section (text_section);
93a27b7b 1276
c8aea42c 1277 dbxout_begin_simple_stabs (remap_debug_filename (filename), N_SOL);
93a27b7b 1278 dbxout_stab_value_internal_label ("Ltext", &source_label_number);
00fe048c
RS
1279 lastfile = filename;
1280 }
1281}
1282
b8698a0f 1283/* Output N_BNSYM, line number symbol entry, and local symbol at
03471b3f 1284 function scope */
8fa5469d
DP
1285
1286static void
1287dbxout_begin_prologue (unsigned int lineno, const char *filename)
1288{
8768c655
RH
1289 if (use_gnu_debug_info_extensions
1290 && !NO_DBX_FUNCTION_END
5d865dac 1291 && !NO_DBX_BNSYM_ENSYM
8768c655 1292 && !flag_debug_only_used_symbols)
93a27b7b 1293 dbxout_stabd (N_BNSYM, 0);
8fa5469d 1294
e098f3a5
CD
1295 /* pre-increment the scope counter */
1296 scope_labelno++;
1297
ed5ef2e4 1298 dbxout_source_line (lineno, filename, 0, true);
b8698a0f 1299 /* Output function begin block at function scope, referenced
03471b3f
CD
1300 by dbxout_block, dbxout_source_line and dbxout_function_end. */
1301 emit_pending_bincls_if_required ();
1302 targetm.asm_out.internal_label (asm_out_file, "LFBB", scope_labelno);
8fa5469d
DP
1303}
1304
653e276c
NB
1305/* Output a line number symbol entry for source file FILENAME and line
1306 number LINENO. */
674c724c 1307
e2a12aca 1308static void
6c52e687 1309dbxout_source_line (unsigned int lineno, const char *filename,
ed5ef2e4
CC
1310 int discriminator ATTRIBUTE_UNUSED,
1311 bool is_stmt ATTRIBUTE_UNUSED)
674c724c 1312{
93a27b7b 1313 dbxout_source_file (filename);
674c724c 1314
3e487b21 1315#ifdef DBX_OUTPUT_SOURCE_LINE
3e487b21 1316 DBX_OUTPUT_SOURCE_LINE (asm_out_file, lineno, dbxout_source_line_counter);
674c724c 1317#else
3e487b21
ZW
1318 if (DBX_LINES_FUNCTION_RELATIVE)
1319 {
03471b3f 1320 char begin_label[20];
93a27b7b 1321 dbxout_begin_stabn_sline (lineno);
03471b3f 1322 /* Reference current function start using LFBB. */
b8698a0f 1323 ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
93a27b7b 1324 dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter,
03471b3f 1325 begin_label);
3e487b21
ZW
1326 }
1327 else
93a27b7b 1328 dbxout_stabd (N_SLINE, lineno);
674c724c
RS
1329#endif
1330}
1331
a5a42b92
NB
1332/* Describe the beginning of an internal block within a function. */
1333
1334static void
7080f735 1335dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
a5a42b92 1336{
33e9d2aa 1337 emit_pending_bincls_if_required ();
3e487b21 1338 targetm.asm_out.internal_label (asm_out_file, "LBB", n);
a5a42b92
NB
1339}
1340
1341/* Describe the end line-number of an internal block within a function. */
1342
1343static void
7080f735 1344dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
a5a42b92 1345{
33e9d2aa 1346 emit_pending_bincls_if_required ();
3e487b21 1347 targetm.asm_out.internal_label (asm_out_file, "LBE", n);
a5a42b92
NB
1348}
1349
2b85879e
NB
1350/* Output dbx data for a function definition.
1351 This includes a definition of the function name itself (a symbol),
1352 definitions of the parameters (locating them in the parameter list)
1353 and then output the block that makes up the function's body
1354 (including all the auto variables of the function). */
1355
1356static void
7080f735 1357dbxout_function_decl (tree decl)
2b85879e 1358{
33e9d2aa 1359 emit_pending_bincls_if_required ();
2b85879e
NB
1360#ifndef DBX_FUNCTION_FIRST
1361 dbxout_begin_function (decl);
1362#endif
1363 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
847d0c08 1364 dbxout_function_end (decl);
2b85879e
NB
1365}
1366
a5a42b92
NB
1367#endif /* DBX_DEBUGGING_INFO */
1368
440aabf8
NB
1369/* Debug information for a global DECL. Called from toplev.c after
1370 compilation proper has finished. */
1371static void
7080f735 1372dbxout_global_decl (tree decl)
440aabf8 1373{
9bfa80fb 1374 if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
6a08f7b3
DP
1375 {
1376 int saved_tree_used = TREE_USED (decl);
1377 TREE_USED (decl) = 1;
1378 dbxout_symbol (decl, 0);
1379 TREE_USED (decl) = saved_tree_used;
1380 }
3a538a66 1381}
440aabf8 1382
21d13d83
ZW
1383/* This is just a function-type adapter; dbxout_symbol does exactly
1384 what we want but returns an int. */
1385static void
1386dbxout_type_decl (tree decl, int local)
1387{
1388 dbxout_symbol (decl, local);
1389}
1390
00fe048c 1391/* At the end of compilation, finish writing the symbol table.
3e487b21 1392 The default is to call debug_free_queue but do nothing else. */
00fe048c 1393
a51d908e 1394static void
7080f735 1395dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
00fe048c
RS
1396{
1397#ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
3e487b21
ZW
1398 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file, filename);
1399#elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
1400 {
d6b5193b 1401 switch_to_section (text_section);
93a27b7b
ZW
1402 dbxout_begin_empty_stabs (N_SO);
1403 dbxout_stab_value_internal_label ("Letext", 0);
3e487b21
ZW
1404 }
1405#endif
6a08f7b3 1406 debug_free_queue ();
00fe048c
RS
1407}
1408
4bcaafd9
ILT
1409/* Output the index of a type. */
1410
1411static void
7080f735 1412dbxout_type_index (tree type)
4bcaafd9
ILT
1413{
1414#ifndef DBX_USE_BINCL
93a27b7b 1415 stabstr_D (TYPE_SYMTAB_ADDRESS (type));
4bcaafd9
ILT
1416#else
1417 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
93a27b7b
ZW
1418 stabstr_C ('(');
1419 stabstr_D (t->file_number);
1420 stabstr_C (',');
1421 stabstr_D (t->type_number);
1422 stabstr_C (')');
4bcaafd9
ILT
1423#endif
1424}
1425
00fe048c 1426\f
1ed13f83
NF
1427/* Generate the symbols for any queued up type symbols we encountered
1428 while generating the type info for some originally used symbol.
1429 This might generate additional entries in the queue. Only when
1430 the nesting depth goes to 0 is this routine called. */
1431
1432static void
1433debug_flush_symbol_queue (void)
1434{
1435 int i;
1436
1437 /* Make sure that additionally queued items are not flushed
1438 prematurely. */
1439
1440 ++debug_nesting;
1441
1442 for (i = 0; i < symbol_queue_index; ++i)
1443 {
1444 /* If we pushed queued symbols then such symbols must be
1445 output no matter what anyone else says. Specifically,
1446 we need to make sure dbxout_symbol() thinks the symbol was
1447 used and also we need to override TYPE_DECL_SUPPRESS_DEBUG
1448 which may be set for outside reasons. */
1449 int saved_tree_used = TREE_USED (symbol_queue[i]);
1450 int saved_suppress_debug = TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]);
1451 TREE_USED (symbol_queue[i]) = 1;
1452 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = 0;
1453
1454#ifdef DBX_DEBUGGING_INFO
1455 dbxout_symbol (symbol_queue[i], 0);
1456#endif
1457
1458 TREE_USED (symbol_queue[i]) = saved_tree_used;
1459 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = saved_suppress_debug;
1460 }
1461
1462 symbol_queue_index = 0;
1463 --debug_nesting;
1464}
1465
1466/* Queue a type symbol needed as part of the definition of a decl
1467 symbol. These symbols are generated when debug_flush_symbol_queue()
1468 is called. */
93a27b7b 1469
1ed13f83
NF
1470static void
1471debug_queue_symbol (tree decl)
1472{
1473 if (symbol_queue_index >= symbol_queue_size)
1474 {
1475 symbol_queue_size += 10;
1476 symbol_queue = XRESIZEVEC (tree, symbol_queue, symbol_queue_size);
1477 }
1478
1479 symbol_queue[symbol_queue_index++] = decl;
1480}
1481
1482/* Free symbol queue. */
1483static void
1484debug_free_queue (void)
1485{
1486 if (symbol_queue)
1487 {
1488 free (symbol_queue);
1489 symbol_queue = NULL;
1490 symbol_queue_size = 0;
1491 }
1492}
1493\f
93a27b7b
ZW
1494/* Used in several places: evaluates to '0' for a private decl,
1495 '1' for a protected decl, '2' for a public decl. */
1496#define DECL_ACCESSIBILITY_CHAR(DECL) \
6e57a01d 1497(TREE_PRIVATE (DECL) ? '0' : TREE_PROTECTED (DECL) ? '1' : '2')
93a27b7b 1498
6dc42e49 1499/* Subroutine of `dbxout_type'. Output the type fields of TYPE.
00fe048c
RS
1500 This must be a separate function because anonymous unions require
1501 recursive calls. */
1502
1503static void
7080f735 1504dbxout_type_fields (tree type)
00fe048c
RS
1505{
1506 tree tem;
665f2503 1507
15a5b8a2 1508 /* Output the name, type, position (in bits), size (in bits) of each
665f2503 1509 field that we can support. */
910ad8de 1510 for (tem = TYPE_FIELDS (type); tem; tem = DECL_CHAIN (tem))
00fe048c 1511 {
666c27b9
KH
1512 /* If one of the nodes is an error_mark or its type is then
1513 return early. */
b504a918 1514 if (error_operand_p (tem))
975421be
AP
1515 return;
1516
00fe048c 1517 /* Omit here local type decls until we know how to support them. */
665f2503 1518 if (TREE_CODE (tem) == TYPE_DECL
b8621d81
AH
1519 /* Omit here the nameless fields that are used to skip bits. */
1520 || DECL_IGNORED_P (tem)
665f2503
RK
1521 /* Omit fields whose position or size are variable or too large to
1522 represent. */
1523 || (TREE_CODE (tem) == FIELD_DECL
9541ffee 1524 && (! tree_fits_shwi_p (bit_position (tem))
06ebf127 1525 || ! DECL_SIZE (tem)
cc269bb6 1526 || ! tree_fits_uhwi_p (DECL_SIZE (tem)))))
7b1f7d51 1527 continue;
665f2503 1528
5b6e175e 1529 else if (TREE_CODE (tem) != CONST_DECL)
00fe048c
RS
1530 {
1531 /* Continue the line if necessary,
1532 but not before the first field. */
1533 if (tem != TYPE_FIELDS (type))
665f2503 1534 CONTIN;
00fe048c 1535
5b6e175e 1536 if (DECL_NAME (tem))
93a27b7b
ZW
1537 stabstr_I (DECL_NAME (tem));
1538 stabstr_C (':');
00fe048c 1539
196cedd0 1540 if (use_gnu_debug_info_extensions
00fe048c
RS
1541 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
1542 || TREE_CODE (tem) != FIELD_DECL))
1543 {
93a27b7b
ZW
1544 stabstr_C ('/');
1545 stabstr_C (DECL_ACCESSIBILITY_CHAR (tem));
00fe048c
RS
1546 }
1547
1548 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
1549 && DECL_BIT_FIELD_TYPE (tem))
deda4b76 1550 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
00fe048c
RS
1551
1552 if (TREE_CODE (tem) == VAR_DECL)
1553 {
196cedd0 1554 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
00fe048c 1555 {
02e3f1a8
RK
1556 tree name = DECL_ASSEMBLER_NAME (tem);
1557
93a27b7b
ZW
1558 stabstr_C (':');
1559 stabstr_I (name);
1560 stabstr_C (';');
00fe048c
RS
1561 }
1562 else
93a27b7b
ZW
1563 /* If TEM is non-static, GDB won't understand it. */
1564 stabstr_S (",0,0;");
00fe048c 1565 }
665f2503 1566 else
00fe048c 1567 {
93a27b7b
ZW
1568 stabstr_C (',');
1569 stabstr_D (int_bit_position (tem));
1570 stabstr_C (',');
ae7e9ddd 1571 stabstr_D (tree_to_uhwi (DECL_SIZE (tem)));
93a27b7b 1572 stabstr_C (';');
00fe048c 1573 }
00fe048c
RS
1574 }
1575 }
1576}
1577\f
6dc42e49 1578/* Subroutine of `dbxout_type_methods'. Output debug info about the
93a27b7b 1579 method described DECL. */
00fe048c
RS
1580
1581static void
93a27b7b 1582dbxout_type_method_1 (tree decl)
00fe048c 1583{
00fe048c
RS
1584 char c1 = 'A', c2;
1585
1586 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
1587 c2 = '?';
1588 else /* it's a METHOD_TYPE. */
1589 {
213ecac9 1590 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
00fe048c
RS
1591 /* A for normal functions.
1592 B for `const' member functions.
1593 C for `volatile' member functions.
1594 D for `const volatile' member functions. */
1595 if (TYPE_READONLY (TREE_TYPE (firstarg)))
1596 c1 += 1;
1597 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
1598 c1 += 2;
1599
1600 if (DECL_VINDEX (decl))
1601 c2 = '*';
1602 else
1603 c2 = '.';
1604 }
1605
93a27b7b
ZW
1606 /* ??? Output the mangled name, which contains an encoding of the
1607 method's type signature. May not be necessary anymore. */
1608 stabstr_C (':');
1609 stabstr_I (DECL_ASSEMBLER_NAME (decl));
1610 stabstr_C (';');
1611 stabstr_C (DECL_ACCESSIBILITY_CHAR (decl));
1612 stabstr_C (c1);
1613 stabstr_C (c2);
665f2503 1614
9541ffee 1615 if (DECL_VINDEX (decl) && tree_fits_shwi_p (DECL_VINDEX (decl)))
00fe048c 1616 {
9439e9a1 1617 stabstr_D (tree_to_shwi (DECL_VINDEX (decl)));
93a27b7b 1618 stabstr_C (';');
deda4b76 1619 dbxout_type (DECL_CONTEXT (decl), 0);
93a27b7b 1620 stabstr_C (';');
00fe048c
RS
1621 }
1622}
1623\f
1624/* Subroutine of `dbxout_type'. Output debug info about the methods defined
1625 in TYPE. */
1626
1627static void
7080f735 1628dbxout_type_methods (tree type)
00fe048c
RS
1629{
1630 /* C++: put out the method names and their parameter lists */
00fe048c 1631 tree methods = TYPE_METHODS (type);
b3694847
SS
1632 tree fndecl;
1633 tree last;
00fe048c
RS
1634
1635 if (methods == NULL_TREE)
1636 return;
1637
6d89b990 1638 if (TREE_CODE (methods) != TREE_VEC)
d26ab756
RS
1639 fndecl = methods;
1640 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
00fe048c 1641 fndecl = TREE_VEC_ELT (methods, 0);
196cedd0
RS
1642 else
1643 fndecl = TREE_VEC_ELT (methods, 1);
00fe048c 1644
00fe048c
RS
1645 while (fndecl)
1646 {
b1a86a99
JM
1647 int need_prefix = 1;
1648
3a7587e4
RS
1649 /* Group together all the methods for the same operation.
1650 These differ in the types of the arguments. */
00fe048c
RS
1651 for (last = NULL_TREE;
1652 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
910ad8de 1653 fndecl = DECL_CHAIN (fndecl))
00fe048c
RS
1654 /* Output the name of the field (after overloading), as
1655 well as the name of the field before overloading, along
1656 with its parameter list */
1657 {
92643fea
MM
1658 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1659 include TEMPLATE_DECLs.) The debugger doesn't know what
1660 to do with such entities anyhow. */
1661 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1662 continue;
1663
00fe048c
RS
1664 CONTIN;
1665
1666 last = fndecl;
3a7587e4 1667
5daf7c0a
JM
1668 /* Also ignore abstract methods; those are only interesting to
1669 the DWARF backends. */
1670 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
3a7587e4
RS
1671 continue;
1672
b1a86a99
JM
1673 /* Redundantly output the plain name, since that's what gdb
1674 expects. */
1675 if (need_prefix)
1676 {
93a27b7b
ZW
1677 stabstr_I (DECL_NAME (fndecl));
1678 stabstr_S ("::");
b1a86a99
JM
1679 need_prefix = 0;
1680 }
1681
deda4b76 1682 dbxout_type (TREE_TYPE (fndecl), 0);
93a27b7b 1683 dbxout_type_method_1 (fndecl);
00fe048c 1684 }
b1a86a99 1685 if (!need_prefix)
93a27b7b 1686 stabstr_C (';');
00fe048c
RS
1687 }
1688}
b238f8de
PB
1689
1690/* Emit a "range" type specification, which has the form:
1691 "r<index type>;<lower bound>;<upper bound>;".
84fb43a1 1692 TYPE is an INTEGER_TYPE, LOW and HIGH are the bounds. */
b238f8de
PB
1693
1694static void
84fb43a1 1695dbxout_range_type (tree type, tree low, tree high)
b238f8de 1696{
93a27b7b 1697 stabstr_C ('r');
6c73937e 1698 if (TREE_TYPE (type))
deda4b76 1699 dbxout_type (TREE_TYPE (type), 0);
d0310c53 1700 else if (TREE_CODE (type) != INTEGER_TYPE)
deda4b76 1701 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
b238f8de
PB
1702 else
1703 {
7ae6c858
PB
1704 /* Traditionally, we made sure 'int' was type 1, and builtin types
1705 were defined to be sub-ranges of int. Unfortunately, this
1706 does not allow us to distinguish true sub-ranges from integer
1707 types. So, instead we define integer (non-sub-range) types as
28144186
JW
1708 sub-ranges of themselves. This matters for Chill. If this isn't
1709 a subrange type, then we want to define it in terms of itself.
1710 However, in C, this may be an anonymous integer type, and we don't
1711 want to emit debug info referring to it. Just calling
1712 dbxout_type_index won't work anyways, because the type hasn't been
1713 defined yet. We make this work for both cases by checked to see
1714 whether this is a defined type, referring to it if it is, and using
1715 'int' otherwise. */
1716 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1717 dbxout_type_index (type);
1718 else
1719 dbxout_type_index (integer_type_node);
b238f8de 1720 }
665f2503 1721
93a27b7b 1722 stabstr_C (';');
9541ffee 1723 if (low && tree_fits_shwi_p (low))
fb2c5c00 1724 {
84fb43a1
EB
1725 if (print_int_cst_bounds_in_octal_p (type, low, high))
1726 stabstr_O (low);
39d658e3 1727 else
9439e9a1 1728 stabstr_D (tree_to_shwi (low));
fb2c5c00 1729 }
b238f8de 1730 else
93a27b7b 1731 stabstr_C ('0');
665f2503 1732
93a27b7b 1733 stabstr_C (';');
9541ffee 1734 if (high && tree_fits_shwi_p (high))
fb2c5c00 1735 {
84fb43a1
EB
1736 if (print_int_cst_bounds_in_octal_p (type, low, high))
1737 stabstr_O (high);
39d658e3 1738 else
9439e9a1 1739 stabstr_D (tree_to_shwi (high));
93a27b7b 1740 stabstr_C (';');
fb2c5c00 1741 }
b238f8de 1742 else
93a27b7b 1743 stabstr_S ("-1;");
b238f8de 1744}
00fe048c 1745\f
6a08f7b3 1746
00fe048c
RS
1747/* Output a reference to a type. If the type has not yet been
1748 described in the dbx output, output its definition now.
1749 For a type already defined, just refer to its definition
1750 using the type number.
1751
1752 If FULL is nonzero, and the type has been described only with
1753 a forward-reference, output the definition now.
1754 If FULL is zero in this case, just refer to the forward-reference
deda4b76 1755 using the number previously allocated. */
00fe048c
RS
1756
1757static void
7080f735 1758dbxout_type (tree type, int full)
00fe048c 1759{
35571e38 1760 static int anonymous_type_number = 0;
84fb43a1 1761 tree tem, main_variant, low, high;
00fe048c 1762
84fb43a1
EB
1763 if (TREE_CODE (type) == INTEGER_TYPE)
1764 {
1765 if (TREE_TYPE (type) == 0)
1766 {
1767 low = TYPE_MIN_VALUE (type);
1768 high = TYPE_MAX_VALUE (type);
1769 }
1770
1771 else if (subrange_type_for_debug_p (type, &low, &high))
1772 ;
1773
1774 /* If this is a subtype that should not be emitted as a subrange type,
1775 use the base type. */
1776 else
1777 {
1778 type = TREE_TYPE (type);
1779 low = TYPE_MIN_VALUE (type);
1780 high = TYPE_MAX_VALUE (type);
1781 }
1782 }
1783
00fe048c
RS
1784 /* If there was an input error and we don't really have a type,
1785 avoid crashing and write something that is at least valid
1786 by assuming `int'. */
1787 if (type == error_mark_node)
1788 type = integer_type_node;
5bfaaeda 1789 else
00fe048c 1790 {
00fe048c
RS
1791 if (TYPE_NAME (type)
1792 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
326af3bf 1793 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
00fe048c
RS
1794 full = 0;
1795 }
1796
821adc5e
JM
1797 /* Try to find the "main variant" with the same name. */
1798 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1799 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1800 main_variant = TREE_TYPE (TYPE_NAME (type));
1801 else
1802 main_variant = TYPE_MAIN_VARIANT (type);
1803
1804 /* If we are not using extensions, stabs does not distinguish const and
1805 volatile, so there is no need to make them separate types. */
1806 if (!use_gnu_debug_info_extensions)
1807 type = main_variant;
1808
00fe048c
RS
1809 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1810 {
1811 /* Type has no dbx number assigned. Assign next available number. */
1812 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1813
1814 /* Make sure type vector is long enough to record about this type. */
1815
1816 if (next_type_number == typevec_len)
1817 {
f883e0a7 1818 typevec = GGC_RESIZEVEC (struct typeinfo, typevec, typevec_len * 2);
703ad42b 1819 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
00fe048c
RS
1820 typevec_len *= 2;
1821 }
4bcaafd9
ILT
1822
1823#ifdef DBX_USE_BINCL
33e9d2aa 1824 emit_pending_bincls_if_required ();
e3da301d
MS
1825 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1826 = current_file->file_number;
1827 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1828 = current_file->next_type_number++;
4bcaafd9 1829#endif
00fe048c
RS
1830 }
1831
6a08f7b3
DP
1832 if (flag_debug_only_used_symbols)
1833 {
1834 if ((TREE_CODE (type) == RECORD_TYPE
1835 || TREE_CODE (type) == UNION_TYPE
1836 || TREE_CODE (type) == QUAL_UNION_TYPE
1837 || TREE_CODE (type) == ENUMERAL_TYPE)
1838 && TYPE_STUB_DECL (type)
6615c446 1839 && DECL_P (TYPE_STUB_DECL (type))
6a08f7b3
DP
1840 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1841 debug_queue_symbol (TYPE_STUB_DECL (type));
1842 else if (TYPE_NAME (type)
1843 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1844 debug_queue_symbol (TYPE_NAME (type));
1845 }
7080f735 1846
00fe048c 1847 /* Output the number of this type, to refer to it. */
4bcaafd9 1848 dbxout_type_index (type);
00fe048c 1849
b372168c
MM
1850#ifdef DBX_TYPE_DEFINED
1851 if (DBX_TYPE_DEFINED (type))
1852 return;
1853#endif
1854
00fe048c
RS
1855 /* If this type's definition has been output or is now being output,
1856 that is all. */
1857
4bcaafd9 1858 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
00fe048c
RS
1859 {
1860 case TYPE_UNSEEN:
1861 break;
1862 case TYPE_XREF:
dad0145a
RS
1863 /* If we have already had a cross reference,
1864 and either that's all we want or that's the best we could do,
1865 don't repeat the cross reference.
1866 Sun dbx crashes if we do. */
d0f062fb 1867 if (! full || !COMPLETE_TYPE_P (type)
dad0145a 1868 /* No way in DBX fmt to describe a variable size. */
cc269bb6 1869 || ! tree_fits_uhwi_p (TYPE_SIZE (type)))
00fe048c
RS
1870 return;
1871 break;
1872 case TYPE_DEFINED:
1873 return;
1874 }
1875
1876#ifdef DBX_NO_XREFS
1877 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1878 leave the type-number completely undefined rather than output
e65f61cf
JW
1879 a cross-reference. If we have already used GNU debug info extensions,
1880 then it is OK to output a cross reference. This is necessary to get
1881 proper C++ debug output. */
1882 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1883 || TREE_CODE (type) == QUAL_UNION_TYPE
1884 || TREE_CODE (type) == ENUMERAL_TYPE)
1885 && ! use_gnu_debug_info_extensions)
e8fca6ce
JW
1886 /* We must use the same test here as we use twice below when deciding
1887 whether to emit a cross-reference. */
1888 if ((TYPE_NAME (type) != 0
1889 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1890 && DECL_IGNORED_P (TYPE_NAME (type)))
1891 && !full)
d0f062fb 1892 || !COMPLETE_TYPE_P (type)
e8fca6ce 1893 /* No way in DBX fmt to describe a variable size. */
cc269bb6 1894 || ! tree_fits_uhwi_p (TYPE_SIZE (type)))
00fe048c 1895 {
4bcaafd9 1896 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
00fe048c
RS
1897 return;
1898 }
1899#endif
1900
1901 /* Output a definition now. */
93a27b7b 1902 stabstr_C ('=');
00fe048c
RS
1903
1904 /* Mark it as defined, so that if it is self-referent
1905 we will not get into an infinite recursion of definitions. */
1906
4bcaafd9 1907 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
00fe048c 1908
821adc5e
JM
1909 /* If this type is a variant of some other, hand off. Types with
1910 different names are usefully distinguished. We only distinguish
1911 cv-qualified types if we're using extensions. */
1912 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1913 {
93a27b7b 1914 stabstr_C ('k');
821adc5e
JM
1915 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1916 return;
1917 }
1918 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1919 {
93a27b7b 1920 stabstr_C ('B');
821adc5e
JM
1921 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1922 return;
1923 }
1924 else if (main_variant != TYPE_MAIN_VARIANT (type))
1925 {
6a08f7b3
DP
1926 if (flag_debug_only_used_symbols)
1927 {
1928 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1929
7080f735 1930 if ((TREE_CODE (orig_type) == RECORD_TYPE
6a08f7b3
DP
1931 || TREE_CODE (orig_type) == UNION_TYPE
1932 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1933 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1934 && TYPE_STUB_DECL (orig_type)
1935 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1936 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1937 }
821adc5e 1938 /* 'type' is a typedef; output the type it refers to. */
deda4b76 1939 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
79afd906
PB
1940 return;
1941 }
821adc5e 1942 /* else continue. */
79afd906 1943
00fe048c
RS
1944 switch (TREE_CODE (type))
1945 {
1946 case VOID_TYPE:
1e85e720 1947 case NULLPTR_TYPE:
00fe048c 1948 case LANG_TYPE:
454ff5cb 1949 /* For a void type, just define it as itself; i.e., "5=5".
00fe048c
RS
1950 This makes us consider it defined
1951 without saying what it is. The debugger will make it
1952 a void type when the reference is seen, and nothing will
1953 ever override that default. */
4bcaafd9 1954 dbxout_type_index (type);
00fe048c
RS
1955 break;
1956
1957 case INTEGER_TYPE:
8df83eae 1958 if (type == char_type_node && ! TYPE_UNSIGNED (type))
4bcaafd9
ILT
1959 {
1960 /* Output the type `char' as a subrange of itself!
1961 I don't understand this definition, just copied it
1962 from the output of pcc.
1963 This used to use `r2' explicitly and we used to
1964 take care to make sure that `char' was type number 2. */
93a27b7b 1965 stabstr_C ('r');
4bcaafd9 1966 dbxout_type_index (type);
93a27b7b 1967 stabstr_S (";0;127;");
4bcaafd9 1968 }
14a774a9
RK
1969
1970 /* If this is a subtype of another integer type, always prefer to
1971 write it as a subtype. */
1972 else if (TREE_TYPE (type) != 0
3342b6fd 1973 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
3a538a66 1974 {
ea619b46
JB
1975 /* If the size is non-standard, say what it is if we can use
1976 GDB extensions. */
1977
1978 if (use_gnu_debug_info_extensions
1979 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1980 {
93a27b7b
ZW
1981 stabstr_S ("@s");
1982 stabstr_D (TYPE_PRECISION (type));
1983 stabstr_C (';');
ea619b46
JB
1984 }
1985
84fb43a1 1986 dbxout_range_type (type, low, high);
3a538a66 1987 }
14a774a9
RK
1988
1989 else
3a538a66 1990 {
14a774a9
RK
1991 /* If the size is non-standard, say what it is if we can use
1992 GDB extensions. */
1993
1994 if (use_gnu_debug_info_extensions
1995 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
02e3f1a8 1996 {
93a27b7b
ZW
1997 stabstr_S ("@s");
1998 stabstr_D (TYPE_PRECISION (type));
1999 stabstr_C (';');
02e3f1a8 2000 }
14a774a9 2001
84fb43a1 2002 if (print_int_cst_bounds_in_octal_p (type, low, high))
14a774a9 2003 {
93a27b7b 2004 stabstr_C ('r');
08b0f5f9
JB
2005
2006 /* If this type derives from another type, output type index of
2007 parent type. This is particularly important when parent type
2008 is an enumerated type, because not generating the parent type
2009 index would transform the definition of this enumerated type
2010 into a plain unsigned type. */
2011 if (TREE_TYPE (type) != 0)
2012 dbxout_type_index (TREE_TYPE (type));
2013 else
2014 dbxout_type_index (type);
2015
93a27b7b 2016 stabstr_C (';');
84fb43a1 2017 stabstr_O (low);
93a27b7b 2018 stabstr_C (';');
84fb43a1 2019 stabstr_O (high);
93a27b7b 2020 stabstr_C (';');
14a774a9
RK
2021 }
2022
2023 else
2024 /* Output other integer types as subranges of `int'. */
84fb43a1 2025 dbxout_range_type (type, low, high);
3a538a66 2026 }
14a774a9 2027
00fe048c
RS
2028 break;
2029
2030 case REAL_TYPE:
325217ed 2031 case FIXED_POINT_TYPE:
00fe048c
RS
2032 /* This used to say `r1' and we used to take care
2033 to make sure that `int' was type number 1. */
93a27b7b 2034 stabstr_C ('r');
4bcaafd9 2035 dbxout_type_index (integer_type_node);
93a27b7b
ZW
2036 stabstr_C (';');
2037 stabstr_D (int_size_in_bytes (type));
2038 stabstr_S (";0;");
00fe048c
RS
2039 break;
2040
72db60c6
PB
2041 case BOOLEAN_TYPE:
2042 if (use_gnu_debug_info_extensions)
e003ca80 2043 {
93a27b7b
ZW
2044 stabstr_S ("@s");
2045 stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
2046 stabstr_S (";-16;");
e003ca80 2047 }
72db60c6 2048 else /* Define as enumeral type (False, True) */
93a27b7b 2049 stabstr_S ("eFalse:0,True:1,;");
15a5b8a2
RS
2050 break;
2051
15a5b8a2 2052 case COMPLEX_TYPE:
3a7cbb76
ZW
2053 /* Differs from the REAL_TYPE by its new data type number.
2054 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
2055 codes since gdb doesn't care anyway. */
15a5b8a2
RS
2056
2057 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
2058 {
93a27b7b
ZW
2059 stabstr_S ("R3;");
2060 stabstr_D (2 * int_size_in_bytes (TREE_TYPE (type)));
2061 stabstr_S (";0;");
47cc012b
RS
2062 }
2063 else
2064 {
2065 /* Output a complex integer type as a structure,
2066 pending some other way to do it. */
93a27b7b
ZW
2067 stabstr_C ('s');
2068 stabstr_D (int_size_in_bytes (type));
02e3f1a8 2069
93a27b7b 2070 stabstr_S ("real:");
deda4b76 2071 dbxout_type (TREE_TYPE (type), 0);
93a27b7b
ZW
2072 stabstr_S (",0,");
2073 stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
2074
2075 stabstr_S (";imag:");
deda4b76 2076 dbxout_type (TREE_TYPE (type), 0);
93a27b7b
ZW
2077 stabstr_C (',');
2078 stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
2079 stabstr_C (',');
2080 stabstr_D (TYPE_PRECISION (TREE_TYPE (type)));
2081 stabstr_S (";;");
47cc012b 2082 }
15a5b8a2
RS
2083 break;
2084
00fe048c 2085 case ARRAY_TYPE:
202fe2d6
DB
2086 /* Make arrays of packed bits look like bitstrings for chill. */
2087 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
2088 {
93a27b7b
ZW
2089 stabstr_S ("@s");
2090 stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
2091 stabstr_S (";@S;S");
deda4b76 2092 dbxout_type (TYPE_DOMAIN (type), 0);
202fe2d6
DB
2093 break;
2094 }
02e3f1a8 2095
00fe048c
RS
2096 /* Output "a" followed by a range type definition
2097 for the index type of the array
2098 followed by a reference to the target-type.
b238f8de 2099 ar1;0;N;M for a C array of type M and size N+1. */
4042d440 2100 /* Check if a character string type, which in Chill is
0f41302f 2101 different from an array of characters. */
4042d440
PB
2102 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
2103 {
93a27b7b 2104 stabstr_S ("@S;");
4042d440 2105 }
b238f8de
PB
2106 tem = TYPE_DOMAIN (type);
2107 if (tem == NULL)
4bcaafd9 2108 {
93a27b7b 2109 stabstr_S ("ar");
4bcaafd9 2110 dbxout_type_index (integer_type_node);
93a27b7b 2111 stabstr_S (";0;-1;");
4bcaafd9 2112 }
b238f8de
PB
2113 else
2114 {
93a27b7b 2115 stabstr_C ('a');
84fb43a1 2116 dbxout_range_type (tem, TYPE_MIN_VALUE (tem), TYPE_MAX_VALUE (tem));
b238f8de 2117 }
02e3f1a8 2118
deda4b76 2119 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2120 break;
2121
cf6a4097
RG
2122 case VECTOR_TYPE:
2123 /* Make vectors look like an array. */
2124 if (use_gnu_debug_info_extensions)
2125 stabstr_S ("@V;");
2126
2127 /* Output "a" followed by a range type definition
2128 for the index type of the array
2129 followed by a reference to the target-type.
2130 ar1;0;N;M for a C array of type M and size N+1. */
2131 stabstr_C ('a');
2132 dbxout_range_type (integer_type_node, size_zero_node,
2133 size_int (TYPE_VECTOR_SUBPARTS (type) - 1));
2134
2135 dbxout_type (TREE_TYPE (type), 0);
2136 break;
2137
00fe048c
RS
2138 case RECORD_TYPE:
2139 case UNION_TYPE:
c1b98a95 2140 case QUAL_UNION_TYPE:
00fe048c 2141 {
fa743e8c 2142 tree binfo = TYPE_BINFO (type);
00fe048c 2143
e8fca6ce
JW
2144 /* Output a structure type. We must use the same test here as we
2145 use in the DBX_NO_XREFS case above. */
b372168c
MM
2146 if ((TYPE_NAME (type) != 0
2147 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
2148 && DECL_IGNORED_P (TYPE_NAME (type)))
2149 && !full)
d0f062fb 2150 || !COMPLETE_TYPE_P (type)
3a7587e4 2151 /* No way in DBX fmt to describe a variable size. */
cc269bb6 2152 || ! tree_fits_uhwi_p (TYPE_SIZE (type)))
00fe048c
RS
2153 {
2154 /* If the type is just a cross reference, output one
2155 and mark the type as partially described.
2156 If it later becomes defined, we will output
2157 its real definition.
2158 If the type has a name, don't nest its definition within
2159 another type's definition; instead, output an xref
2160 and let the definition come when the name is defined. */
93a27b7b 2161 stabstr_S ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
cc459ab4
JJ
2162 if (TYPE_NAME (type) != 0
2163 /* The C frontend creates for anonymous variable length
2164 records/unions TYPE_NAME with DECL_NAME NULL. */
2165 && (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL
2166 || DECL_NAME (TYPE_NAME (type))))
35571e38
RS
2167 dbxout_type_name (type);
2168 else
02e3f1a8 2169 {
93a27b7b
ZW
2170 stabstr_S ("$$");
2171 stabstr_D (anonymous_type_number++);
02e3f1a8
RK
2172 }
2173
93a27b7b 2174 stabstr_C (':');
4bcaafd9 2175 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
00fe048c
RS
2176 break;
2177 }
00fe048c 2178
00fe048c 2179 /* Identify record or union, and print its size. */
93a27b7b
ZW
2180 stabstr_C ((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u');
2181 stabstr_D (int_size_in_bytes (type));
00fe048c 2182
fa743e8c 2183 if (binfo)
00fe048c 2184 {
fa743e8c
NS
2185 int i;
2186 tree child;
9771b263 2187 vec<tree, va_gc> *accesses = BINFO_BASE_ACCESSES (binfo);
b8698a0f 2188
196cedd0 2189 if (use_gnu_debug_info_extensions)
00fe048c 2190 {
fa743e8c
NS
2191 if (BINFO_N_BASE_BINFOS (binfo))
2192 {
93a27b7b
ZW
2193 stabstr_C ('!');
2194 stabstr_U (BINFO_N_BASE_BINFOS (binfo));
2195 stabstr_C (',');
fa743e8c 2196 }
00fe048c 2197 }
fa743e8c 2198 for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++)
00fe048c 2199 {
9771b263 2200 tree access = (accesses ? (*accesses)[i] : access_public_node);
fa743e8c
NS
2201
2202 if (use_gnu_debug_info_extensions)
2203 {
93a27b7b
ZW
2204 stabstr_C (BINFO_VIRTUAL_P (child) ? '1' : '0');
2205 stabstr_C (access == access_public_node ? '2' :
2206 access == access_protected_node
2207 ? '1' :'0');
fa743e8c 2208 if (BINFO_VIRTUAL_P (child)
f37d7c60
DP
2209 && (strcmp (lang_hooks.name, "GNU C++") == 0
2210 || strcmp (lang_hooks.name, "GNU Objective-C++") == 0))
fa743e8c
NS
2211 /* For a virtual base, print the (negative)
2212 offset within the vtable where we must look
2213 to find the necessary adjustment. */
93a27b7b 2214 stabstr_D
9439e9a1 2215 (tree_to_shwi (BINFO_VPTR_FIELD (child))
fa743e8c
NS
2216 * BITS_PER_UNIT);
2217 else
9439e9a1 2218 stabstr_D (tree_to_shwi (BINFO_OFFSET (child))
93a27b7b
ZW
2219 * BITS_PER_UNIT);
2220 stabstr_C (',');
fa743e8c 2221 dbxout_type (BINFO_TYPE (child), 0);
93a27b7b 2222 stabstr_C (';');
fa743e8c
NS
2223 }
2224 else
2225 {
2226 /* Print out the base class information with
2227 fields which have the same names at the types
2228 they hold. */
2229 dbxout_type_name (BINFO_TYPE (child));
93a27b7b 2230 stabstr_C (':');
fa743e8c 2231 dbxout_type (BINFO_TYPE (child), full);
93a27b7b 2232 stabstr_C (',');
9439e9a1 2233 stabstr_D (tree_to_shwi (BINFO_OFFSET (child))
93a27b7b
ZW
2234 * BITS_PER_UNIT);
2235 stabstr_C (',');
2236 stabstr_D
9439e9a1 2237 (tree_to_shwi (TYPE_SIZE (BINFO_TYPE (child)))
fa743e8c 2238 * BITS_PER_UNIT);
93a27b7b 2239 stabstr_C (';');
fa743e8c 2240 }
00fe048c
RS
2241 }
2242 }
2243 }
2244
00fe048c
RS
2245 /* Write out the field declarations. */
2246 dbxout_type_fields (type);
196cedd0 2247 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
00fe048c 2248 {
00fe048c
RS
2249 dbxout_type_methods (type);
2250 }
665f2503 2251
93a27b7b 2252 stabstr_C (';');
00fe048c 2253
196cedd0 2254 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
00fe048c
RS
2255 /* Avoid the ~ if we don't really need it--it confuses dbx. */
2256 && TYPE_VFIELD (type))
2257 {
00fe048c 2258
00fe048c
RS
2259 /* We need to write out info about what field this class
2260 uses as its "main" vtable pointer field, because if this
2261 field is inherited from a base class, GDB cannot necessarily
2262 figure out which field it's using in time. */
93a27b7b
ZW
2263 stabstr_S ("~%");
2264 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
2265 stabstr_C (';');
00fe048c
RS
2266 }
2267 break;
2268
2269 case ENUMERAL_TYPE:
e8fca6ce
JW
2270 /* We must use the same test here as we use in the DBX_NO_XREFS case
2271 above. We simplify it a bit since an enum will never have a variable
2272 size. */
2273 if ((TYPE_NAME (type) != 0
2274 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
2275 && DECL_IGNORED_P (TYPE_NAME (type)))
2276 && !full)
d0f062fb 2277 || !COMPLETE_TYPE_P (type))
00fe048c 2278 {
93a27b7b 2279 stabstr_S ("xe");
00fe048c 2280 dbxout_type_name (type);
4bcaafd9 2281 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
93a27b7b 2282 stabstr_C (':');
00fe048c
RS
2283 return;
2284 }
71b54b53
PB
2285 if (use_gnu_debug_info_extensions
2286 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
02e3f1a8 2287 {
93a27b7b
ZW
2288 stabstr_S ("@s");
2289 stabstr_D (TYPE_PRECISION (type));
2290 stabstr_C (';');
02e3f1a8
RK
2291 }
2292
93a27b7b 2293 stabstr_C ('e');
00fe048c
RS
2294 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
2295 {
adf2edec
DG
2296 tree value = TREE_VALUE (tem);
2297
93a27b7b
ZW
2298 stabstr_I (TREE_PURPOSE (tem));
2299 stabstr_C (':');
2300
adf2edec
DG
2301 if (TREE_CODE (value) == CONST_DECL)
2302 value = DECL_INITIAL (value);
2303
2304 if (TREE_INT_CST_HIGH (value) == 0)
2305 stabstr_D (TREE_INT_CST_LOW (value));
2306 else if (TREE_INT_CST_HIGH (value) == -1
2307 && (HOST_WIDE_INT) TREE_INT_CST_LOW (value) < 0)
2308 stabstr_D (TREE_INT_CST_LOW (value));
71f15013 2309 else
adf2edec 2310 stabstr_O (value);
02e3f1a8 2311
93a27b7b 2312 stabstr_C (',');
00fe048c 2313 if (TREE_CHAIN (tem) != 0)
02e3f1a8 2314 CONTIN;
00fe048c 2315 }
02e3f1a8 2316
93a27b7b 2317 stabstr_C (';');
00fe048c
RS
2318 break;
2319
2320 case POINTER_TYPE:
93a27b7b 2321 stabstr_C ('*');
deda4b76 2322 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2323 break;
2324
2325 case METHOD_TYPE:
196cedd0 2326 if (use_gnu_debug_info_extensions)
00fe048c 2327 {
93a27b7b 2328 stabstr_C ('#');
deda4b76
JM
2329
2330 /* Write the argument types out longhand. */
2331 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
93a27b7b 2332 stabstr_C (',');
deda4b76
JM
2333 dbxout_type (TREE_TYPE (type), 0);
2334 dbxout_args (TYPE_ARG_TYPES (type));
93a27b7b 2335 stabstr_C (';');
00fe048c
RS
2336 }
2337 else
02e3f1a8
RK
2338 /* Treat it as a function type. */
2339 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2340 break;
2341
2342 case OFFSET_TYPE:
196cedd0 2343 if (use_gnu_debug_info_extensions)
00fe048c 2344 {
93a27b7b 2345 stabstr_C ('@');
deda4b76 2346 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
93a27b7b 2347 stabstr_C (',');
deda4b76 2348 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2349 }
2350 else
02e3f1a8
RK
2351 /* Should print as an int, because it is really just an offset. */
2352 dbxout_type (integer_type_node, 0);
00fe048c
RS
2353 break;
2354
2355 case REFERENCE_TYPE:
196cedd0 2356 if (use_gnu_debug_info_extensions)
93a27b7b 2357 {
93a27b7b
ZW
2358 stabstr_C ('&');
2359 }
2360 else
2361 stabstr_C ('*');
deda4b76 2362 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2363 break;
2364
2365 case FUNCTION_TYPE:
93a27b7b 2366 stabstr_C ('f');
deda4b76 2367 dbxout_type (TREE_TYPE (type), 0);
00fe048c
RS
2368 break;
2369
2370 default:
ced3f397 2371 gcc_unreachable ();
00fe048c
RS
2372 }
2373}
2374
6356f892 2375/* Return nonzero if the given type represents an integer whose bounds
39d658e3
JB
2376 should be printed in octal format. */
2377
2378static bool
84fb43a1 2379print_int_cst_bounds_in_octal_p (tree type, tree low, tree high)
39d658e3
JB
2380{
2381 /* If we can use GDB extensions and the size is wider than a long
2382 (the size used by GDB to read them) or we may have trouble writing
2383 the bounds the usual way, write them in octal. Note the test is for
2384 the *target's* size of "long", not that of the host. The host test
2385 is just to make sure we can write it out in case the host wide int
2386 is narrower than the target "long".
7080f735 2387
39d658e3
JB
2388 For unsigned types, we use octal if they are the same size or larger.
2389 This is because we print the bounds as signed decimal, and hence they
2390 can't span same size unsigned types. */
2391
2392 if (use_gnu_debug_info_extensions
84fb43a1
EB
2393 && low && TREE_CODE (low) == INTEGER_CST
2394 && high && TREE_CODE (high) == INTEGER_CST
39d658e3
JB
2395 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
2396 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
8df83eae 2397 && TYPE_UNSIGNED (type))
39d658e3
JB
2398 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
2399 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
8df83eae 2400 && TYPE_UNSIGNED (type))))
39d658e3
JB
2401 return TRUE;
2402 else
2403 return FALSE;
2404}
2405
00fe048c
RS
2406/* Output the name of type TYPE, with no punctuation.
2407 Such names can be set up either by typedef declarations
2408 or by struct, enum and union tags. */
2409
2410static void
7080f735 2411dbxout_type_name (tree type)
00fe048c 2412{
ced3f397 2413 tree t = TYPE_NAME (type);
b8698a0f 2414
ced3f397
NS
2415 gcc_assert (t);
2416 switch (TREE_CODE (t))
00fe048c 2417 {
ced3f397
NS
2418 case IDENTIFIER_NODE:
2419 break;
2420 case TYPE_DECL:
2421 t = DECL_NAME (t);
2422 break;
2423 default:
2424 gcc_unreachable ();
00fe048c 2425 }
00fe048c 2426
93a27b7b 2427 stabstr_I (t);
00fe048c 2428}
b0a93386
KB
2429
2430/* Output leading leading struct or class names needed for qualifying
2431 type whose scope is limited to a struct or class. */
2432
2433static void
7080f735 2434dbxout_class_name_qualifiers (tree decl)
b0a93386
KB
2435{
2436 tree context = decl_type_context (decl);
2437
7080f735 2438 if (context != NULL_TREE
c3284718 2439 && TREE_CODE (context) == RECORD_TYPE
7080f735 2440 && TYPE_NAME (context) != 0
b0a93386
KB
2441 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2442 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2443 {
2444 tree name = TYPE_NAME (context);
2445
2446 if (TREE_CODE (name) == TYPE_DECL)
2447 {
2448 dbxout_class_name_qualifiers (name);
2449 name = DECL_NAME (name);
2450 }
93a27b7b
ZW
2451 stabstr_I (name);
2452 stabstr_S ("::");
b0a93386
KB
2453 }
2454}
00fe048c 2455\f
4e0e2698
RH
2456/* This is a specialized subset of expand_expr for use by dbxout_symbol in
2457 evaluating DECL_VALUE_EXPR. In particular, we stop if we find decls that
fa10beec 2458 haven't been expanded, or if the expression is getting so complex we won't
4e0e2698
RH
2459 be able to represent it in stabs anyway. Returns NULL on failure. */
2460
2461static rtx
2462dbxout_expand_expr (tree expr)
2463{
2464 switch (TREE_CODE (expr))
2465 {
2466 case VAR_DECL:
fcb9237b
JW
2467 /* We can't handle emulated tls variables, because the address is an
2468 offset to the return value of __emutls_get_address, and there is no
2469 way to express that in stabs. Also, there are name mangling issues
2470 here. We end up with references to undefined symbols if we don't
2471 disable debug info for these variables. */
2472 if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr))
2473 return NULL;
9166988f
JJ
2474 if (TREE_STATIC (expr)
2475 && !TREE_ASM_WRITTEN (expr)
2476 && !DECL_HAS_VALUE_EXPR_P (expr)
2477 && !TREE_PUBLIC (expr)
2478 && DECL_RTL_SET_P (expr)
2479 && MEM_P (DECL_RTL (expr)))
2480 {
2481 /* If this is a var that might not be actually output,
2482 return NULL, otherwise stabs might reference an undefined
2483 symbol. */
2c8326a5 2484 varpool_node *node = varpool_get_node (expr);
67348ccc 2485 if (!node || !node->definition)
9166988f
JJ
2486 return NULL;
2487 }
fcb9237b
JW
2488 /* FALLTHRU */
2489
4e0e2698 2490 case PARM_DECL:
8dcfef8f 2491 case RESULT_DECL:
4e0e2698
RH
2492 if (DECL_HAS_VALUE_EXPR_P (expr))
2493 return dbxout_expand_expr (DECL_VALUE_EXPR (expr));
2494 /* FALLTHRU */
2495
2496 case CONST_DECL:
4e0e2698
RH
2497 return DECL_RTL_IF_SET (expr);
2498
2499 case INTEGER_CST:
2500 return expand_expr (expr, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
2501
2502 case COMPONENT_REF:
2503 case ARRAY_REF:
2504 case ARRAY_RANGE_REF:
2505 case BIT_FIELD_REF:
2506 {
2507 enum machine_mode mode;
2508 HOST_WIDE_INT bitsize, bitpos;
2509 tree offset, tem;
2510 int volatilep = 0, unsignedp = 0;
2511 rtx x;
2512
2513 tem = get_inner_reference (expr, &bitsize, &bitpos, &offset,
b3ecff82 2514 &mode, &unsignedp, &volatilep, true);
4e0e2698
RH
2515
2516 x = dbxout_expand_expr (tem);
2517 if (x == NULL || !MEM_P (x))
2518 return NULL;
2519 if (offset != NULL)
2520 {
9541ffee 2521 if (!tree_fits_shwi_p (offset))
4e0e2698 2522 return NULL;
9439e9a1 2523 x = adjust_address_nv (x, mode, tree_to_shwi (offset));
4e0e2698
RH
2524 }
2525 if (bitpos != 0)
2526 x = adjust_address_nv (x, mode, bitpos / BITS_PER_UNIT);
2527
2528 return x;
2529 }
2530
2531 default:
2532 return NULL;
2533 }
2534}
2535
f629051e
DJ
2536/* Helper function for output_used_types. Queue one entry from the
2537 used types hash to be output. */
2538
2539static int
2daec0f0 2540output_used_types_helper (void **slot, void *data)
f629051e 2541{
f883e0a7 2542 tree type = (tree) *slot;
9771b263 2543 vec<tree> *types_p = (vec<tree> *) data;
f629051e
DJ
2544
2545 if ((TREE_CODE (type) == RECORD_TYPE
2546 || TREE_CODE (type) == UNION_TYPE
2547 || TREE_CODE (type) == QUAL_UNION_TYPE
2548 || TREE_CODE (type) == ENUMERAL_TYPE)
2549 && TYPE_STUB_DECL (type)
2550 && DECL_P (TYPE_STUB_DECL (type))
2551 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
9771b263 2552 types_p->quick_push (TYPE_STUB_DECL (type));
f629051e
DJ
2553 else if (TYPE_NAME (type)
2554 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
9771b263 2555 types_p->quick_push (TYPE_NAME (type));
f629051e
DJ
2556
2557 return 1;
2558}
2559
88c4be5e
DJ
2560/* This is a qsort callback which sorts types and declarations into a
2561 predictable order (types, then declarations, sorted by UID
2562 within). */
2563
2daec0f0
DJ
2564static int
2565output_types_sort (const void *pa, const void *pb)
2566{
2567 const tree lhs = *((const tree *)pa);
2568 const tree rhs = *((const tree *)pb);
2569
2570 if (TYPE_P (lhs))
2571 {
2572 if (TYPE_P (rhs))
2573 return TYPE_UID (lhs) - TYPE_UID (rhs);
2574 else
2575 return 1;
2576 }
2577 else
2578 {
2579 if (TYPE_P (rhs))
2580 return -1;
2581 else
2582 return DECL_UID (lhs) - DECL_UID (rhs);
2583 }
2584}
2585
2586
f629051e
DJ
2587/* Force all types used by this function to be output in debug
2588 information. */
88c4be5e 2589
f629051e
DJ
2590static void
2591output_used_types (void)
2592{
2593 if (cfun && cfun->used_types_hash)
2daec0f0 2594 {
9771b263 2595 vec<tree> types;
2daec0f0
DJ
2596 int i;
2597 tree type;
2598
9771b263 2599 types.create (htab_elements (cfun->used_types_hash));
2daec0f0
DJ
2600 htab_traverse (cfun->used_types_hash, output_used_types_helper, &types);
2601
2602 /* Sort by UID to prevent dependence on hash table ordering. */
9771b263 2603 types.qsort (output_types_sort);
2daec0f0 2604
9771b263 2605 FOR_EACH_VEC_ELT (types, i, type)
2daec0f0 2606 debug_queue_symbol (type);
88c4be5e 2607
9771b263 2608 types.release ();
2daec0f0 2609 }
f629051e
DJ
2610}
2611
00fe048c
RS
2612/* Output a .stabs for the symbol defined by DECL,
2613 which must be a ..._DECL node in the normal namespace.
2614 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
00262c8a
ML
2615 LOCAL is nonzero if the scope is less than the entire file.
2616 Return 1 if a stabs might have been emitted. */
00fe048c 2617
00262c8a 2618int
7080f735 2619dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
00fe048c 2620{
00fe048c
RS
2621 tree type = TREE_TYPE (decl);
2622 tree context = NULL_TREE;
00262c8a 2623 int result = 0;
9bfa80fb 2624 rtx decl_rtl;
00fe048c 2625
6a08f7b3
DP
2626 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2627 ++debug_nesting;
2628
00fe048c
RS
2629 /* Ignore nameless syms, but don't ignore type tags. */
2630
2631 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2632 || DECL_IGNORED_P (decl))
6a08f7b3
DP
2633 DBXOUT_DECR_NESTING_AND_RETURN (0);
2634
e0bb17a8 2635 /* If we are to generate only the symbols actually used then such
aabcd309 2636 symbol nodes are flagged with TREE_USED. Ignore any that
fa10beec 2637 aren't flagged as TREE_USED. */
7080f735 2638
21d13d83
ZW
2639 if (flag_debug_only_used_symbols
2640 && (!TREE_USED (decl)
2641 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl))))
2642 DBXOUT_DECR_NESTING_AND_RETURN (0);
2643
2644 /* If dbxout_init has not yet run, queue this symbol for later. */
2645 if (!typevec)
2646 {
2647 preinit_symbols = tree_cons (0, decl, preinit_symbols);
2648 DBXOUT_DECR_NESTING_AND_RETURN (0);
2649 }
2650
6a08f7b3
DP
2651 if (flag_debug_only_used_symbols)
2652 {
2653 tree t;
2654
6a08f7b3
DP
2655 /* We now have a used symbol. We need to generate the info for
2656 the symbol's type in addition to the symbol itself. These
2657 type symbols are queued to be generated after were done with
93a27b7b
ZW
2658 the symbol itself (otherwise they would fight over the
2659 stabstr obstack).
6a08f7b3
DP
2660
2661 Note, because the TREE_TYPE(type) might be something like a
2662 pointer to a named type we need to look for the first name
2663 we see following the TREE_TYPE chain. */
2664
7080f735 2665 t = type;
6a08f7b3
DP
2666 while (POINTER_TYPE_P (t))
2667 t = TREE_TYPE (t);
2668
2669 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2670 need special treatment. The TYPE_STUB_DECL field in these
2671 types generally represents the tag name type we want to
2672 output. In addition there could be a typedef type with
2673 a different name. In that case we also want to output
2674 that. */
2675
75917fc0 2676 if (TREE_CODE (t) == RECORD_TYPE
6a08f7b3
DP
2677 || TREE_CODE (t) == UNION_TYPE
2678 || TREE_CODE (t) == QUAL_UNION_TYPE
2679 || TREE_CODE (t) == ENUMERAL_TYPE)
6a08f7b3 2680 {
75917fc0
AP
2681 if (TYPE_STUB_DECL (t)
2682 && TYPE_STUB_DECL (t) != decl
2683 && DECL_P (TYPE_STUB_DECL (t))
2684 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2685 {
2686 debug_queue_symbol (TYPE_STUB_DECL (t));
2687 if (TYPE_NAME (t)
2688 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2689 && TYPE_NAME (t) != decl
2690 && DECL_P (TYPE_NAME (t)))
2691 debug_queue_symbol (TYPE_NAME (t));
2692 }
2693 }
6a08f7b3
DP
2694 else if (TYPE_NAME (t)
2695 && TYPE_NAME (t) != decl
6615c446 2696 && DECL_P (TYPE_NAME (t)))
6a08f7b3
DP
2697 debug_queue_symbol (TYPE_NAME (t));
2698 }
00fe048c 2699
33e9d2aa
DP
2700 emit_pending_bincls_if_required ();
2701
00fe048c
RS
2702 switch (TREE_CODE (decl))
2703 {
2704 case CONST_DECL:
2705 /* Enum values are defined by defining the enum type. */
2706 break;
2707
2708 case FUNCTION_DECL:
9bfa80fb
RH
2709 decl_rtl = DECL_RTL_IF_SET (decl);
2710 if (!decl_rtl)
6a08f7b3 2711 DBXOUT_DECR_NESTING_AND_RETURN (0);
0924ddef 2712 if (DECL_EXTERNAL (decl))
00fe048c
RS
2713 break;
2714 /* Don't mention a nested function under its parent. */
2715 context = decl_function_context (decl);
2716 if (context == current_function_decl)
2717 break;
b950a32e
EB
2718 /* Don't mention an inline instance of a nested function. */
2719 if (context && DECL_FROM_INLINE (decl))
2720 break;
9bfa80fb
RH
2721 if (!MEM_P (decl_rtl)
2722 || GET_CODE (XEXP (decl_rtl, 0)) != SYMBOL_REF)
00fe048c 2723 break;
00fe048c 2724
f629051e
DJ
2725 if (flag_debug_only_used_symbols)
2726 output_used_types ();
2727
93a27b7b
ZW
2728 dbxout_begin_complex_stabs ();
2729 stabstr_I (DECL_ASSEMBLER_NAME (decl));
2730 stabstr_S (TREE_PUBLIC (decl) ? ":F" : ":f");
00262c8a 2731 result = 1;
00fe048c 2732
00fe048c 2733 if (TREE_TYPE (type))
deda4b76 2734 dbxout_type (TREE_TYPE (type), 0);
00fe048c 2735 else
deda4b76 2736 dbxout_type (void_type_node, 0);
00fe048c
RS
2737
2738 /* For a nested function, when that function is compiled,
2739 mention the containing function name
2740 as well as (since dbx wants it) our own assembler-name. */
2741 if (context != 0)
93a27b7b
ZW
2742 {
2743 stabstr_C (',');
2744 stabstr_I (DECL_ASSEMBLER_NAME (decl));
2745 stabstr_C (',');
2746 stabstr_I (DECL_NAME (context));
2747 }
00fe048c 2748
9bfa80fb 2749 dbxout_finish_complex_stabs (decl, N_FUN, XEXP (decl_rtl, 0), 0, 0);
00fe048c
RS
2750 break;
2751
2752 case TYPE_DECL:
00fe048c
RS
2753 /* Don't output the same typedef twice.
2754 And don't output what language-specific stuff doesn't want output. */
3a83beef 2755 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
6a08f7b3 2756 DBXOUT_DECR_NESTING_AND_RETURN (0);
00fe048c 2757
21d13d83
ZW
2758 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2759#ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2760 {
2761 int fundamental_type_number =
2762 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl);
2763
2764 if (fundamental_type_number != 0)
2765 {
2766 TREE_ASM_WRITTEN (decl) = 1;
2767 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number;
2768 DBXOUT_DECR_NESTING_AND_RETURN (0);
2769 }
2770 }
2771#endif
00fe048c 2772 FORCE_TEXT;
00262c8a 2773 result = 1;
a823f1d8
RS
2774 {
2775 int tag_needed = 1;
3b6c7a7d 2776 int did_output = 0;
25bdb910 2777
a823f1d8
RS
2778 if (DECL_NAME (decl))
2779 {
2780 /* Nonzero means we must output a tag as well as a typedef. */
2781 tag_needed = 0;
00fe048c 2782
edbe40ea
RS
2783 /* Handle the case of a C++ structure or union
2784 where the TYPE_NAME is a TYPE_DECL
2785 which gives both a typedef name and a tag. */
bed7dc7a 2786 /* dbx requires the tag first and the typedef second. */
edbe40ea 2787 if ((TREE_CODE (type) == RECORD_TYPE
c1b98a95
RK
2788 || TREE_CODE (type) == UNION_TYPE
2789 || TREE_CODE (type) == QUAL_UNION_TYPE)
edbe40ea 2790 && TYPE_NAME (type) == decl
abdafc8e 2791 && !use_gnu_debug_info_extensions
bed7dc7a
RS
2792 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2793 /* Distinguish the implicit typedefs of C++
2794 from explicit ones that might be found in C. */
3a538a66 2795 && DECL_ARTIFICIAL (decl)
6a08f7b3
DP
2796 /* Do not generate a tag for incomplete records. */
2797 && COMPLETE_TYPE_P (type)
3342b6fd
RK
2798 /* Do not generate a tag for records of variable size,
2799 since this type can not be properly described in the
2800 DBX format, and it confuses some tools such as objdump. */
cc269bb6 2801 && tree_fits_uhwi_p (TYPE_SIZE (type)))
edbe40ea
RS
2802 {
2803 tree name = TYPE_NAME (type);
2804 if (TREE_CODE (name) == TYPE_DECL)
2805 name = DECL_NAME (name);
2806
93a27b7b
ZW
2807 dbxout_begin_complex_stabs ();
2808 stabstr_I (name);
2809 stabstr_S (":T");
deda4b76 2810 dbxout_type (type, 1);
93a27b7b
ZW
2811 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE,
2812 0, 0, 0);
edbe40ea
RS
2813 }
2814
93a27b7b 2815 dbxout_begin_complex_stabs ();
b0a93386 2816
abdafc8e 2817 /* Output leading class/struct qualifiers. */
b0a93386 2818 if (use_gnu_debug_info_extensions)
93a27b7b 2819 dbxout_class_name_qualifiers (decl);
b0a93386 2820
a823f1d8 2821 /* Output typedef name. */
93a27b7b
ZW
2822 stabstr_I (DECL_NAME (decl));
2823 stabstr_C (':');
25bdb910 2824
a823f1d8
RS
2825 /* Short cut way to output a tag also. */
2826 if ((TREE_CODE (type) == RECORD_TYPE
c1b98a95
RK
2827 || TREE_CODE (type) == UNION_TYPE
2828 || TREE_CODE (type) == QUAL_UNION_TYPE)
37306b1e
RK
2829 && TYPE_NAME (type) == decl
2830 /* Distinguish the implicit typedefs of C++
2831 from explicit ones that might be found in C. */
3a538a66 2832 && DECL_ARTIFICIAL (decl))
a823f1d8 2833 {
abdafc8e 2834 if (use_gnu_debug_info_extensions)
a823f1d8 2835 {
93a27b7b 2836 stabstr_C ('T');
a823f1d8
RS
2837 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2838 }
a823f1d8 2839 }
00fe048c 2840
93a27b7b 2841 stabstr_C ('t');
deda4b76 2842 dbxout_type (type, 1);
93a27b7b
ZW
2843 dbxout_finish_complex_stabs (decl, DBX_TYPE_DECL_STABS_CODE,
2844 0, 0, 0);
3b6c7a7d 2845 did_output = 1;
a823f1d8 2846 }
00fe048c 2847
3342b6fd
RK
2848 /* Don't output a tag if this is an incomplete type. This prevents
2849 the sun4 Sun OS 4.x dbx from crashing. */
83a05a97 2850
bf6ed040
RK
2851 if (tag_needed && TYPE_NAME (type) != 0
2852 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2853 || (DECL_NAME (TYPE_NAME (type)) != 0))
d0f062fb 2854 && COMPLETE_TYPE_P (type)
a823f1d8
RS
2855 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2856 {
2857 /* For a TYPE_DECL with no name, but the type has a name,
2858 output a tag.
2859 This is what represents `struct foo' with no typedef. */
2860 /* In C++, the name of a type is the corresponding typedef.
2861 In C, it is an IDENTIFIER_NODE. */
2862 tree name = TYPE_NAME (type);
2863 if (TREE_CODE (name) == TYPE_DECL)
2864 name = DECL_NAME (name);
2865
93a27b7b
ZW
2866 dbxout_begin_complex_stabs ();
2867 stabstr_I (name);
2868 stabstr_S (":T");
deda4b76 2869 dbxout_type (type, 1);
93a27b7b 2870 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE, 0, 0, 0);
3b6c7a7d
RS
2871 did_output = 1;
2872 }
2873
93a27b7b
ZW
2874 /* If an enum type has no name, it cannot be referred to, but
2875 we must output it anyway, to record the enumeration
2876 constants. */
2877
3b6c7a7d
RS
2878 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2879 {
93a27b7b 2880 dbxout_begin_complex_stabs ();
a63067c2 2881 /* Some debuggers fail when given NULL names, so give this a
93a27b7b
ZW
2882 harmless name of " " (Why not "(anon)"?). */
2883 stabstr_S (" :T");
deda4b76 2884 dbxout_type (type, 1);
93a27b7b 2885 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE, 0, 0, 0);
a823f1d8
RS
2886 }
2887
2888 /* Prevent duplicate output of a typedef. */
2889 TREE_ASM_WRITTEN (decl) = 1;
2890 break;
2891 }
00fe048c
RS
2892
2893 case PARM_DECL:
ed3346c2
EB
2894 if (DECL_HAS_VALUE_EXPR_P (decl))
2895 decl = DECL_VALUE_EXPR (decl);
2896
2897 /* PARM_DECLs go in their own separate chain and are output by
2898 dbxout_reg_parms and dbxout_parms, except for those that are
2899 disguised VAR_DECLs like Out parameters in Ada. */
2900 gcc_assert (TREE_CODE (decl) == VAR_DECL);
2901
2902 /* ... fall through ... */
00fe048c
RS
2903
2904 case RESULT_DECL:
00fe048c 2905 case VAR_DECL:
00fe048c
RS
2906 /* Don't mention a variable that is external.
2907 Let the file that defines it describe it. */
0924ddef 2908 if (DECL_EXTERNAL (decl))
00fe048c
RS
2909 break;
2910
2911 /* If the variable is really a constant
93a27b7b
ZW
2912 and not written in memory, inform the debugger.
2913
2914 ??? Why do we skip emitting the type and location in this case? */
00fe048c
RS
2915 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2916 && DECL_INITIAL (decl) != 0
9541ffee 2917 && tree_fits_shwi_p (DECL_INITIAL (decl))
00fe048c 2918 && ! TREE_ASM_WRITTEN (decl)
1787f59e 2919 && (DECL_FILE_SCOPE_P (decl)
d6b27b56
DP
2920 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK
2921 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
93a27b7b 2922 && TREE_PUBLIC (decl) == 0)
00fe048c 2923 {
93a27b7b 2924 /* The sun4 assembler does not grok this. */
665f2503 2925
93a27b7b
ZW
2926 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2927 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2928 {
eb1ce453 2929 HOST_WIDE_INT ival = tree_to_shwi (DECL_INITIAL (decl));
93a27b7b
ZW
2930
2931 dbxout_begin_complex_stabs ();
d6b27b56
DP
2932 dbxout_symbol_name (decl, NULL, 'c');
2933 stabstr_S ("=i");
93a27b7b
ZW
2934 stabstr_D (ival);
2935 dbxout_finish_complex_stabs (0, N_LSYM, 0, 0, 0);
2936 DBXOUT_DECR_NESTING;
2937 return 1;
00fe048c 2938 }
93a27b7b
ZW
2939 else
2940 break;
00fe048c 2941 }
93a27b7b 2942 /* else it is something we handle like a normal variable. */
00fe048c 2943
d6b27b56
DP
2944 decl_rtl = dbxout_expand_expr (decl);
2945 if (!decl_rtl)
2946 DBXOUT_DECR_NESTING_AND_RETURN (0);
2947
bbbbb16a 2948 decl_rtl = eliminate_regs (decl_rtl, VOIDmode, NULL_RTX);
00fe048c 2949#ifdef LEAF_REG_REMAP
416ff32e 2950 if (crtl->uses_only_leaf_regs)
9bfa80fb 2951 leaf_renumber_regs_insn (decl_rtl);
00fe048c
RS
2952#endif
2953
9bfa80fb 2954 result = dbxout_symbol_location (decl, type, 0, decl_rtl);
e9a25f70 2955 break;
3a538a66 2956
e9a25f70
JL
2957 default:
2958 break;
47700802 2959 }
6a08f7b3 2960 DBXOUT_DECR_NESTING;
00262c8a 2961 return result;
47700802
RS
2962}
2963\f
2964/* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2965 Add SUFFIX to its name, if SUFFIX is not 0.
2966 Describe the variable as residing in HOME
00262c8a
ML
2967 (usually HOME is DECL_RTL (DECL), but not always).
2968 Returns 1 if the stab was really emitted. */
47700802 2969
00262c8a 2970static int
7080f735 2971dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
47700802
RS
2972{
2973 int letter = 0;
dbb6088f 2974 stab_code_type code;
93a27b7b
ZW
2975 rtx addr = 0;
2976 int number = 0;
47700802 2977 int regno = -1;
00fe048c 2978
47700802
RS
2979 /* Don't mention a variable at all
2980 if it was completely optimized into nothingness.
3a538a66 2981
9ec36da5 2982 If the decl was from an inline function, then its rtl
47700802
RS
2983 is not identically the rtl that was used in this
2984 particular compilation. */
c99fa40f 2985 if (GET_CODE (home) == SUBREG)
47700802
RS
2986 {
2987 rtx value = home;
ddef6bc7 2988
47700802 2989 while (GET_CODE (value) == SUBREG)
ddef6bc7 2990 value = SUBREG_REG (value);
f8cfc6aa 2991 if (REG_P (value))
00fe048c 2992 {
ddef6bc7 2993 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
00262c8a 2994 return 0;
00fe048c 2995 }
55a2c322 2996 home = alter_subreg (&home, true);
c99fa40f 2997 }
f8cfc6aa 2998 if (REG_P (home))
c99fa40f
RH
2999 {
3000 regno = REGNO (home);
3001 if (regno >= FIRST_PSEUDO_REGISTER)
3002 return 0;
47700802
RS
3003 }
3004
3005 /* The kind-of-variable letter depends on where
3006 the variable is and on the scope of its name:
3007 G and N_GSYM for static storage and global scope,
3008 S for static storage and file scope,
3009 V for static storage and local scope,
3010 for those two, use N_LCSYM if data is in bss segment,
3011 N_STSYM if in data segment, N_FUN otherwise.
3012 (We used N_FUN originally, then changed to N_STSYM
3013 to please GDB. However, it seems that confused ld.
3014 Now GDB has been fixed to like N_FUN, says Kingdon.)
3015 no letter at all, and N_LSYM, for auto variable,
3016 r and N_RSYM for register variable. */
3017
93a27b7b 3018 if (MEM_P (home) && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
47700802
RS
3019 {
3020 if (TREE_PUBLIC (decl))
00fe048c 3021 {
7151ffbe 3022 int offs;
47700802 3023 letter = 'G';
93a27b7b 3024 code = N_GSYM;
7151ffbe
GH
3025 if (NULL != dbxout_common_check (decl, &offs))
3026 {
3027 letter = 'V';
3028 addr = 0;
3029 number = offs;
3030 }
00fe048c 3031 }
47700802 3032 else
00fe048c 3033 {
93a27b7b 3034 addr = XEXP (home, 0);
00fe048c 3035
47700802 3036 letter = decl_function_context (decl) ? 'V' : 'S';
00fe048c 3037
9ff93eb0
UW
3038 /* Some ports can transform a symbol ref into a label ref,
3039 because the symbol ref is too far away and has to be
3040 dumped into a constant pool. Alternatively, the symbol
3041 in the constant pool might be referenced by a different
3042 symbol. */
3043 if (GET_CODE (addr) == SYMBOL_REF
3044 && CONSTANT_POOL_ADDRESS_P (addr))
3045 {
3046 bool marked;
3047 rtx tmp = get_pool_constant_mark (addr, &marked);
3048
3049 if (GET_CODE (tmp) == SYMBOL_REF)
3050 {
3051 addr = tmp;
3052 if (CONSTANT_POOL_ADDRESS_P (addr))
3053 get_pool_constant_mark (addr, &marked);
3054 else
3055 marked = true;
3056 }
3057 else if (GET_CODE (tmp) == LABEL_REF)
3058 {
3059 addr = tmp;
3060 marked = true;
3061 }
3062
3063 /* If all references to the constant pool were optimized
3064 out, we just ignore the symbol. */
3065 if (!marked)
3066 return 0;
3067 }
3068
6c949b67
JW
3069 /* This should be the same condition as in assemble_variable, but
3070 we don't have access to dont_output_data here. So, instead,
3071 we rely on the fact that error_mark_node initializers always
3072 end up in bss for C++ and never end up in bss for C. */
3073 if (DECL_INITIAL (decl) == 0
3ac88239 3074 || (!strcmp (lang_hooks.name, "GNU C++")
6c949b67 3075 && DECL_INITIAL (decl) == error_mark_node))
7151ffbe
GH
3076 {
3077 int offs;
3078 code = N_LCSYM;
3079 if (NULL != dbxout_common_check (decl, &offs))
3080 {
3081 addr = 0;
3082 number = offs;
3083 letter = 'V';
3084 code = N_GSYM;
3085 }
3086 }
dddfb74b 3087 else if (DECL_IN_TEXT_SECTION (decl))
47700802
RS
3088 /* This is not quite right, but it's the closest
3089 of all the codes that Unix defines. */
93a27b7b 3090 code = DBX_STATIC_CONST_VAR_CODE;
47700802
RS
3091 else
3092 {
3093 /* Ultrix `as' seems to need this. */
00fe048c 3094#ifdef DBX_STATIC_STAB_DATA_SECTION
d6b5193b 3095 switch_to_section (data_section);
00fe048c 3096#endif
93a27b7b 3097 code = N_STSYM;
00fe048c
RS
3098 }
3099 }
47700802
RS
3100 }
3101 else if (regno >= 0)
3102 {
3103 letter = 'r';
93a27b7b
ZW
3104 code = N_RSYM;
3105 number = DBX_REGISTER_NUMBER (regno);
47700802 3106 }
3c0cb5de
JQ
3107 else if (MEM_P (home)
3108 && (MEM_P (XEXP (home, 0))
f8cfc6aa 3109 || (REG_P (XEXP (home, 0))
9571f69b
MM
3110 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
3111 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
e3339d0f 3112#if !HARD_FRAME_POINTER_IS_ARG_POINTER
9571f69b
MM
3113 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
3114#endif
3115 )))
47700802
RS
3116 /* If the value is indirect by memory or by a register
3117 that isn't the frame pointer
3118 then it means the object is variable-sized and address through
3119 that register or stack slot. DBX has no way to represent this
3120 so all we can do is output the variable as a pointer.
6de9cd9a 3121 If it's not a parameter, ignore it. */
47700802 3122 {
f8cfc6aa 3123 if (REG_P (XEXP (home, 0)))
00fe048c
RS
3124 {
3125 letter = 'r';
93a27b7b 3126 code = N_RSYM;
e9716dc5
JJ
3127 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
3128 return 0;
93a27b7b 3129 number = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
00fe048c 3130 }
47700802 3131 else
00fe048c 3132 {
93a27b7b 3133 code = N_LSYM;
47700802 3134 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
00fe048c 3135 We want the value of that CONST_INT. */
93a27b7b 3136 number = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
b372168c 3137 }
47700802
RS
3138
3139 /* Effectively do build_pointer_type, but don't cache this type,
3140 since it might be temporary whereas the type it points to
3141 might have been saved for inlining. */
3142 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
3143 type = make_node (POINTER_TYPE);
3144 TREE_TYPE (type) = TREE_TYPE (decl);
3145 }
3c0cb5de 3146 else if (MEM_P (home)
f8cfc6aa 3147 && REG_P (XEXP (home, 0)))
47700802 3148 {
93a27b7b
ZW
3149 code = N_LSYM;
3150 number = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
47700802 3151 }
3c0cb5de 3152 else if (MEM_P (home)
47700802 3153 && GET_CODE (XEXP (home, 0)) == PLUS
481683e1 3154 && CONST_INT_P (XEXP (XEXP (home, 0), 1)))
47700802 3155 {
93a27b7b 3156 code = N_LSYM;
47700802
RS
3157 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
3158 We want the value of that CONST_INT. */
93a27b7b 3159 number = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
47700802 3160 }
3c0cb5de 3161 else if (MEM_P (home)
47700802
RS
3162 && GET_CODE (XEXP (home, 0)) == CONST)
3163 {
3164 /* Handle an obscure case which can arise when optimizing and
3165 when there are few available registers. (This is *always*
3166 the case for i386/i486 targets). The RTL looks like
3167 (MEM (CONST ...)) even though this variable is a local `auto'
3168 or a local `register' variable. In effect, what has happened
3169 is that the reload pass has seen that all assignments and
3170 references for one such a local variable can be replaced by
3171 equivalent assignments and references to some static storage
3172 variable, thereby avoiding the need for a register. In such
3173 cases we're forced to lie to debuggers and tell them that
3174 this variable was itself `static'. */
7151ffbe 3175 int offs;
93a27b7b 3176 code = N_LCSYM;
47700802 3177 letter = 'V';
7151ffbe
GH
3178 if (NULL == dbxout_common_check (decl, &offs))
3179 addr = XEXP (XEXP (home, 0), 0);
3180 else
3181 {
3182 addr = 0;
3183 number = offs;
3184 code = N_GSYM;
3185 }
47700802
RS
3186 }
3187 else if (GET_CODE (home) == CONCAT)
3188 {
02db7776
JO
3189 tree subtype;
3190
3191 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
3192 for example), then there is no easy way to figure out
3193 what SUBTYPE should be. So, we give up. */
3194 if (TREE_CODE (type) != COMPLEX_TYPE)
3195 return 0;
3196
3197 subtype = TREE_TYPE (type);
47700802
RS
3198
3199 /* If the variable's storage is in two parts,
3200 output each as a separate stab with a modified name. */
3201 if (WORDS_BIG_ENDIAN)
3202 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
00fe048c 3203 else
47700802 3204 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
00fe048c 3205
47700802
RS
3206 if (WORDS_BIG_ENDIAN)
3207 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
3208 else
3209 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
00262c8a 3210 return 1;
47700802
RS
3211 }
3212 else
3213 /* Address might be a MEM, when DECL is a variable-sized object.
3214 Or it might be const0_rtx, meaning previous passes
3215 want us to ignore this variable. */
00262c8a 3216 return 0;
47700802
RS
3217
3218 /* Ok, start a symtab entry and output the variable name. */
859ee18f
ZW
3219 emit_pending_bincls_if_required ();
3220 FORCE_TEXT;
b372168c
MM
3221
3222#ifdef DBX_STATIC_BLOCK_START
93a27b7b 3223 DBX_STATIC_BLOCK_START (asm_out_file, code);
b372168c
MM
3224#endif
3225
859ee18f 3226 dbxout_begin_complex_stabs_noforcetext ();
47700802 3227 dbxout_symbol_name (decl, suffix, letter);
deda4b76 3228 dbxout_type (type, 0);
93a27b7b 3229 dbxout_finish_complex_stabs (decl, code, addr, 0, number);
b372168c
MM
3230
3231#ifdef DBX_STATIC_BLOCK_END
93a27b7b 3232 DBX_STATIC_BLOCK_END (asm_out_file, code);
b372168c 3233#endif
00262c8a 3234 return 1;
47700802
RS
3235}
3236\f
3237/* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
3238 Then output LETTER to indicate the kind of location the symbol has. */
3239
3240static void
7080f735 3241dbxout_symbol_name (tree decl, const char *suffix, int letter)
47700802 3242{
93a27b7b 3243 tree name;
f9d99dd2 3244
b8698a0f 3245 if (DECL_CONTEXT (decl)
a4d8ec65
DP
3246 && (TYPE_P (DECL_CONTEXT (decl))
3247 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
3248 /* One slight hitch: if this is a VAR_DECL which is a class member
3249 or a namespace member, we must put out the mangled name instead of the
f9d99dd2
JM
3250 DECL_NAME. Note also that static member (variable) names DO NOT begin
3251 with underscores in .stabs directives. */
93a27b7b 3252 name = DECL_ASSEMBLER_NAME (decl);
f9d99dd2
JM
3253 else
3254 /* ...but if we're function-local, we don't want to include the junk
3255 added by ASM_FORMAT_PRIVATE_NAME. */
93a27b7b 3256 name = DECL_NAME (decl);
f9d99dd2 3257
93a27b7b
ZW
3258 if (name)
3259 stabstr_I (name);
3260 else
3261 stabstr_S ("(anon)");
47700802 3262
93a27b7b
ZW
3263 if (suffix)
3264 stabstr_S (suffix);
3265 stabstr_C (':');
02e3f1a8 3266 if (letter)
93a27b7b 3267 stabstr_C (letter);
00fe048c
RS
3268}
3269
7151ffbe
GH
3270
3271/* Output the common block name for DECL in a stabs.
3272
3273 Symbols in global common (.comm) get wrapped with an N_BCOMM/N_ECOMM pair
3274 around each group of symbols in the same .comm area. The N_GSYM stabs
3275 that are emitted only contain the offset in the common area. This routine
3276 emits the N_BCOMM and N_ECOMM stabs. */
3277
3278static void
dbb6088f 3279dbxout_common_name (tree decl, const char *name, stab_code_type op)
7151ffbe
GH
3280{
3281 dbxout_begin_complex_stabs ();
3282 stabstr_S (name);
3283 dbxout_finish_complex_stabs (decl, op, NULL_RTX, NULL, 0);
3284}
3285
3286/* Check decl to determine whether it is a VAR_DECL destined for storage in a
3287 common area. If it is, the return value will be a non-null string giving
3288 the name of the common storage block it will go into. If non-null, the
3289 value is the offset into the common block for that symbol's storage. */
3290
3291static const char *
3292dbxout_common_check (tree decl, int *value)
3293{
3294 rtx home;
3295 rtx sym_addr;
3296 const char *name = NULL;
b8698a0f 3297
4d62b56a 3298 /* If the decl isn't a VAR_DECL, or if it isn't static, or if
7151ffbe
GH
3299 it does not have a value (the offset into the common area), or if it
3300 is thread local (as opposed to global) then it isn't common, and shouldn't
3301 be handled as such.
b8698a0f 3302
7151ffbe
GH
3303 ??? DECL_THREAD_LOCAL_P check prevents problems with improper .stabs
3304 for thread-local symbols. Can be handled via same mechanism as used
3305 in dwarf2out.c. */
3306 if (TREE_CODE (decl) != VAR_DECL
c3284718
RS
3307 || !TREE_STATIC (decl)
3308 || !DECL_HAS_VALUE_EXPR_P (decl)
7151ffbe
GH
3309 || DECL_THREAD_LOCAL_P (decl)
3310 || !is_fortran ())
3311 return NULL;
3312
b8698a0f 3313 home = DECL_RTL (decl);
7151ffbe
GH
3314 if (home == NULL_RTX || GET_CODE (home) != MEM)
3315 return NULL;
3316
3317 sym_addr = dbxout_expand_expr (DECL_VALUE_EXPR (decl));
3318 if (sym_addr == NULL_RTX || GET_CODE (sym_addr) != MEM)
3319 return NULL;
3320
3321 sym_addr = XEXP (sym_addr, 0);
3322 if (GET_CODE (sym_addr) == CONST)
3323 sym_addr = XEXP (sym_addr, 0);
3324 if ((GET_CODE (sym_addr) == SYMBOL_REF || GET_CODE (sym_addr) == PLUS)
3325 && DECL_INITIAL (decl) == 0)
3326 {
3327
3328 /* We have a sym that will go into a common area, meaning that it
3329 will get storage reserved with a .comm/.lcomm assembler pseudo-op.
3330
3331 Determine name of common area this symbol will be an offset into,
3332 and offset into that area. Also retrieve the decl for the area
3333 that the symbol is offset into. */
3334 tree cdecl = NULL;
3335
3336 switch (GET_CODE (sym_addr))
3337 {
3338 case PLUS:
481683e1 3339 if (CONST_INT_P (XEXP (sym_addr, 0)))
7151ffbe
GH
3340 {
3341 name =
c3284718 3342 targetm.strip_name_encoding (XSTR (XEXP (sym_addr, 1), 0));
7151ffbe
GH
3343 *value = INTVAL (XEXP (sym_addr, 0));
3344 cdecl = SYMBOL_REF_DECL (XEXP (sym_addr, 1));
3345 }
3346 else
3347 {
3348 name =
c3284718 3349 targetm.strip_name_encoding (XSTR (XEXP (sym_addr, 0), 0));
7151ffbe
GH
3350 *value = INTVAL (XEXP (sym_addr, 1));
3351 cdecl = SYMBOL_REF_DECL (XEXP (sym_addr, 0));
3352 }
3353 break;
3354
3355 case SYMBOL_REF:
c3284718 3356 name = targetm.strip_name_encoding (XSTR (sym_addr, 0));
7151ffbe
GH
3357 *value = 0;
3358 cdecl = SYMBOL_REF_DECL (sym_addr);
3359 break;
3360
3361 default:
3362 error ("common symbol debug info is not structured as "
3363 "symbol+offset");
3364 }
3365
3366 /* Check area common symbol is offset into. If this is not public, then
3367 it is not a symbol in a common block. It must be a .lcomm symbol, not
3368 a .comm symbol. */
c3284718 3369 if (cdecl == NULL || !TREE_PUBLIC (cdecl))
7151ffbe
GH
3370 name = NULL;
3371 }
3372 else
3373 name = NULL;
3374
3375 return name;
3376}
3377
cc2902df 3378/* Output definitions of all the decls in a chain. Return nonzero if
00262c8a 3379 anything was output */
00fe048c 3380
00262c8a 3381int
7080f735 3382dbxout_syms (tree syms)
00fe048c 3383{
00262c8a 3384 int result = 0;
7151ffbe
GH
3385 const char *comm_prev = NULL;
3386 tree syms_prev = NULL;
3387
00fe048c
RS
3388 while (syms)
3389 {
7151ffbe
GH
3390 int temp, copen, cclos;
3391 const char *comm_new;
3392
3393 /* Check for common symbol, and then progression into a new/different
3394 block of common symbols. Emit closing/opening common bracket if
3395 necessary. */
3396 comm_new = dbxout_common_check (syms, &temp);
3397 copen = comm_new != NULL
3398 && (comm_prev == NULL || strcmp (comm_new, comm_prev));
3399 cclos = comm_prev != NULL
3400 && (comm_new == NULL || strcmp (comm_new, comm_prev));
3401 if (cclos)
3402 dbxout_common_name (syms_prev, comm_prev, N_ECOMM);
3403 if (copen)
3404 {
3405 dbxout_common_name (syms, comm_new, N_BCOMM);
3406 syms_prev = syms;
3407 }
3408 comm_prev = comm_new;
3409
00262c8a 3410 result += dbxout_symbol (syms, 1);
910ad8de 3411 syms = DECL_CHAIN (syms);
00fe048c 3412 }
7151ffbe
GH
3413
3414 if (comm_prev != NULL)
3415 dbxout_common_name (syms_prev, comm_prev, N_ECOMM);
3416
00262c8a 3417 return result;
00fe048c
RS
3418}
3419\f
3420/* The following two functions output definitions of function parameters.
3421 Each parameter gets a definition locating it in the parameter list.
3422 Each parameter that is a register variable gets a second definition
3423 locating it in the register.
3424
3425 Printing or argument lists in gdb uses the definitions that
3426 locate in the parameter list. But reference to the variable in
3427 expressions uses preferentially the definition as a register. */
3428
3429/* Output definitions, referring to storage in the parmlist,
3430 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
3431
b372168c 3432void
7080f735 3433dbxout_parms (tree parms)
00fe048c 3434{
6a08f7b3 3435 ++debug_nesting;
33e9d2aa
DP
3436 emit_pending_bincls_if_required ();
3437
910ad8de 3438 for (; parms; parms = DECL_CHAIN (parms))
7a3e01c4
JDA
3439 if (DECL_NAME (parms)
3440 && TREE_TYPE (parms) != error_mark_node
3441 && DECL_RTL_SET_P (parms)
3442 && DECL_INCOMING_RTL (parms))
00fe048c 3443 {
93a27b7b
ZW
3444 tree eff_type;
3445 char letter;
dbb6088f 3446 stab_code_type code;
93a27b7b 3447 int number;
00fe048c
RS
3448
3449 /* Perform any necessary register eliminations on the parameter's rtl,
3450 so that the debugging output will be accurate. */
3451 DECL_INCOMING_RTL (parms)
bbbbb16a
ILT
3452 = eliminate_regs (DECL_INCOMING_RTL (parms), VOIDmode, NULL_RTX);
3453 SET_DECL_RTL (parms,
3454 eliminate_regs (DECL_RTL (parms), VOIDmode, NULL_RTX));
00fe048c 3455#ifdef LEAF_REG_REMAP
416ff32e 3456 if (crtl->uses_only_leaf_regs)
00fe048c
RS
3457 {
3458 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
3459 leaf_renumber_regs_insn (DECL_RTL (parms));
3460 }
3461#endif
3462
3463 if (PARM_PASSED_IN_MEMORY (parms))
3464 {
93a27b7b 3465 rtx inrtl = XEXP (DECL_INCOMING_RTL (parms), 0);
00fe048c
RS
3466
3467 /* ??? Here we assume that the parm address is indexed
3468 off the frame pointer or arg pointer.
3469 If that is not true, we produce meaningless results,
3470 but do not crash. */
93a27b7b 3471 if (GET_CODE (inrtl) == PLUS
481683e1 3472 && CONST_INT_P (XEXP (inrtl, 1)))
93a27b7b 3473 number = INTVAL (XEXP (inrtl, 1));
00fe048c 3474 else
93a27b7b
ZW
3475 number = 0;
3476
3477 code = N_PSYM;
3478 number = DEBUGGER_ARG_OFFSET (number, inrtl);
3479 letter = 'p';
3480
3481 /* It is quite tempting to use TREE_TYPE (parms) instead
3482 of DECL_ARG_TYPE (parms) for the eff_type, so that gcc
3483 reports the actual type of the parameter, rather than
3484 the promoted type. This certainly makes GDB's life
3485 easier, at least for some ports. The change is a bad
3486 idea however, since GDB expects to be able access the
3487 type without performing any conversions. So for
3488 example, if we were passing a float to an unprototyped
3489 function, gcc will store a double on the stack, but if
3490 we emit a stab saying the type is a float, then gdb
3491 will only read in a single value, and this will produce
3492 an erroneous value. */
3493 eff_type = DECL_ARG_TYPE (parms);
00fe048c 3494 }
f8cfc6aa 3495 else if (REG_P (DECL_RTL (parms)))
00fe048c
RS
3496 {
3497 rtx best_rtl;
25b5c537 3498
93a27b7b
ZW
3499 /* Parm passed in registers and lives in registers or nowhere. */
3500 code = DBX_REGPARM_STABS_CODE;
3501 letter = DBX_REGPARM_STABS_LETTER;
3502
3503 /* For parms passed in registers, it is better to use the
3504 declared type of the variable, not the type it arrived in. */
3505 eff_type = TREE_TYPE (parms);
3506
3507 /* If parm lives in a register, use that register; pretend
3508 the parm was passed there. It would be more consistent
3509 to describe the register where the parm was passed, but
3510 in practice that register usually holds something else.
3511 If the parm lives nowhere, use the register where it
3512 was passed. */
770ae6cc 3513 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
93a27b7b 3514 best_rtl = DECL_RTL (parms);
116612b9
EB
3515 else if (GET_CODE (DECL_INCOMING_RTL (parms)) == PARALLEL)
3516 best_rtl = XEXP (XVECEXP (DECL_INCOMING_RTL (parms), 0, 0), 0);
00fe048c 3517 else
93a27b7b 3518 best_rtl = DECL_INCOMING_RTL (parms);
00fe048c 3519
93a27b7b 3520 number = DBX_REGISTER_NUMBER (REGNO (best_rtl));
00fe048c 3521 }
3c0cb5de 3522 else if (MEM_P (DECL_RTL (parms))
f8cfc6aa 3523 && REG_P (XEXP (DECL_RTL (parms), 0))
b205fb6f
JW
3524 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
3525 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
e3339d0f 3526#if !HARD_FRAME_POINTER_IS_ARG_POINTER
b205fb6f
JW
3527 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
3528#endif
3529 )
dad0145a
RS
3530 {
3531 /* Parm was passed via invisible reference.
3532 That is, its address was passed in a register.
3533 Output it as if it lived in that register.
3534 The debugger will know from the type
4828a73e 3535 that it was actually passed by invisible reference. */
ac746f1d 3536
93a27b7b 3537 code = DBX_REGPARM_STABS_CODE;
b8698a0f 3538
93a27b7b
ZW
3539 /* GDB likes this marked with a special letter. */
3540 letter = (use_gnu_debug_info_extensions
3541 ? 'a' : DBX_REGPARM_STABS_LETTER);
3542 eff_type = TREE_TYPE (parms);
dad0145a 3543
4e6ee267
JW
3544 /* DECL_RTL looks like (MEM (REG...). Get the register number.
3545 If it is an unallocated pseudo-reg, then use the register where
93a27b7b
ZW
3546 it was passed instead.
3547 ??? Why is DBX_REGISTER_NUMBER not used here? */
4e6ee267 3548
93a27b7b
ZW
3549 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
3550 number = REGNO (XEXP (DECL_RTL (parms), 0));
dad0145a 3551 else
93a27b7b 3552 number = REGNO (DECL_INCOMING_RTL (parms));
dad0145a 3553 }
3c0cb5de
JQ
3554 else if (MEM_P (DECL_RTL (parms))
3555 && MEM_P (XEXP (DECL_RTL (parms), 0)))
27646dba
JB
3556 {
3557 /* Parm was passed via invisible reference, with the reference
3558 living on the stack. DECL_RTL looks like
ebb0cdf3
CM
3559 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
3560 could look like (MEM (MEM (REG))). */
93a27b7b
ZW
3561
3562 code = N_PSYM;
3563 letter = 'v';
3564 eff_type = TREE_TYPE (parms);
3565
3566 if (!REG_P (XEXP (XEXP (DECL_RTL (parms), 0), 0)))
3567 number = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
ebb0cdf3 3568 else
93a27b7b
ZW
3569 number = 0;
3570
3571 number = DEBUGGER_ARG_OFFSET (number,
3572 XEXP (XEXP (DECL_RTL (parms), 0), 0));
27646dba 3573 }
3c0cb5de 3574 else if (MEM_P (DECL_RTL (parms))
8d291181
RS
3575 && XEXP (DECL_RTL (parms), 0) != const0_rtx
3576 /* ??? A constant address for a parm can happen
3577 when the reg it lives in is equiv to a constant in memory.
3578 Should make this not happen, after 2.4. */
3579 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
00fe048c
RS
3580 {
3581 /* Parm was passed in registers but lives on the stack. */
3582
93a27b7b
ZW
3583 code = N_PSYM;
3584 letter = 'p';
3585 eff_type = TREE_TYPE (parms);
3586
00fe048c
RS
3587 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
3588 in which case we want the value of that CONST_INT,
27646dba 3589 or (MEM (REG ...)),
00fe048c 3590 in which case we use a value of zero. */
93a27b7b
ZW
3591 if (!REG_P (XEXP (DECL_RTL (parms), 0)))
3592 number = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
00fe048c 3593 else
93a27b7b 3594 number = 0;
00fe048c 3595
620422fd
DE
3596 /* Make a big endian correction if the mode of the type of the
3597 parameter is not the same as the mode of the rtl. */
3598 if (BYTES_BIG_ENDIAN
3599 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
3600 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
93a27b7b
ZW
3601 number += (GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
3602 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))));
3603 }
3604 else
3605 /* ??? We don't know how to represent this argument. */
3606 continue;
00fe048c 3607
93a27b7b 3608 dbxout_begin_complex_stabs ();
b8698a0f 3609
93a27b7b
ZW
3610 if (DECL_NAME (parms))
3611 {
3612 stabstr_I (DECL_NAME (parms));
3613 stabstr_C (':');
00fe048c 3614 }
93a27b7b
ZW
3615 else
3616 stabstr_S ("(anon):");
3617 stabstr_C (letter);
3618 dbxout_type (eff_type, 0);
3619 dbxout_finish_complex_stabs (parms, code, 0, 0, number);
00fe048c 3620 }
6a08f7b3 3621 DBXOUT_DECR_NESTING;
00fe048c
RS
3622}
3623
3624/* Output definitions for the places where parms live during the function,
3625 when different from where they were passed, when the parms were passed
3626 in memory.
3627
3628 It is not useful to do this for parms passed in registers
3629 that live during the function in different registers, because it is
3630 impossible to look in the passed register for the passed value,
3631 so we use the within-the-function register to begin with.
3632
3633 PARMS is a chain of PARM_DECL nodes. */
3634
b372168c 3635void
7080f735 3636dbxout_reg_parms (tree parms)
00fe048c 3637{
6a08f7b3
DP
3638 ++debug_nesting;
3639
910ad8de 3640 for (; parms; parms = DECL_CHAIN (parms))
dc2fba60 3641 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
00fe048c 3642 {
00fe048c
RS
3643 /* Report parms that live in registers during the function
3644 but were passed in memory. */
f8cfc6aa 3645 if (REG_P (DECL_RTL (parms))
dc2fba60 3646 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
47700802
RS
3647 dbxout_symbol_location (parms, TREE_TYPE (parms),
3648 0, DECL_RTL (parms));
dc2fba60 3649 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
47700802
RS
3650 dbxout_symbol_location (parms, TREE_TYPE (parms),
3651 0, DECL_RTL (parms));
00fe048c 3652 /* Report parms that live in memory but not where they were passed. */
3c0cb5de 3653 else if (MEM_P (DECL_RTL (parms))
00fe048c 3654 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
dc2fba60
JW
3655 dbxout_symbol_location (parms, TREE_TYPE (parms),
3656 0, DECL_RTL (parms));
00fe048c 3657 }
6a08f7b3 3658 DBXOUT_DECR_NESTING;
00fe048c
RS
3659}
3660\f
3661/* Given a chain of ..._TYPE nodes (as come in a parameter list),
3662 output definitions of those names, in raw form */
3663
e1772ac0 3664static void
7080f735 3665dbxout_args (tree args)
00fe048c
RS
3666{
3667 while (args)
3668 {
93a27b7b 3669 stabstr_C (',');
deda4b76 3670 dbxout_type (TREE_VALUE (args), 0);
00fe048c
RS
3671 args = TREE_CHAIN (args);
3672 }
3673}
3674\f
b420396f
OH
3675#if defined (DBX_DEBUGGING_INFO)
3676
7e2e8179
ZW
3677/* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3678 BEGIN_LABEL is the name of the beginning of the function, which may
3679 be required. */
3680static void
3681dbx_output_lbrac (const char *label,
3682 const char *begin_label ATTRIBUTE_UNUSED)
3683{
93a27b7b 3684 dbxout_begin_stabn (N_LBRAC);
3e487b21 3685 if (DBX_BLOCKS_FUNCTION_RELATIVE)
93a27b7b
ZW
3686 dbxout_stab_value_label_diff (label, begin_label);
3687 else
3688 dbxout_stab_value_label (label);
7e2e8179
ZW
3689}
3690
3691/* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3692 BEGIN_LABEL is the name of the beginning of the function, which may
3693 be required. */
3694static void
3695dbx_output_rbrac (const char *label,
3696 const char *begin_label ATTRIBUTE_UNUSED)
3697{
93a27b7b 3698 dbxout_begin_stabn (N_RBRAC);
3e487b21 3699 if (DBX_BLOCKS_FUNCTION_RELATIVE)
93a27b7b
ZW
3700 dbxout_stab_value_label_diff (label, begin_label);
3701 else
3702 dbxout_stab_value_label (label);
7e2e8179
ZW
3703}
3704
00fe048c
RS
3705/* Output everything about a symbol block (a BLOCK node
3706 that represents a scope level),
3707 including recursive output of contained blocks.
3708
3709 BLOCK is the BLOCK node.
3710 DEPTH is its depth within containing symbol blocks.
3711 ARGS is usually zero; but for the outermost block of the
3712 body of a function, it is a chain of PARM_DECLs for the function parameters.
3713 We output definitions of all the register parms
3714 as if they were local variables of that block.
3715
3716 If -g1 was used, we count blocks just the same, but output nothing
3717 except for the outermost block.
3718
3719 Actually, BLOCK may be several blocks chained together.
3720 We handle them all in sequence. */
3721
3722static void
7080f735 3723dbxout_block (tree block, int depth, tree args)
00fe048c 3724{
03471b3f
CD
3725 char begin_label[20];
3726 /* Reference current function start using LFBB. */
3727 ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
00fe048c
RS
3728
3729 while (block)
3730 {
3731 /* Ignore blocks never expanded or otherwise marked as real. */
5b4c43d7 3732 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
00fe048c 3733 {
711d4bb3 3734 int did_output;
7e2e8179 3735 int blocknum = BLOCK_NUMBER (block);
711d4bb3 3736
00262c8a 3737 /* In dbx format, the syms of a block come before the N_LBRAC.
30f7a378 3738 If nothing is output, we don't need the N_LBRAC, either. */
711d4bb3 3739 did_output = 0;
00fe048c 3740 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
711d4bb3 3741 did_output = dbxout_syms (BLOCK_VARS (block));
00fe048c
RS
3742 if (args)
3743 dbxout_reg_parms (args);
00fe048c
RS
3744
3745 /* Now output an N_LBRAC symbol to represent the beginning of
3746 the block. Use the block's tree-walk order to generate
3747 the assembler symbols LBBn and LBEn
3748 that final will define around the code in this block. */
7e2e8179 3749 if (did_output)
00fe048c
RS
3750 {
3751 char buf[20];
7e2e8179
ZW
3752 const char *scope_start;
3753
3754 if (depth == 0)
3755 /* The outermost block doesn't get LBB labels; use
03471b3f 3756 the LFBB local symbol emitted by dbxout_begin_prologue. */
7e2e8179
ZW
3757 scope_start = begin_label;
3758 else
3759 {
3760 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3761 scope_start = buf;
3762 }
00fe048c 3763
7e2e8179 3764 dbx_output_lbrac (scope_start, begin_label);
00fe048c 3765 }
00fe048c 3766
00fe048c 3767 /* Output the subblocks. */
0d92cbff 3768 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
00fe048c
RS
3769
3770 /* Refer to the marker for the end of the block. */
7e2e8179 3771 if (did_output)
00fe048c 3772 {
7e2e8179
ZW
3773 char buf[100];
3774 if (depth == 0)
3775 /* The outermost block doesn't get LBE labels;
3776 use the "scope" label which will be emitted
3777 by dbxout_function_end. */
3778 ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno);
3779 else
3780 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3781
3782 dbx_output_rbrac (buf, begin_label);
00fe048c
RS
3783 }
3784 }
3785 block = BLOCK_CHAIN (block);
3786 }
3787}
3788
3789/* Output the information about a function and its arguments and result.
3790 Usually this follows the function's code,
3791 but on some systems, it comes before. */
3792
3793static void
7080f735 3794dbxout_begin_function (tree decl)
00fe048c 3795{
847d0c08
RH
3796 int saved_tree_used1;
3797
847d0c08 3798 saved_tree_used1 = TREE_USED (decl);
6a08f7b3
DP
3799 TREE_USED (decl) = 1;
3800 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3801 {
7080f735 3802 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
6a08f7b3
DP
3803 TREE_USED (DECL_RESULT (decl)) = 1;
3804 dbxout_symbol (decl, 0);
3805 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3806 }
3807 else
3808 dbxout_symbol (decl, 0);
3809 TREE_USED (decl) = saved_tree_used1;
3810
00fe048c
RS
3811 dbxout_parms (DECL_ARGUMENTS (decl));
3812 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3813 dbxout_symbol (DECL_RESULT (decl), 1);
3814}
c3fb23f4 3815#endif /* DBX_DEBUGGING_INFO */
00fe048c 3816
4f70758f 3817#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
17211ab5 3818
be7a421e
SB
3819/* Record an element in the table of global destructors. SYMBOL is
3820 a SYMBOL_REF of the function to be called; PRIORITY is a number
3821 between 0 and MAX_INIT_PRIORITY. */
3822
3823void
3824default_stabs_asm_out_destructor (rtx symbol ATTRIBUTE_UNUSED,
3825 int priority ATTRIBUTE_UNUSED)
3826{
3827#if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
3828 /* Tell GNU LD that this is part of the static destructor set.
3829 This will work for any system that uses stabs, most usefully
3830 aout systems. */
3831 dbxout_begin_simple_stabs ("___DTOR_LIST__", 22 /* N_SETT */);
3832 dbxout_stab_value_label (XSTR (symbol, 0));
3833#else
3834 sorry ("global destructors not supported on this target");
3835#endif
3836}
3837
3838/* Likewise for global constructors. */
3839
3840void
3841default_stabs_asm_out_constructor (rtx symbol ATTRIBUTE_UNUSED,
3842 int priority ATTRIBUTE_UNUSED)
3843{
3844#if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
3845 /* Tell GNU LD that this is part of the static destructor set.
3846 This will work for any system that uses stabs, most usefully
3847 aout systems. */
3848 dbxout_begin_simple_stabs ("___CTOR_LIST__", 22 /* N_SETT */);
3849 dbxout_stab_value_label (XSTR (symbol, 0));
3850#else
3851 sorry ("global constructors not supported on this target");
3852#endif
3853}
3854
17211ab5 3855#include "gt-dbxout.h"