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