1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* mike@tredysvr.Tredydev.Unisys.COM says:
23 I modified the struct.c example and have a nm of a .o resulting from the
24 AT&T C compiler. From the example below I would conclude the following:
26 1. All .defs from structures are emitted as scanned. The example below
27 clearly shows the symbol table entries for BoxRec2 are after the first
30 2. All functions and their locals (including statics) are emitted as scanned.
32 3. All nested unnamed union and structure .defs must be emitted before
33 the structure in which they are nested. The AT&T assembler is a
34 one pass beast as far as symbolics are concerned.
36 4. All structure .defs are emitted before the typedefs that refer to them.
38 5. All top level static and external variable definitions are moved to the
39 end of file with all top level statics occurring first before externs.
41 6. All undefined references are at the end of the file.
46 #ifdef SDB_DEBUGGING_INFO
53 #include "insn-config.h"
62 /* 1 if PARM is passed to this function in memory. */
64 #define PARM_PASSED_IN_MEMORY(PARM) \
65 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
67 /* A C expression for the integer offset value of an automatic variable
68 (C_AUTO) having address X (an RTX). */
69 #ifndef DEBUGGER_AUTO_OFFSET
70 #define DEBUGGER_AUTO_OFFSET(X) \
71 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
74 /* A C expression for the integer offset value of an argument (C_ARG)
75 having address X (an RTX). The nominal offset is OFFSET. */
76 #ifndef DEBUGGER_ARG_OFFSET
77 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
80 /* Line number of beginning of current function, minus one.
81 Negative means not in a function or not using sdb. */
83 int sdb_begin_function_line = -1;
85 /* Counter to generate unique "names" for nameless struct members. */
87 static int unnamed_struct_number = 0;
89 extern FILE *asm_out_file;
91 extern tree current_function_decl;
95 static void sdbout_init PARAMS ((const char *));
96 static void sdbout_start_source_file PARAMS ((unsigned, const char *));
97 static void sdbout_end_source_file PARAMS ((unsigned));
98 static void sdbout_begin_block PARAMS ((unsigned, unsigned));
99 static void sdbout_end_block PARAMS ((unsigned, unsigned));
100 static void sdbout_source_line PARAMS ((unsigned int, const char *));
101 static void sdbout_end_epilogue PARAMS ((void));
102 static void sdbout_global_decl PARAMS ((tree));
103 #ifndef MIPS_DEBUGGING_INFO
104 static void sdbout_begin_prologue PARAMS ((unsigned int, const char *));
106 static void sdbout_end_prologue PARAMS ((unsigned int));
107 static void sdbout_begin_function PARAMS ((tree));
108 static void sdbout_end_function PARAMS ((unsigned int));
109 static void sdbout_toplevel_data PARAMS ((tree));
110 static void sdbout_label PARAMS ((rtx));
111 static char *gen_fake_label PARAMS ((void));
112 static int plain_type PARAMS ((tree));
113 static int template_name_p PARAMS ((tree));
114 static void sdbout_record_type_name PARAMS ((tree));
115 static int plain_type_1 PARAMS ((tree, int));
116 static void sdbout_block PARAMS ((tree));
117 static void sdbout_syms PARAMS ((tree));
118 #ifdef SDB_ALLOW_FORWARD_REFERENCES
119 static void sdbout_queue_anonymous_type PARAMS ((tree));
120 static void sdbout_dequeue_anonymous_types PARAMS ((void));
122 static void sdbout_type PARAMS ((tree));
123 static void sdbout_field_types PARAMS ((tree));
124 static void sdbout_one_type PARAMS ((tree));
125 static void sdbout_parms PARAMS ((tree));
126 static void sdbout_reg_parms PARAMS ((tree));
128 /* Random macros describing parts of SDB data. */
130 /* Put something here if lines get too long */
133 /* Default value of delimiter is ";". */
135 #define SDB_DELIM ";"
138 /* Maximum number of dimensions the assembler will allow. */
140 #define SDB_MAX_DIM 4
144 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
147 #ifndef PUT_SDB_INT_VAL
148 #define PUT_SDB_INT_VAL(a) \
150 fputs ("\t.val\t", asm_out_file); \
151 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
152 fprintf (asm_out_file, "%s", SDB_DELIM); \
158 #define PUT_SDB_VAL(a) \
159 ( fputs ("\t.val\t", asm_out_file), \
160 output_addr_const (asm_out_file, (a)), \
161 fprintf (asm_out_file, SDB_DELIM))
165 #define PUT_SDB_DEF(a) \
166 do { fprintf (asm_out_file, "\t.def\t"); \
167 assemble_name (asm_out_file, a); \
168 fprintf (asm_out_file, SDB_DELIM); } while (0)
171 #ifndef PUT_SDB_PLAIN_DEF
172 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
175 #ifndef PUT_SDB_ENDEF
176 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
180 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
184 #define PUT_SDB_SIZE(a) \
186 fputs ("\t.size\t", asm_out_file); \
187 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
188 fprintf (asm_out_file, "%s", SDB_DELIM); \
192 #ifndef PUT_SDB_START_DIM
193 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
196 #ifndef PUT_SDB_NEXT_DIM
197 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
200 #ifndef PUT_SDB_LAST_DIM
201 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
205 #define PUT_SDB_TAG(a) \
206 do { fprintf (asm_out_file, "\t.tag\t"); \
207 assemble_name (asm_out_file, a); \
208 fprintf (asm_out_file, SDB_DELIM); } while (0)
211 #ifndef PUT_SDB_BLOCK_START
212 #define PUT_SDB_BLOCK_START(LINE) \
213 fprintf (asm_out_file, \
214 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
215 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
218 #ifndef PUT_SDB_BLOCK_END
219 #define PUT_SDB_BLOCK_END(LINE) \
220 fprintf (asm_out_file, \
221 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
222 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
225 #ifndef PUT_SDB_FUNCTION_START
226 #define PUT_SDB_FUNCTION_START(LINE) \
227 fprintf (asm_out_file, \
228 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
229 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
232 #ifndef PUT_SDB_FUNCTION_END
233 #define PUT_SDB_FUNCTION_END(LINE) \
234 fprintf (asm_out_file, \
235 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
236 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
239 #ifndef SDB_GENERATE_FAKE
240 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
241 sprintf ((BUFFER), ".%dfake", (NUMBER));
244 /* Return the sdb tag identifier string for TYPE
245 if TYPE has already been defined; otherwise return a null pointer. */
247 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
249 /* Set the sdb tag identifier string for TYPE to NAME. */
251 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
252 TYPE_SYMTAB_POINTER (TYPE) = (NAME)
254 /* Return the name (a string) of the struct, union or enum tag
255 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
257 #define TAG_NAME(link) \
258 (((link) && TREE_PURPOSE ((link)) \
259 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
260 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
262 /* Ensure we don't output a negative line number. */
263 #define MAKE_LINE_SAFE(line) \
264 if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1
266 /* Perform linker optimization of merging header file definitions together
267 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
268 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
269 the optimization just won't be done. The native assembler already has the
270 necessary support. */
272 #ifdef MIPS_DEBUGGING_INFO
274 #ifndef PUT_SDB_SRC_FILE
275 #define PUT_SDB_SRC_FILE(FILENAME) \
276 output_file_directive (asm_out_file, (FILENAME))
279 /* ECOFF linkers have an optimization that does the same kind of thing as
280 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
281 executable. To achieve this, GCC must output a .file for each file
284 /* This is a stack of input files. */
288 struct sdb_file *next;
292 /* This is the top of the stack. */
294 static struct sdb_file *current_file;
296 #endif /* MIPS_DEBUGGING_INFO */
298 /* The debug hooks structure. */
299 struct gcc_debug_hooks sdb_debug_hooks =
302 debug_nothing_charstar,
303 debug_nothing_int_charstar,
304 debug_nothing_int_charstar,
305 sdbout_start_source_file,
306 sdbout_end_source_file,
309 debug_true_tree, /* ignore_block */
311 #ifdef MIPS_DEBUGGING_INFO
312 /* Defer on MIPS systems so that parameter descriptions follow
314 debug_nothing_int_charstar, /* begin_prologue */
315 sdbout_end_prologue, /* end_prologue */
317 sdbout_begin_prologue, /* begin_prologue */
318 debug_nothing_int, /* end_prologue */
321 sdbout_begin_function,
323 debug_nothing_tree, /* function_decl */
325 debug_nothing_tree, /* deferred_inline_function */
326 debug_nothing_tree, /* outlining_inline_function */
332 /* return the tag identifier for type
336 tag_of_ru_type (type,link)
339 if (TYPE_SYMTAB_ADDRESS (type))
340 return TYPE_SYMTAB_ADDRESS (type);
341 if (link && TREE_PURPOSE (link)
342 && IDENTIFIER_POINTER (TREE_PURPOSE (link)))
343 TYPE_SYMTAB_ADDRESS (type) = IDENTIFIER_POINTER (TREE_PURPOSE (link));
345 return (char *) TYPE_SYMTAB_ADDRESS (type);
349 /* Return a unique string to name an anonymous type. */
356 SDB_GENERATE_FAKE (label, unnamed_struct_number);
357 unnamed_struct_number++;
358 labelstr = (char *) permalloc (strlen (label) + 1);
359 strcpy (labelstr, label);
363 /* Return the number which describes TYPE for SDB.
364 For pointers, etc., this function is recursive.
365 Each record, union or enumeral type must already have had a
366 tag number output. */
368 /* The number is given by d6d5d4d3d2d1bbbb
369 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
370 Thus, char *foo () has bbbb=T_CHAR
373 N_BTMASK= 017 1111 basic type field.
374 N_TSHIFT= 2 derived type shift
375 N_BTSHFT= 4 Basic type shift */
377 /* Produce the number that describes a pointer, function or array type.
378 PREV is the number describing the target, value or element type.
379 DT_type describes how to transform that type. */
380 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
381 ((((PREV) & ~(int)N_BTMASK) << (int)N_TSHIFT) \
382 | ((int)DT_type << (int)N_BTSHFT) \
383 | ((PREV) & (int)N_BTMASK))
385 /* Number of elements used in sdb_dims. */
386 static int sdb_n_dims = 0;
388 /* Table of array dimensions of current type. */
389 static int sdb_dims[SDB_MAX_DIM];
391 /* Size of outermost array currently being processed. */
392 static int sdb_type_size = -1;
398 int val = plain_type_1 (type, 0);
400 /* If we have already saved up some array dimensions, print them now. */
405 for (i = sdb_n_dims - 1; i > 0; i--)
406 PUT_SDB_NEXT_DIM (sdb_dims[i]);
407 PUT_SDB_LAST_DIM (sdb_dims[0]);
410 sdb_type_size = int_size_in_bytes (type);
411 /* Don't kill sdb if type is not laid out or has variable size. */
412 if (sdb_type_size < 0)
415 /* If we have computed the size of an array containing this type,
417 if (sdb_type_size >= 0)
419 PUT_SDB_SIZE (sdb_type_size);
426 template_name_p (name)
429 register const char *ptr = IDENTIFIER_POINTER (name);
430 while (*ptr && *ptr != '<')
437 sdbout_record_type_name (type)
440 const char *name = 0;
443 if (KNOWN_TYPE_TAG (type))
446 if (TYPE_NAME (type) != 0)
449 /* Find the IDENTIFIER_NODE for the type name. */
450 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
451 t = TYPE_NAME (type);
452 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
454 t = DECL_NAME (TYPE_NAME (type));
455 /* The DECL_NAME for templates includes "<>", which breaks
456 most assemblers. Use its assembler name instead, which
457 has been mangled into being safe. */
458 if (t && template_name_p (t))
459 t = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
462 /* Now get the name as a string, or invent one. */
464 name = IDENTIFIER_POINTER (t);
467 no_name = (name == 0 || *name == 0);
469 name = gen_fake_label ();
471 SET_KNOWN_TYPE_TAG (type, name);
472 #ifdef SDB_ALLOW_FORWARD_REFERENCES
474 sdbout_queue_anonymous_type (type);
478 /* Return the .type value for type TYPE.
480 LEVEL indicates how many levels deep we have recursed into the type.
481 The SDB debug format can only represent 6 derived levels of types.
482 After that, we must output inaccurate debug info. We deliberately
483 stop before the 7th level, so that ADA recursive types will not give an
487 plain_type_1 (type, level)
492 type = void_type_node;
493 else if (type == error_mark_node)
494 type = integer_type_node;
496 type = TYPE_MAIN_VARIANT (type);
498 switch (TREE_CODE (type))
505 int size = int_size_in_bytes (type) * BITS_PER_UNIT;
507 /* Carefully distinguish all the standard types of C,
508 without messing up if the language is not C.
509 Note that we check only for the names that contain spaces;
510 other names might occur by coincidence in other languages. */
511 if (TYPE_NAME (type) != 0
512 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
513 && DECL_NAME (TYPE_NAME (type)) != 0
514 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
517 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
519 if (!strcmp (name, "char"))
521 if (!strcmp (name, "unsigned char"))
523 if (!strcmp (name, "signed char"))
525 if (!strcmp (name, "int"))
527 if (!strcmp (name, "unsigned int"))
529 if (!strcmp (name, "short int"))
531 if (!strcmp (name, "short unsigned int"))
533 if (!strcmp (name, "long int"))
535 if (!strcmp (name, "long unsigned int"))
539 if (size == INT_TYPE_SIZE)
540 return (TREE_UNSIGNED (type) ? T_UINT : T_INT);
541 if (size == CHAR_TYPE_SIZE)
542 return (TREE_UNSIGNED (type) ? T_UCHAR : T_CHAR);
543 if (size == SHORT_TYPE_SIZE)
544 return (TREE_UNSIGNED (type) ? T_USHORT : T_SHORT);
545 if (size == LONG_TYPE_SIZE)
546 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
547 if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */
548 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
554 int precision = TYPE_PRECISION (type);
555 if (precision == FLOAT_TYPE_SIZE)
557 if (precision == DOUBLE_TYPE_SIZE)
559 #ifdef EXTENDED_SDB_BASIC_TYPES
560 if (precision == LONG_DOUBLE_TYPE_SIZE)
563 if (precision == LONG_DOUBLE_TYPE_SIZE)
564 return T_DOUBLE; /* better than nothing */
575 m = plain_type_1 (TREE_TYPE (type), level+1);
576 if (sdb_n_dims < SDB_MAX_DIM)
577 sdb_dims[sdb_n_dims++]
578 = (TYPE_DOMAIN (type)
579 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
580 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
581 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
582 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0)
583 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
584 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1)
587 return PUSH_DERIVED_LEVEL (DT_ARY, m);
592 case QUAL_UNION_TYPE:
596 #ifdef SDB_ALLOW_FORWARD_REFERENCES
597 sdbout_record_type_name (type);
599 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
600 if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0)
601 #ifdef SDB_ALLOW_FORWARD_REFERENCES
602 || TYPE_MODE (type) != VOIDmode
607 /* Output the referenced structure tag name
608 only if the .def has already been finished.
609 At least on 386, the Unix assembler
610 cannot handle forward references to tags. */
611 /* But the 88100, it requires them, sigh... */
612 /* And the MIPS requires unknown refs as well... */
613 tag = KNOWN_TYPE_TAG (type);
615 /* These 3 lines used to follow the close brace.
616 However, a size of 0 without a tag implies a tag of 0,
617 so if we don't know a tag, we can't mention the size. */
618 sdb_type_size = int_size_in_bytes (type);
619 if (sdb_type_size < 0)
622 return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT
623 : (TREE_CODE (type) == UNION_TYPE) ? T_UNION
624 : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION
634 m = plain_type_1 (TREE_TYPE (type), level+1);
635 return PUSH_DERIVED_LEVEL (DT_PTR, m);
644 m = plain_type_1 (TREE_TYPE (type), level+1);
645 return PUSH_DERIVED_LEVEL (DT_FCN, m);
652 /* Output the symbols defined in block number DO_BLOCK.
654 This function works by walking the tree structure of blocks,
655 counting blocks until it finds the desired block. */
657 static int do_block = 0;
665 /* Ignore blocks never expanded or otherwise marked as real. */
666 if (TREE_USED (block))
668 /* When we reach the specified block, output its symbols. */
669 if (BLOCK_NUMBER (block) == do_block)
670 sdbout_syms (BLOCK_VARS (block));
672 /* If we are past the specified block, stop the scan. */
673 if (BLOCK_NUMBER (block) > do_block)
676 /* Scan the blocks within this block. */
677 sdbout_block (BLOCK_SUBBLOCKS (block));
680 block = BLOCK_CHAIN (block);
684 /* Call sdbout_symbol on each decl in the chain SYMS. */
692 if (TREE_CODE (syms) != LABEL_DECL)
693 sdbout_symbol (syms, 1);
694 syms = TREE_CHAIN (syms);
698 /* Output SDB information for a symbol described by DECL.
699 LOCAL is nonzero if the symbol is not file-scope. */
702 sdbout_symbol (decl, local)
706 tree type = TREE_TYPE (decl);
707 tree context = NULL_TREE;
712 sdbout_one_type (type);
714 #if 0 /* This loses when functions are marked to be ignored,
715 which happens in the C++ front end. */
716 if (DECL_IGNORED_P (decl))
720 switch (TREE_CODE (decl))
723 /* Enum values are defined by defining the enum type. */
727 /* Don't mention a nested function under its parent. */
728 context = decl_function_context (decl);
729 if (context == current_function_decl)
731 /* Check DECL_INITIAL to distinguish declarations from definitions.
732 Don't output debug info here for declarations; they will have
733 a DECL_INITIAL value of 0. */
734 if (! DECL_INITIAL (decl))
736 if (GET_CODE (DECL_RTL (decl)) != MEM
737 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
739 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
740 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
741 PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT);
745 /* Done with tagged types. */
746 if (DECL_NAME (decl) == 0)
748 if (DECL_IGNORED_P (decl))
751 /* Output typedef name. */
752 if (template_name_p (DECL_NAME (decl)))
753 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
755 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl)));
756 PUT_SDB_SCL (C_TPDEF);
760 /* Parm decls go in their own separate chains
761 and are output by sdbout_reg_parms and sdbout_parms. */
765 /* Don't mention a variable that is external.
766 Let the file that defines it describe it. */
767 if (DECL_EXTERNAL (decl))
770 /* Ignore __FUNCTION__, etc. */
771 if (DECL_IGNORED_P (decl))
774 /* If there was an error in the declaration, don't dump core
775 if there is no RTL associated with the variable doesn't
777 if (!DECL_RTL_SET_P (decl))
781 eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
782 #ifdef LEAF_REG_REMAP
783 if (current_function_uses_only_leaf_regs)
784 leaf_renumber_regs_insn (DECL_RTL (decl));
786 value = DECL_RTL (decl);
788 /* Don't mention a variable at all
789 if it was completely optimized into nothingness.
791 If DECL was from an inline function, then its rtl
792 is not identically the rtl that was used in this
793 particular compilation. */
794 if (GET_CODE (value) == REG)
796 regno = REGNO (DECL_RTL (decl));
797 if (regno >= FIRST_PSEUDO_REGISTER)
800 else if (GET_CODE (value) == SUBREG)
802 while (GET_CODE (value) == SUBREG)
803 value = SUBREG_REG (value);
804 if (GET_CODE (value) == REG)
806 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
809 regno = REGNO (alter_subreg (DECL_RTL (decl)));
810 value = DECL_RTL (decl);
812 /* Don't output anything if an auto variable
813 gets RTL that is static.
814 GAS version 2.2 can't handle such output. */
815 else if (GET_CODE (value) == MEM && CONSTANT_P (XEXP (value, 0))
816 && ! TREE_STATIC (decl))
819 /* Emit any structure, union, or enum type that has not been output.
820 This occurs for tag-less structs (et al) used to declare variables
822 if (TREE_CODE (type) == ENUMERAL_TYPE
823 || TREE_CODE (type) == RECORD_TYPE
824 || TREE_CODE (type) == UNION_TYPE
825 || TREE_CODE (type) == QUAL_UNION_TYPE)
827 if (COMPLETE_TYPE_P (type) /* not a forward reference */
828 && KNOWN_TYPE_TAG (type) == 0) /* not yet declared */
829 sdbout_one_type (type);
832 /* Defer SDB information for top-level initialized variables! */
834 && GET_CODE (value) == MEM
835 && DECL_INITIAL (decl))
838 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
839 For now, avoid crashing. */
840 if (DECL_NAME (decl) == NULL_TREE)
843 /* Record the name for, starting a symtab entry. */
845 name = IDENTIFIER_POINTER (DECL_NAME (decl));
847 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
849 if (GET_CODE (value) == MEM
850 && GET_CODE (XEXP (value, 0)) == SYMBOL_REF)
853 if (TREE_PUBLIC (decl))
855 PUT_SDB_VAL (XEXP (value, 0));
860 PUT_SDB_VAL (XEXP (value, 0));
861 PUT_SDB_SCL (C_STAT);
867 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno));
870 else if (GET_CODE (value) == MEM
871 && (GET_CODE (XEXP (value, 0)) == MEM
872 || (GET_CODE (XEXP (value, 0)) == REG
873 && REGNO (XEXP (value, 0)) != HARD_FRAME_POINTER_REGNUM
874 && REGNO (XEXP (value, 0)) != STACK_POINTER_REGNUM)))
875 /* If the value is indirect by memory or by a register
876 that isn't the frame pointer
877 then it means the object is variable-sized and address through
878 that register or stack slot. COFF has no way to represent this
879 so all we can do is output the variable as a pointer. */
882 if (GET_CODE (XEXP (value, 0)) == REG)
884 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value, 0))));
889 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
891 We want the value of that CONST_INT. */
892 /* Encore compiler hates a newline in a macro arg, it seems. */
893 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
894 (XEXP (XEXP (value, 0), 0)));
895 PUT_SDB_SCL (C_AUTO);
898 /* Effectively do build_pointer_type, but don't cache this type,
899 since it might be temporary whereas the type it points to
900 might have been saved for inlining. */
901 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
902 type = make_node (POINTER_TYPE);
903 TREE_TYPE (type) = TREE_TYPE (decl);
905 else if (GET_CODE (value) == MEM
906 && ((GET_CODE (XEXP (value, 0)) == PLUS
907 && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
908 && GET_CODE (XEXP (XEXP (value, 0), 1)) == CONST_INT)
909 /* This is for variables which are at offset zero from
910 the frame pointer. This happens on the Alpha.
911 Non-frame pointer registers are excluded above. */
912 || (GET_CODE (XEXP (value, 0)) == REG)))
914 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
915 or (MEM (REG...)). We want the value of that CONST_INT
918 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value, 0)));
919 PUT_SDB_SCL (C_AUTO);
921 else if (GET_CODE (value) == MEM && GET_CODE (XEXP (value, 0)) == CONST)
923 /* Handle an obscure case which can arise when optimizing and
924 when there are few available registers. (This is *always*
925 the case for i386/i486 targets). The DECL_RTL looks like
926 (MEM (CONST ...)) even though this variable is a local `auto'
927 or a local `register' variable. In effect, what has happened
928 is that the reload pass has seen that all assignments and
929 references for one such a local variable can be replaced by
930 equivalent assignments and references to some static storage
931 variable, thereby avoiding the need for a register. In such
932 cases we're forced to lie to debuggers and tell them that
933 this variable was itself `static'. */
935 PUT_SDB_VAL (XEXP (XEXP (value, 0), 0));
936 PUT_SDB_SCL (C_STAT);
940 /* It is something we don't know how to represent for SDB. */
948 PUT_SDB_TYPE (plain_type (type));
952 /* Output SDB information for a top-level initialized variable
953 that has been delayed. */
956 sdbout_toplevel_data (decl)
959 tree type = TREE_TYPE (decl);
961 if (DECL_IGNORED_P (decl))
964 if (! (TREE_CODE (decl) == VAR_DECL
965 && GET_CODE (DECL_RTL (decl)) == MEM
966 && DECL_INITIAL (decl)))
969 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
970 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
971 if (TREE_PUBLIC (decl))
977 PUT_SDB_SCL (C_STAT);
979 PUT_SDB_TYPE (plain_type (type));
983 #ifdef SDB_ALLOW_FORWARD_REFERENCES
985 /* Machinery to record and output anonymous types. */
987 static tree anonymous_types;
990 sdbout_queue_anonymous_type (type)
993 anonymous_types = tree_cons (NULL_TREE, type, anonymous_types);
997 sdbout_dequeue_anonymous_types ()
999 register tree types, link;
1001 while (anonymous_types)
1003 types = nreverse (anonymous_types);
1004 anonymous_types = NULL_TREE;
1006 for (link = types; link; link = TREE_CHAIN (link))
1008 register tree type = TREE_VALUE (link);
1010 if (type && ! TREE_ASM_WRITTEN (type))
1011 sdbout_one_type (type);
1018 /* Given a chain of ..._TYPE nodes, all of which have names,
1019 output definitions of those names, as typedefs. */
1022 sdbout_types (types)
1023 register tree types;
1027 for (link = types; link; link = TREE_CHAIN (link))
1028 sdbout_one_type (link);
1030 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1031 sdbout_dequeue_anonymous_types ();
1039 if (type == error_mark_node)
1040 type = integer_type_node;
1041 PUT_SDB_TYPE (plain_type (type));
1044 /* Output types of the fields of type TYPE, if they are structs.
1046 Formerly did not chase through pointer types, since that could be circular.
1047 They must come before TYPE, since forward refs are not allowed.
1048 Now james@bigtex.cactus.org says to try them. */
1051 sdbout_field_types (type)
1056 for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
1057 /* This condition should match the one for emitting the actual
1059 if (TREE_CODE (tail) == FIELD_DECL
1062 && host_integerp (DECL_SIZE (tail), 1)
1063 && host_integerp (bit_position (tail), 0))
1065 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1066 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1068 sdbout_one_type (TREE_TYPE (tail));
1072 /* Use this to put out the top level defined record and union types
1073 for later reference. If this is a struct with a name, then put that
1074 name out. Other unnamed structs will have .xxfake labels generated so
1075 that they may be referred to later.
1076 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1077 It may NOT be called recursively. */
1080 sdbout_one_type (type)
1083 if (current_function_decl != NULL_TREE
1084 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
1085 ; /* Don't change section amid function. */
1089 switch (TREE_CODE (type))
1093 case QUAL_UNION_TYPE:
1095 type = TYPE_MAIN_VARIANT (type);
1096 /* Don't output a type twice. */
1097 if (TREE_ASM_WRITTEN (type))
1098 /* James said test TREE_ASM_BEING_WRITTEN here. */
1101 /* Output nothing if type is not yet defined. */
1102 if (!COMPLETE_TYPE_P (type))
1105 TREE_ASM_WRITTEN (type) = 1;
1107 /* This is reputed to cause trouble with the following case,
1108 but perhaps checking TYPE_SIZE above will fix it. */
1110 /* Here is a test case:
1116 typedef struct intermediate {
1120 typedef struct badstr {
1125 TREE_ASM_BEING_WRITTEN (type) = 1;
1127 /* This change, which ought to make better output,
1128 used to make the COFF assembler unhappy.
1129 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1130 /* Before really doing anything, output types we want to refer to. */
1131 /* Note that in version 1 the following two lines
1132 are not used if forward references are in use. */
1133 if (TREE_CODE (type) != ENUMERAL_TYPE)
1134 sdbout_field_types (type);
1136 TREE_ASM_WRITTEN (type) = 1;
1140 /* Output a structure type. */
1142 int size = int_size_in_bytes (type);
1145 int i, n_baseclasses = 0;
1147 /* Record the type tag, but not in its permanent place just yet. */
1148 sdbout_record_type_name (type);
1150 PUT_SDB_DEF (KNOWN_TYPE_TAG (type));
1152 switch (TREE_CODE (type))
1155 case QUAL_UNION_TYPE:
1156 PUT_SDB_SCL (C_UNTAG);
1157 PUT_SDB_TYPE (T_UNION);
1162 PUT_SDB_SCL (C_STRTAG);
1163 PUT_SDB_TYPE (T_STRUCT);
1168 PUT_SDB_SCL (C_ENTAG);
1169 PUT_SDB_TYPE (T_ENUM);
1177 PUT_SDB_SIZE (size);
1180 /* Print out the base class information with fields
1181 named after the types they hold. */
1182 /* This is only relevent to aggregate types. TYPE_BINFO is used
1183 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1185 if (TREE_CODE (type) != ENUMERAL_TYPE)
1187 if (TYPE_BINFO (type)
1188 && TYPE_BINFO_BASETYPES (type))
1189 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1190 for (i = 0; i < n_baseclasses; i++)
1192 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)),
1194 tree child_type = BINFO_TYPE (child);
1195 tree child_type_name;
1196 if (TYPE_NAME (child_type) == 0)
1198 if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
1199 child_type_name = TYPE_NAME (child_type);
1200 else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL)
1202 child_type_name = DECL_NAME (TYPE_NAME (child_type));
1203 if (child_type_name && template_name_p (child_type_name))
1205 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type));
1211 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1212 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0));
1213 PUT_SDB_SCL (member_scl);
1214 sdbout_type (BINFO_TYPE (child));
1219 /* output the individual fields */
1221 if (TREE_CODE (type) == ENUMERAL_TYPE)
1223 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1224 if (host_integerp (TREE_VALUE (tem), 0))
1226 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1227 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem), 0));
1228 PUT_SDB_SCL (C_MOE);
1229 PUT_SDB_TYPE (T_MOE);
1233 else /* record or union type */
1234 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1235 /* Output the name, type, position (in bits), size (in bits)
1238 /* Omit here the nameless fields that are used to skip bits.
1239 Also omit fields with variable size or position.
1240 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1241 if (TREE_CODE (tem) == FIELD_DECL
1244 && host_integerp (DECL_SIZE (tem), 1)
1245 && host_integerp (bit_position (tem), 0))
1250 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1252 if (DECL_BIT_FIELD_TYPE (tem))
1254 PUT_SDB_INT_VAL (int_bit_position (tem));
1255 PUT_SDB_SCL (C_FIELD);
1256 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1257 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1));
1261 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1262 PUT_SDB_SCL (member_scl);
1263 sdbout_type (TREE_TYPE (tem));
1267 /* output end of a structure,union, or enumeral definition */
1269 PUT_SDB_PLAIN_DEF ("eos");
1270 PUT_SDB_INT_VAL (size);
1271 PUT_SDB_SCL (C_EOS);
1272 PUT_SDB_TAG (KNOWN_TYPE_TAG (type));
1273 PUT_SDB_SIZE (size);
1283 /* The following two functions output definitions of function parameters.
1284 Each parameter gets a definition locating it in the parameter list.
1285 Each parameter that is a register variable gets a second definition
1286 locating it in the register.
1288 Printing or argument lists in gdb uses the definitions that
1289 locate in the parameter list. But reference to the variable in
1290 expressions uses preferentially the definition as a register. */
1292 /* Output definitions, referring to storage in the parmlist,
1293 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1296 sdbout_parms (parms)
1299 for (; parms; parms = TREE_CHAIN (parms))
1300 if (DECL_NAME (parms))
1302 int current_sym_value = 0;
1303 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1305 if (name == 0 || *name == 0)
1306 name = gen_fake_label ();
1308 /* Perform any necessary register eliminations on the parameter's rtl,
1309 so that the debugging output will be accurate. */
1310 DECL_INCOMING_RTL (parms)
1311 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
1312 SET_DECL_RTL (parms,
1313 eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
1315 if (PARM_PASSED_IN_MEMORY (parms))
1317 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
1320 /* ??? Here we assume that the parm address is indexed
1321 off the frame pointer or arg pointer.
1322 If that is not true, we produce meaningless results,
1323 but do not crash. */
1324 if (GET_CODE (addr) == PLUS
1325 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
1326 current_sym_value = INTVAL (XEXP (addr, 1));
1328 current_sym_value = 0;
1330 if (GET_CODE (DECL_RTL (parms)) == REG
1331 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1332 type = DECL_ARG_TYPE (parms);
1335 int original_sym_value = current_sym_value;
1337 /* This is the case where the parm is passed as an int or
1338 double and it is converted to a char, short or float
1339 and stored back in the parmlist. In this case, describe
1340 the parm with the variable's declared type, and adjust
1341 the address if the least significant bytes (which we are
1342 using) are not the first ones. */
1343 if (BYTES_BIG_ENDIAN
1344 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1345 current_sym_value +=
1346 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1347 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1349 if (GET_CODE (DECL_RTL (parms)) == MEM
1350 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1351 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1353 && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1354 == current_sym_value))
1355 type = TREE_TYPE (parms);
1358 current_sym_value = original_sym_value;
1359 type = DECL_ARG_TYPE (parms);
1364 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr));
1365 PUT_SDB_SCL (C_ARG);
1366 PUT_SDB_TYPE (plain_type (type));
1369 else if (GET_CODE (DECL_RTL (parms)) == REG)
1372 /* Parm passed in registers and lives in registers or nowhere. */
1374 /* If parm lives in a register, use that register;
1375 pretend the parm was passed there. It would be more consistent
1376 to describe the register where the parm was passed,
1377 but in practice that register usually holds something else. */
1378 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1379 best_rtl = DECL_RTL (parms);
1380 /* If the parm lives nowhere,
1381 use the register where it was passed. */
1383 best_rtl = DECL_INCOMING_RTL (parms);
1386 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl)));
1387 PUT_SDB_SCL (C_REGPARM);
1388 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1391 else if (GET_CODE (DECL_RTL (parms)) == MEM
1392 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1394 /* Parm was passed in registers but lives on the stack. */
1396 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1397 in which case we want the value of that CONST_INT,
1398 or (MEM (REG ...)) or (MEM (MEM ...)),
1399 in which case we use a value of zero. */
1400 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
1401 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
1402 current_sym_value = 0;
1404 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1406 /* Again, this assumes the offset is based on the arg pointer. */
1408 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value,
1409 XEXP (DECL_RTL (parms), 0)));
1410 PUT_SDB_SCL (C_ARG);
1411 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1417 /* Output definitions for the places where parms live during the function,
1418 when different from where they were passed, when the parms were passed
1421 It is not useful to do this for parms passed in registers
1422 that live during the function in different registers, because it is
1423 impossible to look in the passed register for the passed value,
1424 so we use the within-the-function register to begin with.
1426 PARMS is a chain of PARM_DECL nodes. */
1429 sdbout_reg_parms (parms)
1432 for (; parms; parms = TREE_CHAIN (parms))
1433 if (DECL_NAME (parms))
1435 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1437 /* Report parms that live in registers during the function
1438 but were passed in memory. */
1439 if (GET_CODE (DECL_RTL (parms)) == REG
1440 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
1441 && PARM_PASSED_IN_MEMORY (parms))
1443 if (name == 0 || *name == 0)
1444 name = gen_fake_label ();
1446 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
1447 PUT_SDB_SCL (C_REG);
1448 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1451 /* Report parms that live in memory but not where they were passed. */
1452 else if (GET_CODE (DECL_RTL (parms)) == MEM
1453 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1454 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
1455 && PARM_PASSED_IN_MEMORY (parms)
1456 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
1458 #if 0 /* ??? It is not clear yet what should replace this. */
1459 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1460 /* A parm declared char is really passed as an int,
1461 so it occupies the least significant bytes.
1462 On a big-endian machine those are not the low-numbered ones. */
1463 if (BYTES_BIG_ENDIAN
1465 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1466 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1467 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1468 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
1471 if (name == 0 || *name == 0)
1472 name = gen_fake_label ();
1474 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1475 (XEXP (DECL_RTL (parms), 0)));
1476 PUT_SDB_SCL (C_AUTO);
1477 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1484 /* Output debug information for a global DECL. Called from toplev.c
1485 after compilation proper has finished. */
1488 sdbout_global_decl (decl)
1491 if (TREE_CODE (decl) == VAR_DECL
1492 && DECL_INITIAL (decl)
1493 && ! DECL_EXTERNAL (decl)
1494 && DECL_RTL (decl) != 0)
1496 /* The COFF linker can move initialized global vars to the end.
1497 And that can screw up the symbol ordering. By putting the
1498 symbols in that order to begin with, we avoid a problem.
1499 mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1500 if (TREE_PUBLIC (decl))
1501 sdbout_symbol (decl, 0);
1503 /* Output COFF information for non-global file-scope initialized
1505 if (GET_CODE (DECL_RTL (decl)) == MEM)
1506 sdbout_toplevel_data (decl);
1510 /* Describe the beginning of an internal block within a function.
1511 Also output descriptions of variables defined in this block.
1513 N is the number of the block, by order of beginning, counting from 1,
1514 and not counting the outermost (function top-level) block.
1515 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1516 if the count starts at 0 for the outermost one. */
1519 sdbout_begin_block (line, n)
1523 tree decl = current_function_decl;
1524 MAKE_LINE_SAFE (line);
1526 /* The SCO compiler does not emit a separate block for the function level
1527 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1528 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1529 #ifndef MIPS_DEBUGGING_INFO
1532 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1536 /* Include the outermost BLOCK's variables in block 1. */
1537 do_block = BLOCK_NUMBER (DECL_INITIAL (decl));
1538 sdbout_block (DECL_INITIAL (decl));
1540 /* If -g1, suppress all the internal symbols of functions
1541 except for arguments. */
1542 if (debug_info_level != DINFO_LEVEL_TERSE)
1545 sdbout_block (DECL_INITIAL (decl));
1548 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1549 sdbout_dequeue_anonymous_types ();
1553 /* Describe the end line-number of an internal block within a function. */
1556 sdbout_end_block (line, n)
1558 unsigned int n ATTRIBUTE_UNUSED;
1560 MAKE_LINE_SAFE (line);
1562 /* The SCO compiler does not emit a separate block for the function level
1563 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1564 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1565 #ifndef MIPS_DEBUGGING_INFO
1568 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1572 sdbout_source_line (line, filename)
1574 const char *filename ATTRIBUTE_UNUSED;
1576 /* COFF relative line numbers must be positive. */
1577 if (line > sdb_begin_function_line)
1579 #ifdef ASM_OUTPUT_SOURCE_LINE
1580 ASM_OUTPUT_SOURCE_LINE (asm_out_file, line);
1582 fprintf (asm_out_file, "\t.ln\t%d\n",
1583 ((sdb_begin_function_line > -1)
1584 ? line - sdb_begin_function_line : 1));
1589 /* Output sdb info for the current function name.
1590 Called from assemble_start_function. */
1593 sdbout_begin_function (decl)
1594 tree decl ATTRIBUTE_UNUSED;
1596 sdbout_symbol (current_function_decl, 0);
1599 /* Called at beginning of function body (before or after prologue,
1600 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1601 line number, so we can output relative line numbers for the other
1602 lines. Describe beginning of outermost block. Also describe the
1605 #ifndef MIPS_DEBUGGING_INFO
1607 sdbout_begin_prologue (line, file)
1609 const char *file ATTRIBUTE_UNUSED;
1611 sdbout_end_prologue (line);
1616 sdbout_end_prologue (line)
1619 sdb_begin_function_line = line - 1;
1620 PUT_SDB_FUNCTION_START (line);
1621 sdbout_parms (DECL_ARGUMENTS (current_function_decl));
1622 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl));
1625 /* Called at end of function (before epilogue).
1626 Describe end of outermost block. */
1629 sdbout_end_function (line)
1632 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1633 sdbout_dequeue_anonymous_types ();
1636 MAKE_LINE_SAFE (line);
1637 PUT_SDB_FUNCTION_END (line - sdb_begin_function_line);
1639 /* Indicate we are between functions, for line-number output. */
1640 sdb_begin_function_line = -1;
1643 /* Output sdb info for the absolute end of a function.
1644 Called after the epilogue is output. */
1647 sdbout_end_epilogue ()
1650 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
1652 #ifdef PUT_SDB_EPILOGUE_END
1653 PUT_SDB_EPILOGUE_END (name);
1655 fprintf (asm_out_file, "\t.def\t");
1656 assemble_name (asm_out_file, name);
1657 fprintf (asm_out_file, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1658 SDB_DELIM, SDB_DELIM, SDB_DELIM);
1662 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1669 PUT_SDB_DEF (LABEL_NAME (insn));
1671 PUT_SDB_SCL (C_LABEL);
1672 PUT_SDB_TYPE (T_NULL);
1676 /* Change to reading from a new source file. */
1679 sdbout_start_source_file (line, filename)
1680 unsigned int line ATTRIBUTE_UNUSED;
1681 const char *filename ATTRIBUTE_UNUSED;
1683 #ifdef MIPS_DEBUGGING_INFO
1684 struct sdb_file *n = (struct sdb_file *) xmalloc (sizeof *n);
1686 n->next = current_file;
1689 PUT_SDB_SRC_FILE (filename);
1693 /* Revert to reading a previous source file. */
1696 sdbout_end_source_file (line)
1697 unsigned int line ATTRIBUTE_UNUSED;
1699 #ifdef MIPS_DEBUGGING_INFO
1700 struct sdb_file *next;
1702 next = current_file->next;
1703 free (current_file);
1704 current_file = next;
1705 PUT_SDB_SRC_FILE (current_file->name);
1709 /* Set up for SDB output at the start of compilation. */
1712 sdbout_init (input_file_name)
1713 const char *input_file_name ATTRIBUTE_UNUSED;
1715 #ifdef MIPS_DEBUGGING_INFO
1716 current_file = (struct sdb_file *) xmalloc (sizeof *current_file);
1717 current_file->next = NULL;
1718 current_file->name = input_file_name;
1721 #ifdef RMS_QUICK_HACK_1
1723 for (t = getdecls (); t; t = TREE_CHAIN (t))
1724 if (DECL_NAME (t) && IDENTIFIER_POINTER (DECL_NAME (t)) != 0
1725 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t)), "__vtbl_ptr_type"))
1726 sdbout_symbol (t, 0);
1729 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1730 ggc_add_tree_root (&anonymous_types, 1);
1734 #endif /* SDB_DEBUGGING_INFO */