No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / usr.bin / g++ / cc1plus / dbxout.c
blobf8fe3516288adcd53668a8100f76f23cbb06c1c0
1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Output dbx-format symbol table data.
22 This consists of many symbol table entries, each of them
23 a .stabs assembler pseudo-op with four operands:
24 a "name" which is really a description of one symbol and its type,
25 a "code", which is a symbol defined in stab.h whose name starts with N_,
26 an unused operand always 0,
27 and a "value" which is an address or an offset.
28 The name is enclosed in doublequote characters.
30 Each function, variable, typedef, and structure tag
31 has a symbol table entry to define it.
32 The beginning and end of each level of name scoping within
33 a function are also marked by special symbol table entries.
35 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
36 and a data type number. The data type number may be followed by
37 "=" and a type definition; normally this will happen the first time
38 the type number is mentioned. The type definition may refer to
39 other types by number, and those type numbers may be followed
40 by "=" and nested definitions.
42 This can make the "name" quite long.
43 When a name is more than 80 characters, we split the .stabs pseudo-op
44 into two .stabs pseudo-ops, both sharing the same "code" and "value".
45 The first one is marked as continued with a double-backslash at the
46 end of its "name".
48 The kind-of-symbol letter distinguished function names from global
49 variables from file-scope variables from parameters from auto
50 variables in memory from typedef names from register variables.
51 See `dbxout_symbol'.
53 The "code" is mostly redundant with the kind-of-symbol letter
54 that goes in the "name", but not entirely: for symbols located
55 in static storage, the "code" says which segment the address is in,
56 which controls how it is relocated.
58 The "value" for a symbol in static storage
59 is the core address of the symbol (actually, the assembler
60 label for the symbol). For a symbol located in a stack slot
61 it is the stack offset; for one in a register, the register number.
62 For a typedef symbol, it is zero.
64 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
65 output while in the text section.
67 For more on data type definitions, see `dbxout_type'. */
69 #include "config.h"
70 #include "tree.h"
71 #include "cplus-tree.h"
72 #include "rtl.h"
73 #include "flags.h"
74 #include <stdio.h>
75 #include "regs.h"
77 /* Typical USG systems don't have stab.h, and they also have
78 no use for DBX-format debugging info. */
80 #ifdef DBX_DEBUGGING_INFO
82 #ifdef DEBUG_SYMS_TEXT
83 #define FORCE_TEXT text_section ();
84 #else
85 #define FORCE_TEXT
86 #endif
88 #ifdef USG
89 #include "stab.h" /* If doing DBX on sysV, use our own stab.h. */
90 #else
91 #include <stab.h> /* On BSD, use the system's stab.h. */
92 #endif /* not USG */
94 /* Stream for writing to assembler file. */
96 static FILE *asmfile;
98 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
100 /* Vector recording the status of describing C data types.
101 When we first notice a data type (a tree node),
102 we assign it a number using next_type_number.
103 That is its index in this vector.
104 The vector element says whether we have yet output
105 the definition of the type. TYPE_XREF says we have
106 output it as a cross-reference only. */
108 enum typestatus *typevec;
110 /* Number of elements of space allocated in `typevec'. */
112 static int typevec_len;
114 /* In dbx output, each type gets a unique number.
115 This is the number for the next type output.
116 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
118 static int next_type_number;
120 /* In dbx output, we must assign symbol-blocks id numbers
121 in the order in which their beginnings are encountered.
122 We output debugging info that refers to the beginning and
123 end of the ranges of code in each block
124 with assembler labels LBBn and LBEn, where n is the block number.
125 The labels are generated in final, which assigns numbers to the
126 blocks in the same way. */
128 static int next_block_number;
130 /* These variables are for dbxout_symbol to communicate to
131 dbxout_finish_symbol.
132 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
133 current_sym_value and current_sym_addr are two ways to address the
134 value to store in the symtab entry.
135 current_sym_addr if nonzero represents the value as an rtx.
136 If that is zero, current_sym_value is used. This is used
137 when the value is an offset (such as for auto variables,
138 register variables and parms). */
140 static int current_sym_code;
141 static int current_sym_value;
142 static rtx current_sym_addr;
144 /* Number of chars of symbol-description generated so far for the
145 current symbol. Used by CHARS and CONTIN. */
147 static int current_sym_nchars;
149 /* Report having output N chars of the current symbol-description. */
151 #define CHARS(N) (current_sym_nchars += (N))
153 /* Break the current symbol-description, generating a continuation,
154 if it has become long. */
156 #ifndef DBX_CONTIN_LENGTH
157 #define DBX_CONTIN_LENGTH 80
158 #endif
160 #if DBX_CONTIN_LENGTH > 0
161 #define CONTIN \
162 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
163 #else
164 #define CONTIN
165 #endif
167 void dbxout_types ();
168 void dbxout_tags ();
169 void dbxout_args ();
170 void dbxout_symbol ();
171 static void dbxout_type_name ();
172 static void dbxout_type ();
173 static void dbxout_finish_symbol ();
174 static void dbxout_continue ();
176 /* At the beginning of compilation, start writing the symbol table.
177 Initialize `typevec' and output the standard data types of C. */
179 void
180 dbxout_init (asm_file, input_file_name)
181 FILE *asm_file;
182 char *input_file_name;
184 asmfile = asm_file;
186 typevec_len = 100;
187 typevec = (enum typestatus *) xmalloc (typevec_len * sizeof typevec[0]);
188 bzero (typevec, typevec_len * sizeof typevec[0]);
190 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
191 fprintf (asmfile,
192 "\t.stabs \"%s\",%d,0,0,Ltext\nLtext:\n",
193 input_file_name, N_SO);
195 next_type_number = 1;
196 next_block_number = 2;
198 /* Make sure that types `int' and `char' have numbers 1 and 2.
199 Definitions of other integer types will refer to those numbers. */
201 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
202 dbxout_symbol (TYPE_NAME (char_type_node), 0);
204 /* Get all permanent types not yet gotten, and output them. */
206 dbxout_types (get_permanent_types ());
209 /* Change by Bryan Boreham, Kewill, Sun Aug 13 15:31:25 1989.
210 Added to support unexecing of compiler. */
212 void
213 re_init_dbxout_for_unexec (asm_file, input_file_name)
214 FILE *asm_file;
215 char *input_file_name;
217 asmfile = asm_file;
220 /* Continue a symbol-description that gets too big.
221 End one symbol table entry with a double-backslash
222 and start a new one, eventually producing something like
223 .stabs "start......\\",code,0,value
224 .stabs "...rest",code,0,value */
226 static void
227 dbxout_continue ()
229 #ifdef DBX_CONTIN_CHAR
230 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
231 #else
232 fprintf (asmfile, "\\\\");
233 #endif
234 dbxout_finish_symbol ();
235 fprintf (asmfile, ".stabs \"");
236 current_sym_nchars = 0;
239 static void
240 dbxout_type_fields (type)
241 tree type;
243 tree tem;
244 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
246 /* Output the name, type, position (in bits), size (in bits)
247 of each field. */
248 if (DECL_ANON_UNION_ELEM (tem))
249 dbxout_type_fields (TREE_TYPE (tem));
250 /* Omit here local type decls until we know how to support them. */
251 else if (TREE_CODE (tem) == TYPE_DECL)
252 continue;
253 /* Omit here the nameless fields that are used to skip bits. */
254 else if (DECL_NAME (tem) != 0 && TREE_CODE (tem) != CONST_DECL)
256 /* Continue the line if necessary,
257 but not before the first field. */
258 if (tem != TYPE_FIELDS (type))
259 CONTIN;
261 if (use_gdb_dbx_extensions
262 && flag_minimal_debug
263 && TREE_CODE (tem) == FIELD_DECL
264 && (DECL_VIRTUAL_P (tem) || DECL_VBASE_P (tem)))
266 CHARS (3 + TYPE_NAME_LENGTH (DECL_FCONTEXT (tem)));
267 fprintf (asmfile, "$v%c",
268 DECL_VIRTUAL_P (tem) ? 'f' : 'b');
269 dbxout_type (DECL_FCONTEXT (tem), 0);
270 fprintf (asmfile, ":");
271 dbxout_type (TREE_TYPE (tem), 0);
272 fprintf (asmfile, ",%d;", DECL_OFFSET (tem));
273 continue;
276 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
277 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
279 if (use_gdb_dbx_extensions)
281 putc ('/', asmfile);
282 #ifdef TREE_PRIVATE
283 putc ((TREE_PRIVATE (tem) ? '0'
284 : TREE_PROTECTED (tem) ? '1' : '2'),
285 asmfile);
286 #endif
287 CHARS (2);
290 dbxout_type (TREE_TYPE (tem), 0);
291 if (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))
293 if (use_gdb_dbx_extensions)
295 char *name = DECL_ASSEMBLER_NAME (tem);
297 /* Adding 1 here only works on systems
298 which flush an initial underscore from
299 the .stabs entry. This loses for static names
300 which have an initial leading '_' on systems which
301 don't use leading underscores. */
302 if (name[0] == '_')
303 name += 1;
305 fprintf (asmfile, ":%s;", name);
306 CHARS (strlen (name));
308 else
310 fprintf (asmfile, ",0,0;");
313 #if 0
314 else if (TREE_CODE (tem) == VAR_DECL || TREE_CODE (tem) == CONST_DECL)
316 /* GDB 3.2 can't understand these declarations yet. */
317 continue;
319 #endif
320 else
322 fprintf (asmfile, ",%d,%d;", DECL_OFFSET (tem),
323 TREE_INT_CST_LOW (DECL_SIZE (tem)) * DECL_SIZE_UNIT (tem));
325 CHARS (23);
330 /* Output a reference to a type. If the type has not yet been
331 described in the dbx output, output its definition now.
332 For a type already defined, just refer to its definition
333 using the type number.
335 If FULL is nonzero, and the type has been described only with
336 a forward-reference, output the definition now.
337 If FULL is zero in this case, just refer to the forward-reference
338 using the number previously allocated. */
340 static void
341 dbxout_type (type, full)
342 tree type;
343 int full;
345 register tree fields, tem, method_vec;
346 tree *methods, *end;
347 char *vfield_name = 0;
348 tree virtual_basetype = 0;
350 /* If there was an input error and we don't really have a type,
351 avoid crashing and write something that is at least valid
352 by assuming `int'. */
353 if (type == error_mark_node)
354 type = integer_type_node;
355 else /* if (TYPE_SIZE (type) == 0) */
356 type = TYPE_MAIN_VARIANT (type);
358 if (TYPE_SYMTAB_ADDRESS (type) == 0)
360 /* Type has no dbx number assigned. Assign next available number. */
361 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
363 /* Make sure type vector is long enough to record about this type. */
365 if (next_type_number == typevec_len)
367 typevec = (enum typestatus *) xrealloc (typevec, typevec_len * 2 * sizeof typevec[0]);
368 bzero (typevec + typevec_len, typevec_len * sizeof typevec[0]);
369 typevec_len *= 2;
373 /* Output the number of this type, to refer to it. */
374 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
375 CHARS (3);
377 /* If this type's definition has been output or is now being output,
378 that is all. */
380 switch (typevec[TYPE_SYMTAB_ADDRESS (type)])
382 case TYPE_UNSEEN:
383 break;
384 case TYPE_XREF:
385 if (! full)
386 return;
387 break;
388 case TYPE_DEFINED:
389 return;
392 #ifdef DBX_NO_XREFS
393 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
394 leave the type-number completely undefined rather than output
395 a cross-reference. */
396 if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
397 || TREE_CODE (type) == ENUMERAL_TYPE)
399 if ((TYPE_NAME (type) != 0 && !full)
400 || TYPE_SIZE (type) == 0)
402 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
403 return;
405 #endif
407 /* Output a definition now. */
409 fprintf (asmfile, "=");
410 CHARS (1);
412 /* Mark it as defined, so that if it is self-referent
413 we will not get into an infinite recursion of definitions. */
415 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_DEFINED;
417 switch (TREE_CODE (type))
419 case VOID_TYPE:
420 case LANG_TYPE:
421 /* For a void type, just define it as itself; ie, "5=5".
422 This makes us consider it defined
423 without saying what it is. The debugger will make it
424 a void type when the reference is seen, and nothing will
425 ever override that default. */
426 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
427 CHARS (3);
428 break;
430 case INTEGER_TYPE:
431 if (type == char_type_node && ! TREE_UNSIGNED (type))
432 /* Output the type `char' as a subrange of itself!
433 I don't understand this definition, just copied it
434 from the output of pcc. */
435 fprintf (asmfile, "r2;0;127;");
436 else
437 /* Output other integer types as subranges of `int'. */
438 fprintf (asmfile, "r1;%d;%d;",
439 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)),
440 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
441 CHARS (25);
442 break;
444 case REAL_TYPE:
445 /* This must be magic. */
446 fprintf (asmfile, "r1;%d;0;",
447 TREE_INT_CST_LOW (size_in_bytes (type)));
448 CHARS (16);
449 break;
451 case ARRAY_TYPE:
452 /* Output "a" followed by a range type definition
453 for the index type of the array
454 followed by a reference to the target-type.
455 ar1;0;N;M for an array of type M and size N. */
456 fprintf (asmfile, "ar1;0;%d;",
457 (TYPE_DOMAIN (type)
458 ? TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
459 : -1));
460 CHARS (17);
461 dbxout_type (TREE_TYPE (type), 0);
462 break;
464 case RECORD_TYPE:
465 case UNION_TYPE:
467 int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type);
469 /* Output a structure type. */
470 if ((TYPE_NAME (type) != 0 && !full)
471 || TYPE_SIZE (type) == 0)
473 /* If the type is just a cross reference, output one
474 and mark the type as partially described.
475 If it later becomes defined, we will output
476 its real definition.
477 If the type has a name, don't nest its name within
478 another type's definition; instead, output an xref
479 and let the definition come when the name is defined. */
480 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
481 CHARS (3);
482 dbxout_type_name (type);
483 fprintf (asmfile, ":");
484 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
485 break;
487 tem = size_in_bytes (type);
488 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
489 TREE_INT_CST_LOW (tem));
491 if (use_gdb_dbx_extensions)
493 if (n_baseclasses)
495 fprintf (asmfile, "!%d,", n_baseclasses);
496 CHARS (8);
499 for (i = 1; i <= n_baseclasses; i++)
501 tree basetype = CLASSTYPE_BASECLASS (type, i);
502 if (use_gdb_dbx_extensions)
504 putc (CLASSTYPE_VIA_VIRTUAL (type, i) ? '1'
505 : '0',
506 asmfile);
507 putc (CLASSTYPE_VIA_PUBLIC (type, i) ? '2'
508 : '0',
509 asmfile);
510 fprintf (asmfile, "%d,", DECL_OFFSET (TYPE_NAME (basetype)));
511 CHARS (15);
512 dbxout_type (basetype, 0);
513 putc (';', asmfile);
515 else
517 /* Print out the base class information with fields
518 which have the same names at the types they hold. */
519 dbxout_type_name (basetype);
520 putc (':', asmfile);
521 dbxout_type (basetype, full);
522 fprintf (asmfile, ",%d,%d;",
523 DECL_OFFSET (TYPE_NAME (basetype)),
524 TREE_INT_CST_LOW (TYPE_SIZE (basetype)) * DECL_SIZE_UNIT (basetype));
525 CHARS (20);
530 CHARS (11);
532 /* Write out the field declarations. */
533 dbxout_type_fields (type);
535 /* C++: put out the method names and their parameter lists */
536 /* We do constructors, destructor, if any, followed by the method names. */
537 method_vec = use_gdb_dbx_extensions ? CLASSTYPE_METHOD_VEC (type) : NULL_TREE;
538 methods = 0;
539 end = 0;
540 if (use_gdb_dbx_extensions
541 && TREE_CODE (type) == RECORD_TYPE
542 && (TYPE_HAS_DESTRUCTOR (type) | TYPE_HAS_CONSTRUCTOR (type)))
544 tree dtor;
546 methods = &TREE_VEC_ELT (method_vec, 0);
547 end = TREE_VEC_END (method_vec);
548 /* Destructors lie in a special place. */
549 if (TYPE_HAS_DESTRUCTOR (type))
551 dtor = TREE_VEC_ELT (method_vec, 0);
552 tem = TREE_CHAIN (dtor);
554 else
556 dtor = NULL_TREE;
557 tem = *methods;
560 CHARS (2);
562 if (tem)
564 if (TREE_OPERATOR (tem))
565 /* Operators do not belong here. This is for
566 constructors and destructors only. */
567 abort ();
568 else
570 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (tem)));
571 CHARS (IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 3);
574 while (tem)
576 /* Output the name of the field (after overloading), as
577 well as the name of the field before overloading, along
578 with its parameter list. */
579 char c;
580 char *debug_name = IDENTIFIER_POINTER (DECL_NAME (tem));
581 int old_minimal_debug = flag_minimal_debug;
583 CONTIN;
585 if (tem == dtor)
586 /* Always output destructors with full information. */
587 flag_minimal_debug = 0;
589 dbxout_type (TREE_TYPE (tem), 0);
590 flag_minimal_debug = old_minimal_debug;
592 if (DECL_VIRTUAL_P (tem))
593 c = '*';
594 else if (DECL_STATIC_FUNCTION_P (tem))
595 c = '?';
596 else
597 c = '.';
599 if (flag_minimal_debug && tem != dtor)
601 /* Cut down on debugging information by not outputting
602 the parts of the name we can just as easily
603 have the debugger figure out. */
605 /* Get past '__'. */
606 debug_name += 2;
607 /* Get past const and volatile qualifiers. */
608 while (*debug_name == 'C' || *debug_name == 'V')
609 debug_name++;
610 /* Get past numeric type length prefix. */
611 while (*debug_name >= '0' && *debug_name <= '9')
612 debug_name++;
613 /* Get past type of `this'. */
614 debug_name += IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (type)));
616 fprintf (asmfile, ":%s;%c%c", debug_name,
617 TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c);
618 CHARS (IDENTIFIER_LENGTH (DECL_NAME (tem)) + 5
619 - (debug_name - IDENTIFIER_POINTER (DECL_NAME (tem))));
620 if (DECL_VIRTUAL_P (tem))
622 fprintf (asmfile, "%d;",
623 TREE_INT_CST_LOW (DECL_VINDEX (tem)));
624 CHARS (8);
626 if (tem == dtor)
627 break;
628 tem = TREE_CHAIN (tem);
629 if (tem == NULL_TREE)
630 tem = dtor;
632 putc (';', asmfile);
634 if (methods != end)
635 methods++;
637 else if (method_vec != NULL_TREE)
639 methods = &TREE_VEC_ELT (method_vec, 1);
640 end = TREE_VEC_END (method_vec);
643 for (; methods != end; methods++)
645 tem = *methods;
647 if (tem)
649 if (TREE_OPERATOR (tem))
651 char *name1 = operator_name_string (DECL_NAME (tem));
652 fprintf (asmfile, "op$::%s.", name1);
653 CHARS (strlen (name1) + 6);
655 else
657 tree name = DECL_ORIGINAL_NAME (tem);
658 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
659 CHARS (IDENTIFIER_LENGTH (name) + 3);
662 for (; tem; tem = TREE_CHAIN (tem))
663 /* Output the name of the field (after overloading), as
664 well as the name of the field before overloading, along
665 with its parameter list */
667 /* @@ */
668 char c;
669 char *debug_name = IDENTIFIER_POINTER (DECL_NAME (tem));
671 CONTIN;
673 dbxout_type (TREE_TYPE (tem), 0);
674 if (DECL_VIRTUAL_P (tem))
675 c = '*';
676 else if (DECL_STATIC_FUNCTION_P (tem))
677 c = '?';
678 else
679 c = '.';
681 if (flag_minimal_debug)
683 debug_name += IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 2;
684 while (*debug_name == 'C' || *debug_name == 'V')
685 debug_name++;
686 while (*debug_name >= '0' && *debug_name <= '9')
687 debug_name++;
688 debug_name += IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (type)));
691 fprintf (asmfile, ":%s;%c%c", debug_name,
692 TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c);
693 CHARS (IDENTIFIER_LENGTH (DECL_NAME (tem)) + 6
694 - (debug_name - IDENTIFIER_POINTER (DECL_NAME (tem))));
695 if (DECL_VIRTUAL_P (tem))
697 fprintf (asmfile, "%d;",
698 TREE_INT_CST_LOW (DECL_VINDEX (tem)));
699 CHARS (8);
702 putc (';', asmfile);
703 CHARS (1);
707 putc (';', asmfile);
709 if (use_gdb_dbx_extensions && TREE_CODE (type) == RECORD_TYPE)
711 /* Tell GDB+ that it may keep reading. */
712 putc ('~', asmfile);
713 if (TYPE_HAS_DESTRUCTOR (type) && TYPE_HAS_CONSTRUCTOR (type))
714 putc ('=', asmfile);
715 else if (TYPE_HAS_DESTRUCTOR (type))
716 putc ('-', asmfile);
717 else if (TYPE_HAS_CONSTRUCTOR (type))
718 putc ('+', asmfile);
720 if (CLASSTYPE_VSIZE (type))
722 putc ('%', asmfile);
723 dbxout_type (DECL_FCONTEXT (CLASSTYPE_VFIELD (type)), 0);
724 fprintf (asmfile, ";");
726 else
728 putc (';', asmfile);
729 CHARS (3);
732 break;
734 case ENUMERAL_TYPE:
735 if ((TYPE_NAME (type) != 0
736 && !full
737 && ((TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
738 && ! ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type))))
739 || (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
740 && ! ANON_AGGRNAME_P (TYPE_NAME (type)))))
741 || TYPE_SIZE (type) == 0)
743 fprintf (asmfile, "xe");
744 CHARS (3);
745 dbxout_type_name (type);
746 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
747 fprintf (asmfile, ":");
748 return;
750 putc ('e', asmfile);
751 CHARS (1);
752 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
754 fprintf (asmfile, "%s:%d,", IDENTIFIER_POINTER (TREE_PURPOSE (tem)),
755 TREE_INT_CST_LOW (TREE_VALUE (tem)));
756 CHARS (11 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
757 if (TREE_CHAIN (tem) != 0)
758 CONTIN;
760 putc (';', asmfile);
761 CHARS (1);
762 break;
764 case POINTER_TYPE:
765 putc ('*', asmfile);
766 CHARS (1);
767 dbxout_type (TREE_TYPE (type), 0);
768 break;
770 case METHOD_TYPE:
771 if (use_gdb_dbx_extensions)
773 putc ('#', asmfile);
774 CHARS (1);
775 if (flag_minimal_debug)
777 putc ('#', asmfile);
778 dbxout_type (TREE_TYPE (type), 0);
779 putc (';', asmfile);
780 CHARS (1);
782 else
784 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
785 putc (',', asmfile);
786 CHARS (1);
787 dbxout_type (TREE_TYPE (type), 0);
788 dbxout_args (TYPE_ARG_TYPES (type));
789 putc (';', asmfile);
790 CHARS (1);
793 else
795 /* Should print as an int, because it is really
796 just an offset. */
797 dbxout_type (integer_type_node, 0);
799 break;
801 case OFFSET_TYPE:
802 if (use_gdb_dbx_extensions)
804 putc ('@', asmfile);
805 CHARS (1);
806 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
807 putc (',', asmfile);
808 CHARS (1);
809 dbxout_type (TREE_TYPE (type), 0);
811 else
813 /* Should print as an int, because it is really
814 just an offset. */
815 dbxout_type (integer_type_node, 0);
817 break;
819 case REFERENCE_TYPE:
820 putc (use_gdb_dbx_extensions ? '&' : '*', asmfile);
821 CHARS (1);
822 dbxout_type (TREE_TYPE (type), 0);
823 break;
825 case FUNCTION_TYPE:
826 putc ('f', asmfile);
827 CHARS (1);
828 dbxout_type (TREE_TYPE (type), 0);
829 break;
831 default:
832 abort ();
836 /* Output the name of type TYPE, with no punctuation.
837 Such names can be set up either by typedef declarations
838 or by struct, enum and union tags. */
840 static void
841 dbxout_type_name (type)
842 register tree type;
844 tree t;
845 if (TYPE_NAME (type) == 0)
846 abort ();
847 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
849 t = TYPE_NAME (type);
851 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
853 t = DECL_NAME (TYPE_NAME (type));
855 else
856 abort ();
858 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
859 CHARS (IDENTIFIER_LENGTH (t));
862 /* Output a .stabs for the symbol defined by DECL,
863 which must be a ..._DECL node in the normal namespace.
864 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
865 LOCAL is nonzero if the scope is less than the entire file. */
867 void
868 dbxout_symbol (decl, local)
869 tree decl;
870 int local;
872 int letter = 0;
873 tree type = TREE_TYPE (decl);
874 char *name;
875 int regno = -1;
877 /* If global, first output all types and all
878 struct, enum and union tags that have been created
879 and not yet output. */
881 if (local == 0)
883 /* Send out the tags first. */
884 dbxout_tags (gettags ());
885 dbxout_types (get_permanent_types ());
888 current_sym_code = 0;
889 current_sym_value = 0;
890 current_sym_addr = 0;
892 /* The output will always start with the symbol name,
893 so count that always in the length-output-so-far. */
895 if (DECL_NAME (decl) == 0)
896 return;
898 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
900 switch (TREE_CODE (decl))
902 case CONST_DECL:
903 /* Enum values are defined by defining the enum type. */
904 break;
906 case FUNCTION_DECL:
907 if (DECL_RTL (decl) == 0)
908 return;
909 if (TREE_EXTERNAL (decl))
910 break;
911 if (GET_CODE (DECL_RTL (decl)) != MEM
912 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
913 break;
914 FORCE_TEXT;
915 fprintf (asmfile, ".stabs \"%s:%c",
916 IDENTIFIER_POINTER (DECL_NAME (decl)),
917 TREE_PUBLIC (decl) ? 'F' : 'f');
919 current_sym_code = N_FUN;
920 current_sym_addr = XEXP (DECL_RTL (decl), 0);
922 if (TREE_TYPE (TREE_TYPE (decl)))
923 dbxout_type (TREE_TYPE (TREE_TYPE (decl)), 0);
924 else
925 dbxout_type (void_type_node, 0);
926 dbxout_finish_symbol ();
927 break;
929 case TYPE_DECL:
930 #if 0
931 /* This seems all wrong. Outputting most kinds of types gives no name
932 at all. A true definition gives no name; a cross-ref for a
933 structure can give the tag name, but not a type name.
934 It seems that no typedef name is defined by outputting a type. */
936 /* If this typedef name was defined by outputting the type,
937 don't duplicate it. */
938 if (typevec[TYPE_SYMTAB_ADDRESS (type)] == TYPE_DEFINED
939 && TYPE_NAME (TREE_TYPE (decl)) == decl)
940 return;
941 #endif
942 /* Don't output the same typedef twice.
943 And don't output what language-specific stuff doesn't want output. */
944 if (TREE_ASM_WRITTEN (decl)
945 || lang_output_debug_info (TREE_TYPE (decl)) == 0)
946 return;
948 /* Output typedef name. */
949 FORCE_TEXT;
950 fprintf (asmfile, ".stabs \"%s:t",
951 IDENTIFIER_POINTER (DECL_NAME (decl)));
953 current_sym_code = N_LSYM;
955 dbxout_type (TREE_TYPE (decl), 1);
956 dbxout_finish_symbol ();
958 /* Prevent duplicate output of a typedef. */
959 TREE_ASM_WRITTEN (decl) = 1;
960 break;
962 case PARM_DECL:
963 /* Parm decls go in their own separate chains
964 and are output by dbxout_reg_parms and dbxout_parms. */
965 abort ();
967 case RESULT_DECL:
968 /* Named return value, treat like a VAR_DECL. */
969 case VAR_DECL:
970 if (DECL_RTL (decl) == 0)
971 return;
972 /* Don't mention a variable that is external.
973 Let the file that defines it describe it. */
974 if (TREE_EXTERNAL (decl))
975 break;
977 /* If the variable is really a constant, inform dbx of such. */
978 if (TREE_STATIC (decl) && TREE_READONLY (decl)
979 && DECL_INITIAL (decl) != 0
980 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
981 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == LET_STMT))
983 if (TREE_PUBLIC (decl) == 0)
985 /* The sun4 assembler does not grok this. */
986 name = IDENTIFIER_POINTER (DECL_NAME (decl));
987 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
988 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
990 int ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
991 fprintf (asmfile, ".stabs \"%s:c=i%d\",0x%x,0,0,0\n",
992 name, ival, N_LSYM);
993 return;
995 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
997 /* don't know how to do this yet. */
999 break;
1001 /* else it is something we handle like a normal variable. */
1004 /* Don't mention a variable at all
1005 if it was completely optimized into nothingness.
1007 If DECL was from an inline function, then it's rtl
1008 is not identically the rtl that was used in this
1009 particular compilation. */
1010 if (GET_CODE (DECL_RTL (decl)) == REG)
1012 regno = REGNO (DECL_RTL (decl));
1013 if (regno >= FIRST_PSEUDO_REGISTER)
1014 regno = reg_renumber[REGNO (DECL_RTL (decl))];
1015 if (regno < 0)
1016 break;
1019 /* The kind-of-variable letter depends on where
1020 the variable is and on the scope of its name:
1021 G and N_GSYM for static storage and global scope,
1022 S for static storage and file scope,
1023 V for static storage and local scope,
1024 for those two, use N_LCSYM if data is in bss segment,
1025 N_STSYM if in data segment, N_FUN otherwise.
1026 (We used N_FUN originally, then changed to N_STSYM
1027 to please GDB. However, it seems that confused ld.
1028 Now GDB has been fixed to like N_FUN, says Kingdon.)
1029 no letter at all, and N_LSYM, for auto variable,
1030 r and N_RSYM for register variable. */
1032 if (GET_CODE (DECL_RTL (decl)) == MEM
1033 && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
1035 if (TREE_PUBLIC (decl))
1037 letter = 'G';
1038 current_sym_code = N_GSYM;
1040 else
1042 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1044 letter = TREE_PERMANENT (decl) ? 'S' : 'V';
1046 if (!DECL_INITIAL (decl))
1047 current_sym_code = N_LCSYM;
1048 else if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl))
1049 /* This is not quite right, but it's the closest
1050 of all the codes that Unix defines. */
1051 current_sym_code = N_FUN;
1052 else
1053 current_sym_code = N_STSYM;
1056 else if (regno >= 0)
1058 letter = 'r';
1059 current_sym_code = N_RSYM;
1060 current_sym_value = DBX_REGISTER_NUMBER (regno);
1062 else if (GET_CODE (DECL_RTL (decl)) == MEM
1063 && (GET_CODE (XEXP (DECL_RTL (decl), 0)) == MEM
1064 || (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG
1065 && REGNO (XEXP (DECL_RTL (decl), 0)) != FRAME_POINTER_REGNUM)))
1066 /* If the value is indirect by memory or by a register
1067 that isn't the frame pointer
1068 then it means the object is variable-sized and address through
1069 that register or stack slot. DBX has no way to represent this
1070 so all we can do is output the variable as a pointer.
1071 If it's not a parameter, ignore it.
1072 (VAR_DECLs like this can be made by integrate.c.) */
1074 if (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG)
1076 letter = 'r';
1077 current_sym_code = N_RSYM;
1078 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (DECL_RTL (decl), 0)));
1080 else
1082 current_sym_code = N_LSYM;
1083 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
1084 We want the value of that CONST_INT. */
1085 current_sym_value = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (decl), 0), 0), 1));
1088 /* Effectively do build_pointer_type, but don't cache this type,
1089 since it might be temporary whereas the type it points to
1090 might have been saved for inlining. */
1091 type = make_node (POINTER_TYPE);
1092 TREE_TYPE (type) = TREE_TYPE (decl);
1094 else if (GET_CODE (DECL_RTL (decl)) == MEM
1095 && GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG)
1097 current_sym_code = N_LSYM;
1098 current_sym_value = 0;
1100 else if (GET_CODE (DECL_RTL (decl)) == MEM
1101 && GET_CODE (XEXP (DECL_RTL (decl), 0)) == PLUS
1102 && GET_CODE (XEXP (XEXP (DECL_RTL (decl), 0), 1)) == CONST_INT)
1104 current_sym_code = N_LSYM;
1105 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
1106 We want the value of that CONST_INT. */
1107 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (decl), 0), 1));
1109 else
1110 /* Address might be a MEM, when DECL is a variable-sized object.
1111 Or it might be const0_rtx, meaning previous passes
1112 want us to ignore this variable. */
1113 break;
1115 /* Ok, start a symtab entry and output the variable name. */
1116 FORCE_TEXT;
1117 /* One slight hitch: if this is a VAR_DECL which is a static
1118 class member, we must put out the mangled name instead of the
1119 DECL_NAME. */
1120 /* Note also that static member (variable) names DO NOT begin
1121 with underscores in .stabs directives. */
1122 if (DECL_LANG_SPECIFIC (decl))
1124 name = DECL_ASSEMBLER_NAME (decl);
1126 /* Adding 1 here only works on systems
1127 which flush an initial underscore. */
1128 if (name[0] == '_')
1129 name += 1;
1131 else name = IDENTIFIER_POINTER (DECL_NAME (decl));
1133 fprintf (asmfile, ".stabs \"%s:", name);
1134 if (letter) putc (letter, asmfile);
1135 dbxout_type (type, 0);
1136 dbxout_finish_symbol ();
1137 break;
1141 static void
1142 dbxout_finish_symbol ()
1144 fprintf (asmfile, "\",%d,0,0,", current_sym_code);
1145 if (current_sym_addr)
1146 output_addr_const (asmfile, current_sym_addr);
1147 else
1148 fprintf (asmfile, "%d", current_sym_value);
1149 putc ('\n', asmfile);
1152 /* Output definitions of all the decls in a chain. */
1154 static void
1155 dbxout_syms (syms)
1156 tree syms;
1158 while (syms)
1160 dbxout_symbol (syms, 1);
1161 syms = TREE_CHAIN (syms);
1165 /* The following two functions output definitions of function parameters.
1166 Each parameter gets a definition locating it in the parameter list.
1167 Each parameter that is a register variable gets a second definition
1168 locating it in the register.
1170 Printing or argument lists in gdb uses the definitions that
1171 locate in the parameter list. But reference to the variable in
1172 expressions uses preferentially the definition as a register. */
1174 /* Output definitions, referring to storage in the parmlist,
1175 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1177 static void
1178 dbxout_parms (parms)
1179 tree parms;
1181 for (; parms; parms = TREE_CHAIN (parms))
1183 int regno = -1;
1185 if (GET_CODE (DECL_RTL (parms)) == REG)
1186 regno = REGNO (DECL_RTL (parms));
1187 if (regno >= FIRST_PSEUDO_REGISTER)
1188 regno = reg_renumber[regno];
1190 if (DECL_OFFSET (parms) >= 0)
1192 current_sym_code = N_PSYM;
1193 current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT;
1194 current_sym_addr = 0;
1196 FORCE_TEXT;
1197 if (DECL_NAME (parms))
1199 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
1201 fprintf (asmfile, ".stabs \"%s:p",
1202 IDENTIFIER_POINTER (DECL_NAME (parms)));
1204 else
1206 current_sym_nchars = 8;
1207 fprintf (asmfile, ".stabs \"(anon):p");
1210 if (regno >= 0)
1211 dbxout_type (DECL_ARG_TYPE (parms), 0);
1212 else
1214 /* This is the case where the parm is passed as an int or double
1215 and it is converted to a char, short or float and stored back
1216 in the parmlist. In this case, describe the parm
1217 with the variable's declared type, and adjust the address
1218 if the least significant bytes (which we are using) are not
1219 the first ones. */
1220 #ifdef BYTES_BIG_ENDIAN
1221 if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1222 current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1223 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1224 #endif
1226 if (GET_CODE (DECL_RTL (parms)) == MEM
1227 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1228 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
1229 && INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == current_sym_value)
1230 dbxout_type (TREE_TYPE (parms), 0);
1231 else
1233 current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT;
1234 dbxout_type (DECL_ARG_TYPE (parms), 0);
1237 dbxout_finish_symbol ();
1239 /* Parm was passed in registers.
1240 If it lives in a hard register, output a "regparm" symbol
1241 for the register it lives in. */
1242 else if (regno >= 0)
1244 current_sym_code = N_RSYM;
1245 current_sym_value = DBX_REGISTER_NUMBER (regno);
1246 current_sym_addr = 0;
1248 FORCE_TEXT;
1249 if (DECL_NAME (parms))
1251 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
1252 fprintf (asmfile, ".stabs \"%s:P",
1253 IDENTIFIER_POINTER (DECL_NAME (parms)));
1255 else
1257 current_sym_nchars = 8;
1258 fprintf (asmfile, ".stabs \"(anon):P");
1261 dbxout_type (DECL_ARG_TYPE (parms), 0);
1262 dbxout_finish_symbol ();
1264 else if (GET_CODE (DECL_RTL (parms)) == MEM
1265 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1267 current_sym_code = N_LSYM;
1268 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))).
1269 We want the value of that CONST_INT. */
1270 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1271 current_sym_addr = 0;
1273 FORCE_TEXT;
1274 if (DECL_NAME (parms))
1276 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
1277 fprintf (asmfile, ".stabs \"%s:p",
1278 IDENTIFIER_POINTER (DECL_NAME (parms)));
1280 else
1282 current_sym_nchars = 8;
1283 fprintf (asmfile, ".stabs \"(anon):p");
1286 #if 0 /* This is actually the case in which a parameter
1287 is passed in registers but lives on the stack in a local slot.
1288 The address we are using is already correct, so don't change it. */
1290 /* This is the case where the parm is passed as an int or double
1291 and it is converted to a char, short or float and stored back
1292 in the parmlist. In this case, describe the parm
1293 with the variable's declared type, and adjust the address
1294 if the least significant bytes (which we are using) are not
1295 the first ones. */
1296 #ifdef BYTES_BIG_ENDIAN
1297 if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1298 current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1299 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1300 #endif
1301 #endif /* 0 */
1303 dbxout_type (TREE_TYPE (parms), 0);
1304 dbxout_finish_symbol ();
1309 /* Output definitions, referring to registers,
1310 of all the parms in PARMS which are stored in registers during the function.
1311 PARMS is a chain of PARM_DECL nodes. */
1313 static void
1314 dbxout_reg_parms (parms)
1315 tree parms;
1317 while (parms)
1319 int regno = -1;
1321 if (GET_CODE (DECL_RTL (parms)) == REG)
1322 regno = REGNO (DECL_RTL (parms));
1323 if (regno >= FIRST_PSEUDO_REGISTER)
1324 regno = reg_renumber[regno];
1326 /* Report parms that live in registers during the function. */
1327 if (regno >= 0
1328 && DECL_OFFSET (parms) >= 0)
1330 current_sym_code = N_RSYM;
1331 current_sym_value = DBX_REGISTER_NUMBER (regno);
1332 current_sym_addr = 0;
1334 FORCE_TEXT;
1335 if (DECL_NAME (parms))
1337 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
1338 fprintf (asmfile, ".stabs \"%s:r",
1339 IDENTIFIER_POINTER (DECL_NAME (parms)));
1341 else
1343 current_sym_nchars = 8;
1344 fprintf (asmfile, ".stabs \"(anon):r");
1346 dbxout_type (TREE_TYPE (parms), 0);
1347 dbxout_finish_symbol ();
1349 /* Report parms that live in memory but outside the parmlist. */
1350 else if (GET_CODE (DECL_RTL (parms)) == MEM
1351 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1352 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT)
1354 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1355 /* A parm declared char is really passed as an int,
1356 so it occupies the least significant bytes.
1357 On a big-endian machine those are not the low-numbered ones. */
1358 #ifdef BYTES_BIG_ENDIAN
1359 if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1360 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1361 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1362 #endif
1363 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset)
1365 current_sym_code = N_LSYM;
1366 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1367 current_sym_addr = 0;
1368 FORCE_TEXT;
1369 if (DECL_NAME (parms))
1371 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
1372 fprintf (asmfile, ".stabs \"%s:",
1373 IDENTIFIER_POINTER (DECL_NAME (parms)));
1375 else
1377 current_sym_nchars = 8;
1378 fprintf (asmfile, ".stabs \"(anon):");
1380 dbxout_type (TREE_TYPE (parms), 0);
1381 dbxout_finish_symbol ();
1384 parms = TREE_CHAIN (parms);
1388 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
1389 output definitions of those names, in raw form */
1391 void
1392 dbxout_args (args)
1393 tree args;
1395 while (args)
1397 putc (',', asmfile);
1398 dbxout_type (TREE_VALUE (args), 0);
1399 CHARS (1);
1400 args = TREE_CHAIN (args);
1404 /* Given a chain of ..._TYPE nodes,
1405 find those which have typedef names and output those names.
1406 This is to ensure those types get output. */
1408 void
1409 dbxout_types (types)
1410 register tree types;
1412 while (types)
1414 if (TYPE_NAME (types)
1415 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
1416 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
1417 dbxout_symbol (TYPE_NAME (types), 1);
1418 types = TREE_CHAIN (types);
1422 /* Output the tags (struct, union and enum definitions with names) for a block,
1423 given a list of them (a chain of TREE_LIST nodes) in TAGS.
1424 We must check to include those that have been mentioned already with
1425 only a cross-reference. */
1427 void
1428 dbxout_tags (tags)
1429 tree tags;
1431 register tree link;
1432 for (link = tags; link; link = TREE_CHAIN (link))
1434 register tree type = TYPE_MAIN_VARIANT (TREE_VALUE (link));
1435 if (TREE_PURPOSE (link) != 0
1436 && ! TREE_ASM_WRITTEN (link)
1437 && TYPE_SIZE (type) != 0
1438 && lang_output_debug_info (type))
1440 TREE_ASM_WRITTEN (link) = 1;
1441 current_sym_code = N_LSYM;
1442 current_sym_value = 0;
1443 current_sym_addr = 0;
1444 current_sym_nchars = 2 + IDENTIFIER_LENGTH (TREE_PURPOSE (link));
1446 FORCE_TEXT;
1447 fprintf (asmfile, ".stabs \"%s:T",
1448 ANON_AGGRNAME_P (TREE_PURPOSE (link))
1449 ? "" : IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1451 /* If there is a typedecl for this type with the same name
1452 as the tag, output an abbreviated form for that typedecl. */
1453 if (use_gdb_dbx_extensions
1454 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1455 && DECL_NAME (TYPE_NAME (type)) == TREE_PURPOSE (link))
1457 putc ('t', asmfile);
1458 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1460 dbxout_type (type, 1);
1461 dbxout_finish_symbol ();
1463 /* Change by Bryan Boreham, Kewill, Fri Sep 22 16:57:42 1989.
1464 Added to make sure all fully-output structs have typedefs. */
1466 if (!ANON_AGGRNAME_P (TREE_PURPOSE (link))
1467 && (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL
1468 || DECL_NAME (TYPE_NAME (type)) != TREE_PURPOSE (link)))
1470 fprintf (asmfile, ".stabs \"%s:t",
1471 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1473 current_sym_code = N_LSYM;
1475 dbxout_type (type, 1);
1476 dbxout_finish_symbol ();
1482 /* Output everything about a symbol block (that is to say, a LET_STMT node
1483 that represents a scope level),
1484 including recursive output of contained blocks.
1486 STMT is the LET_STMT node.
1487 DEPTH is its depth within containing symbol blocks.
1488 ARGS is usually zero; but for the outermost block of the
1489 body of a function, it is a chain of PARM_DECLs for the function parameters.
1490 We output definitions of all the register parms
1491 as if they were local variables of that block.
1493 Actually, STMT may be several statements chained together.
1494 We handle them all in sequence. */
1496 static void
1497 dbxout_block (stmt, depth, args)
1498 register tree stmt;
1499 int depth;
1500 tree args;
1502 int blocknum;
1504 while (stmt)
1506 switch (TREE_CODE (stmt))
1508 case COMPOUND_STMT:
1509 case LOOP_STMT:
1510 dbxout_block (STMT_BODY (stmt), depth, 0);
1511 break;
1513 case IF_STMT:
1514 dbxout_block (STMT_THEN (stmt), depth, 0);
1515 dbxout_block (STMT_ELSE (stmt), depth, 0);
1516 break;
1518 case LET_STMT:
1519 /* Ignore LET_STMTs for blocks never really used to make RTL. */
1520 if (! TREE_USED (stmt))
1521 break;
1522 /* In dbx format, the syms of a block come before the N_LBRAC. */
1523 dbxout_tags (STMT_TYPE_TAGS (stmt));
1524 dbxout_syms (STMT_VARS (stmt));
1525 if (args)
1526 dbxout_reg_parms (args);
1528 /* Now output an N_LBRAC symbol to represent the beginning of
1529 the block. Use the block's tree-walk order to generate
1530 the assembler symbols LBBn and LBEn
1531 that final will define around the code in this block. */
1532 if (depth > 0)
1534 char buf[20];
1535 blocknum = next_block_number++;
1536 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
1538 if (TREE_LANG_FLAG_1 (stmt) == 0
1539 && TREE_LANG_FLAG_2 (stmt) == 1)
1541 /* A catch block. Must precede N_LBRAC. */
1542 tree decl = STMT_VARS (stmt);
1543 char *name = DECL_NAME (decl) == NULL_TREE
1544 ? "default" : EXCEPTION_NAME_LENGTH + IDENTIFIER_POINTER (DECL_NAME (decl));
1545 fprintf (asmfile, ".stabs \"%s:C1\",%d,0,0,", name, N_CATCH);
1546 assemble_name (asmfile, buf);
1547 fprintf (asmfile, "\n");
1550 fprintf (asmfile, ".stabn %d,0,0,", N_LBRAC);
1551 assemble_name (asmfile, buf);
1552 fprintf (asmfile, "\n");
1555 /* Output the subblocks. */
1556 dbxout_block (STMT_SUBBLOCKS (stmt), depth + 1, 0);
1558 /* Refer to the marker for the end of the block. */
1559 if (depth > 0)
1561 char buf[20];
1562 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
1563 fprintf (asmfile, ".stabn %d,0,0,", N_RBRAC);
1564 assemble_name (asmfile, buf);
1565 fprintf (asmfile, "\n");
1568 stmt = TREE_CHAIN (stmt);
1572 /* Output dbx data for a function definition.
1573 This includes a definition of the function name itself (a symbol),
1574 definitions of the parameters (locating them in the parameter list)
1575 and then output the block that makes up the function's body
1576 (including all the auto variables of the function). */
1578 void
1579 dbxout_function (decl)
1580 tree decl;
1582 extern tree value_identifier;
1584 dbxout_symbol (decl, 0);
1585 dbxout_parms (DECL_ARGUMENTS (decl));
1586 if (DECL_NAME (DECL_RESULT (decl)) != value_identifier)
1587 dbxout_symbol (DECL_RESULT (decl), 1);
1588 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
1590 /* If we made any temporary types in this fn that weren't
1591 output, output them now. */
1592 dbxout_types (get_temporary_types ());
1595 /* GNU C++ extensions. */
1597 /* At the start of the file, emit symbolic information to orient
1598 GDB for this particular file's exception handling implementation.
1599 EH_TYPE is the type name of the exception type.
1600 EH_DECL is the global root of the exception handler stack. */
1602 void
1603 dbxout_eh_init (eh_type, eh_decl)
1604 tree eh_type, eh_decl;
1608 #else /* not DBX_DEBUGGING_INFO */
1610 void
1611 dbxout_init (asm_file, input_file_name)
1612 FILE *asm_file;
1613 char *input_file_name;
1616 void
1617 dbxout_symbol (decl, local)
1618 tree decl;
1619 int local;
1622 void
1623 dbxout_types (types)
1624 register tree types;
1627 void
1628 dbxout_tags (tags)
1629 tree tags;
1632 void
1633 dbxout_function (decl)
1634 tree decl;
1637 void
1638 dbxout_eh_init (eh_type, eh_decl)
1639 tree eh_type, eh_decl;
1643 #endif /* DBX_DEBUGGING_INFO */