1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* mike@tredysvr.Tredydev.Unisys.COM says:
21 I modified the struct.c example and have a nm of a .o resulting from the
22 AT&T C compiler. From the example below I would conclude the following:
24 1. All .defs from structures are emitted as scanned. The example below
25 clearly shows the symbol table entries for BoxRec2 are after the first
28 2. All functions and their locals (including statics) are emitted as scanned.
30 3. All nested unnamed union and structure .defs must be emitted before
31 the structure in which they are nested. The AT&T assembler is a
32 one pass beast as far as symbolics are concerned.
34 4. All structure .defs are emitted before the typedefs that refer to them.
36 5. All top level static and external variable definitions are moved to the
37 end of file with all top level statics occurring first before externs.
39 6. All undefined references are at the end of the file.
44 #include "coretypes.h"
50 #include "stor-layout.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(()) vec<tree, va_gc> *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;
74 #include "insn-config.h"
77 #include "diagnostic-core.h"
79 #include "langhooks.h"
82 /* 1 if PARM is passed to this function in memory. */
84 #define PARM_PASSED_IN_MEMORY(PARM) \
85 (MEM_P (DECL_INCOMING_RTL (PARM)))
87 /* A C expression for the integer offset value of an automatic variable
88 (C_AUTO) having address X (an RTX). */
89 #ifndef DEBUGGER_AUTO_OFFSET
90 #define DEBUGGER_AUTO_OFFSET(X) \
91 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
94 /* A C expression for the integer offset value of an argument (C_ARG)
95 having address X (an RTX). The nominal offset is OFFSET. */
96 #ifndef DEBUGGER_ARG_OFFSET
97 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
100 /* Line number of beginning of current function, minus one.
101 Negative means not in a function or not using sdb. */
103 int sdb_begin_function_line = -1;
106 extern FILE *asm_out_file;
108 extern tree current_function_decl;
112 static void sdbout_init (const char *);
113 static void sdbout_finish (const char *);
114 static void sdbout_start_source_file (unsigned int, const char *);
115 static void sdbout_end_source_file (unsigned int);
116 static void sdbout_begin_block (unsigned int, unsigned int);
117 static void sdbout_end_block (unsigned int, unsigned int);
118 static void sdbout_source_line (unsigned int, const char *, int, bool);
119 static void sdbout_end_epilogue (unsigned int, const char *);
120 static void sdbout_early_global_decl (tree);
121 static void sdbout_late_global_decl (tree);
122 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_code_label *);
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);
145 /* Random macros describing parts of SDB data. */
147 /* Default value of delimiter is ";". */
149 #define SDB_DELIM ";"
152 /* Maximum number of dimensions the assembler will allow. */
154 #define SDB_MAX_DIM 4
158 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
161 #ifndef PUT_SDB_INT_VAL
162 #define PUT_SDB_INT_VAL(a) \
164 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
165 (HOST_WIDE_INT) (a), SDB_DELIM); \
171 #define PUT_SDB_VAL(a) \
172 ( fputs ("\t.val\t", asm_out_file), \
173 output_addr_const (asm_out_file, (a)), \
174 fprintf (asm_out_file, SDB_DELIM))
178 #define PUT_SDB_DEF(a) \
179 do { fprintf (asm_out_file, "\t.def\t"); \
180 assemble_name (asm_out_file, a); \
181 fprintf (asm_out_file, SDB_DELIM); } while (0)
184 #ifndef PUT_SDB_PLAIN_DEF
185 #define PUT_SDB_PLAIN_DEF(a) \
186 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 /* Return the sdb tag identifier string for TYPE
253 if TYPE has already been defined; otherwise return a null pointer. */
255 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
257 /* Set the sdb tag identifier string for TYPE to NAME. */
259 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
260 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
262 /* Return the name (a string) of the struct, union or enum tag
263 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
265 #define TAG_NAME(link) \
266 (((link) && TREE_PURPOSE ((link)) \
267 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
268 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
270 /* Ensure we don't output a negative line number. */
271 #define MAKE_LINE_SAFE(line) \
272 if ((int) line <= sdb_begin_function_line) \
273 line = sdb_begin_function_line + 1
275 /* The debug hooks structure. */
276 const struct gcc_debug_hooks sdb_debug_hooks =
278 sdbout_init, /* init */
279 sdbout_finish, /* finish */
280 debug_nothing_void, /* early_finish */
281 debug_nothing_void, /* assembly_start */
282 debug_nothing_int_charstar, /* define */
283 debug_nothing_int_charstar, /* undef */
284 sdbout_start_source_file, /* start_source_file */
285 sdbout_end_source_file, /* end_source_file */
286 sdbout_begin_block, /* begin_block */
287 sdbout_end_block, /* end_block */
288 debug_true_const_tree, /* ignore_block */
289 sdbout_source_line, /* source_line */
290 sdbout_begin_prologue, /* begin_prologue */
291 debug_nothing_int_charstar, /* end_prologue */
292 debug_nothing_int_charstar, /* begin_epilogue */
293 sdbout_end_epilogue, /* end_epilogue */
294 sdbout_begin_function, /* begin_function */
295 sdbout_end_function, /* end_function */
296 debug_nothing_tree, /* register_main_translation_unit */
297 debug_nothing_tree, /* function_decl */
298 sdbout_early_global_decl, /* early_global_decl */
299 sdbout_late_global_decl, /* late_global_decl */
300 sdbout_symbol, /* type_decl */
301 debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */
302 debug_nothing_tree, /* deferred_inline_function */
303 debug_nothing_tree, /* outlining_inline_function */
304 sdbout_label, /* label */
305 debug_nothing_int, /* handle_pch */
306 debug_nothing_rtx_insn, /* var_location */
307 debug_nothing_tree, /* size_function */
308 debug_nothing_void, /* switch_text_section */
309 debug_nothing_tree_tree, /* set_name */
310 0, /* start_end_main_source_file */
311 TYPE_SYMTAB_IS_POINTER /* tree_type_symtab_field */
314 /* Return a unique string to name an anonymous type. */
317 gen_fake_label (void)
321 sprintf (label, ".%dfake", unnamed_struct_number);
322 unnamed_struct_number++;
323 labelstr = xstrdup (label);
327 /* Return the number which describes TYPE for SDB.
328 For pointers, etc., this function is recursive.
329 Each record, union or enumeral type must already have had a
330 tag number output. */
332 /* The number is given by d6d5d4d3d2d1bbbb
333 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
334 Thus, char *foo () has bbbb=T_CHAR
337 N_BTMASK= 017 1111 basic type field.
338 N_TSHIFT= 2 derived type shift
339 N_BTSHFT= 4 Basic type shift */
341 /* Produce the number that describes a pointer, function or array type.
342 PREV is the number describing the target, value or element type.
343 DT_type describes how to transform that type. */
344 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
345 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
346 | ((int) DT_type << (int) N_BTSHFT) \
347 | ((PREV) & (int) N_BTMASK))
349 /* Number of elements used in sdb_dims. */
350 static int sdb_n_dims = 0;
352 /* Table of array dimensions of current type. */
353 static int sdb_dims[SDB_MAX_DIM];
355 /* Size of outermost array currently being processed. */
356 static int sdb_type_size = -1;
359 plain_type (tree type)
361 int val = plain_type_1 (type, 0);
363 /* If we have already saved up some array dimensions, print them now. */
368 for (i = sdb_n_dims - 1; i > 0; i--)
369 PUT_SDB_NEXT_DIM (sdb_dims[i]);
370 PUT_SDB_LAST_DIM (sdb_dims[0]);
373 sdb_type_size = int_size_in_bytes (type);
374 /* Don't kill sdb if type is not laid out or has variable size. */
375 if (sdb_type_size < 0)
378 /* If we have computed the size of an array containing this type,
380 if (sdb_type_size >= 0)
382 PUT_SDB_SIZE (sdb_type_size);
389 template_name_p (tree name)
391 const char *ptr = IDENTIFIER_POINTER (name);
392 while (*ptr && *ptr != '<')
399 sdbout_record_type_name (tree type)
401 const char *name = 0;
404 if (KNOWN_TYPE_TAG (type))
407 if (TYPE_NAME (type) != 0)
411 /* Find the IDENTIFIER_NODE for the type name. */
412 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
413 t = TYPE_NAME (type);
414 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
416 t = DECL_NAME (TYPE_NAME (type));
417 /* The DECL_NAME for templates includes "<>", which breaks
418 most assemblers. Use its assembler name instead, which
419 has been mangled into being safe. */
420 if (t && template_name_p (t))
421 t = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
424 /* Now get the name as a string, or invent one. */
426 name = IDENTIFIER_POINTER (t);
429 no_name = (name == 0 || *name == 0);
431 name = gen_fake_label ();
433 SET_KNOWN_TYPE_TAG (type, name);
434 #ifdef SDB_ALLOW_FORWARD_REFERENCES
436 sdbout_queue_anonymous_type (type);
440 /* Return the .type value for type TYPE.
442 LEVEL indicates how many levels deep we have recursed into the type.
443 The SDB debug format can only represent 6 derived levels of types.
444 After that, we must output inaccurate debug info. We deliberately
445 stop before the 7th level, so that ADA recursive types will not give an
449 plain_type_1 (tree type, int level)
452 type = void_type_node;
453 else if (type == error_mark_node)
454 type = integer_type_node;
456 type = TYPE_MAIN_VARIANT (type);
458 switch (TREE_CODE (type))
466 int size = int_size_in_bytes (type) * BITS_PER_UNIT;
468 /* Carefully distinguish all the standard types of C,
469 without messing up if the language is not C.
470 Note that we check only for the names that contain spaces;
471 other names might occur by coincidence in other languages. */
472 if (TYPE_NAME (type) != 0
473 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
474 && DECL_NAME (TYPE_NAME (type)) != 0
475 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
477 const char *const name
478 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
480 if (!strcmp (name, "char"))
482 if (!strcmp (name, "unsigned char"))
484 if (!strcmp (name, "signed char"))
486 if (!strcmp (name, "int"))
488 if (!strcmp (name, "unsigned int"))
490 if (!strcmp (name, "short int"))
492 if (!strcmp (name, "short unsigned int"))
494 if (!strcmp (name, "long int"))
496 if (!strcmp (name, "long unsigned int"))
500 if (size == INT_TYPE_SIZE)
501 return (TYPE_UNSIGNED (type) ? T_UINT : T_INT);
502 if (size == CHAR_TYPE_SIZE)
503 return (TYPE_UNSIGNED (type) ? T_UCHAR : T_CHAR);
504 if (size == SHORT_TYPE_SIZE)
505 return (TYPE_UNSIGNED (type) ? T_USHORT : T_SHORT);
506 if (size == LONG_TYPE_SIZE)
507 return (TYPE_UNSIGNED (type) ? T_ULONG : T_LONG);
508 if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */
509 return (TYPE_UNSIGNED (type) ? T_ULONG : T_LONG);
515 int precision = TYPE_PRECISION (type);
516 if (precision == FLOAT_TYPE_SIZE)
518 if (precision == DOUBLE_TYPE_SIZE)
520 if (precision == LONG_DOUBLE_TYPE_SIZE)
521 return T_DOUBLE; /* better than nothing */
532 m = plain_type_1 (TREE_TYPE (type), level+1);
533 if (sdb_n_dims < SDB_MAX_DIM)
534 sdb_dims[sdb_n_dims++]
535 = (TYPE_DOMAIN (type)
536 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
537 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
538 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
539 && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type)))
540 ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
541 - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1)
544 return PUSH_DERIVED_LEVEL (DT_ARY, m);
549 case QUAL_UNION_TYPE:
553 #ifdef SDB_ALLOW_FORWARD_REFERENCES
554 sdbout_record_type_name (type);
556 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
557 if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0)
558 #ifdef SDB_ALLOW_FORWARD_REFERENCES
559 || TYPE_MODE (type) != VOIDmode
564 /* Output the referenced structure tag name
565 only if the .def has already been finished.
566 At least on 386, the Unix assembler
567 cannot handle forward references to tags. */
568 /* But the 88100, it requires them, sigh... */
569 /* And the MIPS requires unknown refs as well... */
570 tag = KNOWN_TYPE_TAG (type);
572 /* These 3 lines used to follow the close brace.
573 However, a size of 0 without a tag implies a tag of 0,
574 so if we don't know a tag, we can't mention the size. */
575 sdb_type_size = int_size_in_bytes (type);
576 if (sdb_type_size < 0)
579 return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT
580 : (TREE_CODE (type) == UNION_TYPE) ? T_UNION
581 : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION
591 m = plain_type_1 (TREE_TYPE (type), level+1);
592 return PUSH_DERIVED_LEVEL (DT_PTR, m);
601 m = plain_type_1 (TREE_TYPE (type), level+1);
602 return PUSH_DERIVED_LEVEL (DT_FCN, m);
609 /* Output the symbols defined in block number DO_BLOCK.
611 This function works by walking the tree structure of blocks,
612 counting blocks until it finds the desired block. */
614 static int do_block = 0;
617 sdbout_block (tree block)
621 /* Ignore blocks never expanded or otherwise marked as real. */
622 if (TREE_USED (block))
624 /* When we reach the specified block, output its symbols. */
625 if (BLOCK_NUMBER (block) == do_block)
626 sdbout_syms (BLOCK_VARS (block));
628 /* If we are past the specified block, stop the scan. */
629 if (BLOCK_NUMBER (block) > do_block)
632 /* Scan the blocks within this block. */
633 sdbout_block (BLOCK_SUBBLOCKS (block));
636 block = BLOCK_CHAIN (block);
640 /* Call sdbout_symbol on each decl in the chain SYMS. */
643 sdbout_syms (tree syms)
647 if (TREE_CODE (syms) != LABEL_DECL)
648 sdbout_symbol (syms, 1);
649 syms = TREE_CHAIN (syms);
653 /* Output SDB information for a symbol described by DECL.
654 LOCAL is nonzero if the symbol is not file-scope. */
657 sdbout_symbol (tree decl, int local)
659 tree type = TREE_TYPE (decl);
660 tree context = NULL_TREE;
665 /* If we are called before sdbout_init is run, just save the symbol
667 if (!sdbout_initialized)
669 preinit_symbols = tree_cons (0, decl, preinit_symbols);
673 sdbout_one_type (type);
675 switch (TREE_CODE (decl))
678 /* Enum values are defined by defining the enum type. */
682 /* Don't mention a nested function under its parent. */
683 context = decl_function_context (decl);
684 if (context == current_function_decl)
686 /* Check DECL_INITIAL to distinguish declarations from definitions.
687 Don't output debug info here for declarations; they will have
688 a DECL_INITIAL value of 0. */
689 if (! DECL_INITIAL (decl))
691 if (!MEM_P (DECL_RTL (decl))
692 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
694 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
695 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
696 PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT);
700 /* Done with tagged types. */
701 if (DECL_NAME (decl) == 0)
703 if (DECL_IGNORED_P (decl))
705 /* Don't output intrinsic types. GAS chokes on SDB .def
706 statements that contain identifiers with embedded spaces
707 (eg "unsigned long"). */
708 if (DECL_IS_BUILTIN (decl))
711 /* Output typedef name. */
712 if (template_name_p (DECL_NAME (decl)))
713 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
715 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl)));
716 PUT_SDB_SCL (C_TPDEF);
720 /* Parm decls go in their own separate chains
721 and are output by sdbout_reg_parms and sdbout_parms. */
725 /* Don't mention a variable that is external.
726 Let the file that defines it describe it. */
727 if (DECL_EXTERNAL (decl))
730 /* Ignore __FUNCTION__, etc. */
731 if (DECL_IGNORED_P (decl))
734 /* If there was an error in the declaration, don't dump core
735 if there is no RTL associated with the variable doesn't
737 if (!DECL_RTL_SET_P (decl))
740 value = DECL_RTL (decl);
742 if (!is_global_var (decl))
743 value = eliminate_regs (value, VOIDmode, NULL_RTX);
745 SET_DECL_RTL (decl, value);
746 #ifdef LEAF_REG_REMAP
747 if (crtl->uses_only_leaf_regs)
748 leaf_renumber_regs_insn (value);
751 /* Don't mention a variable at all
752 if it was completely optimized into nothingness.
754 If DECL was from an inline function, then its rtl
755 is not identically the rtl that was used in this
756 particular compilation. */
759 regno = REGNO (value);
760 if (regno >= FIRST_PSEUDO_REGISTER)
763 else if (GET_CODE (value) == SUBREG)
765 while (GET_CODE (value) == SUBREG)
766 value = SUBREG_REG (value);
769 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
772 regno = REGNO (alter_subreg (&value, true));
773 SET_DECL_RTL (decl, value);
775 /* Don't output anything if an auto variable
776 gets RTL that is static.
777 GAS version 2.2 can't handle such output. */
778 else if (MEM_P (value) && CONSTANT_P (XEXP (value, 0))
779 && ! TREE_STATIC (decl))
782 /* Emit any structure, union, or enum type that has not been output.
783 This occurs for tag-less structs (et al) used to declare variables
785 if (TREE_CODE (type) == ENUMERAL_TYPE
786 || TREE_CODE (type) == RECORD_TYPE
787 || TREE_CODE (type) == UNION_TYPE
788 || TREE_CODE (type) == QUAL_UNION_TYPE)
790 if (COMPLETE_TYPE_P (type) /* not a forward reference */
791 && KNOWN_TYPE_TAG (type) == 0) /* not yet declared */
792 sdbout_one_type (type);
795 /* Defer SDB information for top-level initialized variables! */
798 && DECL_INITIAL (decl))
801 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
802 For now, avoid crashing. */
803 if (DECL_NAME (decl) == NULL_TREE)
806 /* Record the name for, starting a symtab entry. */
808 name = IDENTIFIER_POINTER (DECL_NAME (decl));
810 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
813 && GET_CODE (XEXP (value, 0)) == SYMBOL_REF)
816 if (TREE_PUBLIC (decl))
818 PUT_SDB_VAL (XEXP (value, 0));
823 PUT_SDB_VAL (XEXP (value, 0));
824 PUT_SDB_SCL (C_STAT);
830 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno));
833 else if (MEM_P (value)
834 && (MEM_P (XEXP (value, 0))
835 || (REG_P (XEXP (value, 0))
836 && REGNO (XEXP (value, 0)) != HARD_FRAME_POINTER_REGNUM
837 && REGNO (XEXP (value, 0)) != STACK_POINTER_REGNUM)))
838 /* If the value is indirect by memory or by a register
839 that isn't the frame pointer
840 then it means the object is variable-sized and address through
841 that register or stack slot. COFF has no way to represent this
842 so all we can do is output the variable as a pointer. */
845 if (REG_P (XEXP (value, 0)))
847 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value, 0))));
852 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
854 We want the value of that CONST_INT. */
855 /* Encore compiler hates a newline in a macro arg, it seems. */
856 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
857 (XEXP (XEXP (value, 0), 0)));
858 PUT_SDB_SCL (C_AUTO);
861 /* Effectively do build_pointer_type, but don't cache this type,
862 since it might be temporary whereas the type it points to
863 might have been saved for inlining. */
864 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
865 type = make_node (POINTER_TYPE);
866 TREE_TYPE (type) = TREE_TYPE (decl);
868 else if (MEM_P (value)
869 && ((GET_CODE (XEXP (value, 0)) == PLUS
870 && REG_P (XEXP (XEXP (value, 0), 0))
871 && CONST_INT_P (XEXP (XEXP (value, 0), 1)))
872 /* This is for variables which are at offset zero from
873 the frame pointer. This happens on the Alpha.
874 Non-frame pointer registers are excluded above. */
875 || (REG_P (XEXP (value, 0)))))
877 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
878 or (MEM (REG...)). We want the value of that CONST_INT
881 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value, 0)));
882 PUT_SDB_SCL (C_AUTO);
886 /* It is something we don't know how to represent for SDB. */
894 PUT_SDB_TYPE (plain_type (type));
898 /* Output SDB information for a top-level initialized variable
899 that has been delayed. */
902 sdbout_toplevel_data (tree decl)
904 tree type = TREE_TYPE (decl);
906 if (DECL_IGNORED_P (decl))
909 gcc_assert (TREE_CODE (decl) == VAR_DECL);
910 gcc_assert (MEM_P (DECL_RTL (decl)));
911 gcc_assert (DECL_INITIAL (decl));
913 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
914 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
915 if (TREE_PUBLIC (decl))
921 PUT_SDB_SCL (C_STAT);
923 PUT_SDB_TYPE (plain_type (type));
927 #ifdef SDB_ALLOW_FORWARD_REFERENCES
929 /* Machinery to record and output anonymous types. */
932 sdbout_queue_anonymous_type (tree type)
934 anonymous_types = tree_cons (NULL_TREE, type, anonymous_types);
938 sdbout_dequeue_anonymous_types (void)
942 while (anonymous_types)
944 types = nreverse (anonymous_types);
945 anonymous_types = NULL_TREE;
947 for (link = types; link; link = TREE_CHAIN (link))
949 tree type = TREE_VALUE (link);
951 if (type && ! TREE_ASM_WRITTEN (type))
952 sdbout_one_type (type);
959 /* Given a chain of ..._TYPE nodes, all of which have names,
960 output definitions of those names, as typedefs. */
963 sdbout_types (tree types)
967 for (link = types; link; link = TREE_CHAIN (link))
968 sdbout_one_type (link);
970 #ifdef SDB_ALLOW_FORWARD_REFERENCES
971 sdbout_dequeue_anonymous_types ();
976 sdbout_type (tree type)
978 if (type == error_mark_node)
979 type = integer_type_node;
980 PUT_SDB_TYPE (plain_type (type));
983 /* Output types of the fields of type TYPE, if they are structs.
985 Formerly did not chase through pointer types, since that could be circular.
986 They must come before TYPE, since forward refs are not allowed.
987 Now james@bigtex.cactus.org says to try them. */
990 sdbout_field_types (tree type)
994 for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail))
995 /* This condition should match the one for emitting the actual
997 if (TREE_CODE (tail) == FIELD_DECL
1000 && tree_fits_uhwi_p (DECL_SIZE (tail))
1001 && tree_fits_shwi_p (bit_position (tail)))
1003 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1004 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1006 sdbout_one_type (TREE_TYPE (tail));
1010 /* Use this to put out the top level defined record and union types
1011 for later reference. If this is a struct with a name, then put that
1012 name out. Other unnamed structs will have .xxfake labels generated so
1013 that they may be referred to later.
1014 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1015 It may NOT be called recursively. */
1018 sdbout_one_type (tree type)
1020 if (current_function_decl != NULL_TREE
1021 && DECL_SECTION_NAME (current_function_decl) != NULL)
1022 ; /* Don't change section amid function. */
1024 switch_to_section (current_function_section ());
1026 switch (TREE_CODE (type))
1030 case QUAL_UNION_TYPE:
1032 type = TYPE_MAIN_VARIANT (type);
1033 /* Don't output a type twice. */
1034 if (TREE_ASM_WRITTEN (type))
1035 /* James said test TREE_ASM_BEING_WRITTEN here. */
1038 /* Output nothing if type is not yet defined. */
1039 if (!COMPLETE_TYPE_P (type))
1042 TREE_ASM_WRITTEN (type) = 1;
1044 /* This is reputed to cause trouble with the following case,
1045 but perhaps checking TYPE_SIZE above will fix it. */
1047 /* Here is a testcase:
1053 typedef struct intermediate {
1057 typedef struct badstr {
1061 /* This change, which ought to make better output,
1062 used to make the COFF assembler unhappy.
1063 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1064 /* Before really doing anything, output types we want to refer to. */
1065 /* Note that in version 1 the following two lines
1066 are not used if forward references are in use. */
1067 if (TREE_CODE (type) != ENUMERAL_TYPE)
1068 sdbout_field_types (type);
1070 /* Output a structure type. */
1072 int size = int_size_in_bytes (type);
1076 /* Record the type tag, but not in its permanent place just yet. */
1077 sdbout_record_type_name (type);
1079 PUT_SDB_DEF (KNOWN_TYPE_TAG (type));
1081 switch (TREE_CODE (type))
1084 case QUAL_UNION_TYPE:
1085 PUT_SDB_SCL (C_UNTAG);
1086 PUT_SDB_TYPE (T_UNION);
1091 PUT_SDB_SCL (C_STRTAG);
1092 PUT_SDB_TYPE (T_STRUCT);
1097 PUT_SDB_SCL (C_ENTAG);
1098 PUT_SDB_TYPE (T_ENUM);
1106 PUT_SDB_SIZE (size);
1109 /* Print out the base class information with fields
1110 named after the types they hold. */
1111 /* This is only relevant to aggregate types. TYPE_BINFO is used
1112 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1114 if (TREE_CODE (type) != ENUMERAL_TYPE && TYPE_BINFO (type))
1119 for (binfo = TYPE_BINFO (type), i = 0;
1120 BINFO_BASE_ITERATE (binfo, i, child); i++)
1122 tree child_type = BINFO_TYPE (child);
1123 tree child_type_name;
1125 if (TYPE_NAME (child_type) == 0)
1127 if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE)
1128 child_type_name = TYPE_NAME (child_type);
1129 else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL)
1131 child_type_name = DECL_NAME (TYPE_NAME (child_type));
1132 if (child_type_name && template_name_p (child_type_name))
1134 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type));
1139 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1140 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child)));
1141 PUT_SDB_SCL (member_scl);
1142 sdbout_type (BINFO_TYPE (child));
1147 /* Output the individual fields. */
1149 if (TREE_CODE (type) == ENUMERAL_TYPE)
1151 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1153 tree value = TREE_VALUE (tem);
1155 if (TREE_CODE (value) == CONST_DECL)
1156 value = DECL_INITIAL (value);
1158 if (tree_fits_shwi_p (value))
1160 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1161 PUT_SDB_INT_VAL (tree_to_shwi (value));
1162 PUT_SDB_SCL (C_MOE);
1163 PUT_SDB_TYPE (T_MOE);
1168 else /* record or union type */
1169 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
1170 /* Output the name, type, position (in bits), size (in bits)
1173 /* Omit here the nameless fields that are used to skip bits.
1174 Also omit fields with variable size or position.
1175 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1176 if (TREE_CODE (tem) == FIELD_DECL
1179 && tree_fits_uhwi_p (DECL_SIZE (tem))
1180 && tree_fits_shwi_p (bit_position (tem)))
1184 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1186 if (DECL_BIT_FIELD_TYPE (tem))
1188 PUT_SDB_INT_VAL (int_bit_position (tem));
1189 PUT_SDB_SCL (C_FIELD);
1190 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1191 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem)));
1195 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1196 PUT_SDB_SCL (member_scl);
1197 sdbout_type (TREE_TYPE (tem));
1201 /* Output end of a structure,union, or enumeral definition. */
1203 PUT_SDB_PLAIN_DEF ("eos");
1204 PUT_SDB_INT_VAL (size);
1205 PUT_SDB_SCL (C_EOS);
1206 PUT_SDB_TAG (KNOWN_TYPE_TAG (type));
1207 PUT_SDB_SIZE (size);
1217 /* The following two functions output definitions of function parameters.
1218 Each parameter gets a definition locating it in the parameter list.
1219 Each parameter that is a register variable gets a second definition
1220 locating it in the register.
1222 Printing or argument lists in gdb uses the definitions that
1223 locate in the parameter list. But reference to the variable in
1224 expressions uses preferentially the definition as a register. */
1226 /* Output definitions, referring to storage in the parmlist,
1227 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1230 sdbout_parms (tree parms)
1232 for (; parms; parms = TREE_CHAIN (parms))
1233 if (DECL_NAME (parms)
1234 && TREE_TYPE (parms) != error_mark_node
1235 && DECL_RTL_SET_P (parms)
1236 && DECL_INCOMING_RTL (parms))
1238 int current_sym_value = 0;
1239 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1241 if (name == 0 || *name == 0)
1242 name = gen_fake_label ();
1244 /* Perform any necessary register eliminations on the parameter's rtl,
1245 so that the debugging output will be accurate. */
1246 DECL_INCOMING_RTL (parms)
1247 = eliminate_regs (DECL_INCOMING_RTL (parms), VOIDmode, NULL_RTX);
1248 SET_DECL_RTL (parms,
1249 eliminate_regs (DECL_RTL (parms), VOIDmode, NULL_RTX));
1251 if (PARM_PASSED_IN_MEMORY (parms))
1253 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
1256 /* ??? Here we assume that the parm address is indexed
1257 off the frame pointer or arg pointer.
1258 If that is not true, we produce meaningless results,
1259 but do not crash. */
1260 if (GET_CODE (addr) == PLUS
1261 && CONST_INT_P (XEXP (addr, 1)))
1262 current_sym_value = INTVAL (XEXP (addr, 1));
1264 current_sym_value = 0;
1266 if (REG_P (DECL_RTL (parms))
1267 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1268 type = DECL_ARG_TYPE (parms);
1271 int original_sym_value = current_sym_value;
1273 /* This is the case where the parm is passed as an int or
1274 double and it is converted to a char, short or float
1275 and stored back in the parmlist. In this case, describe
1276 the parm with the variable's declared type, and adjust
1277 the address if the least significant bytes (which we are
1278 using) are not the first ones. */
1279 if (BYTES_BIG_ENDIAN
1280 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1281 current_sym_value +=
1282 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1283 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1285 if (MEM_P (DECL_RTL (parms))
1286 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1287 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1289 && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1290 == current_sym_value))
1291 type = TREE_TYPE (parms);
1294 current_sym_value = original_sym_value;
1295 type = DECL_ARG_TYPE (parms);
1300 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr));
1301 PUT_SDB_SCL (C_ARG);
1302 PUT_SDB_TYPE (plain_type (type));
1305 else if (REG_P (DECL_RTL (parms)))
1308 /* Parm passed in registers and lives in registers or nowhere. */
1310 /* If parm lives in a register, use that register;
1311 pretend the parm was passed there. It would be more consistent
1312 to describe the register where the parm was passed,
1313 but in practice that register usually holds something else. */
1314 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
1315 best_rtl = DECL_RTL (parms);
1316 /* If the parm lives nowhere,
1317 use the register where it was passed. */
1319 best_rtl = DECL_INCOMING_RTL (parms);
1322 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl)));
1323 PUT_SDB_SCL (C_REGPARM);
1324 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1327 else if (MEM_P (DECL_RTL (parms))
1328 && XEXP (DECL_RTL (parms), 0) != const0_rtx)
1330 /* Parm was passed in registers but lives on the stack. */
1332 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1333 in which case we want the value of that CONST_INT,
1334 or (MEM (REG ...)) or (MEM (MEM ...)),
1335 in which case we use a value of zero. */
1336 if (REG_P (XEXP (DECL_RTL (parms), 0))
1337 || MEM_P (XEXP (DECL_RTL (parms), 0)))
1338 current_sym_value = 0;
1340 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
1342 /* Again, this assumes the offset is based on the arg pointer. */
1344 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value,
1345 XEXP (DECL_RTL (parms), 0)));
1346 PUT_SDB_SCL (C_ARG);
1347 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1353 /* Output definitions for the places where parms live during the function,
1354 when different from where they were passed, when the parms were passed
1357 It is not useful to do this for parms passed in registers
1358 that live during the function in different registers, because it is
1359 impossible to look in the passed register for the passed value,
1360 so we use the within-the-function register to begin with.
1362 PARMS is a chain of PARM_DECL nodes. */
1365 sdbout_reg_parms (tree parms)
1367 for (; parms; parms = TREE_CHAIN (parms))
1368 if (DECL_NAME (parms)
1369 && TREE_TYPE (parms) != error_mark_node
1370 && DECL_RTL_SET_P (parms)
1371 && DECL_INCOMING_RTL (parms))
1373 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1375 /* Report parms that live in registers during the function
1376 but were passed in memory. */
1377 if (REG_P (DECL_RTL (parms))
1378 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
1379 && PARM_PASSED_IN_MEMORY (parms))
1381 if (name == 0 || *name == 0)
1382 name = gen_fake_label ();
1384 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
1385 PUT_SDB_SCL (C_REG);
1386 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1389 /* Report parms that live in memory but not where they were passed. */
1390 else if (MEM_P (DECL_RTL (parms))
1391 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1392 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1393 && PARM_PASSED_IN_MEMORY (parms)
1394 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
1396 #if 0 /* ??? It is not clear yet what should replace this. */
1397 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
1398 /* A parm declared char is really passed as an int,
1399 so it occupies the least significant bytes.
1400 On a big-endian machine those are not the low-numbered ones. */
1401 if (BYTES_BIG_ENDIAN
1403 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
1404 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
1405 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
1406 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
1409 if (name == 0 || *name == 0)
1410 name = gen_fake_label ();
1412 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1413 (XEXP (DECL_RTL (parms), 0)));
1414 PUT_SDB_SCL (C_AUTO);
1415 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
1422 /* Output early debug information for a global DECL. Called from
1423 rest_of_decl_compilation during parsing. */
1426 sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED)
1428 /* NYI for non-dwarf. */
1431 /* Output late debug information for a global DECL after location
1432 information is available. */
1435 sdbout_late_global_decl (tree decl)
1437 if (TREE_CODE (decl) == VAR_DECL
1438 && !DECL_EXTERNAL (decl)
1439 && DECL_RTL_SET_P (decl))
1441 /* The COFF linker can move initialized global vars to the end.
1442 And that can screw up the symbol ordering. Defer those for
1443 sdbout_finish (). */
1444 if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
1445 sdbout_symbol (decl, 0);
1447 vec_safe_push (deferred_global_decls, decl);
1449 /* Output COFF information for non-global file-scope initialized
1451 if (DECL_INITIAL (decl) && MEM_P (DECL_RTL (decl)))
1452 sdbout_toplevel_data (decl);
1456 /* Output initialized global vars at the end, in the order of
1457 definition. See comment in sdbout_global_decl. */
1460 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
1465 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls, i, decl)
1466 sdbout_symbol (decl, 0);
1469 /* Describe the beginning of an internal block within a function.
1470 Also output descriptions of variables defined in this block.
1472 N is the number of the block, by order of beginning, counting from 1,
1473 and not counting the outermost (function top-level) block.
1474 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1475 if the count starts at 0 for the outermost one. */
1478 sdbout_begin_block (unsigned int line, unsigned int n)
1480 tree decl = current_function_decl;
1481 MAKE_LINE_SAFE (line);
1483 /* The SCO compiler does not emit a separate block for the function level
1484 scope, so we avoid it here also. */
1485 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1489 /* Include the outermost BLOCK's variables in block 1. */
1490 do_block = BLOCK_NUMBER (DECL_INITIAL (decl));
1491 sdbout_block (DECL_INITIAL (decl));
1493 /* If -g1, suppress all the internal symbols of functions
1494 except for arguments. */
1495 if (debug_info_level != DINFO_LEVEL_TERSE)
1498 sdbout_block (DECL_INITIAL (decl));
1501 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1502 sdbout_dequeue_anonymous_types ();
1506 /* Describe the end line-number of an internal block within a function. */
1509 sdbout_end_block (unsigned int line, unsigned int n ATTRIBUTE_UNUSED)
1511 MAKE_LINE_SAFE (line);
1513 /* The SCO compiler does not emit a separate block for the function level
1514 scope, so we avoid it here also. */
1516 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1519 /* Output a line number symbol entry for source file FILENAME and line
1523 sdbout_source_line (unsigned int line, const char *filename ATTRIBUTE_UNUSED,
1524 int discriminator ATTRIBUTE_UNUSED,
1525 bool is_stmt ATTRIBUTE_UNUSED)
1527 /* COFF relative line numbers must be positive. */
1528 if ((int) line > sdb_begin_function_line)
1530 #ifdef SDB_OUTPUT_SOURCE_LINE
1531 SDB_OUTPUT_SOURCE_LINE (asm_out_file, line);
1533 fprintf (asm_out_file, "\t.ln\t%d\n",
1534 ((sdb_begin_function_line > -1)
1535 ? line - sdb_begin_function_line : 1));
1540 /* Output sdb info for the current function name.
1541 Called from assemble_start_function. */
1544 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED)
1546 sdbout_symbol (current_function_decl, 0);
1549 /* Called at beginning of function body after prologue. Record the
1550 function's starting line number, so we can output relative line numbers
1551 for the other lines. Describe beginning of outermost block. Also
1552 describe the parameter list. */
1555 sdbout_begin_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1557 sdbout_end_prologue (line, file);
1561 sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1563 sdb_begin_function_line = line - 1;
1564 PUT_SDB_FUNCTION_START (line);
1565 sdbout_parms (DECL_ARGUMENTS (current_function_decl));
1566 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl));
1569 /* Called at end of function (before epilogue).
1570 Describe end of outermost block. */
1573 sdbout_end_function (unsigned int line)
1575 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1576 sdbout_dequeue_anonymous_types ();
1579 MAKE_LINE_SAFE (line);
1580 PUT_SDB_FUNCTION_END (line - sdb_begin_function_line);
1582 /* Indicate we are between functions, for line-number output. */
1583 sdb_begin_function_line = -1;
1586 /* Output sdb info for the absolute end of a function.
1587 Called after the epilogue is output. */
1590 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
1591 const char *file ATTRIBUTE_UNUSED)
1593 const char *const name ATTRIBUTE_UNUSED
1594 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
1596 #ifdef PUT_SDB_EPILOGUE_END
1597 PUT_SDB_EPILOGUE_END (name);
1599 fprintf (asm_out_file, "\t.def\t");
1600 assemble_name (asm_out_file, name);
1601 fprintf (asm_out_file, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1602 SDB_DELIM, SDB_DELIM, SDB_DELIM);
1606 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1610 sdbout_label (rtx_code_label *insn)
1612 PUT_SDB_DEF (LABEL_NAME (insn));
1614 PUT_SDB_SCL (C_LABEL);
1615 PUT_SDB_TYPE (T_NULL);
1619 /* Change to reading from a new source file. */
1622 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
1623 const char *filename ATTRIBUTE_UNUSED)
1627 /* Revert to reading a previous source file. */
1630 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
1634 /* Set up for SDB output at the start of compilation. */
1637 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED)
1641 vec_alloc (deferred_global_decls, 12);
1643 /* Emit debug information which was queued by sdbout_symbol before
1645 sdbout_initialized = true;
1647 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
1648 sdbout_symbol (TREE_VALUE (t), 0);
1649 preinit_symbols = 0;
1652 #include "gt-sdbout.h"