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, 2004, 2005, 2007 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 3, 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 COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 /* mike@tredysvr.Tredydev.Unisys.COM says:
22 I modified the struct.c example and have a nm of a .o resulting from the
23 AT&T C compiler. From the example below I would conclude the following:
25 1. All .defs from structures are emitted as scanned. The example below
26 clearly shows the symbol table entries for BoxRec2 are after the first
29 2. All functions and their locals (including statics) are emitted as scanned.
31 3. All nested unnamed union and structure .defs must be emitted before
32 the structure in which they are nested. The AT&T assembler is a
33 one pass beast as far as symbolics are concerned.
35 4. All structure .defs are emitted before the typedefs that refer to them.
37 5. All top level static and external variable definitions are moved to the
38 end of file with all top level statics occurring first before externs.
40 6. All undefined references are at the end of the file.
45 #include "coretypes.h"
52 static GTY(()) tree anonymous_types
;
54 /* Counter to generate unique "names" for nameless struct members. */
56 static GTY(()) int unnamed_struct_number
;
58 /* Declarations whose debug info was deferred till end of compilation. */
60 static GTY(()) varray_type deferred_global_decls
;
62 /* The C front end may call sdbout_symbol before sdbout_init runs.
63 We save all such decls in this list and output them when we get
66 static GTY(()) tree preinit_symbols
;
67 static GTY(()) bool sdbout_initialized
;
69 #ifdef SDB_DEBUGGING_INFO
74 #include "insn-config.h"
80 #include "langhooks.h"
83 /* 1 if PARM is passed to this function in memory. */
85 #define PARM_PASSED_IN_MEMORY(PARM) \
86 (MEM_P (DECL_INCOMING_RTL (PARM)))
88 /* A C expression for the integer offset value of an automatic variable
89 (C_AUTO) having address X (an RTX). */
90 #ifndef DEBUGGER_AUTO_OFFSET
91 #define DEBUGGER_AUTO_OFFSET(X) \
92 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
95 /* A C expression for the integer offset value of an argument (C_ARG)
96 having address X (an RTX). The nominal offset is OFFSET. */
97 #ifndef DEBUGGER_ARG_OFFSET
98 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
101 /* Line number of beginning of current function, minus one.
102 Negative means not in a function or not using sdb. */
104 int sdb_begin_function_line
= -1;
107 extern FILE *asm_out_file
;
109 extern tree current_function_decl
;
113 static void sdbout_init (const char *);
114 static void sdbout_finish (const char *);
115 static void sdbout_start_source_file (unsigned int, const char *);
116 static void sdbout_end_source_file (unsigned int);
117 static void sdbout_begin_block (unsigned int, unsigned int);
118 static void sdbout_end_block (unsigned int, unsigned int);
119 static void sdbout_source_line (unsigned int, const char *);
120 static void sdbout_end_epilogue (unsigned int, const char *);
121 static void sdbout_global_decl (tree
);
122 #ifndef MIPS_DEBUGGING_INFO
123 static void sdbout_begin_prologue (unsigned int, const char *);
125 static void sdbout_end_prologue (unsigned int, const char *);
126 static void sdbout_begin_function (tree
);
127 static void sdbout_end_function (unsigned int);
128 static void sdbout_toplevel_data (tree
);
129 static void sdbout_label (rtx
);
130 static char *gen_fake_label (void);
131 static int plain_type (tree
);
132 static int template_name_p (tree
);
133 static void sdbout_record_type_name (tree
);
134 static int plain_type_1 (tree
, int);
135 static void sdbout_block (tree
);
136 static void sdbout_syms (tree
);
137 #ifdef SDB_ALLOW_FORWARD_REFERENCES
138 static void sdbout_queue_anonymous_type (tree
);
139 static void sdbout_dequeue_anonymous_types (void);
141 static void sdbout_type (tree
);
142 static void sdbout_field_types (tree
);
143 static void sdbout_one_type (tree
);
144 static void sdbout_parms (tree
);
145 static void sdbout_reg_parms (tree
);
146 static void sdbout_global_decl (tree
);
148 /* Random macros describing parts of SDB data. */
150 /* Default value of delimiter is ";". */
152 #define SDB_DELIM ";"
155 /* Maximum number of dimensions the assembler will allow. */
157 #define SDB_MAX_DIM 4
161 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
164 #ifndef PUT_SDB_INT_VAL
165 #define PUT_SDB_INT_VAL(a) \
167 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
168 (HOST_WIDE_INT) (a), SDB_DELIM); \
174 #define PUT_SDB_VAL(a) \
175 ( fputs ("\t.val\t", asm_out_file), \
176 output_addr_const (asm_out_file, (a)), \
177 fprintf (asm_out_file, SDB_DELIM))
181 #define PUT_SDB_DEF(a) \
182 do { fprintf (asm_out_file, "\t.def\t"); \
183 assemble_name (asm_out_file, a); \
184 fprintf (asm_out_file, SDB_DELIM); } while (0)
187 #ifndef PUT_SDB_PLAIN_DEF
188 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
191 #ifndef PUT_SDB_ENDEF
192 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
196 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
200 #define PUT_SDB_SIZE(a) \
202 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
203 (HOST_WIDE_INT) (a), SDB_DELIM); \
207 #ifndef PUT_SDB_START_DIM
208 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
211 #ifndef PUT_SDB_NEXT_DIM
212 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
215 #ifndef PUT_SDB_LAST_DIM
216 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
220 #define PUT_SDB_TAG(a) \
221 do { fprintf (asm_out_file, "\t.tag\t"); \
222 assemble_name (asm_out_file, a); \
223 fprintf (asm_out_file, SDB_DELIM); } while (0)
226 #ifndef PUT_SDB_BLOCK_START
227 #define PUT_SDB_BLOCK_START(LINE) \
228 fprintf (asm_out_file, \
229 "\t.def\t.bb%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_BLOCK_END
234 #define PUT_SDB_BLOCK_END(LINE) \
235 fprintf (asm_out_file, \
236 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
237 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
240 #ifndef PUT_SDB_FUNCTION_START
241 #define PUT_SDB_FUNCTION_START(LINE) \
242 fprintf (asm_out_file, \
243 "\t.def\t.bf%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 PUT_SDB_FUNCTION_END
248 #define PUT_SDB_FUNCTION_END(LINE) \
249 fprintf (asm_out_file, \
250 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
251 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
254 /* Return the sdb tag identifier string for TYPE
255 if TYPE has already been defined; otherwise return a null pointer. */
257 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
259 /* Set the sdb tag identifier string for TYPE to NAME. */
261 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
262 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
264 /* Return the name (a string) of the struct, union or enum tag
265 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
267 #define TAG_NAME(link) \
268 (((link) && TREE_PURPOSE ((link)) \
269 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
270 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
272 /* Ensure we don't output a negative line number. */
273 #define MAKE_LINE_SAFE(line) \
274 if ((int) line <= sdb_begin_function_line) \
275 line = sdb_begin_function_line + 1
277 /* Perform linker optimization of merging header file definitions together
278 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
279 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
280 the optimization just won't be done. The native assembler already has the
281 necessary support. */
283 #ifdef MIPS_DEBUGGING_INFO
285 /* ECOFF linkers have an optimization that does the same kind of thing as
286 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
287 executable. To achieve this, GCC must output a .file for each file
290 /* This is a stack of input files. */
294 struct sdb_file
*next
;
298 /* This is the top of the stack. */
300 static struct sdb_file
*current_file
;
302 #endif /* MIPS_DEBUGGING_INFO */
304 /* The debug hooks structure. */
305 const struct gcc_debug_hooks sdb_debug_hooks
=
307 sdbout_init
, /* init */
308 sdbout_finish
, /* finish */
309 debug_nothing_int_charstar
, /* define */
310 debug_nothing_int_charstar
, /* undef */
311 sdbout_start_source_file
, /* start_source_file */
312 sdbout_end_source_file
, /* end_source_file */
313 sdbout_begin_block
, /* begin_block */
314 sdbout_end_block
, /* end_block */
315 debug_true_const_tree
, /* ignore_block */
316 sdbout_source_line
, /* source_line */
317 #ifdef MIPS_DEBUGGING_INFO
318 /* Defer on MIPS systems so that parameter descriptions follow
320 debug_nothing_int_charstar
, /* begin_prologue */
321 sdbout_end_prologue
, /* end_prologue */
323 sdbout_begin_prologue
, /* begin_prologue */
324 debug_nothing_int_charstar
, /* end_prologue */
326 sdbout_end_epilogue
, /* end_epilogue */
327 sdbout_begin_function
, /* begin_function */
328 sdbout_end_function
, /* end_function */
329 debug_nothing_tree
, /* function_decl */
330 sdbout_global_decl
, /* global_decl */
331 sdbout_symbol
, /* type_decl */
332 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
333 debug_nothing_tree
, /* deferred_inline_function */
334 debug_nothing_tree
, /* outlining_inline_function */
335 sdbout_label
, /* label */
336 debug_nothing_int
, /* handle_pch */
337 debug_nothing_rtx
, /* var_location */
338 debug_nothing_void
, /* switch_text_section */
339 0 /* start_end_main_source_file */
342 /* Return a unique string to name an anonymous type. */
345 gen_fake_label (void)
349 sprintf (label
, ".%dfake", unnamed_struct_number
);
350 unnamed_struct_number
++;
351 labelstr
= xstrdup (label
);
355 /* Return the number which describes TYPE for SDB.
356 For pointers, etc., this function is recursive.
357 Each record, union or enumeral type must already have had a
358 tag number output. */
360 /* The number is given by d6d5d4d3d2d1bbbb
361 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
362 Thus, char *foo () has bbbb=T_CHAR
365 N_BTMASK= 017 1111 basic type field.
366 N_TSHIFT= 2 derived type shift
367 N_BTSHFT= 4 Basic type shift */
369 /* Produce the number that describes a pointer, function or array type.
370 PREV is the number describing the target, value or element type.
371 DT_type describes how to transform that type. */
372 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
373 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
374 | ((int) DT_type << (int) N_BTSHFT) \
375 | ((PREV) & (int) N_BTMASK))
377 /* Number of elements used in sdb_dims. */
378 static int sdb_n_dims
= 0;
380 /* Table of array dimensions of current type. */
381 static int sdb_dims
[SDB_MAX_DIM
];
383 /* Size of outermost array currently being processed. */
384 static int sdb_type_size
= -1;
387 plain_type (tree type
)
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 (tree name
)
419 const char *ptr
= IDENTIFIER_POINTER (name
);
420 while (*ptr
&& *ptr
!= '<')
427 sdbout_record_type_name (tree type
)
429 const char *name
= 0;
432 if (KNOWN_TYPE_TAG (type
))
435 if (TYPE_NAME (type
) != 0)
439 /* Find the IDENTIFIER_NODE for the type name. */
440 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
441 t
= TYPE_NAME (type
);
442 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
444 t
= DECL_NAME (TYPE_NAME (type
));
445 /* The DECL_NAME for templates includes "<>", which breaks
446 most assemblers. Use its assembler name instead, which
447 has been mangled into being safe. */
448 if (t
&& template_name_p (t
))
449 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
452 /* Now get the name as a string, or invent one. */
454 name
= IDENTIFIER_POINTER (t
);
457 no_name
= (name
== 0 || *name
== 0);
459 name
= gen_fake_label ();
461 SET_KNOWN_TYPE_TAG (type
, name
);
462 #ifdef SDB_ALLOW_FORWARD_REFERENCES
464 sdbout_queue_anonymous_type (type
);
468 /* Return the .type value for type TYPE.
470 LEVEL indicates how many levels deep we have recursed into the type.
471 The SDB debug format can only represent 6 derived levels of types.
472 After that, we must output inaccurate debug info. We deliberately
473 stop before the 7th level, so that ADA recursive types will not give an
477 plain_type_1 (tree type
, int level
)
480 type
= void_type_node
;
481 else if (type
== error_mark_node
)
482 type
= integer_type_node
;
484 type
= TYPE_MAIN_VARIANT (type
);
486 switch (TREE_CODE (type
))
493 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
495 /* Carefully distinguish all the standard types of C,
496 without messing up if the language is not C.
497 Note that we check only for the names that contain spaces;
498 other names might occur by coincidence in other languages. */
499 if (TYPE_NAME (type
) != 0
500 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
501 && DECL_NAME (TYPE_NAME (type
)) != 0
502 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
504 const char *const name
505 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
507 if (!strcmp (name
, "char"))
509 if (!strcmp (name
, "unsigned char"))
511 if (!strcmp (name
, "signed char"))
513 if (!strcmp (name
, "int"))
515 if (!strcmp (name
, "unsigned int"))
517 if (!strcmp (name
, "short int"))
519 if (!strcmp (name
, "short unsigned int"))
521 if (!strcmp (name
, "long int"))
523 if (!strcmp (name
, "long unsigned int"))
527 if (size
== INT_TYPE_SIZE
)
528 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
529 if (size
== CHAR_TYPE_SIZE
)
530 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
531 if (size
== SHORT_TYPE_SIZE
)
532 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
533 if (size
== LONG_TYPE_SIZE
)
534 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
535 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
536 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
542 int precision
= TYPE_PRECISION (type
);
543 if (precision
== FLOAT_TYPE_SIZE
)
545 if (precision
== DOUBLE_TYPE_SIZE
)
547 #ifdef EXTENDED_SDB_BASIC_TYPES
548 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
551 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
552 return T_DOUBLE
; /* better than nothing */
563 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
564 if (sdb_n_dims
< SDB_MAX_DIM
)
565 sdb_dims
[sdb_n_dims
++]
566 = (TYPE_DOMAIN (type
)
567 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
568 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
569 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
570 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
571 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
572 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
575 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
580 case QUAL_UNION_TYPE
:
584 #ifdef SDB_ALLOW_FORWARD_REFERENCES
585 sdbout_record_type_name (type
);
587 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
588 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
589 #ifdef SDB_ALLOW_FORWARD_REFERENCES
590 || TYPE_MODE (type
) != VOIDmode
595 /* Output the referenced structure tag name
596 only if the .def has already been finished.
597 At least on 386, the Unix assembler
598 cannot handle forward references to tags. */
599 /* But the 88100, it requires them, sigh... */
600 /* And the MIPS requires unknown refs as well... */
601 tag
= KNOWN_TYPE_TAG (type
);
603 /* These 3 lines used to follow the close brace.
604 However, a size of 0 without a tag implies a tag of 0,
605 so if we don't know a tag, we can't mention the size. */
606 sdb_type_size
= int_size_in_bytes (type
);
607 if (sdb_type_size
< 0)
610 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
611 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
612 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
622 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
623 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
632 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
633 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
640 /* Output the symbols defined in block number DO_BLOCK.
642 This function works by walking the tree structure of blocks,
643 counting blocks until it finds the desired block. */
645 static int do_block
= 0;
648 sdbout_block (tree block
)
652 /* Ignore blocks never expanded or otherwise marked as real. */
653 if (TREE_USED (block
))
655 /* When we reach the specified block, output its symbols. */
656 if (BLOCK_NUMBER (block
) == do_block
)
657 sdbout_syms (BLOCK_VARS (block
));
659 /* If we are past the specified block, stop the scan. */
660 if (BLOCK_NUMBER (block
) > do_block
)
663 /* Scan the blocks within this block. */
664 sdbout_block (BLOCK_SUBBLOCKS (block
));
667 block
= BLOCK_CHAIN (block
);
671 /* Call sdbout_symbol on each decl in the chain SYMS. */
674 sdbout_syms (tree syms
)
678 if (TREE_CODE (syms
) != LABEL_DECL
)
679 sdbout_symbol (syms
, 1);
680 syms
= TREE_CHAIN (syms
);
684 /* Output SDB information for a symbol described by DECL.
685 LOCAL is nonzero if the symbol is not file-scope. */
688 sdbout_symbol (tree decl
, int local
)
690 tree type
= TREE_TYPE (decl
);
691 tree context
= NULL_TREE
;
696 /* If we are called before sdbout_init is run, just save the symbol
698 if (!sdbout_initialized
)
700 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
704 sdbout_one_type (type
);
706 switch (TREE_CODE (decl
))
709 /* Enum values are defined by defining the enum type. */
713 /* Don't mention a nested function under its parent. */
714 context
= decl_function_context (decl
);
715 if (context
== current_function_decl
)
717 /* Check DECL_INITIAL to distinguish declarations from definitions.
718 Don't output debug info here for declarations; they will have
719 a DECL_INITIAL value of 0. */
720 if (! DECL_INITIAL (decl
))
722 if (!MEM_P (DECL_RTL (decl
))
723 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
725 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
726 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
727 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
731 /* Done with tagged types. */
732 if (DECL_NAME (decl
) == 0)
734 if (DECL_IGNORED_P (decl
))
736 /* Don't output intrinsic types. GAS chokes on SDB .def
737 statements that contain identifiers with embedded spaces
738 (eg "unsigned long"). */
739 if (DECL_IS_BUILTIN (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. */
787 regno
= REGNO (value
);
788 if (regno
>= FIRST_PSEUDO_REGISTER
)
791 else if (GET_CODE (value
) == SUBREG
)
793 while (GET_CODE (value
) == SUBREG
)
794 value
= SUBREG_REG (value
);
797 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
800 regno
= REGNO (alter_subreg (&value
));
801 SET_DECL_RTL (decl
, value
);
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 (MEM_P (value
) && 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! */
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
));
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 (MEM_P (value
)
862 && (MEM_P (XEXP (value
, 0))
863 || (REG_P (XEXP (value
, 0))
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 (REG_P (XEXP (value
, 0)))
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 (MEM_P (value
)
897 && ((GET_CODE (XEXP (value
, 0)) == PLUS
898 && REG_P (XEXP (XEXP (value
, 0), 0))
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 || (REG_P (XEXP (value
, 0)))))
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
);
914 /* It is something we don't know how to represent for SDB. */
922 PUT_SDB_TYPE (plain_type (type
));
926 /* Output SDB information for a top-level initialized variable
927 that has been delayed. */
930 sdbout_toplevel_data (tree decl
)
932 tree type
= TREE_TYPE (decl
);
934 if (DECL_IGNORED_P (decl
))
937 gcc_assert (TREE_CODE (decl
) == VAR_DECL
);
938 gcc_assert (MEM_P (DECL_RTL (decl
)));
939 gcc_assert (DECL_INITIAL (decl
));
941 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
942 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
943 if (TREE_PUBLIC (decl
))
949 PUT_SDB_SCL (C_STAT
);
951 PUT_SDB_TYPE (plain_type (type
));
955 #ifdef SDB_ALLOW_FORWARD_REFERENCES
957 /* Machinery to record and output anonymous types. */
960 sdbout_queue_anonymous_type (tree type
)
962 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
966 sdbout_dequeue_anonymous_types (void)
970 while (anonymous_types
)
972 types
= nreverse (anonymous_types
);
973 anonymous_types
= NULL_TREE
;
975 for (link
= types
; link
; link
= TREE_CHAIN (link
))
977 tree type
= TREE_VALUE (link
);
979 if (type
&& ! TREE_ASM_WRITTEN (type
))
980 sdbout_one_type (type
);
987 /* Given a chain of ..._TYPE nodes, all of which have names,
988 output definitions of those names, as typedefs. */
991 sdbout_types (tree types
)
995 for (link
= types
; link
; link
= TREE_CHAIN (link
))
996 sdbout_one_type (link
);
998 #ifdef SDB_ALLOW_FORWARD_REFERENCES
999 sdbout_dequeue_anonymous_types ();
1004 sdbout_type (tree type
)
1006 if (type
== error_mark_node
)
1007 type
= integer_type_node
;
1008 PUT_SDB_TYPE (plain_type (type
));
1011 /* Output types of the fields of type TYPE, if they are structs.
1013 Formerly did not chase through pointer types, since that could be circular.
1014 They must come before TYPE, since forward refs are not allowed.
1015 Now james@bigtex.cactus.org says to try them. */
1018 sdbout_field_types (tree type
)
1022 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1023 /* This condition should match the one for emitting the actual
1025 if (TREE_CODE (tail
) == FIELD_DECL
1028 && host_integerp (DECL_SIZE (tail
), 1)
1029 && host_integerp (bit_position (tail
), 0))
1031 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1032 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1034 sdbout_one_type (TREE_TYPE (tail
));
1038 /* Use this to put out the top level defined record and union types
1039 for later reference. If this is a struct with a name, then put that
1040 name out. Other unnamed structs will have .xxfake labels generated so
1041 that they may be referred to later.
1042 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1043 It may NOT be called recursively. */
1046 sdbout_one_type (tree type
)
1048 if (current_function_decl
!= NULL_TREE
1049 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1050 ; /* Don't change section amid function. */
1052 switch_to_section (text_section
);
1054 switch (TREE_CODE (type
))
1058 case QUAL_UNION_TYPE
:
1060 type
= TYPE_MAIN_VARIANT (type
);
1061 /* Don't output a type twice. */
1062 if (TREE_ASM_WRITTEN (type
))
1063 /* James said test TREE_ASM_BEING_WRITTEN here. */
1066 /* Output nothing if type is not yet defined. */
1067 if (!COMPLETE_TYPE_P (type
))
1070 TREE_ASM_WRITTEN (type
) = 1;
1072 /* This is reputed to cause trouble with the following case,
1073 but perhaps checking TYPE_SIZE above will fix it. */
1075 /* Here is a testcase:
1081 typedef struct intermediate {
1085 typedef struct badstr {
1089 /* This change, which ought to make better output,
1090 used to make the COFF assembler unhappy.
1091 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1092 /* Before really doing anything, output types we want to refer to. */
1093 /* Note that in version 1 the following two lines
1094 are not used if forward references are in use. */
1095 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1096 sdbout_field_types (type
);
1098 /* Output a structure type. */
1100 int size
= int_size_in_bytes (type
);
1104 /* Record the type tag, but not in its permanent place just yet. */
1105 sdbout_record_type_name (type
);
1107 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1109 switch (TREE_CODE (type
))
1112 case QUAL_UNION_TYPE
:
1113 PUT_SDB_SCL (C_UNTAG
);
1114 PUT_SDB_TYPE (T_UNION
);
1119 PUT_SDB_SCL (C_STRTAG
);
1120 PUT_SDB_TYPE (T_STRUCT
);
1125 PUT_SDB_SCL (C_ENTAG
);
1126 PUT_SDB_TYPE (T_ENUM
);
1134 PUT_SDB_SIZE (size
);
1137 /* Print out the base class information with fields
1138 named after the types they hold. */
1139 /* This is only relevant to aggregate types. TYPE_BINFO is used
1140 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1142 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1147 for (binfo
= TYPE_BINFO (type
), i
= 0;
1148 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1150 tree child_type
= BINFO_TYPE (child
);
1151 tree child_type_name
;
1153 if (TYPE_NAME (child_type
) == 0)
1155 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1156 child_type_name
= TYPE_NAME (child_type
);
1157 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1159 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1160 if (child_type_name
&& template_name_p (child_type_name
))
1162 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1167 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1168 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1169 PUT_SDB_SCL (member_scl
);
1170 sdbout_type (BINFO_TYPE (child
));
1175 /* Output the individual fields. */
1177 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1179 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1180 if (host_integerp (TREE_VALUE (tem
), 0))
1182 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1183 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1184 PUT_SDB_SCL (C_MOE
);
1185 PUT_SDB_TYPE (T_MOE
);
1189 else /* record or union type */
1190 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1191 /* Output the name, type, position (in bits), size (in bits)
1194 /* Omit here the nameless fields that are used to skip bits.
1195 Also omit fields with variable size or position.
1196 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1197 if (TREE_CODE (tem
) == FIELD_DECL
1200 && host_integerp (DECL_SIZE (tem
), 1)
1201 && host_integerp (bit_position (tem
), 0))
1205 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1207 if (DECL_BIT_FIELD_TYPE (tem
))
1209 PUT_SDB_INT_VAL (int_bit_position (tem
));
1210 PUT_SDB_SCL (C_FIELD
);
1211 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1212 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1216 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1217 PUT_SDB_SCL (member_scl
);
1218 sdbout_type (TREE_TYPE (tem
));
1222 /* Output end of a structure,union, or enumeral definition. */
1224 PUT_SDB_PLAIN_DEF ("eos");
1225 PUT_SDB_INT_VAL (size
);
1226 PUT_SDB_SCL (C_EOS
);
1227 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1228 PUT_SDB_SIZE (size
);
1238 /* The following two functions output definitions of function parameters.
1239 Each parameter gets a definition locating it in the parameter list.
1240 Each parameter that is a register variable gets a second definition
1241 locating it in the register.
1243 Printing or argument lists in gdb uses the definitions that
1244 locate in the parameter list. But reference to the variable in
1245 expressions uses preferentially the definition as a register. */
1247 /* Output definitions, referring to storage in the parmlist,
1248 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1251 sdbout_parms (tree parms
)
1253 for (; parms
; parms
= TREE_CHAIN (parms
))
1254 if (DECL_NAME (parms
))
1256 int current_sym_value
= 0;
1257 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1259 if (name
== 0 || *name
== 0)
1260 name
= gen_fake_label ();
1262 /* Perform any necessary register eliminations on the parameter's rtl,
1263 so that the debugging output will be accurate. */
1264 DECL_INCOMING_RTL (parms
)
1265 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1266 SET_DECL_RTL (parms
,
1267 eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
1269 if (PARM_PASSED_IN_MEMORY (parms
))
1271 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1274 /* ??? Here we assume that the parm address is indexed
1275 off the frame pointer or arg pointer.
1276 If that is not true, we produce meaningless results,
1277 but do not crash. */
1278 if (GET_CODE (addr
) == PLUS
1279 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1280 current_sym_value
= INTVAL (XEXP (addr
, 1));
1282 current_sym_value
= 0;
1284 if (REG_P (DECL_RTL (parms
))
1285 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1286 type
= DECL_ARG_TYPE (parms
);
1289 int original_sym_value
= current_sym_value
;
1291 /* This is the case where the parm is passed as an int or
1292 double and it is converted to a char, short or float
1293 and stored back in the parmlist. In this case, describe
1294 the parm with the variable's declared type, and adjust
1295 the address if the least significant bytes (which we are
1296 using) are not the first ones. */
1297 if (BYTES_BIG_ENDIAN
1298 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1299 current_sym_value
+=
1300 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1301 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1303 if (MEM_P (DECL_RTL (parms
))
1304 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1305 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1307 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1308 == current_sym_value
))
1309 type
= TREE_TYPE (parms
);
1312 current_sym_value
= original_sym_value
;
1313 type
= DECL_ARG_TYPE (parms
);
1318 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1319 PUT_SDB_SCL (C_ARG
);
1320 PUT_SDB_TYPE (plain_type (type
));
1323 else if (REG_P (DECL_RTL (parms
)))
1326 /* Parm passed in registers and lives in registers or nowhere. */
1328 /* If parm lives in a register, use that register;
1329 pretend the parm was passed there. It would be more consistent
1330 to describe the register where the parm was passed,
1331 but in practice that register usually holds something else. */
1332 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1333 best_rtl
= DECL_RTL (parms
);
1334 /* If the parm lives nowhere,
1335 use the register where it was passed. */
1337 best_rtl
= DECL_INCOMING_RTL (parms
);
1340 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1341 PUT_SDB_SCL (C_REGPARM
);
1342 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1345 else if (MEM_P (DECL_RTL (parms
))
1346 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1348 /* Parm was passed in registers but lives on the stack. */
1350 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1351 in which case we want the value of that CONST_INT,
1352 or (MEM (REG ...)) or (MEM (MEM ...)),
1353 in which case we use a value of zero. */
1354 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1355 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1356 current_sym_value
= 0;
1358 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1360 /* Again, this assumes the offset is based on the arg pointer. */
1362 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1363 XEXP (DECL_RTL (parms
), 0)));
1364 PUT_SDB_SCL (C_ARG
);
1365 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1371 /* Output definitions for the places where parms live during the function,
1372 when different from where they were passed, when the parms were passed
1375 It is not useful to do this for parms passed in registers
1376 that live during the function in different registers, because it is
1377 impossible to look in the passed register for the passed value,
1378 so we use the within-the-function register to begin with.
1380 PARMS is a chain of PARM_DECL nodes. */
1383 sdbout_reg_parms (tree parms
)
1385 for (; parms
; parms
= TREE_CHAIN (parms
))
1386 if (DECL_NAME (parms
))
1388 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1390 /* Report parms that live in registers during the function
1391 but were passed in memory. */
1392 if (REG_P (DECL_RTL (parms
))
1393 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1394 && PARM_PASSED_IN_MEMORY (parms
))
1396 if (name
== 0 || *name
== 0)
1397 name
= gen_fake_label ();
1399 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1400 PUT_SDB_SCL (C_REG
);
1401 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1404 /* Report parms that live in memory but not where they were passed. */
1405 else if (MEM_P (DECL_RTL (parms
))
1406 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1407 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1408 && PARM_PASSED_IN_MEMORY (parms
)
1409 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1411 #if 0 /* ??? It is not clear yet what should replace this. */
1412 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1413 /* A parm declared char is really passed as an int,
1414 so it occupies the least significant bytes.
1415 On a big-endian machine those are not the low-numbered ones. */
1416 if (BYTES_BIG_ENDIAN
1418 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1419 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1420 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1421 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1424 if (name
== 0 || *name
== 0)
1425 name
= gen_fake_label ();
1427 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1428 (XEXP (DECL_RTL (parms
), 0)));
1429 PUT_SDB_SCL (C_AUTO
);
1430 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1437 /* Output debug information for a global DECL. Called from toplev.c
1438 after compilation proper has finished. */
1441 sdbout_global_decl (tree decl
)
1443 if (TREE_CODE (decl
) == VAR_DECL
1444 && !DECL_EXTERNAL (decl
)
1445 && DECL_RTL_SET_P (decl
))
1447 /* The COFF linker can move initialized global vars to the end.
1448 And that can screw up the symbol ordering. Defer those for
1449 sdbout_finish (). */
1450 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1451 sdbout_symbol (decl
, 0);
1453 VARRAY_PUSH_TREE (deferred_global_decls
, decl
);
1455 /* Output COFF information for non-global file-scope initialized
1457 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1458 sdbout_toplevel_data (decl
);
1462 /* Output initialized global vars at the end, in the order of
1463 definition. See comment in sdbout_global_decl. */
1466 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1470 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (deferred_global_decls
); i
++)
1471 sdbout_symbol (VARRAY_TREE (deferred_global_decls
, i
), 0);
1474 /* Describe the beginning of an internal block within a function.
1475 Also output descriptions of variables defined in this block.
1477 N is the number of the block, by order of beginning, counting from 1,
1478 and not counting the outermost (function top-level) block.
1479 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1480 if the count starts at 0 for the outermost one. */
1483 sdbout_begin_block (unsigned int line
, unsigned int n
)
1485 tree decl
= current_function_decl
;
1486 MAKE_LINE_SAFE (line
);
1488 /* The SCO compiler does not emit a separate block for the function level
1489 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1490 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1491 #ifndef MIPS_DEBUGGING_INFO
1494 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1498 /* Include the outermost BLOCK's variables in block 1. */
1499 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1500 sdbout_block (DECL_INITIAL (decl
));
1502 /* If -g1, suppress all the internal symbols of functions
1503 except for arguments. */
1504 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1507 sdbout_block (DECL_INITIAL (decl
));
1510 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1511 sdbout_dequeue_anonymous_types ();
1515 /* Describe the end line-number of an internal block within a function. */
1518 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1520 MAKE_LINE_SAFE (line
);
1522 /* The SCO compiler does not emit a separate block for the function level
1523 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1524 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1525 #ifndef MIPS_DEBUGGING_INFO
1528 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1531 /* Output a line number symbol entry for source file FILENAME and line
1535 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
)
1537 /* COFF relative line numbers must be positive. */
1538 if ((int) line
> sdb_begin_function_line
)
1540 #ifdef SDB_OUTPUT_SOURCE_LINE
1541 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1543 fprintf (asm_out_file
, "\t.ln\t%d\n",
1544 ((sdb_begin_function_line
> -1)
1545 ? line
- sdb_begin_function_line
: 1));
1550 /* Output sdb info for the current function name.
1551 Called from assemble_start_function. */
1554 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1556 sdbout_symbol (current_function_decl
, 0);
1559 /* Called at beginning of function body (before or after prologue,
1560 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1561 line number, so we can output relative line numbers for the other
1562 lines. Describe beginning of outermost block. Also describe the
1565 #ifndef MIPS_DEBUGGING_INFO
1567 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1569 sdbout_end_prologue (line
, file
);
1574 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1576 sdb_begin_function_line
= line
- 1;
1577 PUT_SDB_FUNCTION_START (line
);
1578 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1579 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1582 /* Called at end of function (before epilogue).
1583 Describe end of outermost block. */
1586 sdbout_end_function (unsigned int line
)
1588 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1589 sdbout_dequeue_anonymous_types ();
1592 MAKE_LINE_SAFE (line
);
1593 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1595 /* Indicate we are between functions, for line-number output. */
1596 sdb_begin_function_line
= -1;
1599 /* Output sdb info for the absolute end of a function.
1600 Called after the epilogue is output. */
1603 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1604 const char *file ATTRIBUTE_UNUSED
)
1606 const char *const name ATTRIBUTE_UNUSED
1607 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1609 #ifdef PUT_SDB_EPILOGUE_END
1610 PUT_SDB_EPILOGUE_END (name
);
1612 fprintf (asm_out_file
, "\t.def\t");
1613 assemble_name (asm_out_file
, name
);
1614 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1615 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1619 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1623 sdbout_label (rtx insn
)
1625 PUT_SDB_DEF (LABEL_NAME (insn
));
1627 PUT_SDB_SCL (C_LABEL
);
1628 PUT_SDB_TYPE (T_NULL
);
1632 /* Change to reading from a new source file. */
1635 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1636 const char *filename ATTRIBUTE_UNUSED
)
1638 #ifdef MIPS_DEBUGGING_INFO
1639 struct sdb_file
*n
= XNEW (struct sdb_file
);
1641 n
->next
= current_file
;
1644 output_file_directive (asm_out_file
, filename
);
1648 /* Revert to reading a previous source file. */
1651 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1653 #ifdef MIPS_DEBUGGING_INFO
1654 struct sdb_file
*next
;
1656 next
= current_file
->next
;
1657 free (current_file
);
1658 current_file
= next
;
1659 output_file_directive (asm_out_file
, current_file
->name
);
1663 /* Set up for SDB output at the start of compilation. */
1666 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1670 #ifdef MIPS_DEBUGGING_INFO
1671 current_file
= XNEW (struct sdb_file
);
1672 current_file
->next
= NULL
;
1673 current_file
->name
= input_file_name
;
1676 VARRAY_TREE_INIT (deferred_global_decls
, 12, "deferred_global_decls");
1678 /* Emit debug information which was queued by sdbout_symbol before
1680 sdbout_initialized
= true;
1682 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1683 sdbout_symbol (TREE_VALUE (t
), 0);
1684 preinit_symbols
= 0;
1687 #else /* SDB_DEBUGGING_INFO */
1689 /* This should never be used, but its address is needed for comparisons. */
1690 const struct gcc_debug_hooks sdb_debug_hooks
;
1692 #endif /* SDB_DEBUGGING_INFO */
1694 #include "gt-sdbout.h"