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 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"
53 static GTY(()) tree anonymous_types;
55 /* Counter to generate unique "names" for nameless struct members. */
57 static GTY(()) int unnamed_struct_number;
59 /* Declarations whose debug info was deferred till end of compilation. */
61 static GTY(()) varray_type deferred_global_decls;
63 /* The C front end may call sdbout_symbol before sdbout_init runs.
64 We save all such decls in this list and output them when we get
67 static GTY(()) tree preinit_symbols;
68 static GTY(()) bool sdbout_initialized;
70 #ifdef SDB_DEBUGGING_INFO
75 #include "insn-config.h"
81 #include "langhooks.h"
84 /* 1 if PARM is passed to this function in memory. */
86 #define PARM_PASSED_IN_MEMORY(PARM) \
87 (MEM_P (DECL_INCOMING_RTL (PARM)))
89 /* A C expression for the integer offset value of an automatic variable
90 (C_AUTO) having address X (an RTX). */
91 #ifndef DEBUGGER_AUTO_OFFSET
92 #define DEBUGGER_AUTO_OFFSET(X) \
93 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
96 /* A C expression for the integer offset value of an argument (C_ARG)
97 having address X (an RTX). The nominal offset is OFFSET. */
98 #ifndef DEBUGGER_ARG_OFFSET
99 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
102 /* Line number of beginning of current function, minus one.
103 Negative means not in a function or not using sdb. */
105 int sdb_begin_function_line = -1;
108 extern FILE *asm_out_file;
110 extern tree current_function_decl;
114 static void sdbout_init (const char *);
115 static void sdbout_finish (const char *);
116 static void sdbout_start_source_file (unsigned int, const char *);
117 static void sdbout_end_source_file (unsigned int);
118 static void sdbout_begin_block (unsigned int, unsigned int);
119 static void sdbout_end_block (unsigned int, unsigned int);
120 static void sdbout_source_line (unsigned int, const char *);
121 static void sdbout_end_epilogue (unsigned int, const char *);
122 static void sdbout_global_decl (tree);
123 #ifndef MIPS_DEBUGGING_INFO
124 static void sdbout_begin_prologue (unsigned int, const char *);
126 static void sdbout_end_prologue (unsigned int, const char *);
127 static void sdbout_begin_function (tree);
128 static void sdbout_end_function (unsigned int);
129 static void sdbout_toplevel_data (tree);
130 static void sdbout_label (rtx);
131 static char *gen_fake_label (void);
132 static int plain_type (tree);
133 static int template_name_p (tree);
134 static void sdbout_record_type_name (tree);
135 static int plain_type_1 (tree, int);
136 static void sdbout_block (tree);
137 static void sdbout_syms (tree);
138 #ifdef SDB_ALLOW_FORWARD_REFERENCES
139 static void sdbout_queue_anonymous_type (tree);
140 static void sdbout_dequeue_anonymous_types (void);
142 static void sdbout_type (tree);
143 static void sdbout_field_types (tree);
144 static void sdbout_one_type (tree);
145 static void sdbout_parms (tree);
146 static void sdbout_reg_parms (tree);
147 static void sdbout_global_decl (tree);
149 /* Random macros describing parts of SDB data. */
151 /* Default value of delimiter is ";". */
153 #define SDB_DELIM ";"
156 /* Maximum number of dimensions the assembler will allow. */
158 #define SDB_MAX_DIM 4
162 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
165 #ifndef PUT_SDB_INT_VAL
166 #define PUT_SDB_INT_VAL(a) \
168 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
169 (HOST_WIDE_INT) (a), SDB_DELIM); \
175 #define PUT_SDB_VAL(a) \
176 ( fputs ("\t.val\t", asm_out_file), \
177 output_addr_const (asm_out_file, (a)), \
178 fprintf (asm_out_file, SDB_DELIM))
182 #define PUT_SDB_DEF(a) \
183 do { fprintf (asm_out_file, "\t.def\t"); \
184 assemble_name (asm_out_file, a); \
185 fprintf (asm_out_file, SDB_DELIM); } while (0)
188 #ifndef PUT_SDB_PLAIN_DEF
189 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
192 #ifndef PUT_SDB_ENDEF
193 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
197 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
201 #define PUT_SDB_SIZE(a) \
203 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
204 (HOST_WIDE_INT) (a), SDB_DELIM); \
208 #ifndef PUT_SDB_START_DIM
209 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
212 #ifndef PUT_SDB_NEXT_DIM
213 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
216 #ifndef PUT_SDB_LAST_DIM
217 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
221 #define PUT_SDB_TAG(a) \
222 do { fprintf (asm_out_file, "\t.tag\t"); \
223 assemble_name (asm_out_file, a); \
224 fprintf (asm_out_file, SDB_DELIM); } while (0)
227 #ifndef PUT_SDB_BLOCK_START
228 #define PUT_SDB_BLOCK_START(LINE) \
229 fprintf (asm_out_file, \
230 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
231 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
234 #ifndef PUT_SDB_BLOCK_END
235 #define PUT_SDB_BLOCK_END(LINE) \
236 fprintf (asm_out_file, \
237 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
238 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
241 #ifndef PUT_SDB_FUNCTION_START
242 #define PUT_SDB_FUNCTION_START(LINE) \
243 fprintf (asm_out_file, \
244 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
245 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
248 #ifndef PUT_SDB_FUNCTION_END
249 #define PUT_SDB_FUNCTION_END(LINE) \
250 fprintf (asm_out_file, \
251 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
252 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
255 #ifndef SDB_GENERATE_FAKE
256 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
257 sprintf ((BUFFER), ".%dfake", (NUMBER));
260 /* Return the sdb tag identifier string for TYPE
261 if TYPE has already been defined; otherwise return a null pointer. */
263 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
265 /* Set the sdb tag identifier string for TYPE to NAME. */
267 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
268 TYPE_SYMTAB_POINTER (TYPE) = (char *)(NAME)
270 /* Return the name (a string) of the struct, union or enum tag
271 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
273 #define TAG_NAME(link) \
274 (((link) && TREE_PURPOSE ((link)) \
275 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
276 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
278 /* Ensure we don't output a negative line number. */
279 #define MAKE_LINE_SAFE(line) \
280 if ((int) line <= sdb_begin_function_line) \
281 line = sdb_begin_function_line + 1
283 /* Perform linker optimization of merging header file definitions together
284 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
285 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
286 the optimization just won't be done. The native assembler already has the
287 necessary support. */
289 #ifdef MIPS_DEBUGGING_INFO
291 /* ECOFF linkers have an optimization that does the same kind of thing as
292 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
293 executable. To achieve this, GCC must output a .file for each file
296 /* This is a stack of input files. */
300 struct sdb_file *next;
304 /* This is the top of the stack. */
306 static struct sdb_file *current_file;
308 #endif /* MIPS_DEBUGGING_INFO */
310 /* The debug hooks structure. */
311 const struct gcc_debug_hooks sdb_debug_hooks =
313 sdbout_init, /* init */
314 sdbout_finish, /* finish */
315 debug_nothing_int_charstar, /* define */
316 debug_nothing_int_charstar, /* undef */
317 sdbout_start_source_file, /* start_source_file */
318 sdbout_end_source_file, /* end_source_file */
319 sdbout_begin_block, /* begin_block */
320 sdbout_end_block, /* end_block */
321 debug_true_tree, /* ignore_block */
322 sdbout_source_line, /* source_line */
323 #ifdef MIPS_DEBUGGING_INFO
324 /* Defer on MIPS systems so that parameter descriptions follow
326 debug_nothing_int_charstar, /* begin_prologue */
327 sdbout_end_prologue, /* end_prologue */
329 sdbout_begin_prologue, /* begin_prologue */
330 debug_nothing_int_charstar, /* end_prologue */
332 sdbout_end_epilogue, /* end_epilogue */
333 sdbout_begin_function, /* begin_function */
334 sdbout_end_function, /* end_function */
335 debug_nothing_tree, /* function_decl */
336 sdbout_global_decl, /* global_decl */
337 sdbout_symbol, /* type_decl */
338 debug_nothing_tree_tree, /* imported_module_or_decl */
339 debug_nothing_tree, /* deferred_inline_function */
340 debug_nothing_tree, /* outlining_inline_function */
341 sdbout_label, /* label */
342 debug_nothing_int, /* handle_pch */
343 debug_nothing_rtx /* var_location */
346 /* Return a unique string to name an anonymous type. */
349 gen_fake_label (void)
353 SDB_GENERATE_FAKE (label, unnamed_struct_number);
354 unnamed_struct_number++;
355 labelstr = xstrdup (label);
359 /* Return the number which describes TYPE for SDB.
360 For pointers, etc., this function is recursive.
361 Each record, union or enumeral type must already have had a
362 tag number output. */
364 /* The number is given by d6d5d4d3d2d1bbbb
365 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
366 Thus, char *foo () has bbbb=T_CHAR
369 N_BTMASK= 017 1111 basic type field.
370 N_TSHIFT= 2 derived type shift
371 N_BTSHFT= 4 Basic type shift */
373 /* Produce the number that describes a pointer, function or array type.
374 PREV is the number describing the target, value or element type.
375 DT_type describes how to transform that type. */
376 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
377 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
378 | ((int) DT_type << (int) N_BTSHFT) \
379 | ((PREV) & (int) N_BTMASK))
381 /* Number of elements used in sdb_dims. */
382 static int sdb_n_dims = 0;
384 /* Table of array dimensions of current type. */
385 static int sdb_dims[SDB_MAX_DIM];
387 /* Size of outermost array currently being processed. */
388 static int sdb_type_size = -1;
391 plain_type (tree type)
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 (tree name)
423 const char *ptr = IDENTIFIER_POINTER (name);
424 while (*ptr && *ptr != '<')
431 sdbout_record_type_name (tree type)
433 const char *name = 0;
436 if (KNOWN_TYPE_TAG (type))
439 if (TYPE_NAME (type) != 0)
443 /* Find the IDENTIFIER_NODE for the type name. */
444 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
445 t = TYPE_NAME (type);
446 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
448 t = DECL_NAME (TYPE_NAME (type));
449 /* The DECL_NAME for templates includes "<>", which breaks
450 most assemblers. Use its assembler name instead, which
451 has been mangled into being safe. */
452 if (t && template_name_p (t))
453 t = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
456 /* Now get the name as a string, or invent one. */
458 name = IDENTIFIER_POINTER (t);
461 no_name = (name == 0 || *name == 0);
463 name = gen_fake_label ();
465 SET_KNOWN_TYPE_TAG (type, name);
466 #ifdef SDB_ALLOW_FORWARD_REFERENCES
468 sdbout_queue_anonymous_type (type);
472 /* Return the .type value for type TYPE.
474 LEVEL indicates how many levels deep we have recursed into the type.
475 The SDB debug format can only represent 6 derived levels of types.
476 After that, we must output inaccurate debug info. We deliberately
477 stop before the 7th level, so that ADA recursive types will not give an
481 plain_type_1 (tree type, int level)
484 type = void_type_node;
485 else if (type == error_mark_node)
486 type = integer_type_node;
488 type = TYPE_MAIN_VARIANT (type);
490 switch (TREE_CODE (type))
497 int size = int_size_in_bytes (type) * BITS_PER_UNIT;
499 /* Carefully distinguish all the standard types of C,
500 without messing up if the language is not C.
501 Note that we check only for the names that contain spaces;
502 other names might occur by coincidence in other languages. */
503 if (TYPE_NAME (type) != 0
504 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
505 && DECL_NAME (TYPE_NAME (type)) != 0
506 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
508 const char *const name
509 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
511 if (!strcmp (name, "char"))
513 if (!strcmp (name, "unsigned char"))
515 if (!strcmp (name, "signed char"))
517 if (!strcmp (name, "int"))
519 if (!strcmp (name, "unsigned int"))
521 if (!strcmp (name, "short int"))
523 if (!strcmp (name, "short unsigned int"))
525 if (!strcmp (name, "long int"))
527 if (!strcmp (name, "long unsigned int"))
531 if (size == INT_TYPE_SIZE)
532 return (TYPE_UNSIGNED (type) ? T_UINT : T_INT);
533 if (size == CHAR_TYPE_SIZE)
534 return (TYPE_UNSIGNED (type) ? T_UCHAR : T_CHAR);
535 if (size == SHORT_TYPE_SIZE)
536 return (TYPE_UNSIGNED (type) ? T_USHORT : T_SHORT);
537 if (size == LONG_TYPE_SIZE)
538 return (TYPE_UNSIGNED (type) ? T_ULONG : T_LONG);
539 if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */
540 return (TYPE_UNSIGNED (type) ? T_ULONG : T_LONG);
546 int precision = TYPE_PRECISION (type);
547 if (precision == FLOAT_TYPE_SIZE)
549 if (precision == DOUBLE_TYPE_SIZE)
551 #ifdef EXTENDED_SDB_BASIC_TYPES
552 if (precision == LONG_DOUBLE_TYPE_SIZE)
555 if (precision == LONG_DOUBLE_TYPE_SIZE)
556 return T_DOUBLE; /* better than nothing */
567 m = plain_type_1 (TREE_TYPE (type), level+1);
568 if (sdb_n_dims < SDB_MAX_DIM)
569 sdb_dims[sdb_n_dims++]
570 = (TYPE_DOMAIN (type)
571 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
572 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
573 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
574 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0)
575 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
576 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1)
579 return PUSH_DERIVED_LEVEL (DT_ARY, m);
584 case QUAL_UNION_TYPE:
588 #ifdef SDB_ALLOW_FORWARD_REFERENCES
589 sdbout_record_type_name (type);
591 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
592 if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0)
593 #ifdef SDB_ALLOW_FORWARD_REFERENCES
594 || TYPE_MODE (type) != VOIDmode
599 /* Output the referenced structure tag name
600 only if the .def has already been finished.
601 At least on 386, the Unix assembler
602 cannot handle forward references to tags. */
603 /* But the 88100, it requires them, sigh... */
604 /* And the MIPS requires unknown refs as well... */
605 tag = KNOWN_TYPE_TAG (type);
607 /* These 3 lines used to follow the close brace.
608 However, a size of 0 without a tag implies a tag of 0,
609 so if we don't know a tag, we can't mention the size. */
610 sdb_type_size = int_size_in_bytes (type);
611 if (sdb_type_size < 0)
614 return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT
615 : (TREE_CODE (type) == UNION_TYPE) ? T_UNION
616 : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION
626 m = plain_type_1 (TREE_TYPE (type), level+1);
627 return PUSH_DERIVED_LEVEL (DT_PTR, m);
636 m = plain_type_1 (TREE_TYPE (type), level+1);
637 return PUSH_DERIVED_LEVEL (DT_FCN, m);
644 /* Output the symbols defined in block number DO_BLOCK.
646 This function works by walking the tree structure of blocks,
647 counting blocks until it finds the desired block. */
649 static int do_block = 0;
652 sdbout_block (tree block)
656 /* Ignore blocks never expanded or otherwise marked as real. */
657 if (TREE_USED (block))
659 /* When we reach the specified block, output its symbols. */
660 if (BLOCK_NUMBER (block) == do_block)
661 sdbout_syms (BLOCK_VARS (block));
663 /* If we are past the specified block, stop the scan. */
664 if (BLOCK_NUMBER (block) > do_block)
667 /* Scan the blocks within this block. */
668 sdbout_block (BLOCK_SUBBLOCKS (block));
671 block = BLOCK_CHAIN (block);
675 /* Call sdbout_symbol on each decl in the chain SYMS. */
678 sdbout_syms (tree syms)
682 if (TREE_CODE (syms) != LABEL_DECL)
683 sdbout_symbol (syms, 1);
684 syms = TREE_CHAIN (syms);
688 /* Output SDB information for a symbol described by DECL.
689 LOCAL is nonzero if the symbol is not file-scope. */
692 sdbout_symbol (tree decl, int local)
694 tree type = TREE_TYPE (decl);
695 tree context = NULL_TREE;
700 /* If we are called before sdbout_init is run, just save the symbol
702 if (!sdbout_initialized)
704 preinit_symbols = tree_cons (0, decl, preinit_symbols);
708 sdbout_one_type (type);
710 switch (TREE_CODE (decl))
713 /* Enum values are defined by defining the enum type. */
717 /* Don't mention a nested function under its parent. */
718 context = decl_function_context (decl);
719 if (context == current_function_decl)
721 /* Check DECL_INITIAL to distinguish declarations from definitions.
722 Don't output debug info here for declarations; they will have
723 a DECL_INITIAL value of 0. */
724 if (! DECL_INITIAL (decl))
726 if (!MEM_P (DECL_RTL (decl))
727 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
729 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
730 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
731 PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT);
735 /* Done with tagged types. */
736 if (DECL_NAME (decl) == 0)
738 if (DECL_IGNORED_P (decl))
740 /* Don't output intrinsic types. GAS chokes on SDB .def
741 statements that contain identifiers with embedded spaces
742 (eg "unsigned long"). */
743 if (DECL_IS_BUILTIN (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. */
791 regno = REGNO (value);
792 if (regno >= FIRST_PSEUDO_REGISTER)
795 else if (GET_CODE (value) == SUBREG)
797 while (GET_CODE (value) == SUBREG)
798 value = SUBREG_REG (value);
801 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
804 regno = REGNO (alter_subreg (&value));
805 SET_DECL_RTL (decl, value);
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 (MEM_P (value) && 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! */
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));
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 (MEM_P (value)
866 && (MEM_P (XEXP (value, 0))
867 || (REG_P (XEXP (value, 0))
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 (REG_P (XEXP (value, 0)))
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 (MEM_P (value)
901 && ((GET_CODE (XEXP (value, 0)) == PLUS
902 && REG_P (XEXP (XEXP (value, 0), 0))
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 || (REG_P (XEXP (value, 0)))))
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);
918 /* It is something we don't know how to represent for SDB. */
926 PUT_SDB_TYPE (plain_type (type));
930 /* Output SDB information for a top-level initialized variable
931 that has been delayed. */
934 sdbout_toplevel_data (tree decl)
936 tree type = TREE_TYPE (decl);
938 if (DECL_IGNORED_P (decl))
941 gcc_assert (TREE_CODE (decl) == VAR_DECL);
942 gcc_assert (MEM_P (DECL_RTL (decl)));
943 gcc_assert (DECL_INITIAL (decl));
945 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
946 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
947 if (TREE_PUBLIC (decl))
953 PUT_SDB_SCL (C_STAT);
955 PUT_SDB_TYPE (plain_type (type));
959 #ifdef SDB_ALLOW_FORWARD_REFERENCES
961 /* Machinery to record and output anonymous types. */
964 sdbout_queue_anonymous_type (tree type)
966 anonymous_types = tree_cons (NULL_TREE, type, anonymous_types);
970 sdbout_dequeue_anonymous_types (void)
974 while (anonymous_types)
976 types = nreverse (anonymous_types);
977 anonymous_types = NULL_TREE;
979 for (link = types; link; link = TREE_CHAIN (link))
981 tree type = TREE_VALUE (link);
983 if (type && ! TREE_ASM_WRITTEN (type))
984 sdbout_one_type (type);
991 /* Given a chain of ..._TYPE nodes, all of which have names,
992 output definitions of those names, as typedefs. */
995 sdbout_types (tree types)
999 for (link = types; link; link = TREE_CHAIN (link))
1000 sdbout_one_type (link);
1002 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1003 sdbout_dequeue_anonymous_types ();
1008 sdbout_type (tree type)
1010 if (type == error_mark_node)
1011 type = integer_type_node;
1012 PUT_SDB_TYPE (plain_type (type));
1015 /* Output types of the fields of type TYPE, if they are structs.
1017 Formerly did not chase through pointer types, since that could be circular.
1018 They must come before TYPE, since forward refs are not allowed.
1019 Now james@bigtex.cactus.org says to try them. */
1022 sdbout_field_types (tree type)
1026 for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
1027 /* This condition should match the one for emitting the actual
1029 if (TREE_CODE (tail) == FIELD_DECL
1032 && host_integerp (DECL_SIZE (tail), 1)
1033 && host_integerp (bit_position (tail), 0))
1035 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1036 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1038 sdbout_one_type (TREE_TYPE (tail));
1042 /* Use this to put out the top level defined record and union types
1043 for later reference. If this is a struct with a name, then put that
1044 name out. Other unnamed structs will have .xxfake labels generated so
1045 that they may be referred to later.
1046 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1047 It may NOT be called recursively. */
1050 sdbout_one_type (tree type)
1052 if (current_function_decl != NULL_TREE
1053 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
1054 ; /* Don't change section amid function. */
1058 switch (TREE_CODE (type))
1062 case QUAL_UNION_TYPE:
1064 type = TYPE_MAIN_VARIANT (type);
1065 /* Don't output a type twice. */
1066 if (TREE_ASM_WRITTEN (type))
1067 /* James said test TREE_ASM_BEING_WRITTEN here. */
1070 /* Output nothing if type is not yet defined. */
1071 if (!COMPLETE_TYPE_P (type))
1074 TREE_ASM_WRITTEN (type) = 1;
1076 /* This is reputed to cause trouble with the following case,
1077 but perhaps checking TYPE_SIZE above will fix it. */
1079 /* Here is a testcase:
1085 typedef struct intermediate {
1089 typedef struct badstr {
1093 /* This change, which ought to make better output,
1094 used to make the COFF assembler unhappy.
1095 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1096 /* Before really doing anything, output types we want to refer to. */
1097 /* Note that in version 1 the following two lines
1098 are not used if forward references are in use. */
1099 if (TREE_CODE (type) != ENUMERAL_TYPE)
1100 sdbout_field_types (type);
1102 /* Output a structure type. */
1104 int size = int_size_in_bytes (type);
1108 /* Record the type tag, but not in its permanent place just yet. */
1109 sdbout_record_type_name (type);
1111 PUT_SDB_DEF (KNOWN_TYPE_TAG (type));
1113 switch (TREE_CODE (type))
1116 case QUAL_UNION_TYPE:
1117 PUT_SDB_SCL (C_UNTAG);
1118 PUT_SDB_TYPE (T_UNION);
1123 PUT_SDB_SCL (C_STRTAG);
1124 PUT_SDB_TYPE (T_STRUCT);
1129 PUT_SDB_SCL (C_ENTAG);
1130 PUT_SDB_TYPE (T_ENUM);
1138 PUT_SDB_SIZE (size);
1141 /* Print out the base class information with fields
1142 named after the types they hold. */
1143 /* This is only relevant to aggregate types. TYPE_BINFO is used
1144 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1146 if (TREE_CODE (type) != ENUMERAL_TYPE && TYPE_BINFO (type))
1151 for (binfo = TYPE_BINFO (type), i = 0;
1152 BINFO_BASE_ITERATE (binfo, i, child); i++)
1154 tree child_type = BINFO_TYPE (child);
1155 tree child_type_name;
1157 if (TYPE_NAME (child_type) == 0)
1159 if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
1160 child_type_name = TYPE_NAME (child_type);
1161 else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL)
1163 child_type_name = DECL_NAME (TYPE_NAME (child_type));
1164 if (child_type_name && template_name_p (child_type_name))
1166 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type));
1171 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1172 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0));
1173 PUT_SDB_SCL (member_scl);
1174 sdbout_type (BINFO_TYPE (child));
1179 /* Output the individual fields. */
1181 if (TREE_CODE (type) == ENUMERAL_TYPE)
1183 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1184 if (host_integerp (TREE_VALUE (tem), 0))
1186 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1187 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem), 0));
1188 PUT_SDB_SCL (C_MOE);
1189 PUT_SDB_TYPE (T_MOE);
1193 else /* record or union type */
1194 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1195 /* Output the name, type, position (in bits), size (in bits)
1198 /* Omit here the nameless fields that are used to skip bits.
1199 Also omit fields with variable size or position.
1200 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1201 if (TREE_CODE (tem) == FIELD_DECL
1204 && host_integerp (DECL_SIZE (tem), 1)
1205 && host_integerp (bit_position (tem), 0))
1209 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1211 if (DECL_BIT_FIELD_TYPE (tem))
1213 PUT_SDB_INT_VAL (int_bit_position (tem));
1214 PUT_SDB_SCL (C_FIELD);
1215 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1216 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1));
1220 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1221 PUT_SDB_SCL (member_scl);
1222 sdbout_type (TREE_TYPE (tem));
1226 /* Output end of a structure,union, or enumeral definition. */
1228 PUT_SDB_PLAIN_DEF ("eos");
1229 PUT_SDB_INT_VAL (size);
1230 PUT_SDB_SCL (C_EOS);
1231 PUT_SDB_TAG (KNOWN_TYPE_TAG (type));
1232 PUT_SDB_SIZE (size);
1242 /* The following two functions output definitions of function parameters.
1243 Each parameter gets a definition locating it in the parameter list.
1244 Each parameter that is a register variable gets a second definition
1245 locating it in the register.
1247 Printing or argument lists in gdb uses the definitions that
1248 locate in the parameter list. But reference to the variable in
1249 expressions uses preferentially the definition as a register. */
1251 /* Output definitions, referring to storage in the parmlist,
1252 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1255 sdbout_parms (tree parms)
1257 for (; parms; parms = TREE_CHAIN (parms))
1258 if (DECL_NAME (parms))
1260 int current_sym_value = 0;
1261 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1263 if (name == 0 || *name == 0)
1264 name = gen_fake_label ();
1266 /* Perform any necessary register eliminations on the parameter's rtl,
1267 so that the debugging output will be accurate. */
1268 DECL_INCOMING_RTL (parms)
1269 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
1270 SET_DECL_RTL (parms,
1271 eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
1273 if (PARM_PASSED_IN_MEMORY (parms))
1275 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
1278 /* ??? Here we assume that the parm address is indexed
1279 off the frame pointer or arg pointer.
1280 If that is not true, we produce meaningless results,
1281 but do not crash. */
1282 if (GET_CODE (addr) == PLUS
1283 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
1284 current_sym_value = INTVAL (XEXP (addr, 1));
1286 current_sym_value = 0;
1288 if (REG_P (DECL_RTL (parms))
1289 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1290 type = DECL_ARG_TYPE (parms);
1293 int original_sym_value = current_sym_value;
1295 /* This is the case where the parm is passed as an int or
1296 double and it is converted to a char, short or float
1297 and stored back in the parmlist. In this case, describe
1298 the parm with the variable's declared type, and adjust
1299 the address if the least significant bytes (which we are
1300 using) are not the first ones. */
1301 if (BYTES_BIG_ENDIAN
1302 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1303 current_sym_value +=
1304 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1305 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1307 if (MEM_P (DECL_RTL (parms))
1308 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1309 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1311 && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1312 == current_sym_value))
1313 type = TREE_TYPE (parms);
1316 current_sym_value = original_sym_value;
1317 type = DECL_ARG_TYPE (parms);
1322 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr));
1323 PUT_SDB_SCL (C_ARG);
1324 PUT_SDB_TYPE (plain_type (type));
1327 else if (REG_P (DECL_RTL (parms)))
1330 /* Parm passed in registers and lives in registers or nowhere. */
1332 /* If parm lives in a register, use that register;
1333 pretend the parm was passed there. It would be more consistent
1334 to describe the register where the parm was passed,
1335 but in practice that register usually holds something else. */
1336 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1337 best_rtl = DECL_RTL (parms);
1338 /* If the parm lives nowhere,
1339 use the register where it was passed. */
1341 best_rtl = DECL_INCOMING_RTL (parms);
1344 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl)));
1345 PUT_SDB_SCL (C_REGPARM);
1346 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1349 else if (MEM_P (DECL_RTL (parms))
1350 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1352 /* Parm was passed in registers but lives on the stack. */
1354 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1355 in which case we want the value of that CONST_INT,
1356 or (MEM (REG ...)) or (MEM (MEM ...)),
1357 in which case we use a value of zero. */
1358 if (REG_P (XEXP (DECL_RTL (parms), 0))
1359 || MEM_P (XEXP (DECL_RTL (parms), 0)))
1360 current_sym_value = 0;
1362 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1364 /* Again, this assumes the offset is based on the arg pointer. */
1366 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value,
1367 XEXP (DECL_RTL (parms), 0)));
1368 PUT_SDB_SCL (C_ARG);
1369 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1375 /* Output definitions for the places where parms live during the function,
1376 when different from where they were passed, when the parms were passed
1379 It is not useful to do this for parms passed in registers
1380 that live during the function in different registers, because it is
1381 impossible to look in the passed register for the passed value,
1382 so we use the within-the-function register to begin with.
1384 PARMS is a chain of PARM_DECL nodes. */
1387 sdbout_reg_parms (tree parms)
1389 for (; parms; parms = TREE_CHAIN (parms))
1390 if (DECL_NAME (parms))
1392 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1394 /* Report parms that live in registers during the function
1395 but were passed in memory. */
1396 if (REG_P (DECL_RTL (parms))
1397 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
1398 && PARM_PASSED_IN_MEMORY (parms))
1400 if (name == 0 || *name == 0)
1401 name = gen_fake_label ();
1403 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
1404 PUT_SDB_SCL (C_REG);
1405 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1408 /* Report parms that live in memory but not where they were passed. */
1409 else if (MEM_P (DECL_RTL (parms))
1410 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1411 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
1412 && PARM_PASSED_IN_MEMORY (parms)
1413 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
1415 #if 0 /* ??? It is not clear yet what should replace this. */
1416 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1417 /* A parm declared char is really passed as an int,
1418 so it occupies the least significant bytes.
1419 On a big-endian machine those are not the low-numbered ones. */
1420 if (BYTES_BIG_ENDIAN
1422 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1423 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1424 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1425 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
1428 if (name == 0 || *name == 0)
1429 name = gen_fake_label ();
1431 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1432 (XEXP (DECL_RTL (parms), 0)));
1433 PUT_SDB_SCL (C_AUTO);
1434 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1441 /* Output debug information for a global DECL. Called from toplev.c
1442 after compilation proper has finished. */
1445 sdbout_global_decl (tree decl)
1447 if (TREE_CODE (decl) == VAR_DECL
1448 && !DECL_EXTERNAL (decl)
1449 && DECL_RTL_SET_P (decl))
1451 /* The COFF linker can move initialized global vars to the end.
1452 And that can screw up the symbol ordering. Defer those for
1453 sdbout_finish (). */
1454 if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
1455 sdbout_symbol (decl, 0);
1457 VARRAY_PUSH_TREE (deferred_global_decls, decl);
1459 /* Output COFF information for non-global file-scope initialized
1461 if (DECL_INITIAL (decl) && MEM_P (DECL_RTL (decl)))
1462 sdbout_toplevel_data (decl);
1466 /* Output initialized global vars at the end, in the order of
1467 definition. See comment in sdbout_global_decl. */
1470 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
1474 for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_global_decls); i++)
1475 sdbout_symbol (VARRAY_TREE (deferred_global_decls, i), 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 (unsigned int line, const char *filename ATTRIBUTE_UNUSED)
1541 /* COFF relative line numbers must be positive. */
1542 if ((int) line > sdb_begin_function_line)
1544 #ifdef SDB_OUTPUT_SOURCE_LINE
1545 SDB_OUTPUT_SOURCE_LINE (asm_out_file, line);
1547 fprintf (asm_out_file, "\t.ln\t%d\n",
1548 ((sdb_begin_function_line > -1)
1549 ? line - sdb_begin_function_line : 1));
1554 /* Output sdb info for the current function name.
1555 Called from assemble_start_function. */
1558 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED)
1560 sdbout_symbol (current_function_decl, 0);
1563 /* Called at beginning of function body (before or after prologue,
1564 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1565 line number, so we can output relative line numbers for the other
1566 lines. Describe beginning of outermost block. Also describe the
1569 #ifndef MIPS_DEBUGGING_INFO
1571 sdbout_begin_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1573 sdbout_end_prologue (line, file);
1578 sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1580 sdb_begin_function_line = line - 1;
1581 PUT_SDB_FUNCTION_START (line);
1582 sdbout_parms (DECL_ARGUMENTS (current_function_decl));
1583 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl));
1586 /* Called at end of function (before epilogue).
1587 Describe end of outermost block. */
1590 sdbout_end_function (unsigned int line)
1592 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1593 sdbout_dequeue_anonymous_types ();
1596 MAKE_LINE_SAFE (line);
1597 PUT_SDB_FUNCTION_END (line - sdb_begin_function_line);
1599 /* Indicate we are between functions, for line-number output. */
1600 sdb_begin_function_line = -1;
1603 /* Output sdb info for the absolute end of a function.
1604 Called after the epilogue is output. */
1607 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
1608 const char *file ATTRIBUTE_UNUSED)
1610 const char *const name ATTRIBUTE_UNUSED
1611 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
1613 #ifdef PUT_SDB_EPILOGUE_END
1614 PUT_SDB_EPILOGUE_END (name);
1616 fprintf (asm_out_file, "\t.def\t");
1617 assemble_name (asm_out_file, name);
1618 fprintf (asm_out_file, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1619 SDB_DELIM, SDB_DELIM, SDB_DELIM);
1623 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1627 sdbout_label (rtx insn)
1629 PUT_SDB_DEF (LABEL_NAME (insn));
1631 PUT_SDB_SCL (C_LABEL);
1632 PUT_SDB_TYPE (T_NULL);
1636 /* Change to reading from a new source file. */
1639 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
1640 const char *filename ATTRIBUTE_UNUSED)
1642 #ifdef MIPS_DEBUGGING_INFO
1643 struct sdb_file *n = xmalloc (sizeof *n);
1645 n->next = current_file;
1648 output_file_directive (asm_out_file, filename);
1652 /* Revert to reading a previous source file. */
1655 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
1657 #ifdef MIPS_DEBUGGING_INFO
1658 struct sdb_file *next;
1660 next = current_file->next;
1661 free (current_file);
1662 current_file = next;
1663 output_file_directive (asm_out_file, current_file->name);
1667 /* Set up for SDB output at the start of compilation. */
1670 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED)
1674 #ifdef MIPS_DEBUGGING_INFO
1675 current_file = xmalloc (sizeof *current_file);
1676 current_file->next = NULL;
1677 current_file->name = input_file_name;
1680 VARRAY_TREE_INIT (deferred_global_decls, 12, "deferred_global_decls");
1682 /* Emit debug information which was queued by sdbout_symbol before
1684 sdbout_initialized = true;
1686 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
1687 sdbout_symbol (TREE_VALUE (t), 0);
1688 preinit_symbols = 0;
1691 #else /* SDB_DEBUGGING_INFO */
1693 /* This should never be used, but its address is needed for comparisons. */
1694 const struct gcc_debug_hooks sdb_debug_hooks;
1696 #endif /* SDB_DEBUGGING_INFO */
1698 #include "gt-sdbout.h"