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 char *gen_fake_label
PARAMS ((void));
110 static int plain_type
PARAMS ((tree
));
111 static int template_name_p
PARAMS ((tree
));
112 static void sdbout_record_type_name
PARAMS ((tree
));
113 static int plain_type_1
PARAMS ((tree
, int));
114 static void sdbout_block
PARAMS ((tree
));
115 static void sdbout_syms
PARAMS ((tree
));
116 #ifdef SDB_ALLOW_FORWARD_REFERENCES
117 static void sdbout_queue_anonymous_type
PARAMS ((tree
));
118 static void sdbout_dequeue_anonymous_types
PARAMS ((void));
120 static void sdbout_type
PARAMS ((tree
));
121 static void sdbout_field_types
PARAMS ((tree
));
122 static void sdbout_one_type
PARAMS ((tree
));
123 static void sdbout_parms
PARAMS ((tree
));
124 static void sdbout_reg_parms
PARAMS ((tree
));
126 /* Random macros describing parts of SDB data. */
128 /* Put something here if lines get too long */
131 /* Default value of delimiter is ";". */
133 #define SDB_DELIM ";"
136 /* Maximum number of dimensions the assembler will allow. */
138 #define SDB_MAX_DIM 4
142 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
145 #ifndef PUT_SDB_INT_VAL
146 #define PUT_SDB_INT_VAL(a) \
148 fputs ("\t.val\t", asm_out_file); \
149 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
150 fprintf (asm_out_file, "%s", SDB_DELIM); \
156 #define PUT_SDB_VAL(a) \
157 ( fputs ("\t.val\t", asm_out_file), \
158 output_addr_const (asm_out_file, (a)), \
159 fprintf (asm_out_file, SDB_DELIM))
163 #define PUT_SDB_DEF(a) \
164 do { fprintf (asm_out_file, "\t.def\t"); \
165 assemble_name (asm_out_file, a); \
166 fprintf (asm_out_file, SDB_DELIM); } while (0)
169 #ifndef PUT_SDB_PLAIN_DEF
170 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
173 #ifndef PUT_SDB_ENDEF
174 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
178 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
182 #define PUT_SDB_SIZE(a) \
184 fputs ("\t.size\t", asm_out_file); \
185 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
186 fprintf (asm_out_file, "%s", SDB_DELIM); \
190 #ifndef PUT_SDB_START_DIM
191 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
194 #ifndef PUT_SDB_NEXT_DIM
195 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
198 #ifndef PUT_SDB_LAST_DIM
199 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
203 #define PUT_SDB_TAG(a) \
204 do { fprintf (asm_out_file, "\t.tag\t"); \
205 assemble_name (asm_out_file, a); \
206 fprintf (asm_out_file, SDB_DELIM); } while (0)
209 #ifndef PUT_SDB_BLOCK_START
210 #define PUT_SDB_BLOCK_START(LINE) \
211 fprintf (asm_out_file, \
212 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
213 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
216 #ifndef PUT_SDB_BLOCK_END
217 #define PUT_SDB_BLOCK_END(LINE) \
218 fprintf (asm_out_file, \
219 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
220 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
223 #ifndef PUT_SDB_FUNCTION_START
224 #define PUT_SDB_FUNCTION_START(LINE) \
225 fprintf (asm_out_file, \
226 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
227 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
230 #ifndef PUT_SDB_FUNCTION_END
231 #define PUT_SDB_FUNCTION_END(LINE) \
232 fprintf (asm_out_file, \
233 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
234 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
237 #ifndef SDB_GENERATE_FAKE
238 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
239 sprintf ((BUFFER), ".%dfake", (NUMBER));
242 /* Return the sdb tag identifier string for TYPE
243 if TYPE has already been defined; otherwise return a null pointer. */
245 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
247 /* Set the sdb tag identifier string for TYPE to NAME. */
249 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
250 TYPE_SYMTAB_POINTER (TYPE) = (NAME)
252 /* Return the name (a string) of the struct, union or enum tag
253 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
255 #define TAG_NAME(link) \
256 (((link) && TREE_PURPOSE ((link)) \
257 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
258 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
260 /* Ensure we don't output a negative line number. */
261 #define MAKE_LINE_SAFE(line) \
262 if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1
264 /* Perform linker optimization of merging header file definitions together
265 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
266 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
267 the optimization just won't be done. The native assembler already has the
268 necessary support. */
270 #ifdef MIPS_DEBUGGING_INFO
272 #ifndef PUT_SDB_SRC_FILE
273 #define PUT_SDB_SRC_FILE(FILENAME) \
274 output_file_directive (asm_out_file, (FILENAME))
277 /* ECOFF linkers have an optimization that does the same kind of thing as
278 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
279 executable. To achieve this, GCC must output a .file for each file
282 /* This is a stack of input files. */
286 struct sdb_file
*next
;
290 /* This is the top of the stack. */
292 static struct sdb_file
*current_file
;
294 #endif /* MIPS_DEBUGGING_INFO */
296 /* The debug hooks structure. */
297 struct gcc_debug_hooks sdb_debug_hooks
=
300 debug_nothing_charstar
,
301 debug_nothing_int_charstar
,
302 debug_nothing_int_charstar
,
303 sdbout_start_source_file
,
304 sdbout_end_source_file
,
308 #ifdef MIPS_DEBUGGING_INFO
309 /* Defer on MIPS systems so that parameter descriptions follow
311 debug_nothing_int_charstar
, /* begin_prologue */
312 sdbout_end_prologue
, /* end_prologue */
314 sdbout_begin_prologue
, /* begin_prologue */
315 debug_nothing_int
, /* end_prologue */
318 sdbout_begin_function
,
320 debug_nothing_tree
, /* function_decl */
322 debug_nothing_tree
/* deferred_inline_function */
327 /* return the tag identifier for type
331 tag_of_ru_type (type
,link
)
334 if (TYPE_SYMTAB_ADDRESS (type
))
335 return TYPE_SYMTAB_ADDRESS (type
);
336 if (link
&& TREE_PURPOSE (link
)
337 && IDENTIFIER_POINTER (TREE_PURPOSE (link
)))
338 TYPE_SYMTAB_ADDRESS (type
) = IDENTIFIER_POINTER (TREE_PURPOSE (link
));
340 return (char *) TYPE_SYMTAB_ADDRESS (type
);
344 /* Return a unique string to name an anonymous type. */
351 SDB_GENERATE_FAKE (label
, unnamed_struct_number
);
352 unnamed_struct_number
++;
353 labelstr
= (char *) permalloc (strlen (label
) + 1);
354 strcpy (labelstr
, label
);
358 /* Return the number which describes TYPE for SDB.
359 For pointers, etc., this function is recursive.
360 Each record, union or enumeral type must already have had a
361 tag number output. */
363 /* The number is given by d6d5d4d3d2d1bbbb
364 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
365 Thus, char *foo () has bbbb=T_CHAR
368 N_BTMASK= 017 1111 basic type field.
369 N_TSHIFT= 2 derived type shift
370 N_BTSHFT= 4 Basic type shift */
372 /* Produce the number that describes a pointer, function or array type.
373 PREV is the number describing the target, value or element type.
374 DT_type describes how to transform that type. */
375 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
376 ((((PREV) & ~(int)N_BTMASK) << (int)N_TSHIFT) \
377 | ((int)DT_type << (int)N_BTSHFT) \
378 | ((PREV) & (int)N_BTMASK))
380 /* Number of elements used in sdb_dims. */
381 static int sdb_n_dims
= 0;
383 /* Table of array dimensions of current type. */
384 static int sdb_dims
[SDB_MAX_DIM
];
386 /* Size of outermost array currently being processed. */
387 static int sdb_type_size
= -1;
393 int val
= plain_type_1 (type
, 0);
395 /* If we have already saved up some array dimensions, print them now. */
400 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
401 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
402 PUT_SDB_LAST_DIM (sdb_dims
[0]);
405 sdb_type_size
= int_size_in_bytes (type
);
406 /* Don't kill sdb if type is not laid out or has variable size. */
407 if (sdb_type_size
< 0)
410 /* If we have computed the size of an array containing this type,
412 if (sdb_type_size
>= 0)
414 PUT_SDB_SIZE (sdb_type_size
);
421 template_name_p (name
)
424 register const char *ptr
= IDENTIFIER_POINTER (name
);
425 while (*ptr
&& *ptr
!= '<')
432 sdbout_record_type_name (type
)
435 const char *name
= 0;
438 if (KNOWN_TYPE_TAG (type
))
441 if (TYPE_NAME (type
) != 0)
444 /* Find the IDENTIFIER_NODE for the type name. */
445 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
446 t
= TYPE_NAME (type
);
447 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
449 t
= DECL_NAME (TYPE_NAME (type
));
450 /* The DECL_NAME for templates includes "<>", which breaks
451 most assemblers. Use its assembler name instead, which
452 has been mangled into being safe. */
453 if (t
&& template_name_p (t
))
454 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
457 /* Now get the name as a string, or invent one. */
459 name
= IDENTIFIER_POINTER (t
);
462 no_name
= (name
== 0 || *name
== 0);
464 name
= gen_fake_label ();
466 SET_KNOWN_TYPE_TAG (type
, name
);
467 #ifdef SDB_ALLOW_FORWARD_REFERENCES
469 sdbout_queue_anonymous_type (type
);
473 /* Return the .type value for type TYPE.
475 LEVEL indicates how many levels deep we have recursed into the type.
476 The SDB debug format can only represent 6 derived levels of types.
477 After that, we must output inaccurate debug info. We deliberately
478 stop before the 7th level, so that ADA recursive types will not give an
482 plain_type_1 (type
, level
)
487 type
= void_type_node
;
488 else if (type
== error_mark_node
)
489 type
= integer_type_node
;
491 type
= TYPE_MAIN_VARIANT (type
);
493 switch (TREE_CODE (type
))
500 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
502 /* Carefully distinguish all the standard types of C,
503 without messing up if the language is not C.
504 Note that we check only for the names that contain spaces;
505 other names might occur by coincidence in other languages. */
506 if (TYPE_NAME (type
) != 0
507 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
508 && DECL_NAME (TYPE_NAME (type
)) != 0
509 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
512 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
514 if (!strcmp (name
, "char"))
516 if (!strcmp (name
, "unsigned char"))
518 if (!strcmp (name
, "signed char"))
520 if (!strcmp (name
, "int"))
522 if (!strcmp (name
, "unsigned int"))
524 if (!strcmp (name
, "short int"))
526 if (!strcmp (name
, "short unsigned int"))
528 if (!strcmp (name
, "long int"))
530 if (!strcmp (name
, "long unsigned int"))
534 if (size
== INT_TYPE_SIZE
)
535 return (TREE_UNSIGNED (type
) ? T_UINT
: T_INT
);
536 if (size
== CHAR_TYPE_SIZE
)
537 return (TREE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
538 if (size
== SHORT_TYPE_SIZE
)
539 return (TREE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
540 if (size
== LONG_TYPE_SIZE
)
541 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
542 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
543 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
549 int precision
= TYPE_PRECISION (type
);
550 if (precision
== FLOAT_TYPE_SIZE
)
552 if (precision
== DOUBLE_TYPE_SIZE
)
554 #ifdef EXTENDED_SDB_BASIC_TYPES
555 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
558 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
559 return T_DOUBLE
; /* better than nothing */
570 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
571 if (sdb_n_dims
< SDB_MAX_DIM
)
572 sdb_dims
[sdb_n_dims
++]
573 = (TYPE_DOMAIN (type
)
574 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
575 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
576 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
577 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
578 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
579 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
582 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
587 case QUAL_UNION_TYPE
:
591 #ifdef SDB_ALLOW_FORWARD_REFERENCES
592 sdbout_record_type_name (type
);
594 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
595 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
596 #ifdef SDB_ALLOW_FORWARD_REFERENCES
597 || TYPE_MODE (type
) != VOIDmode
602 /* Output the referenced structure tag name
603 only if the .def has already been finished.
604 At least on 386, the Unix assembler
605 cannot handle forward references to tags. */
606 /* But the 88100, it requires them, sigh... */
607 /* And the MIPS requires unknown refs as well... */
608 tag
= KNOWN_TYPE_TAG (type
);
610 /* These 3 lines used to follow the close brace.
611 However, a size of 0 without a tag implies a tag of 0,
612 so if we don't know a tag, we can't mention the size. */
613 sdb_type_size
= int_size_in_bytes (type
);
614 if (sdb_type_size
< 0)
617 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
618 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
619 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
629 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
630 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
639 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
640 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
647 /* Output the symbols defined in block number DO_BLOCK.
649 This function works by walking the tree structure of blocks,
650 counting blocks until it finds the desired block. */
652 static int do_block
= 0;
660 /* Ignore blocks never expanded or otherwise marked as real. */
661 if (TREE_USED (block
))
663 /* When we reach the specified block, output its symbols. */
664 if (BLOCK_NUMBER (block
) == do_block
)
665 sdbout_syms (BLOCK_VARS (block
));
667 /* If we are past the specified block, stop the scan. */
668 if (BLOCK_NUMBER (block
) > do_block
)
671 /* Scan the blocks within this block. */
672 sdbout_block (BLOCK_SUBBLOCKS (block
));
675 block
= BLOCK_CHAIN (block
);
679 /* Call sdbout_symbol on each decl in the chain SYMS. */
687 if (TREE_CODE (syms
) != LABEL_DECL
)
688 sdbout_symbol (syms
, 1);
689 syms
= TREE_CHAIN (syms
);
693 /* Output SDB information for a symbol described by DECL.
694 LOCAL is nonzero if the symbol is not file-scope. */
697 sdbout_symbol (decl
, local
)
701 tree type
= TREE_TYPE (decl
);
702 tree context
= NULL_TREE
;
707 sdbout_one_type (type
);
709 #if 0 /* This loses when functions are marked to be ignored,
710 which happens in the C++ front end. */
711 if (DECL_IGNORED_P (decl
))
715 switch (TREE_CODE (decl
))
718 /* Enum values are defined by defining the enum type. */
722 /* Don't mention a nested function under its parent. */
723 context
= decl_function_context (decl
);
724 if (context
== current_function_decl
)
726 /* Check DECL_INITIAL to distinguish declarations from definitions.
727 Don't output debug info here for declarations; they will have
728 a DECL_INITIAL value of 0. */
729 if (! DECL_INITIAL (decl
))
731 if (GET_CODE (DECL_RTL (decl
)) != MEM
732 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
734 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
735 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
736 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
740 /* Done with tagged types. */
741 if (DECL_NAME (decl
) == 0)
743 if (DECL_IGNORED_P (decl
))
746 /* Output typedef name. */
747 if (template_name_p (DECL_NAME (decl
)))
748 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
750 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
751 PUT_SDB_SCL (C_TPDEF
);
755 /* Parm decls go in their own separate chains
756 and are output by sdbout_reg_parms and sdbout_parms. */
760 /* Don't mention a variable that is external.
761 Let the file that defines it describe it. */
762 if (DECL_EXTERNAL (decl
))
765 /* Ignore __FUNCTION__, etc. */
766 if (DECL_IGNORED_P (decl
))
769 /* If there was an error in the declaration, don't dump core
770 if there is no RTL associated with the variable doesn't
772 if (!DECL_RTL_SET_P (decl
))
776 eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
777 #ifdef LEAF_REG_REMAP
778 if (current_function_uses_only_leaf_regs
)
779 leaf_renumber_regs_insn (DECL_RTL (decl
));
781 value
= DECL_RTL (decl
);
783 /* Don't mention a variable at all
784 if it was completely optimized into nothingness.
786 If DECL was from an inline function, then its rtl
787 is not identically the rtl that was used in this
788 particular compilation. */
789 if (GET_CODE (value
) == REG
)
791 regno
= REGNO (DECL_RTL (decl
));
792 if (regno
>= FIRST_PSEUDO_REGISTER
)
795 else if (GET_CODE (value
) == SUBREG
)
797 while (GET_CODE (value
) == SUBREG
)
798 value
= SUBREG_REG (value
);
799 if (GET_CODE (value
) == REG
)
801 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
804 regno
= REGNO (alter_subreg (DECL_RTL (decl
)));
805 value
= DECL_RTL (decl
);
807 /* Don't output anything if an auto variable
808 gets RTL that is static.
809 GAS version 2.2 can't handle such output. */
810 else if (GET_CODE (value
) == MEM
&& CONSTANT_P (XEXP (value
, 0))
811 && ! TREE_STATIC (decl
))
814 /* Emit any structure, union, or enum type that has not been output.
815 This occurs for tag-less structs (et al) used to declare variables
817 if (TREE_CODE (type
) == ENUMERAL_TYPE
818 || TREE_CODE (type
) == RECORD_TYPE
819 || TREE_CODE (type
) == UNION_TYPE
820 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
822 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
823 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
824 sdbout_one_type (type
);
827 /* Defer SDB information for top-level initialized variables! */
829 && GET_CODE (value
) == MEM
830 && DECL_INITIAL (decl
))
833 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
834 For now, avoid crashing. */
835 if (DECL_NAME (decl
) == NULL_TREE
)
838 /* Record the name for, starting a symtab entry. */
840 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
842 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
844 if (GET_CODE (value
) == MEM
845 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
848 if (TREE_PUBLIC (decl
))
850 PUT_SDB_VAL (XEXP (value
, 0));
855 PUT_SDB_VAL (XEXP (value
, 0));
856 PUT_SDB_SCL (C_STAT
);
862 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
865 else if (GET_CODE (value
) == MEM
866 && (GET_CODE (XEXP (value
, 0)) == MEM
867 || (GET_CODE (XEXP (value
, 0)) == REG
868 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
869 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
870 /* If the value is indirect by memory or by a register
871 that isn't the frame pointer
872 then it means the object is variable-sized and address through
873 that register or stack slot. COFF has no way to represent this
874 so all we can do is output the variable as a pointer. */
877 if (GET_CODE (XEXP (value
, 0)) == REG
)
879 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
884 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
886 We want the value of that CONST_INT. */
887 /* Encore compiler hates a newline in a macro arg, it seems. */
888 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
889 (XEXP (XEXP (value
, 0), 0)));
890 PUT_SDB_SCL (C_AUTO
);
893 /* Effectively do build_pointer_type, but don't cache this type,
894 since it might be temporary whereas the type it points to
895 might have been saved for inlining. */
896 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
897 type
= make_node (POINTER_TYPE
);
898 TREE_TYPE (type
) = TREE_TYPE (decl
);
900 else if (GET_CODE (value
) == MEM
901 && ((GET_CODE (XEXP (value
, 0)) == PLUS
902 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
903 && GET_CODE (XEXP (XEXP (value
, 0), 1)) == CONST_INT
)
904 /* This is for variables which are at offset zero from
905 the frame pointer. This happens on the Alpha.
906 Non-frame pointer registers are excluded above. */
907 || (GET_CODE (XEXP (value
, 0)) == REG
)))
909 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
910 or (MEM (REG...)). We want the value of that CONST_INT
913 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
914 PUT_SDB_SCL (C_AUTO
);
916 else if (GET_CODE (value
) == MEM
&& GET_CODE (XEXP (value
, 0)) == CONST
)
918 /* Handle an obscure case which can arise when optimizing and
919 when there are few available registers. (This is *always*
920 the case for i386/i486 targets). The DECL_RTL looks like
921 (MEM (CONST ...)) even though this variable is a local `auto'
922 or a local `register' variable. In effect, what has happened
923 is that the reload pass has seen that all assignments and
924 references for one such a local variable can be replaced by
925 equivalent assignments and references to some static storage
926 variable, thereby avoiding the need for a register. In such
927 cases we're forced to lie to debuggers and tell them that
928 this variable was itself `static'. */
930 PUT_SDB_VAL (XEXP (XEXP (value
, 0), 0));
931 PUT_SDB_SCL (C_STAT
);
935 /* It is something we don't know how to represent for SDB. */
943 PUT_SDB_TYPE (plain_type (type
));
947 /* Output SDB information for a top-level initialized variable
948 that has been delayed. */
951 sdbout_toplevel_data (decl
)
954 tree type
= TREE_TYPE (decl
);
956 if (DECL_IGNORED_P (decl
))
959 if (! (TREE_CODE (decl
) == VAR_DECL
960 && GET_CODE (DECL_RTL (decl
)) == MEM
961 && DECL_INITIAL (decl
)))
964 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
965 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
966 if (TREE_PUBLIC (decl
))
972 PUT_SDB_SCL (C_STAT
);
974 PUT_SDB_TYPE (plain_type (type
));
978 #ifdef SDB_ALLOW_FORWARD_REFERENCES
980 /* Machinery to record and output anonymous types. */
982 static tree anonymous_types
;
985 sdbout_queue_anonymous_type (type
)
988 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
992 sdbout_dequeue_anonymous_types ()
994 register tree types
, link
;
996 while (anonymous_types
)
998 types
= nreverse (anonymous_types
);
999 anonymous_types
= NULL_TREE
;
1001 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1003 register tree type
= TREE_VALUE (link
);
1005 if (type
&& ! TREE_ASM_WRITTEN (type
))
1006 sdbout_one_type (type
);
1013 /* Given a chain of ..._TYPE nodes, all of which have names,
1014 output definitions of those names, as typedefs. */
1017 sdbout_types (types
)
1018 register tree types
;
1022 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1023 sdbout_one_type (link
);
1025 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1026 sdbout_dequeue_anonymous_types ();
1034 if (type
== error_mark_node
)
1035 type
= integer_type_node
;
1036 PUT_SDB_TYPE (plain_type (type
));
1039 /* Output types of the fields of type TYPE, if they are structs.
1041 Formerly did not chase through pointer types, since that could be circular.
1042 They must come before TYPE, since forward refs are not allowed.
1043 Now james@bigtex.cactus.org says to try them. */
1046 sdbout_field_types (type
)
1051 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1052 /* This condition should match the one for emitting the actual
1054 if (TREE_CODE (tail
) == FIELD_DECL
1057 && host_integerp (DECL_SIZE (tail
), 1)
1058 && host_integerp (bit_position (tail
), 0))
1060 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1061 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1063 sdbout_one_type (TREE_TYPE (tail
));
1067 /* Use this to put out the top level defined record and union types
1068 for later reference. If this is a struct with a name, then put that
1069 name out. Other unnamed structs will have .xxfake labels generated so
1070 that they may be referred to later.
1071 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1072 It may NOT be called recursively. */
1075 sdbout_one_type (type
)
1078 if (current_function_decl
!= NULL_TREE
1079 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1080 ; /* Don't change section amid function. */
1084 switch (TREE_CODE (type
))
1088 case QUAL_UNION_TYPE
:
1090 type
= TYPE_MAIN_VARIANT (type
);
1091 /* Don't output a type twice. */
1092 if (TREE_ASM_WRITTEN (type
))
1093 /* James said test TREE_ASM_BEING_WRITTEN here. */
1096 /* Output nothing if type is not yet defined. */
1097 if (!COMPLETE_TYPE_P (type
))
1100 TREE_ASM_WRITTEN (type
) = 1;
1102 /* This is reputed to cause trouble with the following case,
1103 but perhaps checking TYPE_SIZE above will fix it. */
1105 /* Here is a test case:
1111 typedef struct intermediate {
1115 typedef struct badstr {
1120 TREE_ASM_BEING_WRITTEN (type
) = 1;
1122 /* This change, which ought to make better output,
1123 used to make the COFF assembler unhappy.
1124 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1125 /* Before really doing anything, output types we want to refer to. */
1126 /* Note that in version 1 the following two lines
1127 are not used if forward references are in use. */
1128 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1129 sdbout_field_types (type
);
1131 TREE_ASM_WRITTEN (type
) = 1;
1135 /* Output a structure type. */
1137 int size
= int_size_in_bytes (type
);
1140 int i
, n_baseclasses
= 0;
1142 /* Record the type tag, but not in its permanent place just yet. */
1143 sdbout_record_type_name (type
);
1145 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1147 switch (TREE_CODE (type
))
1150 case QUAL_UNION_TYPE
:
1151 PUT_SDB_SCL (C_UNTAG
);
1152 PUT_SDB_TYPE (T_UNION
);
1157 PUT_SDB_SCL (C_STRTAG
);
1158 PUT_SDB_TYPE (T_STRUCT
);
1163 PUT_SDB_SCL (C_ENTAG
);
1164 PUT_SDB_TYPE (T_ENUM
);
1172 PUT_SDB_SIZE (size
);
1175 /* Print out the base class information with fields
1176 named after the types they hold. */
1177 /* This is only relevent to aggregate types. TYPE_BINFO is used
1178 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1180 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1182 if (TYPE_BINFO (type
)
1183 && TYPE_BINFO_BASETYPES (type
))
1184 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1185 for (i
= 0; i
< n_baseclasses
; i
++)
1187 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)),
1189 tree child_type
= BINFO_TYPE (child
);
1190 tree child_type_name
;
1191 if (TYPE_NAME (child_type
) == 0)
1193 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1194 child_type_name
= TYPE_NAME (child_type
);
1195 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1197 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1198 if (child_type_name
&& template_name_p (child_type_name
))
1200 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1206 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1207 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1208 PUT_SDB_SCL (member_scl
);
1209 sdbout_type (BINFO_TYPE (child
));
1214 /* output the individual fields */
1216 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1218 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1219 if (host_integerp (TREE_VALUE (tem
), 0))
1221 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1222 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1223 PUT_SDB_SCL (C_MOE
);
1224 PUT_SDB_TYPE (T_MOE
);
1228 else /* record or union type */
1229 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1230 /* Output the name, type, position (in bits), size (in bits)
1233 /* Omit here the nameless fields that are used to skip bits.
1234 Also omit fields with variable size or position.
1235 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1236 if (TREE_CODE (tem
) == FIELD_DECL
1239 && host_integerp (DECL_SIZE (tem
), 1)
1240 && host_integerp (bit_position (tem
), 0))
1245 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1247 if (DECL_BIT_FIELD_TYPE (tem
))
1249 PUT_SDB_INT_VAL (int_bit_position (tem
));
1250 PUT_SDB_SCL (C_FIELD
);
1251 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1252 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1256 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1257 PUT_SDB_SCL (member_scl
);
1258 sdbout_type (TREE_TYPE (tem
));
1262 /* output end of a structure,union, or enumeral definition */
1264 PUT_SDB_PLAIN_DEF ("eos");
1265 PUT_SDB_INT_VAL (size
);
1266 PUT_SDB_SCL (C_EOS
);
1267 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1268 PUT_SDB_SIZE (size
);
1278 /* The following two functions output definitions of function parameters.
1279 Each parameter gets a definition locating it in the parameter list.
1280 Each parameter that is a register variable gets a second definition
1281 locating it in the register.
1283 Printing or argument lists in gdb uses the definitions that
1284 locate in the parameter list. But reference to the variable in
1285 expressions uses preferentially the definition as a register. */
1287 /* Output definitions, referring to storage in the parmlist,
1288 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1291 sdbout_parms (parms
)
1294 for (; parms
; parms
= TREE_CHAIN (parms
))
1295 if (DECL_NAME (parms
))
1297 int current_sym_value
= 0;
1298 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1300 if (name
== 0 || *name
== 0)
1301 name
= gen_fake_label ();
1303 /* Perform any necessary register eliminations on the parameter's rtl,
1304 so that the debugging output will be accurate. */
1305 DECL_INCOMING_RTL (parms
)
1306 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1307 SET_DECL_RTL (parms
,
1308 eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
1310 if (PARM_PASSED_IN_MEMORY (parms
))
1312 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1315 /* ??? Here we assume that the parm address is indexed
1316 off the frame pointer or arg pointer.
1317 If that is not true, we produce meaningless results,
1318 but do not crash. */
1319 if (GET_CODE (addr
) == PLUS
1320 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1321 current_sym_value
= INTVAL (XEXP (addr
, 1));
1323 current_sym_value
= 0;
1325 if (GET_CODE (DECL_RTL (parms
)) == REG
1326 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1327 type
= DECL_ARG_TYPE (parms
);
1330 int original_sym_value
= current_sym_value
;
1332 /* This is the case where the parm is passed as an int or
1333 double and it is converted to a char, short or float
1334 and stored back in the parmlist. In this case, describe
1335 the parm with the variable's declared type, and adjust
1336 the address if the least significant bytes (which we are
1337 using) are not the first ones. */
1338 if (BYTES_BIG_ENDIAN
1339 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1340 current_sym_value
+=
1341 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1342 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1344 if (GET_CODE (DECL_RTL (parms
)) == MEM
1345 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1346 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1348 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1349 == current_sym_value
))
1350 type
= TREE_TYPE (parms
);
1353 current_sym_value
= original_sym_value
;
1354 type
= DECL_ARG_TYPE (parms
);
1359 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1360 PUT_SDB_SCL (C_ARG
);
1361 PUT_SDB_TYPE (plain_type (type
));
1364 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
1367 /* Parm passed in registers and lives in registers or nowhere. */
1369 /* If parm lives in a register, use that register;
1370 pretend the parm was passed there. It would be more consistent
1371 to describe the register where the parm was passed,
1372 but in practice that register usually holds something else. */
1373 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1374 best_rtl
= DECL_RTL (parms
);
1375 /* If the parm lives nowhere,
1376 use the register where it was passed. */
1378 best_rtl
= DECL_INCOMING_RTL (parms
);
1381 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1382 PUT_SDB_SCL (C_REGPARM
);
1383 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1386 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1387 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1389 /* Parm was passed in registers but lives on the stack. */
1391 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1392 in which case we want the value of that CONST_INT,
1393 or (MEM (REG ...)) or (MEM (MEM ...)),
1394 in which case we use a value of zero. */
1395 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
1396 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
1397 current_sym_value
= 0;
1399 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1401 /* Again, this assumes the offset is based on the arg pointer. */
1403 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1404 XEXP (DECL_RTL (parms
), 0)));
1405 PUT_SDB_SCL (C_ARG
);
1406 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1412 /* Output definitions for the places where parms live during the function,
1413 when different from where they were passed, when the parms were passed
1416 It is not useful to do this for parms passed in registers
1417 that live during the function in different registers, because it is
1418 impossible to look in the passed register for the passed value,
1419 so we use the within-the-function register to begin with.
1421 PARMS is a chain of PARM_DECL nodes. */
1424 sdbout_reg_parms (parms
)
1427 for (; parms
; parms
= TREE_CHAIN (parms
))
1428 if (DECL_NAME (parms
))
1430 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1432 /* Report parms that live in registers during the function
1433 but were passed in memory. */
1434 if (GET_CODE (DECL_RTL (parms
)) == REG
1435 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1436 && PARM_PASSED_IN_MEMORY (parms
))
1438 if (name
== 0 || *name
== 0)
1439 name
= gen_fake_label ();
1441 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1442 PUT_SDB_SCL (C_REG
);
1443 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1446 /* Report parms that live in memory but not where they were passed. */
1447 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1448 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1449 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1450 && PARM_PASSED_IN_MEMORY (parms
)
1451 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1453 #if 0 /* ??? It is not clear yet what should replace this. */
1454 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1455 /* A parm declared char is really passed as an int,
1456 so it occupies the least significant bytes.
1457 On a big-endian machine those are not the low-numbered ones. */
1458 if (BYTES_BIG_ENDIAN
1460 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1461 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1462 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1463 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1466 if (name
== 0 || *name
== 0)
1467 name
= gen_fake_label ();
1469 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1470 (XEXP (DECL_RTL (parms
), 0)));
1471 PUT_SDB_SCL (C_AUTO
);
1472 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1479 /* Output debug information for a global DECL. Called from toplev.c
1480 after compilation proper has finished. */
1483 sdbout_global_decl (decl
)
1486 if (TREE_CODE (decl
) == VAR_DECL
1487 && DECL_INITIAL (decl
)
1488 && ! DECL_EXTERNAL (decl
)
1489 && DECL_RTL (decl
) != 0)
1491 /* The COFF linker can move initialized global vars to the end.
1492 And that can screw up the symbol ordering. By putting the
1493 symbols in that order to begin with, we avoid a problem.
1494 mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */
1495 if (TREE_PUBLIC (decl
))
1496 sdbout_symbol (decl
, 0);
1498 /* Output COFF information for non-global file-scope initialized
1500 if (GET_CODE (DECL_RTL (decl
)) == MEM
)
1501 sdbout_toplevel_data (decl
);
1505 /* Describe the beginning of an internal block within a function.
1506 Also output descriptions of variables defined in this block.
1508 N is the number of the block, by order of beginning, counting from 1,
1509 and not counting the outermost (function top-level) block.
1510 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1511 if the count starts at 0 for the outermost one. */
1514 sdbout_begin_block (line
, n
)
1518 tree decl
= current_function_decl
;
1519 MAKE_LINE_SAFE (line
);
1521 /* The SCO compiler does not emit a separate block for the function level
1522 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1523 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1524 #ifndef MIPS_DEBUGGING_INFO
1527 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1531 /* Include the outermost BLOCK's variables in block 1. */
1532 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1533 sdbout_block (DECL_INITIAL (decl
));
1535 /* If -g1, suppress all the internal symbols of functions
1536 except for arguments. */
1537 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1540 sdbout_block (DECL_INITIAL (decl
));
1543 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1544 sdbout_dequeue_anonymous_types ();
1548 /* Describe the end line-number of an internal block within a function. */
1551 sdbout_end_block (line
, n
)
1553 unsigned int n ATTRIBUTE_UNUSED
;
1555 MAKE_LINE_SAFE (line
);
1557 /* The SCO compiler does not emit a separate block for the function level
1558 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1559 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1560 #ifndef MIPS_DEBUGGING_INFO
1563 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1567 sdbout_source_line (line
, filename
)
1569 const char *filename ATTRIBUTE_UNUSED
;
1571 /* COFF relative line numbers must be positive. */
1572 if (line
> sdb_begin_function_line
)
1574 #ifdef ASM_OUTPUT_SOURCE_LINE
1575 ASM_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1577 fprintf (asm_out_file
, "\t.ln\t%d\n",
1578 ((sdb_begin_function_line
> -1)
1579 ? line
- sdb_begin_function_line
: 1));
1584 /* Output sdb info for the current function name.
1585 Called from assemble_start_function. */
1588 sdbout_begin_function (decl
)
1589 tree decl ATTRIBUTE_UNUSED
;
1591 sdbout_symbol (current_function_decl
, 0);
1594 /* Called at beginning of function body (before or after prologue,
1595 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1596 line number, so we can output relative line numbers for the other
1597 lines. Describe beginning of outermost block. Also describe the
1600 #ifndef MIPS_DEBUGGING_INFO
1602 sdbout_begin_prologue (line
, file
)
1604 const char *file ATTRIBUTE_UNUSED
;
1606 sdbout_end_prologue (line
);
1611 sdbout_end_prologue (line
)
1614 sdb_begin_function_line
= line
- 1;
1615 PUT_SDB_FUNCTION_START (line
);
1616 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1617 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1620 /* Called at end of function (before epilogue).
1621 Describe end of outermost block. */
1624 sdbout_end_function (line
)
1627 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1628 sdbout_dequeue_anonymous_types ();
1631 MAKE_LINE_SAFE (line
);
1632 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1634 /* Indicate we are between functions, for line-number output. */
1635 sdb_begin_function_line
= -1;
1638 /* Output sdb info for the absolute end of a function.
1639 Called after the epilogue is output. */
1642 sdbout_end_epilogue ()
1645 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1647 #ifdef PUT_SDB_EPILOGUE_END
1648 PUT_SDB_EPILOGUE_END (name
);
1650 fprintf (asm_out_file
, "\t.def\t");
1651 assemble_name (asm_out_file
, name
);
1652 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1653 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1657 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1664 PUT_SDB_DEF (LABEL_NAME (insn
));
1666 PUT_SDB_SCL (C_LABEL
);
1667 PUT_SDB_TYPE (T_NULL
);
1671 /* Change to reading from a new source file. */
1674 sdbout_start_source_file (line
, filename
)
1675 unsigned int line ATTRIBUTE_UNUSED
;
1676 const char *filename ATTRIBUTE_UNUSED
;
1678 #ifdef MIPS_DEBUGGING_INFO
1679 struct sdb_file
*n
= (struct sdb_file
*) xmalloc (sizeof *n
);
1681 n
->next
= current_file
;
1684 PUT_SDB_SRC_FILE (filename
);
1688 /* Revert to reading a previous source file. */
1691 sdbout_end_source_file (line
)
1692 unsigned int line ATTRIBUTE_UNUSED
;
1694 #ifdef MIPS_DEBUGGING_INFO
1695 struct sdb_file
*next
;
1697 next
= current_file
->next
;
1698 free (current_file
);
1699 current_file
= next
;
1700 PUT_SDB_SRC_FILE (current_file
->name
);
1704 /* Set up for SDB output at the start of compilation. */
1707 sdbout_init (input_file_name
)
1708 const char *input_file_name ATTRIBUTE_UNUSED
;
1710 #ifdef MIPS_DEBUGGING_INFO
1711 current_file
= (struct sdb_file
*) xmalloc (sizeof *current_file
);
1712 current_file
->next
= NULL
;
1713 current_file
->name
= input_file_name
;
1716 #ifdef RMS_QUICK_HACK_1
1718 for (t
= getdecls (); t
; t
= TREE_CHAIN (t
))
1719 if (DECL_NAME (t
) && IDENTIFIER_POINTER (DECL_NAME (t
)) != 0
1720 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t
)), "__vtbl_ptr_type"))
1721 sdbout_symbol (t
, 0);
1724 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1725 ggc_add_tree_root (&anonymous_types
, 1);
1729 #endif /* SDB_DEBUGGING_INFO */