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, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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 #include "coretypes.h"
52 static GTY(()) tree anonymous_types
;
54 /* Counter for sdbout_source_line. */
56 static GTY(()) int sdbout_source_line_counter
;
58 /* Counter to generate unique "names" for nameless struct members. */
60 static GTY(()) int unnamed_struct_number
;
62 #ifdef SDB_DEBUGGING_INFO
67 #include "insn-config.h"
73 #include "langhooks.h"
76 /* 1 if PARM is passed to this function in memory. */
78 #define PARM_PASSED_IN_MEMORY(PARM) \
79 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
81 /* A C expression for the integer offset value of an automatic variable
82 (C_AUTO) having address X (an RTX). */
83 #ifndef DEBUGGER_AUTO_OFFSET
84 #define DEBUGGER_AUTO_OFFSET(X) \
85 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
88 /* A C expression for the integer offset value of an argument (C_ARG)
89 having address X (an RTX). The nominal offset is OFFSET. */
90 #ifndef DEBUGGER_ARG_OFFSET
91 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
94 /* Line number of beginning of current function, minus one.
95 Negative means not in a function or not using sdb. */
97 int sdb_begin_function_line
= -1;
100 extern FILE *asm_out_file
;
102 extern tree current_function_decl
;
106 static void sdbout_init (const char *);
107 static void sdbout_finish (const char *);
108 static void sdbout_start_source_file (unsigned int, const char *);
109 static void sdbout_end_source_file (unsigned int);
110 static void sdbout_begin_block (unsigned int, unsigned int);
111 static void sdbout_end_block (unsigned int, unsigned int);
112 static void sdbout_source_line (unsigned int, const char *);
113 static void sdbout_end_epilogue (unsigned int, const char *);
114 static void sdbout_global_decl (tree
);
115 #ifndef MIPS_DEBUGGING_INFO
116 static void sdbout_begin_prologue (unsigned int, const char *);
118 static void sdbout_end_prologue (unsigned int, const char *);
119 static void sdbout_begin_function (tree
);
120 static void sdbout_end_function (unsigned int);
121 static void sdbout_toplevel_data (tree
);
122 static void sdbout_label (rtx
);
123 static char *gen_fake_label (void);
124 static int plain_type (tree
);
125 static int template_name_p (tree
);
126 static void sdbout_record_type_name (tree
);
127 static int plain_type_1 (tree
, int);
128 static void sdbout_block (tree
);
129 static void sdbout_syms (tree
);
130 #ifdef SDB_ALLOW_FORWARD_REFERENCES
131 static void sdbout_queue_anonymous_type (tree
);
132 static void sdbout_dequeue_anonymous_types (void);
134 static void sdbout_type (tree
);
135 static void sdbout_field_types (tree
);
136 static void sdbout_one_type (tree
);
137 static void sdbout_parms (tree
);
138 static void sdbout_reg_parms (tree
);
139 static void sdbout_global_decl (tree
);
141 /* Random macros describing parts of SDB data. */
143 /* Default value of delimiter is ";". */
145 #define SDB_DELIM ";"
148 /* Maximum number of dimensions the assembler will allow. */
150 #define SDB_MAX_DIM 4
154 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
157 #ifndef PUT_SDB_INT_VAL
158 #define PUT_SDB_INT_VAL(a) \
160 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
161 (HOST_WIDE_INT) (a), SDB_DELIM); \
167 #define PUT_SDB_VAL(a) \
168 ( fputs ("\t.val\t", asm_out_file), \
169 output_addr_const (asm_out_file, (a)), \
170 fprintf (asm_out_file, SDB_DELIM))
174 #define PUT_SDB_DEF(a) \
175 do { fprintf (asm_out_file, "\t.def\t"); \
176 assemble_name (asm_out_file, a); \
177 fprintf (asm_out_file, SDB_DELIM); } while (0)
180 #ifndef PUT_SDB_PLAIN_DEF
181 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
184 #ifndef PUT_SDB_ENDEF
185 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
189 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
193 #define PUT_SDB_SIZE(a) \
195 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
196 (HOST_WIDE_INT) (a), SDB_DELIM); \
200 #ifndef PUT_SDB_START_DIM
201 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
204 #ifndef PUT_SDB_NEXT_DIM
205 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
208 #ifndef PUT_SDB_LAST_DIM
209 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
213 #define PUT_SDB_TAG(a) \
214 do { fprintf (asm_out_file, "\t.tag\t"); \
215 assemble_name (asm_out_file, a); \
216 fprintf (asm_out_file, SDB_DELIM); } while (0)
219 #ifndef PUT_SDB_BLOCK_START
220 #define PUT_SDB_BLOCK_START(LINE) \
221 fprintf (asm_out_file, \
222 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
223 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
226 #ifndef PUT_SDB_BLOCK_END
227 #define PUT_SDB_BLOCK_END(LINE) \
228 fprintf (asm_out_file, \
229 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
230 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
233 #ifndef PUT_SDB_FUNCTION_START
234 #define PUT_SDB_FUNCTION_START(LINE) \
235 fprintf (asm_out_file, \
236 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
237 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
240 #ifndef PUT_SDB_FUNCTION_END
241 #define PUT_SDB_FUNCTION_END(LINE) \
242 fprintf (asm_out_file, \
243 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
244 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
247 #ifndef SDB_GENERATE_FAKE
248 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
249 sprintf ((BUFFER), ".%dfake", (NUMBER));
252 /* Return the sdb tag identifier string for TYPE
253 if TYPE has already been defined; otherwise return a null pointer. */
255 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
257 /* Set the sdb tag identifier string for TYPE to NAME. */
259 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
260 TYPE_SYMTAB_POINTER (TYPE) = (char *)(NAME)
262 /* Return the name (a string) of the struct, union or enum tag
263 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
265 #define TAG_NAME(link) \
266 (((link) && TREE_PURPOSE ((link)) \
267 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
268 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
270 /* Ensure we don't output a negative line number. */
271 #define MAKE_LINE_SAFE(line) \
272 if ((int) line <= sdb_begin_function_line) \
273 line = sdb_begin_function_line + 1
275 /* Perform linker optimization of merging header file definitions together
276 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
277 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
278 the optimization just won't be done. The native assembler already has the
279 necessary support. */
281 #ifdef MIPS_DEBUGGING_INFO
283 #ifndef PUT_SDB_SRC_FILE
284 #define PUT_SDB_SRC_FILE(FILENAME) \
285 output_file_directive (asm_out_file, (FILENAME))
288 /* ECOFF linkers have an optimization that does the same kind of thing as
289 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
290 executable. To achieve this, GCC must output a .file for each file
293 /* This is a stack of input files. */
297 struct sdb_file
*next
;
301 /* This is the top of the stack. */
303 static struct sdb_file
*current_file
;
305 #endif /* MIPS_DEBUGGING_INFO */
307 /* The debug hooks structure. */
308 const struct gcc_debug_hooks sdb_debug_hooks
=
310 sdbout_init
, /* init */
311 sdbout_finish
, /* finish */
312 debug_nothing_int_charstar
, /* define */
313 debug_nothing_int_charstar
, /* undef */
314 sdbout_start_source_file
, /* start_source_file */
315 sdbout_end_source_file
, /* end_source_file */
316 sdbout_begin_block
, /* begin_block */
317 sdbout_end_block
, /* end_block */
318 debug_true_tree
, /* ignore_block */
319 sdbout_source_line
, /* source_line */
320 #ifdef MIPS_DEBUGGING_INFO
321 /* Defer on MIPS systems so that parameter descriptions follow
323 debug_nothing_int_charstar
, /* begin_prologue */
324 sdbout_end_prologue
, /* end_prologue */
326 sdbout_begin_prologue
, /* begin_prologue */
327 debug_nothing_int_charstar
, /* end_prologue */
329 sdbout_end_epilogue
, /* end_epilogue */
330 sdbout_begin_function
, /* begin_function */
331 sdbout_end_function
, /* end_function */
332 debug_nothing_tree
, /* function_decl */
333 sdbout_global_decl
, /* global_decl */
334 debug_nothing_tree
, /* deferred_inline_function */
335 debug_nothing_tree
, /* outlining_inline_function */
336 sdbout_label
, /* label */
337 debug_nothing_int
/* handle_pch */
340 /* Return a unique string to name an anonymous type. */
343 gen_fake_label (void)
347 SDB_GENERATE_FAKE (label
, unnamed_struct_number
);
348 unnamed_struct_number
++;
349 labelstr
= xstrdup (label
);
353 /* Return the number which describes TYPE for SDB.
354 For pointers, etc., this function is recursive.
355 Each record, union or enumeral type must already have had a
356 tag number output. */
358 /* The number is given by d6d5d4d3d2d1bbbb
359 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
360 Thus, char *foo () has bbbb=T_CHAR
363 N_BTMASK= 017 1111 basic type field.
364 N_TSHIFT= 2 derived type shift
365 N_BTSHFT= 4 Basic type shift */
367 /* Produce the number that describes a pointer, function or array type.
368 PREV is the number describing the target, value or element type.
369 DT_type describes how to transform that type. */
370 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
371 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
372 | ((int) DT_type << (int) N_BTSHFT) \
373 | ((PREV) & (int) N_BTMASK))
375 /* Number of elements used in sdb_dims. */
376 static int sdb_n_dims
= 0;
378 /* Table of array dimensions of current type. */
379 static int sdb_dims
[SDB_MAX_DIM
];
381 /* Size of outermost array currently being processed. */
382 static int sdb_type_size
= -1;
385 plain_type (tree type
)
387 int val
= plain_type_1 (type
, 0);
389 /* If we have already saved up some array dimensions, print them now. */
394 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
395 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
396 PUT_SDB_LAST_DIM (sdb_dims
[0]);
399 sdb_type_size
= int_size_in_bytes (type
);
400 /* Don't kill sdb if type is not laid out or has variable size. */
401 if (sdb_type_size
< 0)
404 /* If we have computed the size of an array containing this type,
406 if (sdb_type_size
>= 0)
408 PUT_SDB_SIZE (sdb_type_size
);
415 template_name_p (tree name
)
417 const char *ptr
= IDENTIFIER_POINTER (name
);
418 while (*ptr
&& *ptr
!= '<')
425 sdbout_record_type_name (tree type
)
427 const char *name
= 0;
430 if (KNOWN_TYPE_TAG (type
))
433 if (TYPE_NAME (type
) != 0)
437 /* Find the IDENTIFIER_NODE for the type name. */
438 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
439 t
= TYPE_NAME (type
);
440 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
442 t
= DECL_NAME (TYPE_NAME (type
));
443 /* The DECL_NAME for templates includes "<>", which breaks
444 most assemblers. Use its assembler name instead, which
445 has been mangled into being safe. */
446 if (t
&& template_name_p (t
))
447 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
450 /* Now get the name as a string, or invent one. */
452 name
= IDENTIFIER_POINTER (t
);
455 no_name
= (name
== 0 || *name
== 0);
457 name
= gen_fake_label ();
459 SET_KNOWN_TYPE_TAG (type
, name
);
460 #ifdef SDB_ALLOW_FORWARD_REFERENCES
462 sdbout_queue_anonymous_type (type
);
466 /* Return the .type value for type TYPE.
468 LEVEL indicates how many levels deep we have recursed into the type.
469 The SDB debug format can only represent 6 derived levels of types.
470 After that, we must output inaccurate debug info. We deliberately
471 stop before the 7th level, so that ADA recursive types will not give an
475 plain_type_1 (tree type
, int level
)
478 type
= void_type_node
;
479 else if (type
== error_mark_node
)
480 type
= integer_type_node
;
482 type
= TYPE_MAIN_VARIANT (type
);
484 switch (TREE_CODE (type
))
491 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
493 /* Carefully distinguish all the standard types of C,
494 without messing up if the language is not C.
495 Note that we check only for the names that contain spaces;
496 other names might occur by coincidence in other languages. */
497 if (TYPE_NAME (type
) != 0
498 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
499 && DECL_NAME (TYPE_NAME (type
)) != 0
500 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
502 const char *const name
503 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
505 if (!strcmp (name
, "char"))
507 if (!strcmp (name
, "unsigned char"))
509 if (!strcmp (name
, "signed char"))
511 if (!strcmp (name
, "int"))
513 if (!strcmp (name
, "unsigned int"))
515 if (!strcmp (name
, "short int"))
517 if (!strcmp (name
, "short unsigned int"))
519 if (!strcmp (name
, "long int"))
521 if (!strcmp (name
, "long unsigned int"))
525 if (size
== INT_TYPE_SIZE
)
526 return (TREE_UNSIGNED (type
) ? T_UINT
: T_INT
);
527 if (size
== CHAR_TYPE_SIZE
)
528 return (TREE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
529 if (size
== SHORT_TYPE_SIZE
)
530 return (TREE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
531 if (size
== LONG_TYPE_SIZE
)
532 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
533 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
534 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
540 int precision
= TYPE_PRECISION (type
);
541 if (precision
== FLOAT_TYPE_SIZE
)
543 if (precision
== DOUBLE_TYPE_SIZE
)
545 #ifdef EXTENDED_SDB_BASIC_TYPES
546 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
549 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
550 return T_DOUBLE
; /* better than nothing */
561 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
562 if (sdb_n_dims
< SDB_MAX_DIM
)
563 sdb_dims
[sdb_n_dims
++]
564 = (TYPE_DOMAIN (type
)
565 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
566 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
567 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
568 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
569 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
570 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
573 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
578 case QUAL_UNION_TYPE
:
582 #ifdef SDB_ALLOW_FORWARD_REFERENCES
583 sdbout_record_type_name (type
);
585 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
586 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
587 #ifdef SDB_ALLOW_FORWARD_REFERENCES
588 || TYPE_MODE (type
) != VOIDmode
593 /* Output the referenced structure tag name
594 only if the .def has already been finished.
595 At least on 386, the Unix assembler
596 cannot handle forward references to tags. */
597 /* But the 88100, it requires them, sigh... */
598 /* And the MIPS requires unknown refs as well... */
599 tag
= KNOWN_TYPE_TAG (type
);
601 /* These 3 lines used to follow the close brace.
602 However, a size of 0 without a tag implies a tag of 0,
603 so if we don't know a tag, we can't mention the size. */
604 sdb_type_size
= int_size_in_bytes (type
);
605 if (sdb_type_size
< 0)
608 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
609 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
610 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
620 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
621 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
630 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
631 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
638 /* Output the symbols defined in block number DO_BLOCK.
640 This function works by walking the tree structure of blocks,
641 counting blocks until it finds the desired block. */
643 static int do_block
= 0;
646 sdbout_block (tree block
)
650 /* Ignore blocks never expanded or otherwise marked as real. */
651 if (TREE_USED (block
))
653 /* When we reach the specified block, output its symbols. */
654 if (BLOCK_NUMBER (block
) == do_block
)
655 sdbout_syms (BLOCK_VARS (block
));
657 /* If we are past the specified block, stop the scan. */
658 if (BLOCK_NUMBER (block
) > do_block
)
661 /* Scan the blocks within this block. */
662 sdbout_block (BLOCK_SUBBLOCKS (block
));
665 block
= BLOCK_CHAIN (block
);
669 /* Call sdbout_symbol on each decl in the chain SYMS. */
672 sdbout_syms (tree syms
)
676 if (TREE_CODE (syms
) != LABEL_DECL
)
677 sdbout_symbol (syms
, 1);
678 syms
= TREE_CHAIN (syms
);
682 /* Output SDB information for a symbol described by DECL.
683 LOCAL is nonzero if the symbol is not file-scope. */
686 sdbout_symbol (tree decl
, int local
)
688 tree type
= TREE_TYPE (decl
);
689 tree context
= NULL_TREE
;
694 sdbout_one_type (type
);
696 switch (TREE_CODE (decl
))
699 /* Enum values are defined by defining the enum type. */
703 /* Don't mention a nested function under its parent. */
704 context
= decl_function_context (decl
);
705 if (context
== current_function_decl
)
707 /* Check DECL_INITIAL to distinguish declarations from definitions.
708 Don't output debug info here for declarations; they will have
709 a DECL_INITIAL value of 0. */
710 if (! DECL_INITIAL (decl
))
712 if (GET_CODE (DECL_RTL (decl
)) != MEM
713 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
715 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
716 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
717 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
721 /* Done with tagged types. */
722 if (DECL_NAME (decl
) == 0)
724 if (DECL_IGNORED_P (decl
))
727 /* Output typedef name. */
728 if (template_name_p (DECL_NAME (decl
)))
729 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
731 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
732 PUT_SDB_SCL (C_TPDEF
);
736 /* Parm decls go in their own separate chains
737 and are output by sdbout_reg_parms and sdbout_parms. */
741 /* Don't mention a variable that is external.
742 Let the file that defines it describe it. */
743 if (DECL_EXTERNAL (decl
))
746 /* Ignore __FUNCTION__, etc. */
747 if (DECL_IGNORED_P (decl
))
750 /* If there was an error in the declaration, don't dump core
751 if there is no RTL associated with the variable doesn't
753 if (!DECL_RTL_SET_P (decl
))
757 eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
758 #ifdef LEAF_REG_REMAP
759 if (current_function_uses_only_leaf_regs
)
760 leaf_renumber_regs_insn (DECL_RTL (decl
));
762 value
= DECL_RTL (decl
);
764 /* Don't mention a variable at all
765 if it was completely optimized into nothingness.
767 If DECL was from an inline function, then its rtl
768 is not identically the rtl that was used in this
769 particular compilation. */
770 if (GET_CODE (value
) == REG
)
772 regno
= REGNO (value
);
773 if (regno
>= FIRST_PSEUDO_REGISTER
)
776 else if (GET_CODE (value
) == SUBREG
)
778 while (GET_CODE (value
) == SUBREG
)
779 value
= SUBREG_REG (value
);
780 if (GET_CODE (value
) == REG
)
782 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
785 regno
= REGNO (alter_subreg (&value
));
786 SET_DECL_RTL (decl
, value
);
788 /* Don't output anything if an auto variable
789 gets RTL that is static.
790 GAS version 2.2 can't handle such output. */
791 else if (GET_CODE (value
) == MEM
&& CONSTANT_P (XEXP (value
, 0))
792 && ! TREE_STATIC (decl
))
795 /* Emit any structure, union, or enum type that has not been output.
796 This occurs for tag-less structs (et al) used to declare variables
798 if (TREE_CODE (type
) == ENUMERAL_TYPE
799 || TREE_CODE (type
) == RECORD_TYPE
800 || TREE_CODE (type
) == UNION_TYPE
801 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
803 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
804 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
805 sdbout_one_type (type
);
808 /* Defer SDB information for top-level initialized variables! */
810 && GET_CODE (value
) == MEM
811 && DECL_INITIAL (decl
))
814 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
815 For now, avoid crashing. */
816 if (DECL_NAME (decl
) == NULL_TREE
)
819 /* Record the name for, starting a symtab entry. */
821 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
823 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
825 if (GET_CODE (value
) == MEM
826 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
829 if (TREE_PUBLIC (decl
))
831 PUT_SDB_VAL (XEXP (value
, 0));
836 PUT_SDB_VAL (XEXP (value
, 0));
837 PUT_SDB_SCL (C_STAT
);
843 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
846 else if (GET_CODE (value
) == MEM
847 && (GET_CODE (XEXP (value
, 0)) == MEM
848 || (GET_CODE (XEXP (value
, 0)) == REG
849 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
850 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
851 /* If the value is indirect by memory or by a register
852 that isn't the frame pointer
853 then it means the object is variable-sized and address through
854 that register or stack slot. COFF has no way to represent this
855 so all we can do is output the variable as a pointer. */
858 if (GET_CODE (XEXP (value
, 0)) == REG
)
860 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
865 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
867 We want the value of that CONST_INT. */
868 /* Encore compiler hates a newline in a macro arg, it seems. */
869 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
870 (XEXP (XEXP (value
, 0), 0)));
871 PUT_SDB_SCL (C_AUTO
);
874 /* Effectively do build_pointer_type, but don't cache this type,
875 since it might be temporary whereas the type it points to
876 might have been saved for inlining. */
877 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
878 type
= make_node (POINTER_TYPE
);
879 TREE_TYPE (type
) = TREE_TYPE (decl
);
881 else if (GET_CODE (value
) == MEM
882 && ((GET_CODE (XEXP (value
, 0)) == PLUS
883 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
884 && GET_CODE (XEXP (XEXP (value
, 0), 1)) == CONST_INT
)
885 /* This is for variables which are at offset zero from
886 the frame pointer. This happens on the Alpha.
887 Non-frame pointer registers are excluded above. */
888 || (GET_CODE (XEXP (value
, 0)) == REG
)))
890 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
891 or (MEM (REG...)). We want the value of that CONST_INT
894 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
895 PUT_SDB_SCL (C_AUTO
);
899 /* It is something we don't know how to represent for SDB. */
907 PUT_SDB_TYPE (plain_type (type
));
911 /* Output SDB information for a top-level initialized variable
912 that has been delayed. */
915 sdbout_toplevel_data (tree decl
)
917 tree type
= TREE_TYPE (decl
);
919 if (DECL_IGNORED_P (decl
))
922 if (! (TREE_CODE (decl
) == VAR_DECL
923 && GET_CODE (DECL_RTL (decl
)) == MEM
924 && DECL_INITIAL (decl
)))
927 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
928 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
929 if (TREE_PUBLIC (decl
))
935 PUT_SDB_SCL (C_STAT
);
937 PUT_SDB_TYPE (plain_type (type
));
941 #ifdef SDB_ALLOW_FORWARD_REFERENCES
943 /* Machinery to record and output anonymous types. */
946 sdbout_queue_anonymous_type (tree type
)
948 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
952 sdbout_dequeue_anonymous_types (void)
956 while (anonymous_types
)
958 types
= nreverse (anonymous_types
);
959 anonymous_types
= NULL_TREE
;
961 for (link
= types
; link
; link
= TREE_CHAIN (link
))
963 tree type
= TREE_VALUE (link
);
965 if (type
&& ! TREE_ASM_WRITTEN (type
))
966 sdbout_one_type (type
);
973 /* Given a chain of ..._TYPE nodes, all of which have names,
974 output definitions of those names, as typedefs. */
977 sdbout_types (tree types
)
981 for (link
= types
; link
; link
= TREE_CHAIN (link
))
982 sdbout_one_type (link
);
984 #ifdef SDB_ALLOW_FORWARD_REFERENCES
985 sdbout_dequeue_anonymous_types ();
990 sdbout_type (tree type
)
992 if (type
== error_mark_node
)
993 type
= integer_type_node
;
994 PUT_SDB_TYPE (plain_type (type
));
997 /* Output types of the fields of type TYPE, if they are structs.
999 Formerly did not chase through pointer types, since that could be circular.
1000 They must come before TYPE, since forward refs are not allowed.
1001 Now james@bigtex.cactus.org says to try them. */
1004 sdbout_field_types (tree type
)
1008 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1009 /* This condition should match the one for emitting the actual
1011 if (TREE_CODE (tail
) == FIELD_DECL
1014 && host_integerp (DECL_SIZE (tail
), 1)
1015 && host_integerp (bit_position (tail
), 0))
1017 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1018 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1020 sdbout_one_type (TREE_TYPE (tail
));
1024 /* Use this to put out the top level defined record and union types
1025 for later reference. If this is a struct with a name, then put that
1026 name out. Other unnamed structs will have .xxfake labels generated so
1027 that they may be referred to later.
1028 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1029 It may NOT be called recursively. */
1032 sdbout_one_type (tree type
)
1034 if (current_function_decl
!= NULL_TREE
1035 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1036 ; /* Don't change section amid function. */
1040 switch (TREE_CODE (type
))
1044 case QUAL_UNION_TYPE
:
1046 type
= TYPE_MAIN_VARIANT (type
);
1047 /* Don't output a type twice. */
1048 if (TREE_ASM_WRITTEN (type
))
1049 /* James said test TREE_ASM_BEING_WRITTEN here. */
1052 /* Output nothing if type is not yet defined. */
1053 if (!COMPLETE_TYPE_P (type
))
1056 TREE_ASM_WRITTEN (type
) = 1;
1058 /* This is reputed to cause trouble with the following case,
1059 but perhaps checking TYPE_SIZE above will fix it. */
1061 /* Here is a test case:
1067 typedef struct intermediate {
1071 typedef struct badstr {
1075 /* This change, which ought to make better output,
1076 used to make the COFF assembler unhappy.
1077 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1078 /* Before really doing anything, output types we want to refer to. */
1079 /* Note that in version 1 the following two lines
1080 are not used if forward references are in use. */
1081 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1082 sdbout_field_types (type
);
1084 /* Output a structure type. */
1086 int size
= int_size_in_bytes (type
);
1089 int i
, n_baseclasses
= 0;
1091 /* Record the type tag, but not in its permanent place just yet. */
1092 sdbout_record_type_name (type
);
1094 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1096 switch (TREE_CODE (type
))
1099 case QUAL_UNION_TYPE
:
1100 PUT_SDB_SCL (C_UNTAG
);
1101 PUT_SDB_TYPE (T_UNION
);
1106 PUT_SDB_SCL (C_STRTAG
);
1107 PUT_SDB_TYPE (T_STRUCT
);
1112 PUT_SDB_SCL (C_ENTAG
);
1113 PUT_SDB_TYPE (T_ENUM
);
1121 PUT_SDB_SIZE (size
);
1124 /* Print out the base class information with fields
1125 named after the types they hold. */
1126 /* This is only relevant to aggregate types. TYPE_BINFO is used
1127 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1129 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1131 if (TYPE_BINFO (type
)
1132 && TYPE_BINFO_BASETYPES (type
))
1133 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1134 for (i
= 0; i
< n_baseclasses
; i
++)
1136 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)),
1138 tree child_type
= BINFO_TYPE (child
);
1139 tree child_type_name
;
1140 if (TYPE_NAME (child_type
) == 0)
1142 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1143 child_type_name
= TYPE_NAME (child_type
);
1144 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1146 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1147 if (child_type_name
&& template_name_p (child_type_name
))
1149 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1154 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1155 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1156 PUT_SDB_SCL (member_scl
);
1157 sdbout_type (BINFO_TYPE (child
));
1162 /* output the individual fields */
1164 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1166 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1167 if (host_integerp (TREE_VALUE (tem
), 0))
1169 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1170 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1171 PUT_SDB_SCL (C_MOE
);
1172 PUT_SDB_TYPE (T_MOE
);
1176 else /* record or union type */
1177 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1178 /* Output the name, type, position (in bits), size (in bits)
1181 /* Omit here the nameless fields that are used to skip bits.
1182 Also omit fields with variable size or position.
1183 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1184 if (TREE_CODE (tem
) == FIELD_DECL
1187 && host_integerp (DECL_SIZE (tem
), 1)
1188 && host_integerp (bit_position (tem
), 0))
1192 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1194 if (DECL_BIT_FIELD_TYPE (tem
))
1196 PUT_SDB_INT_VAL (int_bit_position (tem
));
1197 PUT_SDB_SCL (C_FIELD
);
1198 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1199 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1203 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1204 PUT_SDB_SCL (member_scl
);
1205 sdbout_type (TREE_TYPE (tem
));
1209 /* output end of a structure,union, or enumeral definition */
1211 PUT_SDB_PLAIN_DEF ("eos");
1212 PUT_SDB_INT_VAL (size
);
1213 PUT_SDB_SCL (C_EOS
);
1214 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1215 PUT_SDB_SIZE (size
);
1225 /* The following two functions output definitions of function parameters.
1226 Each parameter gets a definition locating it in the parameter list.
1227 Each parameter that is a register variable gets a second definition
1228 locating it in the register.
1230 Printing or argument lists in gdb uses the definitions that
1231 locate in the parameter list. But reference to the variable in
1232 expressions uses preferentially the definition as a register. */
1234 /* Output definitions, referring to storage in the parmlist,
1235 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1238 sdbout_parms (tree parms
)
1240 for (; parms
; parms
= TREE_CHAIN (parms
))
1241 if (DECL_NAME (parms
))
1243 int current_sym_value
= 0;
1244 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1246 if (name
== 0 || *name
== 0)
1247 name
= gen_fake_label ();
1249 /* Perform any necessary register eliminations on the parameter's rtl,
1250 so that the debugging output will be accurate. */
1251 DECL_INCOMING_RTL (parms
)
1252 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1253 SET_DECL_RTL (parms
,
1254 eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
1256 if (PARM_PASSED_IN_MEMORY (parms
))
1258 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1261 /* ??? Here we assume that the parm address is indexed
1262 off the frame pointer or arg pointer.
1263 If that is not true, we produce meaningless results,
1264 but do not crash. */
1265 if (GET_CODE (addr
) == PLUS
1266 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1267 current_sym_value
= INTVAL (XEXP (addr
, 1));
1269 current_sym_value
= 0;
1271 if (GET_CODE (DECL_RTL (parms
)) == REG
1272 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1273 type
= DECL_ARG_TYPE (parms
);
1276 int original_sym_value
= current_sym_value
;
1278 /* This is the case where the parm is passed as an int or
1279 double and it is converted to a char, short or float
1280 and stored back in the parmlist. In this case, describe
1281 the parm with the variable's declared type, and adjust
1282 the address if the least significant bytes (which we are
1283 using) are not the first ones. */
1284 if (BYTES_BIG_ENDIAN
1285 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1286 current_sym_value
+=
1287 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1288 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1290 if (GET_CODE (DECL_RTL (parms
)) == MEM
1291 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1292 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1294 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1295 == current_sym_value
))
1296 type
= TREE_TYPE (parms
);
1299 current_sym_value
= original_sym_value
;
1300 type
= DECL_ARG_TYPE (parms
);
1305 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1306 PUT_SDB_SCL (C_ARG
);
1307 PUT_SDB_TYPE (plain_type (type
));
1310 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
1313 /* Parm passed in registers and lives in registers or nowhere. */
1315 /* If parm lives in a register, use that register;
1316 pretend the parm was passed there. It would be more consistent
1317 to describe the register where the parm was passed,
1318 but in practice that register usually holds something else. */
1319 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1320 best_rtl
= DECL_RTL (parms
);
1321 /* If the parm lives nowhere,
1322 use the register where it was passed. */
1324 best_rtl
= DECL_INCOMING_RTL (parms
);
1327 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1328 PUT_SDB_SCL (C_REGPARM
);
1329 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1332 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1333 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1335 /* Parm was passed in registers but lives on the stack. */
1337 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1338 in which case we want the value of that CONST_INT,
1339 or (MEM (REG ...)) or (MEM (MEM ...)),
1340 in which case we use a value of zero. */
1341 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
1342 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
1343 current_sym_value
= 0;
1345 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1347 /* Again, this assumes the offset is based on the arg pointer. */
1349 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1350 XEXP (DECL_RTL (parms
), 0)));
1351 PUT_SDB_SCL (C_ARG
);
1352 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1358 /* Output definitions for the places where parms live during the function,
1359 when different from where they were passed, when the parms were passed
1362 It is not useful to do this for parms passed in registers
1363 that live during the function in different registers, because it is
1364 impossible to look in the passed register for the passed value,
1365 so we use the within-the-function register to begin with.
1367 PARMS is a chain of PARM_DECL nodes. */
1370 sdbout_reg_parms (tree parms
)
1372 for (; parms
; parms
= TREE_CHAIN (parms
))
1373 if (DECL_NAME (parms
))
1375 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1377 /* Report parms that live in registers during the function
1378 but were passed in memory. */
1379 if (GET_CODE (DECL_RTL (parms
)) == REG
1380 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1381 && PARM_PASSED_IN_MEMORY (parms
))
1383 if (name
== 0 || *name
== 0)
1384 name
= gen_fake_label ();
1386 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1387 PUT_SDB_SCL (C_REG
);
1388 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1391 /* Report parms that live in memory but not where they were passed. */
1392 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1393 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1394 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1395 && PARM_PASSED_IN_MEMORY (parms
)
1396 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1398 #if 0 /* ??? It is not clear yet what should replace this. */
1399 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1400 /* A parm declared char is really passed as an int,
1401 so it occupies the least significant bytes.
1402 On a big-endian machine those are not the low-numbered ones. */
1403 if (BYTES_BIG_ENDIAN
1405 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1406 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1407 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1408 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1411 if (name
== 0 || *name
== 0)
1412 name
= gen_fake_label ();
1414 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1415 (XEXP (DECL_RTL (parms
), 0)));
1416 PUT_SDB_SCL (C_AUTO
);
1417 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1424 /* Output debug information for a global DECL. Called from toplev.c
1425 after compilation proper has finished. */
1428 sdbout_global_decl (tree decl
)
1430 if (TREE_CODE (decl
) == VAR_DECL
1431 && !DECL_EXTERNAL (decl
)
1432 && DECL_RTL_SET_P (decl
))
1434 /* The COFF linker can move initialized global vars to the end.
1435 And that can screw up the symbol ordering. Defer those for
1436 sdbout_finish (). */
1437 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1438 sdbout_symbol (decl
, 0);
1440 /* Output COFF information for non-global file-scope initialized
1442 if (DECL_INITIAL (decl
) && GET_CODE (DECL_RTL (decl
)) == MEM
)
1443 sdbout_toplevel_data (decl
);
1447 /* Output initialized global vars at the end, in the order of
1448 definition. See comment in sdbout_global_decl. */
1451 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1453 tree decl
= (*lang_hooks
.decls
.getdecls
) ();
1454 unsigned int len
= list_length (decl
);
1455 tree
*vec
= (tree
*) xmalloc (sizeof (tree
) * len
);
1458 /* Process the decls in reverse order--earliest first. Put them
1459 into VEC from back to front, then take out from front. */
1461 for (i
= 0; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
1462 vec
[len
- i
- 1] = decl
;
1464 for (i
= 0; i
< len
; i
++)
1467 if (TREE_CODE (decl
) == VAR_DECL
1468 && ! DECL_EXTERNAL (decl
)
1469 && DECL_INITIAL (decl
)
1470 && TREE_PUBLIC (decl
)
1471 && DECL_RTL_SET_P (decl
))
1472 sdbout_symbol (decl
, 0);
1478 /* Describe the beginning of an internal block within a function.
1479 Also output descriptions of variables defined in this block.
1481 N is the number of the block, by order of beginning, counting from 1,
1482 and not counting the outermost (function top-level) block.
1483 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1484 if the count starts at 0 for the outermost one. */
1487 sdbout_begin_block (unsigned int line
, unsigned int n
)
1489 tree decl
= current_function_decl
;
1490 MAKE_LINE_SAFE (line
);
1492 /* The SCO compiler does not emit a separate block for the function level
1493 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1494 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1495 #ifndef MIPS_DEBUGGING_INFO
1498 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1502 /* Include the outermost BLOCK's variables in block 1. */
1503 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1504 sdbout_block (DECL_INITIAL (decl
));
1506 /* If -g1, suppress all the internal symbols of functions
1507 except for arguments. */
1508 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1511 sdbout_block (DECL_INITIAL (decl
));
1514 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1515 sdbout_dequeue_anonymous_types ();
1519 /* Describe the end line-number of an internal block within a function. */
1522 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
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_END (line
- sdb_begin_function_line
);
1535 /* Output a line number symbol entry for source file FILENAME and line
1539 sdbout_source_line (line
, filename
)
1541 const char *filename ATTRIBUTE_UNUSED
;
1543 /* COFF relative line numbers must be positive. */
1544 if ((int) line
> sdb_begin_function_line
)
1546 #ifdef ASM_OUTPUT_SOURCE_LINE
1547 sdbout_source_line_counter
+= 1;
1548 ASM_OUTPUT_SOURCE_LINE (asm_out_file
, line
, sdbout_source_line_counter
);
1550 fprintf (asm_out_file
, "\t.ln\t%d\n",
1551 ((sdb_begin_function_line
> -1)
1552 ? line
- sdb_begin_function_line
: 1));
1557 /* Output sdb info for the current function name.
1558 Called from assemble_start_function. */
1561 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1563 sdbout_symbol (current_function_decl
, 0);
1566 /* Called at beginning of function body (before or after prologue,
1567 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1568 line number, so we can output relative line numbers for the other
1569 lines. Describe beginning of outermost block. Also describe the
1572 #ifndef MIPS_DEBUGGING_INFO
1574 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1576 sdbout_end_prologue (line
, file
);
1581 sdbout_end_prologue (line
, file
)
1583 const char *file ATTRIBUTE_UNUSED
;
1585 sdb_begin_function_line
= line
- 1;
1586 PUT_SDB_FUNCTION_START (line
);
1587 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1588 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1591 /* Called at end of function (before epilogue).
1592 Describe end of outermost block. */
1595 sdbout_end_function (unsigned int 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 (unsigned int line ATTRIBUTE_UNUSED
,
1613 const char *file ATTRIBUTE_UNUSED
)
1615 const char *const name ATTRIBUTE_UNUSED
1616 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1618 #ifdef PUT_SDB_EPILOGUE_END
1619 PUT_SDB_EPILOGUE_END (name
);
1621 fprintf (asm_out_file
, "\t.def\t");
1622 assemble_name (asm_out_file
, name
);
1623 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1624 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1628 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1632 sdbout_label (rtx 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 (unsigned int line ATTRIBUTE_UNUSED
,
1645 const char *filename ATTRIBUTE_UNUSED
)
1647 #ifdef MIPS_DEBUGGING_INFO
1648 struct sdb_file
*n
= (struct sdb_file
*) xmalloc (sizeof *n
);
1650 n
->next
= current_file
;
1653 PUT_SDB_SRC_FILE (filename
);
1657 /* Revert to reading a previous source file. */
1660 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1662 #ifdef MIPS_DEBUGGING_INFO
1663 struct sdb_file
*next
;
1665 next
= current_file
->next
;
1666 free (current_file
);
1667 current_file
= next
;
1668 PUT_SDB_SRC_FILE (current_file
->name
);
1672 /* Set up for SDB output at the start of compilation. */
1675 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1677 #ifdef MIPS_DEBUGGING_INFO
1678 current_file
= (struct sdb_file
*) xmalloc (sizeof *current_file
);
1679 current_file
->next
= NULL
;
1680 current_file
->name
= input_file_name
;
1684 #else /* SDB_DEBUGGING_INFO */
1686 /* This should never be used, but its address is needed for comparisons. */
1687 const struct gcc_debug_hooks sdb_debug_hooks
;
1689 #endif /* SDB_DEBUGGING_INFO */
1691 #include "gt-sdbout.h"