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 for sdbout_source_line. */
57 static GTY(()) int sdbout_source_line_counter;
59 /* Counter to generate unique "names" for nameless struct members. */
61 static GTY(()) int unnamed_struct_number;
63 /* Declarations whose debug info was deferred till end of compilation. */
65 static GTY(()) varray_type deferred_global_decls;
67 #ifdef SDB_DEBUGGING_INFO
72 #include "insn-config.h"
78 #include "langhooks.h"
81 /* 1 if PARM is passed to this function in memory. */
83 #define PARM_PASSED_IN_MEMORY(PARM) \
84 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
86 /* A C expression for the integer offset value of an automatic variable
87 (C_AUTO) having address X (an RTX). */
88 #ifndef DEBUGGER_AUTO_OFFSET
89 #define DEBUGGER_AUTO_OFFSET(X) \
90 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
93 /* A C expression for the integer offset value of an argument (C_ARG)
94 having address X (an RTX). The nominal offset is OFFSET. */
95 #ifndef DEBUGGER_ARG_OFFSET
96 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
99 /* Line number of beginning of current function, minus one.
100 Negative means not in a function or not using sdb. */
102 int sdb_begin_function_line = -1;
105 extern FILE *asm_out_file;
107 extern tree current_function_decl;
111 static void sdbout_init (const char *);
112 static void sdbout_finish (const char *);
113 static void sdbout_start_source_file (unsigned int, const char *);
114 static void sdbout_end_source_file (unsigned int);
115 static void sdbout_begin_block (unsigned int, unsigned int);
116 static void sdbout_end_block (unsigned int, unsigned int);
117 static void sdbout_source_line (unsigned int, const char *);
118 static void sdbout_end_epilogue (unsigned int, const char *);
119 static void sdbout_global_decl (tree);
120 #ifndef MIPS_DEBUGGING_INFO
121 static void sdbout_begin_prologue (unsigned int, const char *);
123 static void sdbout_end_prologue (unsigned int, const char *);
124 static void sdbout_begin_function (tree);
125 static void sdbout_end_function (unsigned int);
126 static void sdbout_toplevel_data (tree);
127 static void sdbout_label (rtx);
128 static char *gen_fake_label (void);
129 static int plain_type (tree);
130 static int template_name_p (tree);
131 static void sdbout_record_type_name (tree);
132 static int plain_type_1 (tree, int);
133 static void sdbout_block (tree);
134 static void sdbout_syms (tree);
135 #ifdef SDB_ALLOW_FORWARD_REFERENCES
136 static void sdbout_queue_anonymous_type (tree);
137 static void sdbout_dequeue_anonymous_types (void);
139 static void sdbout_type (tree);
140 static void sdbout_field_types (tree);
141 static void sdbout_one_type (tree);
142 static void sdbout_parms (tree);
143 static void sdbout_reg_parms (tree);
144 static void sdbout_global_decl (tree);
146 /* Random macros describing parts of SDB data. */
148 /* Default value of delimiter is ";". */
150 #define SDB_DELIM ";"
153 /* Maximum number of dimensions the assembler will allow. */
155 #define SDB_MAX_DIM 4
159 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
162 #ifndef PUT_SDB_INT_VAL
163 #define PUT_SDB_INT_VAL(a) \
165 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
166 (HOST_WIDE_INT) (a), SDB_DELIM); \
172 #define PUT_SDB_VAL(a) \
173 ( fputs ("\t.val\t", asm_out_file), \
174 output_addr_const (asm_out_file, (a)), \
175 fprintf (asm_out_file, SDB_DELIM))
179 #define PUT_SDB_DEF(a) \
180 do { fprintf (asm_out_file, "\t.def\t"); \
181 assemble_name (asm_out_file, a); \
182 fprintf (asm_out_file, SDB_DELIM); } while (0)
185 #ifndef PUT_SDB_PLAIN_DEF
186 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
189 #ifndef PUT_SDB_ENDEF
190 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
194 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
198 #define PUT_SDB_SIZE(a) \
200 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
201 (HOST_WIDE_INT) (a), SDB_DELIM); \
205 #ifndef PUT_SDB_START_DIM
206 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
209 #ifndef PUT_SDB_NEXT_DIM
210 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
213 #ifndef PUT_SDB_LAST_DIM
214 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
218 #define PUT_SDB_TAG(a) \
219 do { fprintf (asm_out_file, "\t.tag\t"); \
220 assemble_name (asm_out_file, a); \
221 fprintf (asm_out_file, SDB_DELIM); } while (0)
224 #ifndef PUT_SDB_BLOCK_START
225 #define PUT_SDB_BLOCK_START(LINE) \
226 fprintf (asm_out_file, \
227 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
228 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
231 #ifndef PUT_SDB_BLOCK_END
232 #define PUT_SDB_BLOCK_END(LINE) \
233 fprintf (asm_out_file, \
234 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
235 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
238 #ifndef PUT_SDB_FUNCTION_START
239 #define PUT_SDB_FUNCTION_START(LINE) \
240 fprintf (asm_out_file, \
241 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
242 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
245 #ifndef PUT_SDB_FUNCTION_END
246 #define PUT_SDB_FUNCTION_END(LINE) \
247 fprintf (asm_out_file, \
248 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
249 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
252 #ifndef SDB_GENERATE_FAKE
253 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
254 sprintf ((BUFFER), ".%dfake", (NUMBER));
257 /* Return the sdb tag identifier string for TYPE
258 if TYPE has already been defined; otherwise return a null pointer. */
260 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
262 /* Set the sdb tag identifier string for TYPE to NAME. */
264 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
265 TYPE_SYMTAB_POINTER (TYPE) = (char *)(NAME)
267 /* Return the name (a string) of the struct, union or enum tag
268 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
270 #define TAG_NAME(link) \
271 (((link) && TREE_PURPOSE ((link)) \
272 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
273 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
275 /* Ensure we don't output a negative line number. */
276 #define MAKE_LINE_SAFE(line) \
277 if ((int) line <= sdb_begin_function_line) \
278 line = sdb_begin_function_line + 1
280 /* Perform linker optimization of merging header file definitions together
281 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
282 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
283 the optimization just won't be done. The native assembler already has the
284 necessary support. */
286 #ifdef MIPS_DEBUGGING_INFO
288 #ifndef PUT_SDB_SRC_FILE
289 #define PUT_SDB_SRC_FILE(FILENAME) \
290 output_file_directive (asm_out_file, (FILENAME))
293 /* ECOFF linkers have an optimization that does the same kind of thing as
294 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
295 executable. To achieve this, GCC must output a .file for each file
298 /* This is a stack of input files. */
302 struct sdb_file *next;
306 /* This is the top of the stack. */
308 static struct sdb_file *current_file;
310 #endif /* MIPS_DEBUGGING_INFO */
312 /* The debug hooks structure. */
313 const struct gcc_debug_hooks sdb_debug_hooks =
315 sdbout_init, /* init */
316 sdbout_finish, /* finish */
317 debug_nothing_int_charstar, /* define */
318 debug_nothing_int_charstar, /* undef */
319 sdbout_start_source_file, /* start_source_file */
320 sdbout_end_source_file, /* end_source_file */
321 sdbout_begin_block, /* begin_block */
322 sdbout_end_block, /* end_block */
323 debug_true_tree, /* ignore_block */
324 sdbout_source_line, /* source_line */
325 #ifdef MIPS_DEBUGGING_INFO
326 /* Defer on MIPS systems so that parameter descriptions follow
328 debug_nothing_int_charstar, /* begin_prologue */
329 sdbout_end_prologue, /* end_prologue */
331 sdbout_begin_prologue, /* begin_prologue */
332 debug_nothing_int_charstar, /* end_prologue */
334 sdbout_end_epilogue, /* end_epilogue */
335 sdbout_begin_function, /* begin_function */
336 sdbout_end_function, /* end_function */
337 debug_nothing_tree, /* function_decl */
338 sdbout_global_decl, /* global_decl */
339 sdbout_type_decl, /* type_decl */
340 debug_nothing_tree_tree, /* imported_module_or_decl */
341 debug_nothing_tree, /* deferred_inline_function */
342 debug_nothing_tree, /* outlining_inline_function */
343 sdbout_label, /* label */
344 debug_nothing_int, /* handle_pch */
345 debug_nothing_rtx /* var_location */
348 /* Return a unique string to name an anonymous type. */
351 gen_fake_label (void)
355 SDB_GENERATE_FAKE (label, unnamed_struct_number);
356 unnamed_struct_number++;
357 labelstr = xstrdup (label);
361 /* Return the number which describes TYPE for SDB.
362 For pointers, etc., this function is recursive.
363 Each record, union or enumeral type must already have had a
364 tag number output. */
366 /* The number is given by d6d5d4d3d2d1bbbb
367 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
368 Thus, char *foo () has bbbb=T_CHAR
371 N_BTMASK= 017 1111 basic type field.
372 N_TSHIFT= 2 derived type shift
373 N_BTSHFT= 4 Basic type shift */
375 /* Produce the number that describes a pointer, function or array type.
376 PREV is the number describing the target, value or element type.
377 DT_type describes how to transform that type. */
378 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
379 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
380 | ((int) DT_type << (int) N_BTSHFT) \
381 | ((PREV) & (int) N_BTMASK))
383 /* Number of elements used in sdb_dims. */
384 static int sdb_n_dims = 0;
386 /* Table of array dimensions of current type. */
387 static int sdb_dims[SDB_MAX_DIM];
389 /* Size of outermost array currently being processed. */
390 static int sdb_type_size = -1;
393 plain_type (tree type)
395 int val = plain_type_1 (type, 0);
397 /* If we have already saved up some array dimensions, print them now. */
402 for (i = sdb_n_dims - 1; i > 0; i--)
403 PUT_SDB_NEXT_DIM (sdb_dims[i]);
404 PUT_SDB_LAST_DIM (sdb_dims[0]);
407 sdb_type_size = int_size_in_bytes (type);
408 /* Don't kill sdb if type is not laid out or has variable size. */
409 if (sdb_type_size < 0)
412 /* If we have computed the size of an array containing this type,
414 if (sdb_type_size >= 0)
416 PUT_SDB_SIZE (sdb_type_size);
423 template_name_p (tree name)
425 const char *ptr = IDENTIFIER_POINTER (name);
426 while (*ptr && *ptr != '<')
433 sdbout_record_type_name (tree type)
435 const char *name = 0;
438 if (KNOWN_TYPE_TAG (type))
441 if (TYPE_NAME (type) != 0)
445 /* Find the IDENTIFIER_NODE for the type name. */
446 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
447 t = TYPE_NAME (type);
448 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
450 t = DECL_NAME (TYPE_NAME (type));
451 /* The DECL_NAME for templates includes "<>", which breaks
452 most assemblers. Use its assembler name instead, which
453 has been mangled into being safe. */
454 if (t && template_name_p (t))
455 t = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
458 /* Now get the name as a string, or invent one. */
460 name = IDENTIFIER_POINTER (t);
463 no_name = (name == 0 || *name == 0);
465 name = gen_fake_label ();
467 SET_KNOWN_TYPE_TAG (type, name);
468 #ifdef SDB_ALLOW_FORWARD_REFERENCES
470 sdbout_queue_anonymous_type (type);
474 /* Return the .type value for type TYPE.
476 LEVEL indicates how many levels deep we have recursed into the type.
477 The SDB debug format can only represent 6 derived levels of types.
478 After that, we must output inaccurate debug info. We deliberately
479 stop before the 7th level, so that ADA recursive types will not give an
483 plain_type_1 (tree type, int level)
486 type = void_type_node;
487 else if (type == error_mark_node)
488 type = integer_type_node;
490 type = TYPE_MAIN_VARIANT (type);
492 switch (TREE_CODE (type))
499 int size = int_size_in_bytes (type) * BITS_PER_UNIT;
501 /* Carefully distinguish all the standard types of C,
502 without messing up if the language is not C.
503 Note that we check only for the names that contain spaces;
504 other names might occur by coincidence in other languages. */
505 if (TYPE_NAME (type) != 0
506 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
507 && DECL_NAME (TYPE_NAME (type)) != 0
508 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
510 const char *const name
511 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
513 if (!strcmp (name, "char"))
515 if (!strcmp (name, "unsigned char"))
517 if (!strcmp (name, "signed char"))
519 if (!strcmp (name, "int"))
521 if (!strcmp (name, "unsigned int"))
523 if (!strcmp (name, "short int"))
525 if (!strcmp (name, "short unsigned int"))
527 if (!strcmp (name, "long int"))
529 if (!strcmp (name, "long unsigned int"))
533 if (size == INT_TYPE_SIZE)
534 return (TREE_UNSIGNED (type) ? T_UINT : T_INT);
535 if (size == CHAR_TYPE_SIZE)
536 return (TREE_UNSIGNED (type) ? T_UCHAR : T_CHAR);
537 if (size == SHORT_TYPE_SIZE)
538 return (TREE_UNSIGNED (type) ? T_USHORT : T_SHORT);
539 if (size == LONG_TYPE_SIZE)
540 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
541 if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */
542 return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG);
548 int precision = TYPE_PRECISION (type);
549 if (precision == FLOAT_TYPE_SIZE)
551 if (precision == DOUBLE_TYPE_SIZE)
553 #ifdef EXTENDED_SDB_BASIC_TYPES
554 if (precision == LONG_DOUBLE_TYPE_SIZE)
557 if (precision == LONG_DOUBLE_TYPE_SIZE)
558 return T_DOUBLE; /* better than nothing */
569 m = plain_type_1 (TREE_TYPE (type), level+1);
570 if (sdb_n_dims < SDB_MAX_DIM)
571 sdb_dims[sdb_n_dims++]
572 = (TYPE_DOMAIN (type)
573 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
574 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
575 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
576 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0)
577 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
578 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1)
581 return PUSH_DERIVED_LEVEL (DT_ARY, m);
586 case QUAL_UNION_TYPE:
590 #ifdef SDB_ALLOW_FORWARD_REFERENCES
591 sdbout_record_type_name (type);
593 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
594 if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0)
595 #ifdef SDB_ALLOW_FORWARD_REFERENCES
596 || TYPE_MODE (type) != VOIDmode
601 /* Output the referenced structure tag name
602 only if the .def has already been finished.
603 At least on 386, the Unix assembler
604 cannot handle forward references to tags. */
605 /* But the 88100, it requires them, sigh... */
606 /* And the MIPS requires unknown refs as well... */
607 tag = KNOWN_TYPE_TAG (type);
609 /* These 3 lines used to follow the close brace.
610 However, a size of 0 without a tag implies a tag of 0,
611 so if we don't know a tag, we can't mention the size. */
612 sdb_type_size = int_size_in_bytes (type);
613 if (sdb_type_size < 0)
616 return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT
617 : (TREE_CODE (type) == UNION_TYPE) ? T_UNION
618 : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION
628 m = plain_type_1 (TREE_TYPE (type), level+1);
629 return PUSH_DERIVED_LEVEL (DT_PTR, m);
638 m = plain_type_1 (TREE_TYPE (type), level+1);
639 return PUSH_DERIVED_LEVEL (DT_FCN, m);
646 /* Output the symbols defined in block number DO_BLOCK.
648 This function works by walking the tree structure of blocks,
649 counting blocks until it finds the desired block. */
651 static int do_block = 0;
654 sdbout_block (tree block)
658 /* Ignore blocks never expanded or otherwise marked as real. */
659 if (TREE_USED (block))
661 /* When we reach the specified block, output its symbols. */
662 if (BLOCK_NUMBER (block) == do_block)
663 sdbout_syms (BLOCK_VARS (block));
665 /* If we are past the specified block, stop the scan. */
666 if (BLOCK_NUMBER (block) > do_block)
669 /* Scan the blocks within this block. */
670 sdbout_block (BLOCK_SUBBLOCKS (block));
673 block = BLOCK_CHAIN (block);
677 /* Call sdbout_symbol on each decl in the chain SYMS. */
680 sdbout_syms (tree syms)
684 if (TREE_CODE (syms) != LABEL_DECL)
685 sdbout_symbol (syms, 1);
686 syms = TREE_CHAIN (syms);
690 /* Output SDB information for a symbol described by DECL.
691 LOCAL is nonzero if the symbol is not file-scope. */
694 sdbout_symbol (tree decl, int local)
696 tree type = TREE_TYPE (decl);
697 tree context = NULL_TREE;
702 sdbout_one_type (type);
704 switch (TREE_CODE (decl))
707 /* Enum values are defined by defining the enum type. */
711 /* Don't mention a nested function under its parent. */
712 context = decl_function_context (decl);
713 if (context == current_function_decl)
715 /* Check DECL_INITIAL to distinguish declarations from definitions.
716 Don't output debug info here for declarations; they will have
717 a DECL_INITIAL value of 0. */
718 if (! DECL_INITIAL (decl))
720 if (GET_CODE (DECL_RTL (decl)) != MEM
721 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
723 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
724 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
725 PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT);
729 /* Done with tagged types. */
730 if (DECL_NAME (decl) == 0)
732 if (DECL_IGNORED_P (decl))
735 /* Output typedef name. */
736 if (template_name_p (DECL_NAME (decl)))
737 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
739 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl)));
740 PUT_SDB_SCL (C_TPDEF);
744 /* Parm decls go in their own separate chains
745 and are output by sdbout_reg_parms and sdbout_parms. */
749 /* Don't mention a variable that is external.
750 Let the file that defines it describe it. */
751 if (DECL_EXTERNAL (decl))
754 /* Ignore __FUNCTION__, etc. */
755 if (DECL_IGNORED_P (decl))
758 /* If there was an error in the declaration, don't dump core
759 if there is no RTL associated with the variable doesn't
761 if (!DECL_RTL_SET_P (decl))
765 eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
766 #ifdef LEAF_REG_REMAP
767 if (current_function_uses_only_leaf_regs)
768 leaf_renumber_regs_insn (DECL_RTL (decl));
770 value = DECL_RTL (decl);
772 /* Don't mention a variable at all
773 if it was completely optimized into nothingness.
775 If DECL was from an inline function, then its rtl
776 is not identically the rtl that was used in this
777 particular compilation. */
778 if (GET_CODE (value) == REG)
780 regno = REGNO (value);
781 if (regno >= FIRST_PSEUDO_REGISTER)
784 else if (GET_CODE (value) == SUBREG)
786 while (GET_CODE (value) == SUBREG)
787 value = SUBREG_REG (value);
788 if (GET_CODE (value) == REG)
790 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
793 regno = REGNO (alter_subreg (&value));
794 SET_DECL_RTL (decl, value);
796 /* Don't output anything if an auto variable
797 gets RTL that is static.
798 GAS version 2.2 can't handle such output. */
799 else if (GET_CODE (value) == MEM && CONSTANT_P (XEXP (value, 0))
800 && ! TREE_STATIC (decl))
803 /* Emit any structure, union, or enum type that has not been output.
804 This occurs for tag-less structs (et al) used to declare variables
806 if (TREE_CODE (type) == ENUMERAL_TYPE
807 || TREE_CODE (type) == RECORD_TYPE
808 || TREE_CODE (type) == UNION_TYPE
809 || TREE_CODE (type) == QUAL_UNION_TYPE)
811 if (COMPLETE_TYPE_P (type) /* not a forward reference */
812 && KNOWN_TYPE_TAG (type) == 0) /* not yet declared */
813 sdbout_one_type (type);
816 /* Defer SDB information for top-level initialized variables! */
818 && GET_CODE (value) == MEM
819 && DECL_INITIAL (decl))
822 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
823 For now, avoid crashing. */
824 if (DECL_NAME (decl) == NULL_TREE)
827 /* Record the name for, starting a symtab entry. */
829 name = IDENTIFIER_POINTER (DECL_NAME (decl));
831 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
833 if (GET_CODE (value) == MEM
834 && GET_CODE (XEXP (value, 0)) == SYMBOL_REF)
837 if (TREE_PUBLIC (decl))
839 PUT_SDB_VAL (XEXP (value, 0));
844 PUT_SDB_VAL (XEXP (value, 0));
845 PUT_SDB_SCL (C_STAT);
851 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno));
854 else if (GET_CODE (value) == MEM
855 && (GET_CODE (XEXP (value, 0)) == MEM
856 || (GET_CODE (XEXP (value, 0)) == REG
857 && REGNO (XEXP (value, 0)) != HARD_FRAME_POINTER_REGNUM
858 && REGNO (XEXP (value, 0)) != STACK_POINTER_REGNUM)))
859 /* If the value is indirect by memory or by a register
860 that isn't the frame pointer
861 then it means the object is variable-sized and address through
862 that register or stack slot. COFF has no way to represent this
863 so all we can do is output the variable as a pointer. */
866 if (GET_CODE (XEXP (value, 0)) == REG)
868 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value, 0))));
873 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
875 We want the value of that CONST_INT. */
876 /* Encore compiler hates a newline in a macro arg, it seems. */
877 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
878 (XEXP (XEXP (value, 0), 0)));
879 PUT_SDB_SCL (C_AUTO);
882 /* Effectively do build_pointer_type, but don't cache this type,
883 since it might be temporary whereas the type it points to
884 might have been saved for inlining. */
885 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
886 type = make_node (POINTER_TYPE);
887 TREE_TYPE (type) = TREE_TYPE (decl);
889 else if (GET_CODE (value) == MEM
890 && ((GET_CODE (XEXP (value, 0)) == PLUS
891 && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
892 && GET_CODE (XEXP (XEXP (value, 0), 1)) == CONST_INT)
893 /* This is for variables which are at offset zero from
894 the frame pointer. This happens on the Alpha.
895 Non-frame pointer registers are excluded above. */
896 || (GET_CODE (XEXP (value, 0)) == REG)))
898 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
899 or (MEM (REG...)). We want the value of that CONST_INT
902 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value, 0)));
903 PUT_SDB_SCL (C_AUTO);
907 /* It is something we don't know how to represent for SDB. */
915 PUT_SDB_TYPE (plain_type (type));
919 /* Output SDB information for a top-level initialized variable
920 that has been delayed. */
923 sdbout_toplevel_data (tree decl)
925 tree type = TREE_TYPE (decl);
927 if (DECL_IGNORED_P (decl))
930 if (! (TREE_CODE (decl) == VAR_DECL
931 && GET_CODE (DECL_RTL (decl)) == MEM
932 && DECL_INITIAL (decl)))
935 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
936 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
937 if (TREE_PUBLIC (decl))
943 PUT_SDB_SCL (C_STAT);
945 PUT_SDB_TYPE (plain_type (type));
949 #ifdef SDB_ALLOW_FORWARD_REFERENCES
951 /* Machinery to record and output anonymous types. */
954 sdbout_queue_anonymous_type (tree type)
956 anonymous_types = tree_cons (NULL_TREE, type, anonymous_types);
960 sdbout_dequeue_anonymous_types (void)
964 while (anonymous_types)
966 types = nreverse (anonymous_types);
967 anonymous_types = NULL_TREE;
969 for (link = types; link; link = TREE_CHAIN (link))
971 tree type = TREE_VALUE (link);
973 if (type && ! TREE_ASM_WRITTEN (type))
974 sdbout_one_type (type);
981 /* Given a chain of ..._TYPE nodes, all of which have names,
982 output definitions of those names, as typedefs. */
985 sdbout_types (tree types)
989 for (link = types; link; link = TREE_CHAIN (link))
990 sdbout_one_type (link);
992 #ifdef SDB_ALLOW_FORWARD_REFERENCES
993 sdbout_dequeue_anonymous_types ();
998 sdbout_type (tree type)
1000 if (type == error_mark_node)
1001 type = integer_type_node;
1002 PUT_SDB_TYPE (plain_type (type));
1005 /* Output types of the fields of type TYPE, if they are structs.
1007 Formerly did not chase through pointer types, since that could be circular.
1008 They must come before TYPE, since forward refs are not allowed.
1009 Now james@bigtex.cactus.org says to try them. */
1012 sdbout_field_types (tree type)
1016 for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
1017 /* This condition should match the one for emitting the actual
1019 if (TREE_CODE (tail) == FIELD_DECL
1022 && host_integerp (DECL_SIZE (tail), 1)
1023 && host_integerp (bit_position (tail), 0))
1025 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1026 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1028 sdbout_one_type (TREE_TYPE (tail));
1032 /* Use this to put out the top level defined record and union types
1033 for later reference. If this is a struct with a name, then put that
1034 name out. Other unnamed structs will have .xxfake labels generated so
1035 that they may be referred to later.
1036 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1037 It may NOT be called recursively. */
1040 sdbout_one_type (tree type)
1042 if (current_function_decl != NULL_TREE
1043 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
1044 ; /* Don't change section amid function. */
1048 switch (TREE_CODE (type))
1052 case QUAL_UNION_TYPE:
1054 type = TYPE_MAIN_VARIANT (type);
1055 /* Don't output a type twice. */
1056 if (TREE_ASM_WRITTEN (type))
1057 /* James said test TREE_ASM_BEING_WRITTEN here. */
1060 /* Output nothing if type is not yet defined. */
1061 if (!COMPLETE_TYPE_P (type))
1064 TREE_ASM_WRITTEN (type) = 1;
1066 /* This is reputed to cause trouble with the following case,
1067 but perhaps checking TYPE_SIZE above will fix it. */
1069 /* Here is a testcase:
1075 typedef struct intermediate {
1079 typedef struct badstr {
1083 /* This change, which ought to make better output,
1084 used to make the COFF assembler unhappy.
1085 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1086 /* Before really doing anything, output types we want to refer to. */
1087 /* Note that in version 1 the following two lines
1088 are not used if forward references are in use. */
1089 if (TREE_CODE (type) != ENUMERAL_TYPE)
1090 sdbout_field_types (type);
1092 /* Output a structure type. */
1094 int size = int_size_in_bytes (type);
1097 int i, n_baseclasses = 0;
1099 /* Record the type tag, but not in its permanent place just yet. */
1100 sdbout_record_type_name (type);
1102 PUT_SDB_DEF (KNOWN_TYPE_TAG (type));
1104 switch (TREE_CODE (type))
1107 case QUAL_UNION_TYPE:
1108 PUT_SDB_SCL (C_UNTAG);
1109 PUT_SDB_TYPE (T_UNION);
1114 PUT_SDB_SCL (C_STRTAG);
1115 PUT_SDB_TYPE (T_STRUCT);
1120 PUT_SDB_SCL (C_ENTAG);
1121 PUT_SDB_TYPE (T_ENUM);
1129 PUT_SDB_SIZE (size);
1132 /* Print out the base class information with fields
1133 named after the types they hold. */
1134 /* This is only relevant to aggregate types. TYPE_BINFO is used
1135 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1137 if (TREE_CODE (type) != ENUMERAL_TYPE)
1139 if (TYPE_BINFO (type)
1140 && TYPE_BINFO_BASETYPES (type))
1141 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1142 for (i = 0; i < n_baseclasses; i++)
1144 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)),
1146 tree child_type = BINFO_TYPE (child);
1147 tree child_type_name;
1148 if (TYPE_NAME (child_type) == 0)
1150 if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
1151 child_type_name = TYPE_NAME (child_type);
1152 else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL)
1154 child_type_name = DECL_NAME (TYPE_NAME (child_type));
1155 if (child_type_name && template_name_p (child_type_name))
1157 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type));
1162 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1163 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0));
1164 PUT_SDB_SCL (member_scl);
1165 sdbout_type (BINFO_TYPE (child));
1170 /* Output the individual fields. */
1172 if (TREE_CODE (type) == ENUMERAL_TYPE)
1174 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1175 if (host_integerp (TREE_VALUE (tem), 0))
1177 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1178 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem), 0));
1179 PUT_SDB_SCL (C_MOE);
1180 PUT_SDB_TYPE (T_MOE);
1184 else /* record or union type */
1185 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1186 /* Output the name, type, position (in bits), size (in bits)
1189 /* Omit here the nameless fields that are used to skip bits.
1190 Also omit fields with variable size or position.
1191 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1192 if (TREE_CODE (tem) == FIELD_DECL
1195 && host_integerp (DECL_SIZE (tem), 1)
1196 && host_integerp (bit_position (tem), 0))
1200 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1202 if (DECL_BIT_FIELD_TYPE (tem))
1204 PUT_SDB_INT_VAL (int_bit_position (tem));
1205 PUT_SDB_SCL (C_FIELD);
1206 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1207 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1));
1211 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1212 PUT_SDB_SCL (member_scl);
1213 sdbout_type (TREE_TYPE (tem));
1217 /* Output end of a structure,union, or enumeral definition. */
1219 PUT_SDB_PLAIN_DEF ("eos");
1220 PUT_SDB_INT_VAL (size);
1221 PUT_SDB_SCL (C_EOS);
1222 PUT_SDB_TAG (KNOWN_TYPE_TAG (type));
1223 PUT_SDB_SIZE (size);
1233 /* The following two functions output definitions of function parameters.
1234 Each parameter gets a definition locating it in the parameter list.
1235 Each parameter that is a register variable gets a second definition
1236 locating it in the register.
1238 Printing or argument lists in gdb uses the definitions that
1239 locate in the parameter list. But reference to the variable in
1240 expressions uses preferentially the definition as a register. */
1242 /* Output definitions, referring to storage in the parmlist,
1243 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1246 sdbout_parms (tree parms)
1248 for (; parms; parms = TREE_CHAIN (parms))
1249 if (DECL_NAME (parms))
1251 int current_sym_value = 0;
1252 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1254 if (name == 0 || *name == 0)
1255 name = gen_fake_label ();
1257 /* Perform any necessary register eliminations on the parameter's rtl,
1258 so that the debugging output will be accurate. */
1259 DECL_INCOMING_RTL (parms)
1260 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
1261 SET_DECL_RTL (parms,
1262 eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
1264 if (PARM_PASSED_IN_MEMORY (parms))
1266 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
1269 /* ??? Here we assume that the parm address is indexed
1270 off the frame pointer or arg pointer.
1271 If that is not true, we produce meaningless results,
1272 but do not crash. */
1273 if (GET_CODE (addr) == PLUS
1274 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
1275 current_sym_value = INTVAL (XEXP (addr, 1));
1277 current_sym_value = 0;
1279 if (GET_CODE (DECL_RTL (parms)) == REG
1280 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1281 type = DECL_ARG_TYPE (parms);
1284 int original_sym_value = current_sym_value;
1286 /* This is the case where the parm is passed as an int or
1287 double and it is converted to a char, short or float
1288 and stored back in the parmlist. In this case, describe
1289 the parm with the variable's declared type, and adjust
1290 the address if the least significant bytes (which we are
1291 using) are not the first ones. */
1292 if (BYTES_BIG_ENDIAN
1293 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1294 current_sym_value +=
1295 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1296 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1298 if (GET_CODE (DECL_RTL (parms)) == MEM
1299 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1300 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1302 && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1303 == current_sym_value))
1304 type = TREE_TYPE (parms);
1307 current_sym_value = original_sym_value;
1308 type = DECL_ARG_TYPE (parms);
1313 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr));
1314 PUT_SDB_SCL (C_ARG);
1315 PUT_SDB_TYPE (plain_type (type));
1318 else if (GET_CODE (DECL_RTL (parms)) == REG)
1321 /* Parm passed in registers and lives in registers or nowhere. */
1323 /* If parm lives in a register, use that register;
1324 pretend the parm was passed there. It would be more consistent
1325 to describe the register where the parm was passed,
1326 but in practice that register usually holds something else. */
1327 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1328 best_rtl = DECL_RTL (parms);
1329 /* If the parm lives nowhere,
1330 use the register where it was passed. */
1332 best_rtl = DECL_INCOMING_RTL (parms);
1335 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl)));
1336 PUT_SDB_SCL (C_REGPARM);
1337 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1340 else if (GET_CODE (DECL_RTL (parms)) == MEM
1341 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1343 /* Parm was passed in registers but lives on the stack. */
1345 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1346 in which case we want the value of that CONST_INT,
1347 or (MEM (REG ...)) or (MEM (MEM ...)),
1348 in which case we use a value of zero. */
1349 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
1350 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
1351 current_sym_value = 0;
1353 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1355 /* Again, this assumes the offset is based on the arg pointer. */
1357 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value,
1358 XEXP (DECL_RTL (parms), 0)));
1359 PUT_SDB_SCL (C_ARG);
1360 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1366 /* Output definitions for the places where parms live during the function,
1367 when different from where they were passed, when the parms were passed
1370 It is not useful to do this for parms passed in registers
1371 that live during the function in different registers, because it is
1372 impossible to look in the passed register for the passed value,
1373 so we use the within-the-function register to begin with.
1375 PARMS is a chain of PARM_DECL nodes. */
1378 sdbout_reg_parms (tree parms)
1380 for (; parms; parms = TREE_CHAIN (parms))
1381 if (DECL_NAME (parms))
1383 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1385 /* Report parms that live in registers during the function
1386 but were passed in memory. */
1387 if (GET_CODE (DECL_RTL (parms)) == REG
1388 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
1389 && PARM_PASSED_IN_MEMORY (parms))
1391 if (name == 0 || *name == 0)
1392 name = gen_fake_label ();
1394 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
1395 PUT_SDB_SCL (C_REG);
1396 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1399 /* Report parms that live in memory but not where they were passed. */
1400 else if (GET_CODE (DECL_RTL (parms)) == MEM
1401 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1402 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
1403 && PARM_PASSED_IN_MEMORY (parms)
1404 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
1406 #if 0 /* ??? It is not clear yet what should replace this. */
1407 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1408 /* A parm declared char is really passed as an int,
1409 so it occupies the least significant bytes.
1410 On a big-endian machine those are not the low-numbered ones. */
1411 if (BYTES_BIG_ENDIAN
1413 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1414 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1415 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1416 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
1419 if (name == 0 || *name == 0)
1420 name = gen_fake_label ();
1422 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1423 (XEXP (DECL_RTL (parms), 0)));
1424 PUT_SDB_SCL (C_AUTO);
1425 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1432 /* Output debug information for a global DECL. Called from toplev.c
1433 after compilation proper has finished. */
1436 sdbout_global_decl (tree decl)
1438 if (TREE_CODE (decl) == VAR_DECL
1439 && !DECL_EXTERNAL (decl)
1440 && DECL_RTL_SET_P (decl))
1442 /* The COFF linker can move initialized global vars to the end.
1443 And that can screw up the symbol ordering. Defer those for
1444 sdbout_finish (). */
1445 if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
1446 sdbout_symbol (decl, 0);
1448 VARRAY_PUSH_TREE (deferred_global_decls, decl);
1450 /* Output COFF information for non-global file-scope initialized
1452 if (DECL_INITIAL (decl) && GET_CODE (DECL_RTL (decl)) == MEM)
1453 sdbout_toplevel_data (decl);
1457 /* Output initialized global vars at the end, in the order of
1458 definition. See comment in sdbout_global_decl. */
1461 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
1465 for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_global_decls); i++)
1466 sdbout_symbol (VARRAY_TREE (deferred_global_decls, i), 0);
1468 VARRAY_FREE (deferred_global_decls);
1471 /* Describe the beginning of an internal block within a function.
1472 Also output descriptions of variables defined in this block.
1474 N is the number of the block, by order of beginning, counting from 1,
1475 and not counting the outermost (function top-level) block.
1476 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1477 if the count starts at 0 for the outermost one. */
1480 sdbout_begin_block (unsigned int line, unsigned int n)
1482 tree decl = current_function_decl;
1483 MAKE_LINE_SAFE (line);
1485 /* The SCO compiler does not emit a separate block for the function level
1486 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1487 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1488 #ifndef MIPS_DEBUGGING_INFO
1491 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1495 /* Include the outermost BLOCK's variables in block 1. */
1496 do_block = BLOCK_NUMBER (DECL_INITIAL (decl));
1497 sdbout_block (DECL_INITIAL (decl));
1499 /* If -g1, suppress all the internal symbols of functions
1500 except for arguments. */
1501 if (debug_info_level != DINFO_LEVEL_TERSE)
1504 sdbout_block (DECL_INITIAL (decl));
1507 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1508 sdbout_dequeue_anonymous_types ();
1512 /* Describe the end line-number of an internal block within a function. */
1515 sdbout_end_block (unsigned int line, unsigned int n ATTRIBUTE_UNUSED)
1517 MAKE_LINE_SAFE (line);
1519 /* The SCO compiler does not emit a separate block for the function level
1520 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1521 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1522 #ifndef MIPS_DEBUGGING_INFO
1525 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1528 /* Output a line number symbol entry for source file FILENAME and line
1532 sdbout_source_line (unsigned int line, const char *filename ATTRIBUTE_UNUSED)
1534 /* COFF relative line numbers must be positive. */
1535 if ((int) line > sdb_begin_function_line)
1537 #ifdef ASM_OUTPUT_SOURCE_LINE
1538 sdbout_source_line_counter += 1;
1539 ASM_OUTPUT_SOURCE_LINE (asm_out_file, line, sdbout_source_line_counter);
1541 fprintf (asm_out_file, "\t.ln\t%d\n",
1542 ((sdb_begin_function_line > -1)
1543 ? line - sdb_begin_function_line : 1));
1548 /* Output sdb info for the current function name.
1549 Called from assemble_start_function. */
1552 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED)
1554 sdbout_symbol (current_function_decl, 0);
1557 /* Called at beginning of function body (before or after prologue,
1558 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1559 line number, so we can output relative line numbers for the other
1560 lines. Describe beginning of outermost block. Also describe the
1563 #ifndef MIPS_DEBUGGING_INFO
1565 sdbout_begin_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1567 sdbout_end_prologue (line, file);
1572 sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1574 sdb_begin_function_line = line - 1;
1575 PUT_SDB_FUNCTION_START (line);
1576 sdbout_parms (DECL_ARGUMENTS (current_function_decl));
1577 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl));
1580 /* Called at end of function (before epilogue).
1581 Describe end of outermost block. */
1584 sdbout_end_function (unsigned int line)
1586 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1587 sdbout_dequeue_anonymous_types ();
1590 MAKE_LINE_SAFE (line);
1591 PUT_SDB_FUNCTION_END (line - sdb_begin_function_line);
1593 /* Indicate we are between functions, for line-number output. */
1594 sdb_begin_function_line = -1;
1597 /* Output sdb info for the absolute end of a function.
1598 Called after the epilogue is output. */
1601 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
1602 const char *file ATTRIBUTE_UNUSED)
1604 const char *const name ATTRIBUTE_UNUSED
1605 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
1607 #ifdef PUT_SDB_EPILOGUE_END
1608 PUT_SDB_EPILOGUE_END (name);
1610 fprintf (asm_out_file, "\t.def\t");
1611 assemble_name (asm_out_file, name);
1612 fprintf (asm_out_file, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1613 SDB_DELIM, SDB_DELIM, SDB_DELIM);
1617 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1621 sdbout_label (rtx insn)
1623 PUT_SDB_DEF (LABEL_NAME (insn));
1625 PUT_SDB_SCL (C_LABEL);
1626 PUT_SDB_TYPE (T_NULL);
1630 /* Change to reading from a new source file. */
1633 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
1634 const char *filename ATTRIBUTE_UNUSED)
1636 #ifdef MIPS_DEBUGGING_INFO
1637 struct sdb_file *n = xmalloc (sizeof *n);
1639 n->next = current_file;
1642 PUT_SDB_SRC_FILE (filename);
1646 /* Revert to reading a previous source file. */
1649 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
1651 #ifdef MIPS_DEBUGGING_INFO
1652 struct sdb_file *next;
1654 next = current_file->next;
1655 free (current_file);
1656 current_file = next;
1657 PUT_SDB_SRC_FILE (current_file->name);
1661 /* Set up for SDB output at the start of compilation. */
1664 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED)
1666 #ifdef MIPS_DEBUGGING_INFO
1667 current_file = xmalloc (sizeof *current_file);
1668 current_file->next = NULL;
1669 current_file->name = input_file_name;
1672 VARRAY_TREE_INIT (deferred_global_decls, 12, "deferred_global_decls");
1675 #else /* SDB_DEBUGGING_INFO */
1677 /* This should never be used, but its address is needed for comparisons. */
1678 const struct gcc_debug_hooks sdb_debug_hooks;
1680 #endif /* SDB_DEBUGGING_INFO */
1682 #include "gt-sdbout.h"