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 #ifndef MIPS_DEBUGGING_INFO
103 static void sdbout_begin_prologue PARAMS ((unsigned int, const char *));
105 static void sdbout_end_prologue PARAMS ((unsigned int));
106 static void sdbout_begin_function PARAMS ((tree));
107 static void sdbout_end_function PARAMS ((unsigned int));
108 static char *gen_fake_label PARAMS ((void));
109 static int plain_type PARAMS ((tree));
110 static int template_name_p PARAMS ((tree));
111 static void sdbout_record_type_name PARAMS ((tree));
112 static int plain_type_1 PARAMS ((tree, int));
113 static void sdbout_block PARAMS ((tree));
114 static void sdbout_syms PARAMS ((tree));
115 #ifdef SDB_ALLOW_FORWARD_REFERENCES
116 static void sdbout_queue_anonymous_type PARAMS ((tree));
117 static void sdbout_dequeue_anonymous_types PARAMS ((void));
119 static void sdbout_type PARAMS ((tree));
120 static void sdbout_field_types PARAMS ((tree));
121 static void sdbout_one_type PARAMS ((tree));
122 static void sdbout_parms PARAMS ((tree));
123 static void sdbout_reg_parms PARAMS ((tree));
125 /* Random macros describing parts of SDB data. */
127 /* Put something here if lines get too long */
130 /* Default value of delimiter is ";". */
132 #define SDB_DELIM ";"
135 /* Maximum number of dimensions the assembler will allow. */
137 #define SDB_MAX_DIM 4
141 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
144 #ifndef PUT_SDB_INT_VAL
145 #define PUT_SDB_INT_VAL(a) \
147 fputs ("\t.val\t", asm_out_file); \
148 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
149 fprintf (asm_out_file, "%s", SDB_DELIM); \
155 #define PUT_SDB_VAL(a) \
156 ( fputs ("\t.val\t", asm_out_file), \
157 output_addr_const (asm_out_file, (a)), \
158 fprintf (asm_out_file, SDB_DELIM))
162 #define PUT_SDB_DEF(a) \
163 do { fprintf (asm_out_file, "\t.def\t"); \
164 assemble_name (asm_out_file, a); \
165 fprintf (asm_out_file, SDB_DELIM); } while (0)
168 #ifndef PUT_SDB_PLAIN_DEF
169 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
172 #ifndef PUT_SDB_ENDEF
173 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
177 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
181 #define PUT_SDB_SIZE(a) \
183 fputs ("\t.size\t", asm_out_file); \
184 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
185 fprintf (asm_out_file, "%s", SDB_DELIM); \
189 #ifndef PUT_SDB_START_DIM
190 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
193 #ifndef PUT_SDB_NEXT_DIM
194 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
197 #ifndef PUT_SDB_LAST_DIM
198 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
202 #define PUT_SDB_TAG(a) \
203 do { fprintf (asm_out_file, "\t.tag\t"); \
204 assemble_name (asm_out_file, a); \
205 fprintf (asm_out_file, SDB_DELIM); } while (0)
208 #ifndef PUT_SDB_BLOCK_START
209 #define PUT_SDB_BLOCK_START(LINE) \
210 fprintf (asm_out_file, \
211 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
212 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
215 #ifndef PUT_SDB_BLOCK_END
216 #define PUT_SDB_BLOCK_END(LINE) \
217 fprintf (asm_out_file, \
218 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
219 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
222 #ifndef PUT_SDB_FUNCTION_START
223 #define PUT_SDB_FUNCTION_START(LINE) \
224 fprintf (asm_out_file, \
225 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
226 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
229 #ifndef PUT_SDB_FUNCTION_END
230 #define PUT_SDB_FUNCTION_END(LINE) \
231 fprintf (asm_out_file, \
232 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
233 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
236 #ifndef SDB_GENERATE_FAKE
237 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
238 sprintf ((BUFFER), ".%dfake", (NUMBER));
241 /* Return the sdb tag identifier string for TYPE
242 if TYPE has already been defined; otherwise return a null pointer. */
244 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
246 /* Set the sdb tag identifier string for TYPE to NAME. */
248 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
249 TYPE_SYMTAB_POINTER (TYPE) = (NAME)
251 /* Return the name (a string) of the struct, union or enum tag
252 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
254 #define TAG_NAME(link) \
255 (((link) && TREE_PURPOSE ((link)) \
256 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
257 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
259 /* Ensure we don't output a negative line number. */
260 #define MAKE_LINE_SAFE(line) \
261 if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1
263 /* Perform linker optimization of merging header file definitions together
264 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
265 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
266 the optimization just won't be done. The native assembler already has the
267 necessary support. */
269 #ifdef MIPS_DEBUGGING_INFO
271 #ifndef PUT_SDB_SRC_FILE
272 #define PUT_SDB_SRC_FILE(FILENAME) \
273 output_file_directive (asm_out_file, (FILENAME))
276 /* ECOFF linkers have an optimization that does the same kind of thing as
277 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
278 executable. To achieve this, GCC must output a .file for each file
281 /* This is a stack of input files. */
285 struct sdb_file *next;
289 /* This is the top of the stack. */
291 static struct sdb_file *current_file;
293 #endif /* MIPS_DEBUGGING_INFO */
295 /* The debug hooks structure. */
296 struct gcc_debug_hooks sdb_debug_hooks =
299 debug_nothing_charstar,
300 debug_nothing_int_charstar,
301 debug_nothing_int_charstar,
302 sdbout_start_source_file,
303 sdbout_end_source_file,
307 #ifdef MIPS_DEBUGGING_INFO
308 /* Defer on MIPS systems so that parameter descriptions follow
310 debug_nothing_int_charstar, /* begin_prologue */
311 sdbout_end_prologue, /* end_prologue */
313 sdbout_begin_prologue, /* begin_prologue */
314 debug_nothing_int, /* end_prologue */
317 sdbout_begin_function,
323 /* return the tag identifier for type
327 tag_of_ru_type (type,link)
330 if (TYPE_SYMTAB_ADDRESS (type))
331 return TYPE_SYMTAB_ADDRESS (type);
332 if (link && TREE_PURPOSE (link)
333 && IDENTIFIER_POINTER (TREE_PURPOSE (link)))
334 TYPE_SYMTAB_ADDRESS (type) = IDENTIFIER_POINTER (TREE_PURPOSE (link));
336 return (char *) TYPE_SYMTAB_ADDRESS (type);
340 /* Return a unique string to name an anonymous type. */
347 SDB_GENERATE_FAKE (label, unnamed_struct_number);
348 unnamed_struct_number++;
349 labelstr = (char *) permalloc (strlen (label) + 1);
350 strcpy (labelstr, label);
354 /* Return the number which describes TYPE for SDB.
355 For pointers, etc., this function is recursive.
356 Each record, union or enumeral type must already have had a
357 tag number output. */
359 /* The number is given by d6d5d4d3d2d1bbbb
360 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
361 Thus, char *foo () has bbbb=T_CHAR
364 N_BTMASK= 017 1111 basic type field.
365 N_TSHIFT= 2 derived type shift
366 N_BTSHFT= 4 Basic type shift */
368 /* Produce the number that describes a pointer, function or array type.
369 PREV is the number describing the target, value or element type.
370 DT_type describes how to transform that type. */
371 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
372 ((((PREV) & ~(int)N_BTMASK) << (int)N_TSHIFT) \
373 | ((int)DT_type << (int)N_BTSHFT) \
374 | ((PREV) & (int)N_BTMASK))
376 /* Number of elements used in sdb_dims. */
377 static int sdb_n_dims = 0;
379 /* Table of array dimensions of current type. */
380 static int sdb_dims[SDB_MAX_DIM];
382 /* Size of outermost array currently being processed. */
383 static int sdb_type_size = -1;
389 int val = plain_type_1 (type, 0);
391 /* If we have already saved up some array dimensions, print them now. */
396 for (i = sdb_n_dims - 1; i > 0; i--)
397 PUT_SDB_NEXT_DIM (sdb_dims[i]);
398 PUT_SDB_LAST_DIM (sdb_dims[0]);
401 sdb_type_size = int_size_in_bytes (type);
402 /* Don't kill sdb if type is not laid out or has variable size. */
403 if (sdb_type_size < 0)
406 /* If we have computed the size of an array containing this type,
408 if (sdb_type_size >= 0)
410 PUT_SDB_SIZE (sdb_type_size);
417 template_name_p (name)
420 register const char *ptr = IDENTIFIER_POINTER (name);
421 while (*ptr && *ptr != '<')
428 sdbout_record_type_name (type)
431 const char *name = 0;
434 if (KNOWN_TYPE_TAG (type))
437 if (TYPE_NAME (type) != 0)
440 /* Find the IDENTIFIER_NODE for the type name. */
441 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
442 t = TYPE_NAME (type);
443 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
445 t = DECL_NAME (TYPE_NAME (type));
446 /* The DECL_NAME for templates includes "<>", which breaks
447 most assemblers. Use its assembler name instead, which
448 has been mangled into being safe. */
449 if (t && template_name_p (t))
450 t = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
453 /* Now get the name as a string, or invent one. */
455 name = IDENTIFIER_POINTER (t);
458 no_name = (name == 0 || *name == 0);
460 name = gen_fake_label ();
462 SET_KNOWN_TYPE_TAG (type, name);
463 #ifdef SDB_ALLOW_FORWARD_REFERENCES
465 sdbout_queue_anonymous_type (type);
469 /* Return the .type value for type TYPE.
471 LEVEL indicates how many levels deep we have recursed into the type.
472 The SDB debug format can only represent 6 derived levels of types.
473 After that, we must output inaccurate debug info. We deliberately
474 stop before the 7th level, so that ADA recursive types will not give an
478 plain_type_1 (type, level)
483 type = void_type_node;
484 else if (type == error_mark_node)
485 type = integer_type_node;
487 type = TYPE_MAIN_VARIANT (type);
489 switch (TREE_CODE (type))
496 int size = int_size_in_bytes (type) * BITS_PER_UNIT;
498 /* Carefully distinguish all the standard types of C,
499 without messing up if the language is not C.
500 Note that we check only for the names that contain spaces;
501 other names might occur by coincidence in other languages. */
502 if (TYPE_NAME (type) != 0
503 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
504 && DECL_NAME (TYPE_NAME (type)) != 0
505 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
508 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
510 if (!strcmp (name, "char"))
512 if (!strcmp (name, "unsigned char"))
514 if (!strcmp (name, "signed char"))
516 if (!strcmp (name, "int"))
518 if (!strcmp (name, "unsigned int"))
520 if (!strcmp (name, "short int"))
522 if (!strcmp (name, "short unsigned int"))
524 if (!strcmp (name, "long int"))
526 if (!strcmp (name, "long unsigned int"))
530 if (size == INT_TYPE_SIZE)
531 return (TREE_UNSIGNED (type) ? T_UINT : T_INT);
532 if (size == CHAR_TYPE_SIZE)
533 return (TREE_UNSIGNED (type) ? T_UCHAR : T_CHAR);
534 if (size == SHORT_TYPE_SIZE)
535 return (TREE_UNSIGNED (type) ? T_USHORT : T_SHORT);
536 if (size == LONG_TYPE_SIZE)
537 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
538 if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */
539 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
545 int precision = TYPE_PRECISION (type);
546 if (precision == FLOAT_TYPE_SIZE)
548 if (precision == DOUBLE_TYPE_SIZE)
550 #ifdef EXTENDED_SDB_BASIC_TYPES
551 if (precision == LONG_DOUBLE_TYPE_SIZE)
554 if (precision == LONG_DOUBLE_TYPE_SIZE)
555 return T_DOUBLE; /* better than nothing */
566 m = plain_type_1 (TREE_TYPE (type), level+1);
567 if (sdb_n_dims < SDB_MAX_DIM)
568 sdb_dims[sdb_n_dims++]
569 = (TYPE_DOMAIN (type)
570 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
571 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
572 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
573 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0)
574 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
575 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1)
578 return PUSH_DERIVED_LEVEL (DT_ARY, m);
583 case QUAL_UNION_TYPE:
587 #ifdef SDB_ALLOW_FORWARD_REFERENCES
588 sdbout_record_type_name (type);
590 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
591 if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0)
592 #ifdef SDB_ALLOW_FORWARD_REFERENCES
593 || TYPE_MODE (type) != VOIDmode
598 /* Output the referenced structure tag name
599 only if the .def has already been finished.
600 At least on 386, the Unix assembler
601 cannot handle forward references to tags. */
602 /* But the 88100, it requires them, sigh... */
603 /* And the MIPS requires unknown refs as well... */
604 tag = KNOWN_TYPE_TAG (type);
606 /* These 3 lines used to follow the close brace.
607 However, a size of 0 without a tag implies a tag of 0,
608 so if we don't know a tag, we can't mention the size. */
609 sdb_type_size = int_size_in_bytes (type);
610 if (sdb_type_size < 0)
613 return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT
614 : (TREE_CODE (type) == UNION_TYPE) ? T_UNION
615 : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION
625 m = plain_type_1 (TREE_TYPE (type), level+1);
626 return PUSH_DERIVED_LEVEL (DT_PTR, m);
635 m = plain_type_1 (TREE_TYPE (type), level+1);
636 return PUSH_DERIVED_LEVEL (DT_FCN, m);
643 /* Output the symbols defined in block number DO_BLOCK.
645 This function works by walking the tree structure of blocks,
646 counting blocks until it finds the desired block. */
648 static int do_block = 0;
656 /* Ignore blocks never expanded or otherwise marked as real. */
657 if (TREE_USED (block))
659 /* When we reach the specified block, output its symbols. */
660 if (BLOCK_NUMBER (block) == do_block)
661 sdbout_syms (BLOCK_VARS (block));
663 /* If we are past the specified block, stop the scan. */
664 if (BLOCK_NUMBER (block) > do_block)
667 /* Scan the blocks within this block. */
668 sdbout_block (BLOCK_SUBBLOCKS (block));
671 block = BLOCK_CHAIN (block);
675 /* Call sdbout_symbol on each decl in the chain SYMS. */
683 if (TREE_CODE (syms) != LABEL_DECL)
684 sdbout_symbol (syms, 1);
685 syms = TREE_CHAIN (syms);
689 /* Output SDB information for a symbol described by DECL.
690 LOCAL is nonzero if the symbol is not file-scope. */
693 sdbout_symbol (decl, local)
697 tree type = TREE_TYPE (decl);
698 tree context = NULL_TREE;
703 sdbout_one_type (type);
705 #if 0 /* This loses when functions are marked to be ignored,
706 which happens in the C++ front end. */
707 if (DECL_IGNORED_P (decl))
711 switch (TREE_CODE (decl))
714 /* Enum values are defined by defining the enum type. */
718 /* Don't mention a nested function under its parent. */
719 context = decl_function_context (decl);
720 if (context == current_function_decl)
722 /* Check DECL_INITIAL to distinguish declarations from definitions.
723 Don't output debug info here for declarations; they will have
724 a DECL_INITIAL value of 0. */
725 if (! DECL_INITIAL (decl))
727 if (GET_CODE (DECL_RTL (decl)) != MEM
728 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
730 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
731 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
732 PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT);
736 /* Done with tagged types. */
737 if (DECL_NAME (decl) == 0)
739 if (DECL_IGNORED_P (decl))
742 /* Output typedef name. */
743 if (template_name_p (DECL_NAME (decl)))
744 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
746 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl)));
747 PUT_SDB_SCL (C_TPDEF);
751 /* Parm decls go in their own separate chains
752 and are output by sdbout_reg_parms and sdbout_parms. */
756 /* Don't mention a variable that is external.
757 Let the file that defines it describe it. */
758 if (DECL_EXTERNAL (decl))
761 /* Ignore __FUNCTION__, etc. */
762 if (DECL_IGNORED_P (decl))
765 /* If there was an error in the declaration, don't dump core
766 if there is no RTL associated with the variable doesn't
768 if (!DECL_RTL_SET_P (decl))
772 eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
773 #ifdef LEAF_REG_REMAP
774 if (current_function_uses_only_leaf_regs)
775 leaf_renumber_regs_insn (DECL_RTL (decl));
777 value = DECL_RTL (decl);
779 /* Don't mention a variable at all
780 if it was completely optimized into nothingness.
782 If DECL was from an inline function, then its rtl
783 is not identically the rtl that was used in this
784 particular compilation. */
785 if (GET_CODE (value) == REG)
787 regno = REGNO (DECL_RTL (decl));
788 if (regno >= FIRST_PSEUDO_REGISTER)
791 else if (GET_CODE (value) == SUBREG)
793 while (GET_CODE (value) == SUBREG)
794 value = SUBREG_REG (value);
795 if (GET_CODE (value) == REG)
797 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
800 regno = REGNO (alter_subreg (DECL_RTL (decl)));
801 value = DECL_RTL (decl);
803 /* Don't output anything if an auto variable
804 gets RTL that is static.
805 GAS version 2.2 can't handle such output. */
806 else if (GET_CODE (value) == MEM && CONSTANT_P (XEXP (value, 0))
807 && ! TREE_STATIC (decl))
810 /* Emit any structure, union, or enum type that has not been output.
811 This occurs for tag-less structs (et al) used to declare variables
813 if (TREE_CODE (type) == ENUMERAL_TYPE
814 || TREE_CODE (type) == RECORD_TYPE
815 || TREE_CODE (type) == UNION_TYPE
816 || TREE_CODE (type) == QUAL_UNION_TYPE)
818 if (COMPLETE_TYPE_P (type) /* not a forward reference */
819 && KNOWN_TYPE_TAG (type) == 0) /* not yet declared */
820 sdbout_one_type (type);
823 /* Defer SDB information for top-level initialized variables! */
825 && GET_CODE (value) == MEM
826 && DECL_INITIAL (decl))
829 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
830 For now, avoid crashing. */
831 if (DECL_NAME (decl) == NULL_TREE)
834 /* Record the name for, starting a symtab entry. */
836 name = IDENTIFIER_POINTER (DECL_NAME (decl));
838 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
840 if (GET_CODE (value) == MEM
841 && GET_CODE (XEXP (value, 0)) == SYMBOL_REF)
844 if (TREE_PUBLIC (decl))
846 PUT_SDB_VAL (XEXP (value, 0));
851 PUT_SDB_VAL (XEXP (value, 0));
852 PUT_SDB_SCL (C_STAT);
858 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno));
861 else if (GET_CODE (value) == MEM
862 && (GET_CODE (XEXP (value, 0)) == MEM
863 || (GET_CODE (XEXP (value, 0)) == REG
864 && REGNO (XEXP (value, 0)) != HARD_FRAME_POINTER_REGNUM
865 && REGNO (XEXP (value, 0)) != STACK_POINTER_REGNUM)))
866 /* If the value is indirect by memory or by a register
867 that isn't the frame pointer
868 then it means the object is variable-sized and address through
869 that register or stack slot. COFF has no way to represent this
870 so all we can do is output the variable as a pointer. */
873 if (GET_CODE (XEXP (value, 0)) == REG)
875 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value, 0))));
880 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
882 We want the value of that CONST_INT. */
883 /* Encore compiler hates a newline in a macro arg, it seems. */
884 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
885 (XEXP (XEXP (value, 0), 0)));
886 PUT_SDB_SCL (C_AUTO);
889 /* Effectively do build_pointer_type, but don't cache this type,
890 since it might be temporary whereas the type it points to
891 might have been saved for inlining. */
892 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
893 type = make_node (POINTER_TYPE);
894 TREE_TYPE (type) = TREE_TYPE (decl);
896 else if (GET_CODE (value) == MEM
897 && ((GET_CODE (XEXP (value, 0)) == PLUS
898 && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
899 && GET_CODE (XEXP (XEXP (value, 0), 1)) == CONST_INT)
900 /* This is for variables which are at offset zero from
901 the frame pointer. This happens on the Alpha.
902 Non-frame pointer registers are excluded above. */
903 || (GET_CODE (XEXP (value, 0)) == REG)))
905 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
906 or (MEM (REG...)). We want the value of that CONST_INT
909 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value, 0)));
910 PUT_SDB_SCL (C_AUTO);
912 else if (GET_CODE (value) == MEM && GET_CODE (XEXP (value, 0)) == CONST)
914 /* Handle an obscure case which can arise when optimizing and
915 when there are few available registers. (This is *always*
916 the case for i386/i486 targets). The DECL_RTL looks like
917 (MEM (CONST ...)) even though this variable is a local `auto'
918 or a local `register' variable. In effect, what has happened
919 is that the reload pass has seen that all assignments and
920 references for one such a local variable can be replaced by
921 equivalent assignments and references to some static storage
922 variable, thereby avoiding the need for a register. In such
923 cases we're forced to lie to debuggers and tell them that
924 this variable was itself `static'. */
926 PUT_SDB_VAL (XEXP (XEXP (value, 0), 0));
927 PUT_SDB_SCL (C_STAT);
931 /* It is something we don't know how to represent for SDB. */
939 PUT_SDB_TYPE (plain_type (type));
943 /* Output SDB information for a top-level initialized variable
944 that has been delayed. */
947 sdbout_toplevel_data (decl)
950 tree type = TREE_TYPE (decl);
952 if (DECL_IGNORED_P (decl))
955 if (! (TREE_CODE (decl) == VAR_DECL
956 && GET_CODE (DECL_RTL (decl)) == MEM
957 && DECL_INITIAL (decl)))
960 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
961 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
962 if (TREE_PUBLIC (decl))
968 PUT_SDB_SCL (C_STAT);
970 PUT_SDB_TYPE (plain_type (type));
974 #ifdef SDB_ALLOW_FORWARD_REFERENCES
976 /* Machinery to record and output anonymous types. */
978 static tree anonymous_types;
981 sdbout_queue_anonymous_type (type)
984 anonymous_types = tree_cons (NULL_TREE, type, anonymous_types);
988 sdbout_dequeue_anonymous_types ()
990 register tree types, link;
992 while (anonymous_types)
994 types = nreverse (anonymous_types);
995 anonymous_types = NULL_TREE;
997 for (link = types; link; link = TREE_CHAIN (link))
999 register tree type = TREE_VALUE (link);
1001 if (type && ! TREE_ASM_WRITTEN (type))
1002 sdbout_one_type (type);
1009 /* Given a chain of ..._TYPE nodes, all of which have names,
1010 output definitions of those names, as typedefs. */
1013 sdbout_types (types)
1014 register tree types;
1018 for (link = types; link; link = TREE_CHAIN (link))
1019 sdbout_one_type (link);
1021 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1022 sdbout_dequeue_anonymous_types ();
1030 if (type == error_mark_node)
1031 type = integer_type_node;
1032 PUT_SDB_TYPE (plain_type (type));
1035 /* Output types of the fields of type TYPE, if they are structs.
1037 Formerly did not chase through pointer types, since that could be circular.
1038 They must come before TYPE, since forward refs are not allowed.
1039 Now james@bigtex.cactus.org says to try them. */
1042 sdbout_field_types (type)
1047 for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
1048 /* This condition should match the one for emitting the actual
1050 if (TREE_CODE (tail) == FIELD_DECL
1053 && host_integerp (DECL_SIZE (tail), 1)
1054 && host_integerp (bit_position (tail), 0))
1056 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1057 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1059 sdbout_one_type (TREE_TYPE (tail));
1063 /* Use this to put out the top level defined record and union types
1064 for later reference. If this is a struct with a name, then put that
1065 name out. Other unnamed structs will have .xxfake labels generated so
1066 that they may be referred to later.
1067 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1068 It may NOT be called recursively. */
1071 sdbout_one_type (type)
1074 if (current_function_decl != NULL_TREE
1075 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
1076 ; /* Don't change section amid function. */
1080 switch (TREE_CODE (type))
1084 case QUAL_UNION_TYPE:
1086 type = TYPE_MAIN_VARIANT (type);
1087 /* Don't output a type twice. */
1088 if (TREE_ASM_WRITTEN (type))
1089 /* James said test TREE_ASM_BEING_WRITTEN here. */
1092 /* Output nothing if type is not yet defined. */
1093 if (!COMPLETE_TYPE_P (type))
1096 TREE_ASM_WRITTEN (type) = 1;
1098 /* This is reputed to cause trouble with the following case,
1099 but perhaps checking TYPE_SIZE above will fix it. */
1101 /* Here is a test case:
1107 typedef struct intermediate {
1111 typedef struct badstr {
1116 TREE_ASM_BEING_WRITTEN (type) = 1;
1118 /* This change, which ought to make better output,
1119 used to make the COFF assembler unhappy.
1120 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1121 /* Before really doing anything, output types we want to refer to. */
1122 /* Note that in version 1 the following two lines
1123 are not used if forward references are in use. */
1124 if (TREE_CODE (type) != ENUMERAL_TYPE)
1125 sdbout_field_types (type);
1127 TREE_ASM_WRITTEN (type) = 1;
1131 /* Output a structure type. */
1133 int size = int_size_in_bytes (type);
1136 int i, n_baseclasses = 0;
1138 /* Record the type tag, but not in its permanent place just yet. */
1139 sdbout_record_type_name (type);
1141 PUT_SDB_DEF (KNOWN_TYPE_TAG (type));
1143 switch (TREE_CODE (type))
1146 case QUAL_UNION_TYPE:
1147 PUT_SDB_SCL (C_UNTAG);
1148 PUT_SDB_TYPE (T_UNION);
1153 PUT_SDB_SCL (C_STRTAG);
1154 PUT_SDB_TYPE (T_STRUCT);
1159 PUT_SDB_SCL (C_ENTAG);
1160 PUT_SDB_TYPE (T_ENUM);
1168 PUT_SDB_SIZE (size);
1171 /* Print out the base class information with fields
1172 named after the types they hold. */
1173 /* This is only relevent to aggregate types. TYPE_BINFO is used
1174 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1176 if (TREE_CODE (type) != ENUMERAL_TYPE)
1178 if (TYPE_BINFO (type)
1179 && TYPE_BINFO_BASETYPES (type))
1180 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1181 for (i = 0; i < n_baseclasses; i++)
1183 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)),
1185 tree child_type = BINFO_TYPE (child);
1186 tree child_type_name;
1187 if (TYPE_NAME (child_type) == 0)
1189 if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
1190 child_type_name = TYPE_NAME (child_type);
1191 else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL)
1193 child_type_name = DECL_NAME (TYPE_NAME (child_type));
1194 if (child_type_name && template_name_p (child_type_name))
1196 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type));
1202 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1203 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0));
1204 PUT_SDB_SCL (member_scl);
1205 sdbout_type (BINFO_TYPE (child));
1210 /* output the individual fields */
1212 if (TREE_CODE (type) == ENUMERAL_TYPE)
1214 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1215 if (host_integerp (TREE_VALUE (tem), 0))
1217 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1218 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem), 0));
1219 PUT_SDB_SCL (C_MOE);
1220 PUT_SDB_TYPE (T_MOE);
1224 else /* record or union type */
1225 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1226 /* Output the name, type, position (in bits), size (in bits)
1229 /* Omit here the nameless fields that are used to skip bits.
1230 Also omit fields with variable size or position.
1231 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1232 if (TREE_CODE (tem) == FIELD_DECL
1235 && host_integerp (DECL_SIZE (tem), 1)
1236 && host_integerp (bit_position (tem), 0))
1241 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1243 if (DECL_BIT_FIELD_TYPE (tem))
1245 PUT_SDB_INT_VAL (int_bit_position (tem));
1246 PUT_SDB_SCL (C_FIELD);
1247 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1248 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1));
1252 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1253 PUT_SDB_SCL (member_scl);
1254 sdbout_type (TREE_TYPE (tem));
1258 /* output end of a structure,union, or enumeral definition */
1260 PUT_SDB_PLAIN_DEF ("eos");
1261 PUT_SDB_INT_VAL (size);
1262 PUT_SDB_SCL (C_EOS);
1263 PUT_SDB_TAG (KNOWN_TYPE_TAG (type));
1264 PUT_SDB_SIZE (size);
1274 /* The following two functions output definitions of function parameters.
1275 Each parameter gets a definition locating it in the parameter list.
1276 Each parameter that is a register variable gets a second definition
1277 locating it in the register.
1279 Printing or argument lists in gdb uses the definitions that
1280 locate in the parameter list. But reference to the variable in
1281 expressions uses preferentially the definition as a register. */
1283 /* Output definitions, referring to storage in the parmlist,
1284 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1287 sdbout_parms (parms)
1290 for (; parms; parms = TREE_CHAIN (parms))
1291 if (DECL_NAME (parms))
1293 int current_sym_value = 0;
1294 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1296 if (name == 0 || *name == 0)
1297 name = gen_fake_label ();
1299 /* Perform any necessary register eliminations on the parameter's rtl,
1300 so that the debugging output will be accurate. */
1301 DECL_INCOMING_RTL (parms)
1302 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
1303 SET_DECL_RTL (parms,
1304 eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
1306 if (PARM_PASSED_IN_MEMORY (parms))
1308 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
1311 /* ??? Here we assume that the parm address is indexed
1312 off the frame pointer or arg pointer.
1313 If that is not true, we produce meaningless results,
1314 but do not crash. */
1315 if (GET_CODE (addr) == PLUS
1316 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
1317 current_sym_value = INTVAL (XEXP (addr, 1));
1319 current_sym_value = 0;
1321 if (GET_CODE (DECL_RTL (parms)) == REG
1322 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1323 type = DECL_ARG_TYPE (parms);
1326 int original_sym_value = current_sym_value;
1328 /* This is the case where the parm is passed as an int or
1329 double and it is converted to a char, short or float
1330 and stored back in the parmlist. In this case, describe
1331 the parm with the variable's declared type, and adjust
1332 the address if the least significant bytes (which we are
1333 using) are not the first ones. */
1334 if (BYTES_BIG_ENDIAN
1335 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1336 current_sym_value +=
1337 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1338 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1340 if (GET_CODE (DECL_RTL (parms)) == MEM
1341 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1342 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1344 && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1345 == current_sym_value))
1346 type = TREE_TYPE (parms);
1349 current_sym_value = original_sym_value;
1350 type = DECL_ARG_TYPE (parms);
1355 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr));
1356 PUT_SDB_SCL (C_ARG);
1357 PUT_SDB_TYPE (plain_type (type));
1360 else if (GET_CODE (DECL_RTL (parms)) == REG)
1363 /* Parm passed in registers and lives in registers or nowhere. */
1365 /* If parm lives in a register, use that register;
1366 pretend the parm was passed there. It would be more consistent
1367 to describe the register where the parm was passed,
1368 but in practice that register usually holds something else. */
1369 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1370 best_rtl = DECL_RTL (parms);
1371 /* If the parm lives nowhere,
1372 use the register where it was passed. */
1374 best_rtl = DECL_INCOMING_RTL (parms);
1377 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl)));
1378 PUT_SDB_SCL (C_REGPARM);
1379 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1382 else if (GET_CODE (DECL_RTL (parms)) == MEM
1383 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1385 /* Parm was passed in registers but lives on the stack. */
1387 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1388 in which case we want the value of that CONST_INT,
1389 or (MEM (REG ...)) or (MEM (MEM ...)),
1390 in which case we use a value of zero. */
1391 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
1392 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
1393 current_sym_value = 0;
1395 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1397 /* Again, this assumes the offset is based on the arg pointer. */
1399 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value,
1400 XEXP (DECL_RTL (parms), 0)));
1401 PUT_SDB_SCL (C_ARG);
1402 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1408 /* Output definitions for the places where parms live during the function,
1409 when different from where they were passed, when the parms were passed
1412 It is not useful to do this for parms passed in registers
1413 that live during the function in different registers, because it is
1414 impossible to look in the passed register for the passed value,
1415 so we use the within-the-function register to begin with.
1417 PARMS is a chain of PARM_DECL nodes. */
1420 sdbout_reg_parms (parms)
1423 for (; parms; parms = TREE_CHAIN (parms))
1424 if (DECL_NAME (parms))
1426 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1428 /* Report parms that live in registers during the function
1429 but were passed in memory. */
1430 if (GET_CODE (DECL_RTL (parms)) == REG
1431 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
1432 && PARM_PASSED_IN_MEMORY (parms))
1434 if (name == 0 || *name == 0)
1435 name = gen_fake_label ();
1437 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
1438 PUT_SDB_SCL (C_REG);
1439 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1442 /* Report parms that live in memory but not where they were passed. */
1443 else if (GET_CODE (DECL_RTL (parms)) == MEM
1444 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1445 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
1446 && PARM_PASSED_IN_MEMORY (parms)
1447 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
1449 #if 0 /* ??? It is not clear yet what should replace this. */
1450 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1451 /* A parm declared char is really passed as an int,
1452 so it occupies the least significant bytes.
1453 On a big-endian machine those are not the low-numbered ones. */
1454 if (BYTES_BIG_ENDIAN
1456 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1457 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1458 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1459 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
1462 if (name == 0 || *name == 0)
1463 name = gen_fake_label ();
1465 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1466 (XEXP (DECL_RTL (parms), 0)));
1467 PUT_SDB_SCL (C_AUTO);
1468 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1475 /* Describe the beginning of an internal block within a function.
1476 Also output descriptions of variables defined in this block.
1478 N is the number of the block, by order of beginning, counting from 1,
1479 and not counting the outermost (function top-level) block.
1480 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1481 if the count starts at 0 for the outermost one. */
1484 sdbout_begin_block (line, n)
1488 tree decl = current_function_decl;
1489 MAKE_LINE_SAFE (line);
1491 /* The SCO compiler does not emit a separate block for the function level
1492 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1493 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1494 #ifndef MIPS_DEBUGGING_INFO
1497 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1501 /* Include the outermost BLOCK's variables in block 1. */
1502 do_block = BLOCK_NUMBER (DECL_INITIAL (decl));
1503 sdbout_block (DECL_INITIAL (decl));
1505 /* If -g1, suppress all the internal symbols of functions
1506 except for arguments. */
1507 if (debug_info_level != DINFO_LEVEL_TERSE)
1510 sdbout_block (DECL_INITIAL (decl));
1513 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1514 sdbout_dequeue_anonymous_types ();
1518 /* Describe the end line-number of an internal block within a function. */
1521 sdbout_end_block (line, n)
1523 unsigned int n ATTRIBUTE_UNUSED;
1525 MAKE_LINE_SAFE (line);
1527 /* The SCO compiler does not emit a separate block for the function level
1528 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1529 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1530 #ifndef MIPS_DEBUGGING_INFO
1533 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1537 sdbout_source_line (line, filename)
1539 const char *filename ATTRIBUTE_UNUSED;
1541 /* COFF relative line numbers must be positive. */
1542 if (line > sdb_begin_function_line)
1544 #ifdef ASM_OUTPUT_SOURCE_LINE
1545 ASM_OUTPUT_SOURCE_LINE (asm_out_file, line);
1547 fprintf (asm_out_file, "\t.ln\t%d\n",
1548 ((sdb_begin_function_line > -1)
1549 ? line - sdb_begin_function_line : 1));
1554 /* Output sdb info for the current function name.
1555 Called from assemble_start_function. */
1558 sdbout_begin_function (decl)
1559 tree decl ATTRIBUTE_UNUSED;
1561 sdbout_symbol (current_function_decl, 0);
1564 /* Called at beginning of function body (before or after prologue,
1565 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1566 line number, so we can output relative line numbers for the other
1567 lines. Describe beginning of outermost block. Also describe the
1570 #ifndef MIPS_DEBUGGING_INFO
1572 sdbout_begin_prologue (line, file)
1574 const char *file ATTRIBUTE_UNUSED;
1576 sdbout_end_prologue (line);
1581 sdbout_end_prologue (line)
1584 sdb_begin_function_line = line - 1;
1585 PUT_SDB_FUNCTION_START (line);
1586 sdbout_parms (DECL_ARGUMENTS (current_function_decl));
1587 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl));
1590 /* Called at end of function (before epilogue).
1591 Describe end of outermost block. */
1594 sdbout_end_function (line)
1597 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1598 sdbout_dequeue_anonymous_types ();
1601 MAKE_LINE_SAFE (line);
1602 PUT_SDB_FUNCTION_END (line - sdb_begin_function_line);
1604 /* Indicate we are between functions, for line-number output. */
1605 sdb_begin_function_line = -1;
1608 /* Output sdb info for the absolute end of a function.
1609 Called after the epilogue is output. */
1612 sdbout_end_epilogue ()
1615 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
1617 #ifdef PUT_SDB_EPILOGUE_END
1618 PUT_SDB_EPILOGUE_END (name);
1620 fprintf (asm_out_file, "\t.def\t");
1621 assemble_name (asm_out_file, name);
1622 fprintf (asm_out_file, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1623 SDB_DELIM, SDB_DELIM, SDB_DELIM);
1627 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1634 PUT_SDB_DEF (LABEL_NAME (insn));
1636 PUT_SDB_SCL (C_LABEL);
1637 PUT_SDB_TYPE (T_NULL);
1641 /* Change to reading from a new source file. */
1644 sdbout_start_source_file (line, filename)
1645 unsigned int line ATTRIBUTE_UNUSED;
1646 const char *filename ATTRIBUTE_UNUSED;
1648 #ifdef MIPS_DEBUGGING_INFO
1649 struct sdb_file *n = (struct sdb_file *) xmalloc (sizeof *n);
1651 n->next = current_file;
1654 PUT_SDB_SRC_FILE (filename);
1658 /* Revert to reading a previous source file. */
1661 sdbout_end_source_file (line)
1662 unsigned int line ATTRIBUTE_UNUSED;
1664 #ifdef MIPS_DEBUGGING_INFO
1665 struct sdb_file *next;
1667 next = current_file->next;
1668 free (current_file);
1669 current_file = next;
1670 PUT_SDB_SRC_FILE (current_file->name);
1674 /* Set up for SDB output at the start of compilation. */
1677 sdbout_init (input_file_name)
1678 const char *input_file_name ATTRIBUTE_UNUSED;
1680 #ifdef MIPS_DEBUGGING_INFO
1681 current_file = (struct sdb_file *) xmalloc (sizeof *current_file);
1682 current_file->next = NULL;
1683 current_file->name = input_file_name;
1686 #ifdef RMS_QUICK_HACK_1
1688 for (t = getdecls (); t; t = TREE_CHAIN (t))
1689 if (DECL_NAME (t) && IDENTIFIER_POINTER (DECL_NAME (t)) != 0
1690 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t)), "__vtbl_ptr_type"))
1691 sdbout_symbol (t, 0);
1694 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1695 ggc_add_tree_root (&anonymous_types, 1);
1699 #endif /* SDB_DEBUGGING_INFO */