1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
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(()) VEC(tree
,gc
) *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"
78 #include "diagnostic-core.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 *, int, bool);
121 static void sdbout_end_epilogue (unsigned int, const char *);
122 static void sdbout_global_decl (tree
);
123 static void sdbout_begin_prologue (unsigned int, const char *);
124 static void sdbout_end_prologue (unsigned int, const char *);
125 static void sdbout_begin_function (tree
);
126 static void sdbout_end_function (unsigned int);
127 static void sdbout_toplevel_data (tree
);
128 static void sdbout_label (rtx
);
129 static char *gen_fake_label (void);
130 static int plain_type (tree
);
131 static int template_name_p (tree
);
132 static void sdbout_record_type_name (tree
);
133 static int plain_type_1 (tree
, int);
134 static void sdbout_block (tree
);
135 static void sdbout_syms (tree
);
136 #ifdef SDB_ALLOW_FORWARD_REFERENCES
137 static void sdbout_queue_anonymous_type (tree
);
138 static void sdbout_dequeue_anonymous_types (void);
140 static void sdbout_type (tree
);
141 static void sdbout_field_types (tree
);
142 static void sdbout_one_type (tree
);
143 static void sdbout_parms (tree
);
144 static void sdbout_reg_parms (tree
);
145 static void sdbout_global_decl (tree
);
147 /* Random macros describing parts of SDB data. */
149 /* Default value of delimiter is ";". */
151 #define SDB_DELIM ";"
154 /* Maximum number of dimensions the assembler will allow. */
156 #define SDB_MAX_DIM 4
160 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
163 #ifndef PUT_SDB_INT_VAL
164 #define PUT_SDB_INT_VAL(a) \
166 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
167 (HOST_WIDE_INT) (a), SDB_DELIM); \
173 #define PUT_SDB_VAL(a) \
174 ( fputs ("\t.val\t", asm_out_file), \
175 output_addr_const (asm_out_file, (a)), \
176 fprintf (asm_out_file, SDB_DELIM))
180 #define PUT_SDB_DEF(a) \
181 do { fprintf (asm_out_file, "\t.def\t"); \
182 assemble_name (asm_out_file, a); \
183 fprintf (asm_out_file, SDB_DELIM); } while (0)
186 #ifndef PUT_SDB_PLAIN_DEF
187 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
190 #ifndef PUT_SDB_ENDEF
191 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
195 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
199 #define PUT_SDB_SIZE(a) \
201 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
202 (HOST_WIDE_INT) (a), SDB_DELIM); \
206 #ifndef PUT_SDB_START_DIM
207 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
210 #ifndef PUT_SDB_NEXT_DIM
211 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
214 #ifndef PUT_SDB_LAST_DIM
215 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
219 #define PUT_SDB_TAG(a) \
220 do { fprintf (asm_out_file, "\t.tag\t"); \
221 assemble_name (asm_out_file, a); \
222 fprintf (asm_out_file, SDB_DELIM); } while (0)
225 #ifndef PUT_SDB_BLOCK_START
226 #define PUT_SDB_BLOCK_START(LINE) \
227 fprintf (asm_out_file, \
228 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
229 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
232 #ifndef PUT_SDB_BLOCK_END
233 #define PUT_SDB_BLOCK_END(LINE) \
234 fprintf (asm_out_file, \
235 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
236 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
239 #ifndef PUT_SDB_FUNCTION_START
240 #define PUT_SDB_FUNCTION_START(LINE) \
241 fprintf (asm_out_file, \
242 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
243 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
246 #ifndef PUT_SDB_FUNCTION_END
247 #define PUT_SDB_FUNCTION_END(LINE) \
248 fprintf (asm_out_file, \
249 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
250 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
253 /* Return the sdb tag identifier string for TYPE
254 if TYPE has already been defined; otherwise return a null pointer. */
256 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
258 /* Set the sdb tag identifier string for TYPE to NAME. */
260 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
261 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
263 /* Return the name (a string) of the struct, union or enum tag
264 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
266 #define TAG_NAME(link) \
267 (((link) && TREE_PURPOSE ((link)) \
268 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
269 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
271 /* Ensure we don't output a negative line number. */
272 #define MAKE_LINE_SAFE(line) \
273 if ((int) line <= sdb_begin_function_line) \
274 line = sdb_begin_function_line + 1
276 /* The debug hooks structure. */
277 const struct gcc_debug_hooks sdb_debug_hooks
=
279 sdbout_init
, /* init */
280 sdbout_finish
, /* 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
, /* function_decl */
297 sdbout_global_decl
, /* global_decl */
298 sdbout_symbol
, /* type_decl */
299 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
300 debug_nothing_tree
, /* deferred_inline_function */
301 debug_nothing_tree
, /* outlining_inline_function */
302 sdbout_label
, /* label */
303 debug_nothing_int
, /* handle_pch */
304 debug_nothing_rtx
, /* var_location */
305 debug_nothing_void
, /* switch_text_section */
306 debug_nothing_tree_tree
, /* set_name */
307 0, /* start_end_main_source_file */
308 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
311 /* Return a unique string to name an anonymous type. */
314 gen_fake_label (void)
318 sprintf (label
, ".%dfake", unnamed_struct_number
);
319 unnamed_struct_number
++;
320 labelstr
= xstrdup (label
);
324 /* Return the number which describes TYPE for SDB.
325 For pointers, etc., this function is recursive.
326 Each record, union or enumeral type must already have had a
327 tag number output. */
329 /* The number is given by d6d5d4d3d2d1bbbb
330 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
331 Thus, char *foo () has bbbb=T_CHAR
334 N_BTMASK= 017 1111 basic type field.
335 N_TSHIFT= 2 derived type shift
336 N_BTSHFT= 4 Basic type shift */
338 /* Produce the number that describes a pointer, function or array type.
339 PREV is the number describing the target, value or element type.
340 DT_type describes how to transform that type. */
341 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
342 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
343 | ((int) DT_type << (int) N_BTSHFT) \
344 | ((PREV) & (int) N_BTMASK))
346 /* Number of elements used in sdb_dims. */
347 static int sdb_n_dims
= 0;
349 /* Table of array dimensions of current type. */
350 static int sdb_dims
[SDB_MAX_DIM
];
352 /* Size of outermost array currently being processed. */
353 static int sdb_type_size
= -1;
356 plain_type (tree type
)
358 int val
= plain_type_1 (type
, 0);
360 /* If we have already saved up some array dimensions, print them now. */
365 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
366 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
367 PUT_SDB_LAST_DIM (sdb_dims
[0]);
370 sdb_type_size
= int_size_in_bytes (type
);
371 /* Don't kill sdb if type is not laid out or has variable size. */
372 if (sdb_type_size
< 0)
375 /* If we have computed the size of an array containing this type,
377 if (sdb_type_size
>= 0)
379 PUT_SDB_SIZE (sdb_type_size
);
386 template_name_p (tree name
)
388 const char *ptr
= IDENTIFIER_POINTER (name
);
389 while (*ptr
&& *ptr
!= '<')
396 sdbout_record_type_name (tree type
)
398 const char *name
= 0;
401 if (KNOWN_TYPE_TAG (type
))
404 if (TYPE_NAME (type
) != 0)
408 /* Find the IDENTIFIER_NODE for the type name. */
409 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
410 t
= TYPE_NAME (type
);
411 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
413 t
= DECL_NAME (TYPE_NAME (type
));
414 /* The DECL_NAME for templates includes "<>", which breaks
415 most assemblers. Use its assembler name instead, which
416 has been mangled into being safe. */
417 if (t
&& template_name_p (t
))
418 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
421 /* Now get the name as a string, or invent one. */
423 name
= IDENTIFIER_POINTER (t
);
426 no_name
= (name
== 0 || *name
== 0);
428 name
= gen_fake_label ();
430 SET_KNOWN_TYPE_TAG (type
, name
);
431 #ifdef SDB_ALLOW_FORWARD_REFERENCES
433 sdbout_queue_anonymous_type (type
);
437 /* Return the .type value for type TYPE.
439 LEVEL indicates how many levels deep we have recursed into the type.
440 The SDB debug format can only represent 6 derived levels of types.
441 After that, we must output inaccurate debug info. We deliberately
442 stop before the 7th level, so that ADA recursive types will not give an
446 plain_type_1 (tree type
, int level
)
449 type
= void_type_node
;
450 else if (type
== error_mark_node
)
451 type
= integer_type_node
;
453 type
= TYPE_MAIN_VARIANT (type
);
455 switch (TREE_CODE (type
))
463 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
465 /* Carefully distinguish all the standard types of C,
466 without messing up if the language is not C.
467 Note that we check only for the names that contain spaces;
468 other names might occur by coincidence in other languages. */
469 if (TYPE_NAME (type
) != 0
470 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
471 && DECL_NAME (TYPE_NAME (type
)) != 0
472 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
474 const char *const name
475 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
477 if (!strcmp (name
, "char"))
479 if (!strcmp (name
, "unsigned char"))
481 if (!strcmp (name
, "signed char"))
483 if (!strcmp (name
, "int"))
485 if (!strcmp (name
, "unsigned int"))
487 if (!strcmp (name
, "short int"))
489 if (!strcmp (name
, "short unsigned int"))
491 if (!strcmp (name
, "long int"))
493 if (!strcmp (name
, "long unsigned int"))
497 if (size
== INT_TYPE_SIZE
)
498 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
499 if (size
== CHAR_TYPE_SIZE
)
500 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
501 if (size
== SHORT_TYPE_SIZE
)
502 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
503 if (size
== LONG_TYPE_SIZE
)
504 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
505 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
506 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
512 int precision
= TYPE_PRECISION (type
);
513 if (precision
== FLOAT_TYPE_SIZE
)
515 if (precision
== DOUBLE_TYPE_SIZE
)
517 #ifdef EXTENDED_SDB_BASIC_TYPES
518 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
521 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
522 return T_DOUBLE
; /* better than nothing */
533 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
534 if (sdb_n_dims
< SDB_MAX_DIM
)
535 sdb_dims
[sdb_n_dims
++]
536 = (TYPE_DOMAIN (type
)
537 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
538 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
539 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
540 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
541 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
542 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
545 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
550 case QUAL_UNION_TYPE
:
554 #ifdef SDB_ALLOW_FORWARD_REFERENCES
555 sdbout_record_type_name (type
);
557 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
558 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
559 #ifdef SDB_ALLOW_FORWARD_REFERENCES
560 || TYPE_MODE (type
) != VOIDmode
565 /* Output the referenced structure tag name
566 only if the .def has already been finished.
567 At least on 386, the Unix assembler
568 cannot handle forward references to tags. */
569 /* But the 88100, it requires them, sigh... */
570 /* And the MIPS requires unknown refs as well... */
571 tag
= KNOWN_TYPE_TAG (type
);
573 /* These 3 lines used to follow the close brace.
574 However, a size of 0 without a tag implies a tag of 0,
575 so if we don't know a tag, we can't mention the size. */
576 sdb_type_size
= int_size_in_bytes (type
);
577 if (sdb_type_size
< 0)
580 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
581 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
582 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
592 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
593 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
602 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
603 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
610 /* Output the symbols defined in block number DO_BLOCK.
612 This function works by walking the tree structure of blocks,
613 counting blocks until it finds the desired block. */
615 static int do_block
= 0;
618 sdbout_block (tree block
)
622 /* Ignore blocks never expanded or otherwise marked as real. */
623 if (TREE_USED (block
))
625 /* When we reach the specified block, output its symbols. */
626 if (BLOCK_NUMBER (block
) == do_block
)
627 sdbout_syms (BLOCK_VARS (block
));
629 /* If we are past the specified block, stop the scan. */
630 if (BLOCK_NUMBER (block
) > do_block
)
633 /* Scan the blocks within this block. */
634 sdbout_block (BLOCK_SUBBLOCKS (block
));
637 block
= BLOCK_CHAIN (block
);
641 /* Call sdbout_symbol on each decl in the chain SYMS. */
644 sdbout_syms (tree syms
)
648 if (TREE_CODE (syms
) != LABEL_DECL
)
649 sdbout_symbol (syms
, 1);
650 syms
= TREE_CHAIN (syms
);
654 /* Output SDB information for a symbol described by DECL.
655 LOCAL is nonzero if the symbol is not file-scope. */
658 sdbout_symbol (tree decl
, int local
)
660 tree type
= TREE_TYPE (decl
);
661 tree context
= NULL_TREE
;
666 /* If we are called before sdbout_init is run, just save the symbol
668 if (!sdbout_initialized
)
670 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
674 sdbout_one_type (type
);
676 switch (TREE_CODE (decl
))
679 /* Enum values are defined by defining the enum type. */
683 /* Don't mention a nested function under its parent. */
684 context
= decl_function_context (decl
);
685 if (context
== current_function_decl
)
687 /* Check DECL_INITIAL to distinguish declarations from definitions.
688 Don't output debug info here for declarations; they will have
689 a DECL_INITIAL value of 0. */
690 if (! DECL_INITIAL (decl
))
692 if (!MEM_P (DECL_RTL (decl
))
693 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
695 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
696 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
697 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
701 /* Done with tagged types. */
702 if (DECL_NAME (decl
) == 0)
704 if (DECL_IGNORED_P (decl
))
706 /* Don't output intrinsic types. GAS chokes on SDB .def
707 statements that contain identifiers with embedded spaces
708 (eg "unsigned long"). */
709 if (DECL_IS_BUILTIN (decl
))
712 /* Output typedef name. */
713 if (template_name_p (DECL_NAME (decl
)))
714 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
716 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
717 PUT_SDB_SCL (C_TPDEF
);
721 /* Parm decls go in their own separate chains
722 and are output by sdbout_reg_parms and sdbout_parms. */
726 /* Don't mention a variable that is external.
727 Let the file that defines it describe it. */
728 if (DECL_EXTERNAL (decl
))
731 /* Ignore __FUNCTION__, etc. */
732 if (DECL_IGNORED_P (decl
))
735 /* If there was an error in the declaration, don't dump core
736 if there is no RTL associated with the variable doesn't
738 if (!DECL_RTL_SET_P (decl
))
742 eliminate_regs (DECL_RTL (decl
), VOIDmode
, NULL_RTX
));
743 #ifdef LEAF_REG_REMAP
744 if (current_function_uses_only_leaf_regs
)
745 leaf_renumber_regs_insn (DECL_RTL (decl
));
747 value
= DECL_RTL (decl
);
749 /* Don't mention a variable at all
750 if it was completely optimized into nothingness.
752 If DECL was from an inline function, then its rtl
753 is not identically the rtl that was used in this
754 particular compilation. */
757 regno
= REGNO (value
);
758 if (regno
>= FIRST_PSEUDO_REGISTER
)
761 else if (GET_CODE (value
) == SUBREG
)
763 while (GET_CODE (value
) == SUBREG
)
764 value
= SUBREG_REG (value
);
767 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
770 regno
= REGNO (alter_subreg (&value
));
771 SET_DECL_RTL (decl
, value
);
773 /* Don't output anything if an auto variable
774 gets RTL that is static.
775 GAS version 2.2 can't handle such output. */
776 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
777 && ! TREE_STATIC (decl
))
780 /* Emit any structure, union, or enum type that has not been output.
781 This occurs for tag-less structs (et al) used to declare variables
783 if (TREE_CODE (type
) == ENUMERAL_TYPE
784 || TREE_CODE (type
) == RECORD_TYPE
785 || TREE_CODE (type
) == UNION_TYPE
786 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
788 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
789 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
790 sdbout_one_type (type
);
793 /* Defer SDB information for top-level initialized variables! */
796 && DECL_INITIAL (decl
))
799 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
800 For now, avoid crashing. */
801 if (DECL_NAME (decl
) == NULL_TREE
)
804 /* Record the name for, starting a symtab entry. */
806 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
808 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
811 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
814 if (TREE_PUBLIC (decl
))
816 PUT_SDB_VAL (XEXP (value
, 0));
821 PUT_SDB_VAL (XEXP (value
, 0));
822 PUT_SDB_SCL (C_STAT
);
828 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
831 else if (MEM_P (value
)
832 && (MEM_P (XEXP (value
, 0))
833 || (REG_P (XEXP (value
, 0))
834 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
835 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
836 /* If the value is indirect by memory or by a register
837 that isn't the frame pointer
838 then it means the object is variable-sized and address through
839 that register or stack slot. COFF has no way to represent this
840 so all we can do is output the variable as a pointer. */
843 if (REG_P (XEXP (value
, 0)))
845 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
850 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
852 We want the value of that CONST_INT. */
853 /* Encore compiler hates a newline in a macro arg, it seems. */
854 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
855 (XEXP (XEXP (value
, 0), 0)));
856 PUT_SDB_SCL (C_AUTO
);
859 /* Effectively do build_pointer_type, but don't cache this type,
860 since it might be temporary whereas the type it points to
861 might have been saved for inlining. */
862 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
863 type
= make_node (POINTER_TYPE
);
864 TREE_TYPE (type
) = TREE_TYPE (decl
);
866 else if (MEM_P (value
)
867 && ((GET_CODE (XEXP (value
, 0)) == PLUS
868 && REG_P (XEXP (XEXP (value
, 0), 0))
869 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
870 /* This is for variables which are at offset zero from
871 the frame pointer. This happens on the Alpha.
872 Non-frame pointer registers are excluded above. */
873 || (REG_P (XEXP (value
, 0)))))
875 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
876 or (MEM (REG...)). We want the value of that CONST_INT
879 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
880 PUT_SDB_SCL (C_AUTO
);
884 /* It is something we don't know how to represent for SDB. */
892 PUT_SDB_TYPE (plain_type (type
));
896 /* Output SDB information for a top-level initialized variable
897 that has been delayed. */
900 sdbout_toplevel_data (tree decl
)
902 tree type
= TREE_TYPE (decl
);
904 if (DECL_IGNORED_P (decl
))
907 gcc_assert (TREE_CODE (decl
) == VAR_DECL
);
908 gcc_assert (MEM_P (DECL_RTL (decl
)));
909 gcc_assert (DECL_INITIAL (decl
));
911 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
912 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
913 if (TREE_PUBLIC (decl
))
919 PUT_SDB_SCL (C_STAT
);
921 PUT_SDB_TYPE (plain_type (type
));
925 #ifdef SDB_ALLOW_FORWARD_REFERENCES
927 /* Machinery to record and output anonymous types. */
930 sdbout_queue_anonymous_type (tree type
)
932 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
936 sdbout_dequeue_anonymous_types (void)
940 while (anonymous_types
)
942 types
= nreverse (anonymous_types
);
943 anonymous_types
= NULL_TREE
;
945 for (link
= types
; link
; link
= TREE_CHAIN (link
))
947 tree type
= TREE_VALUE (link
);
949 if (type
&& ! TREE_ASM_WRITTEN (type
))
950 sdbout_one_type (type
);
957 /* Given a chain of ..._TYPE nodes, all of which have names,
958 output definitions of those names, as typedefs. */
961 sdbout_types (tree types
)
965 for (link
= types
; link
; link
= TREE_CHAIN (link
))
966 sdbout_one_type (link
);
968 #ifdef SDB_ALLOW_FORWARD_REFERENCES
969 sdbout_dequeue_anonymous_types ();
974 sdbout_type (tree type
)
976 if (type
== error_mark_node
)
977 type
= integer_type_node
;
978 PUT_SDB_TYPE (plain_type (type
));
981 /* Output types of the fields of type TYPE, if they are structs.
983 Formerly did not chase through pointer types, since that could be circular.
984 They must come before TYPE, since forward refs are not allowed.
985 Now james@bigtex.cactus.org says to try them. */
988 sdbout_field_types (tree type
)
992 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
993 /* This condition should match the one for emitting the actual
995 if (TREE_CODE (tail
) == FIELD_DECL
998 && host_integerp (DECL_SIZE (tail
), 1)
999 && host_integerp (bit_position (tail
), 0))
1001 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1002 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1004 sdbout_one_type (TREE_TYPE (tail
));
1008 /* Use this to put out the top level defined record and union types
1009 for later reference. If this is a struct with a name, then put that
1010 name out. Other unnamed structs will have .xxfake labels generated so
1011 that they may be referred to later.
1012 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1013 It may NOT be called recursively. */
1016 sdbout_one_type (tree type
)
1018 if (current_function_decl
!= NULL_TREE
1019 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1020 ; /* Don't change section amid function. */
1022 switch_to_section (text_section
);
1024 switch (TREE_CODE (type
))
1028 case QUAL_UNION_TYPE
:
1030 type
= TYPE_MAIN_VARIANT (type
);
1031 /* Don't output a type twice. */
1032 if (TREE_ASM_WRITTEN (type
))
1033 /* James said test TREE_ASM_BEING_WRITTEN here. */
1036 /* Output nothing if type is not yet defined. */
1037 if (!COMPLETE_TYPE_P (type
))
1040 TREE_ASM_WRITTEN (type
) = 1;
1042 /* This is reputed to cause trouble with the following case,
1043 but perhaps checking TYPE_SIZE above will fix it. */
1045 /* Here is a testcase:
1051 typedef struct intermediate {
1055 typedef struct badstr {
1059 /* This change, which ought to make better output,
1060 used to make the COFF assembler unhappy.
1061 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1062 /* Before really doing anything, output types we want to refer to. */
1063 /* Note that in version 1 the following two lines
1064 are not used if forward references are in use. */
1065 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1066 sdbout_field_types (type
);
1068 /* Output a structure type. */
1070 int size
= int_size_in_bytes (type
);
1074 /* Record the type tag, but not in its permanent place just yet. */
1075 sdbout_record_type_name (type
);
1077 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1079 switch (TREE_CODE (type
))
1082 case QUAL_UNION_TYPE
:
1083 PUT_SDB_SCL (C_UNTAG
);
1084 PUT_SDB_TYPE (T_UNION
);
1089 PUT_SDB_SCL (C_STRTAG
);
1090 PUT_SDB_TYPE (T_STRUCT
);
1095 PUT_SDB_SCL (C_ENTAG
);
1096 PUT_SDB_TYPE (T_ENUM
);
1104 PUT_SDB_SIZE (size
);
1107 /* Print out the base class information with fields
1108 named after the types they hold. */
1109 /* This is only relevant to aggregate types. TYPE_BINFO is used
1110 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1112 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1117 for (binfo
= TYPE_BINFO (type
), i
= 0;
1118 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1120 tree child_type
= BINFO_TYPE (child
);
1121 tree child_type_name
;
1123 if (TYPE_NAME (child_type
) == 0)
1125 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1126 child_type_name
= TYPE_NAME (child_type
);
1127 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1129 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1130 if (child_type_name
&& template_name_p (child_type_name
))
1132 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1137 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1138 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1139 PUT_SDB_SCL (member_scl
);
1140 sdbout_type (BINFO_TYPE (child
));
1145 /* Output the individual fields. */
1147 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1149 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1151 tree value
= TREE_VALUE (tem
);
1153 if (TREE_CODE (value
) == CONST_DECL
)
1154 value
= DECL_INITIAL (value
);
1156 if (host_integerp (value
, 0))
1158 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1159 PUT_SDB_INT_VAL (tree_low_cst (value
, 0));
1160 PUT_SDB_SCL (C_MOE
);
1161 PUT_SDB_TYPE (T_MOE
);
1166 else /* record or union type */
1167 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1168 /* Output the name, type, position (in bits), size (in bits)
1171 /* Omit here the nameless fields that are used to skip bits.
1172 Also omit fields with variable size or position.
1173 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1174 if (TREE_CODE (tem
) == FIELD_DECL
1177 && host_integerp (DECL_SIZE (tem
), 1)
1178 && host_integerp (bit_position (tem
), 0))
1182 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1184 if (DECL_BIT_FIELD_TYPE (tem
))
1186 PUT_SDB_INT_VAL (int_bit_position (tem
));
1187 PUT_SDB_SCL (C_FIELD
);
1188 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1189 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1193 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1194 PUT_SDB_SCL (member_scl
);
1195 sdbout_type (TREE_TYPE (tem
));
1199 /* Output end of a structure,union, or enumeral definition. */
1201 PUT_SDB_PLAIN_DEF ("eos");
1202 PUT_SDB_INT_VAL (size
);
1203 PUT_SDB_SCL (C_EOS
);
1204 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1205 PUT_SDB_SIZE (size
);
1215 /* The following two functions output definitions of function parameters.
1216 Each parameter gets a definition locating it in the parameter list.
1217 Each parameter that is a register variable gets a second definition
1218 locating it in the register.
1220 Printing or argument lists in gdb uses the definitions that
1221 locate in the parameter list. But reference to the variable in
1222 expressions uses preferentially the definition as a register. */
1224 /* Output definitions, referring to storage in the parmlist,
1225 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1228 sdbout_parms (tree parms
)
1230 for (; parms
; parms
= TREE_CHAIN (parms
))
1231 if (DECL_NAME (parms
))
1233 int current_sym_value
= 0;
1234 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1236 if (name
== 0 || *name
== 0)
1237 name
= gen_fake_label ();
1239 /* Perform any necessary register eliminations on the parameter's rtl,
1240 so that the debugging output will be accurate. */
1241 DECL_INCOMING_RTL (parms
)
1242 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1243 SET_DECL_RTL (parms
,
1244 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1246 if (PARM_PASSED_IN_MEMORY (parms
))
1248 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1251 /* ??? Here we assume that the parm address is indexed
1252 off the frame pointer or arg pointer.
1253 If that is not true, we produce meaningless results,
1254 but do not crash. */
1255 if (GET_CODE (addr
) == PLUS
1256 && CONST_INT_P (XEXP (addr
, 1)))
1257 current_sym_value
= INTVAL (XEXP (addr
, 1));
1259 current_sym_value
= 0;
1261 if (REG_P (DECL_RTL (parms
))
1262 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1263 type
= DECL_ARG_TYPE (parms
);
1266 int original_sym_value
= current_sym_value
;
1268 /* This is the case where the parm is passed as an int or
1269 double and it is converted to a char, short or float
1270 and stored back in the parmlist. In this case, describe
1271 the parm with the variable's declared type, and adjust
1272 the address if the least significant bytes (which we are
1273 using) are not the first ones. */
1274 if (BYTES_BIG_ENDIAN
1275 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1276 current_sym_value
+=
1277 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1278 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1280 if (MEM_P (DECL_RTL (parms
))
1281 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1282 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1284 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1285 == current_sym_value
))
1286 type
= TREE_TYPE (parms
);
1289 current_sym_value
= original_sym_value
;
1290 type
= DECL_ARG_TYPE (parms
);
1295 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1296 PUT_SDB_SCL (C_ARG
);
1297 PUT_SDB_TYPE (plain_type (type
));
1300 else if (REG_P (DECL_RTL (parms
)))
1303 /* Parm passed in registers and lives in registers or nowhere. */
1305 /* If parm lives in a register, use that register;
1306 pretend the parm was passed there. It would be more consistent
1307 to describe the register where the parm was passed,
1308 but in practice that register usually holds something else. */
1309 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1310 best_rtl
= DECL_RTL (parms
);
1311 /* If the parm lives nowhere,
1312 use the register where it was passed. */
1314 best_rtl
= DECL_INCOMING_RTL (parms
);
1317 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1318 PUT_SDB_SCL (C_REGPARM
);
1319 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1322 else if (MEM_P (DECL_RTL (parms
))
1323 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1325 /* Parm was passed in registers but lives on the stack. */
1327 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1328 in which case we want the value of that CONST_INT,
1329 or (MEM (REG ...)) or (MEM (MEM ...)),
1330 in which case we use a value of zero. */
1331 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1332 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1333 current_sym_value
= 0;
1335 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1337 /* Again, this assumes the offset is based on the arg pointer. */
1339 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1340 XEXP (DECL_RTL (parms
), 0)));
1341 PUT_SDB_SCL (C_ARG
);
1342 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1348 /* Output definitions for the places where parms live during the function,
1349 when different from where they were passed, when the parms were passed
1352 It is not useful to do this for parms passed in registers
1353 that live during the function in different registers, because it is
1354 impossible to look in the passed register for the passed value,
1355 so we use the within-the-function register to begin with.
1357 PARMS is a chain of PARM_DECL nodes. */
1360 sdbout_reg_parms (tree parms
)
1362 for (; parms
; parms
= TREE_CHAIN (parms
))
1363 if (DECL_NAME (parms
))
1365 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1367 /* Report parms that live in registers during the function
1368 but were passed in memory. */
1369 if (REG_P (DECL_RTL (parms
))
1370 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1371 && PARM_PASSED_IN_MEMORY (parms
))
1373 if (name
== 0 || *name
== 0)
1374 name
= gen_fake_label ();
1376 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1377 PUT_SDB_SCL (C_REG
);
1378 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1381 /* Report parms that live in memory but not where they were passed. */
1382 else if (MEM_P (DECL_RTL (parms
))
1383 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1384 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1385 && PARM_PASSED_IN_MEMORY (parms
)
1386 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1388 #if 0 /* ??? It is not clear yet what should replace this. */
1389 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1390 /* A parm declared char is really passed as an int,
1391 so it occupies the least significant bytes.
1392 On a big-endian machine those are not the low-numbered ones. */
1393 if (BYTES_BIG_ENDIAN
1395 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1396 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1397 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1398 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1401 if (name
== 0 || *name
== 0)
1402 name
= gen_fake_label ();
1404 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1405 (XEXP (DECL_RTL (parms
), 0)));
1406 PUT_SDB_SCL (C_AUTO
);
1407 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1414 /* Output debug information for a global DECL. Called from toplev.c
1415 after compilation proper has finished. */
1418 sdbout_global_decl (tree decl
)
1420 if (TREE_CODE (decl
) == VAR_DECL
1421 && !DECL_EXTERNAL (decl
)
1422 && DECL_RTL_SET_P (decl
))
1424 /* The COFF linker can move initialized global vars to the end.
1425 And that can screw up the symbol ordering. Defer those for
1426 sdbout_finish (). */
1427 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1428 sdbout_symbol (decl
, 0);
1430 VEC_safe_push (tree
, gc
, deferred_global_decls
, decl
);
1432 /* Output COFF information for non-global file-scope initialized
1434 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1435 sdbout_toplevel_data (decl
);
1439 /* Output initialized global vars at the end, in the order of
1440 definition. See comment in sdbout_global_decl. */
1443 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1448 FOR_EACH_VEC_ELT (tree
, deferred_global_decls
, i
, decl
)
1449 sdbout_symbol (decl
, 0);
1452 /* Describe the beginning of an internal block within a function.
1453 Also output descriptions of variables defined in this block.
1455 N is the number of the block, by order of beginning, counting from 1,
1456 and not counting the outermost (function top-level) block.
1457 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1458 if the count starts at 0 for the outermost one. */
1461 sdbout_begin_block (unsigned int line
, unsigned int n
)
1463 tree decl
= current_function_decl
;
1464 MAKE_LINE_SAFE (line
);
1466 /* The SCO compiler does not emit a separate block for the function level
1467 scope, so we avoid it here also. */
1468 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1472 /* Include the outermost BLOCK's variables in block 1. */
1473 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1474 sdbout_block (DECL_INITIAL (decl
));
1476 /* If -g1, suppress all the internal symbols of functions
1477 except for arguments. */
1478 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1481 sdbout_block (DECL_INITIAL (decl
));
1484 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1485 sdbout_dequeue_anonymous_types ();
1489 /* Describe the end line-number of an internal block within a function. */
1492 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1494 MAKE_LINE_SAFE (line
);
1496 /* The SCO compiler does not emit a separate block for the function level
1497 scope, so we avoid it here also. */
1499 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1502 /* Output a line number symbol entry for source file FILENAME and line
1506 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1507 int discriminator ATTRIBUTE_UNUSED
,
1508 bool is_stmt ATTRIBUTE_UNUSED
)
1510 /* COFF relative line numbers must be positive. */
1511 if ((int) line
> sdb_begin_function_line
)
1513 #ifdef SDB_OUTPUT_SOURCE_LINE
1514 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1516 fprintf (asm_out_file
, "\t.ln\t%d\n",
1517 ((sdb_begin_function_line
> -1)
1518 ? line
- sdb_begin_function_line
: 1));
1523 /* Output sdb info for the current function name.
1524 Called from assemble_start_function. */
1527 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1529 sdbout_symbol (current_function_decl
, 0);
1532 /* Called at beginning of function body after prologue. Record the
1533 function's starting line number, so we can output relative line numbers
1534 for the other lines. Describe beginning of outermost block. Also
1535 describe the parameter list. */
1538 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1540 sdbout_end_prologue (line
, file
);
1544 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1546 sdb_begin_function_line
= line
- 1;
1547 PUT_SDB_FUNCTION_START (line
);
1548 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1549 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1552 /* Called at end of function (before epilogue).
1553 Describe end of outermost block. */
1556 sdbout_end_function (unsigned int line
)
1558 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1559 sdbout_dequeue_anonymous_types ();
1562 MAKE_LINE_SAFE (line
);
1563 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1565 /* Indicate we are between functions, for line-number output. */
1566 sdb_begin_function_line
= -1;
1569 /* Output sdb info for the absolute end of a function.
1570 Called after the epilogue is output. */
1573 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1574 const char *file ATTRIBUTE_UNUSED
)
1576 const char *const name ATTRIBUTE_UNUSED
1577 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1579 #ifdef PUT_SDB_EPILOGUE_END
1580 PUT_SDB_EPILOGUE_END (name
);
1582 fprintf (asm_out_file
, "\t.def\t");
1583 assemble_name (asm_out_file
, name
);
1584 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1585 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1589 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1593 sdbout_label (rtx insn
)
1595 PUT_SDB_DEF (LABEL_NAME (insn
));
1597 PUT_SDB_SCL (C_LABEL
);
1598 PUT_SDB_TYPE (T_NULL
);
1602 /* Change to reading from a new source file. */
1605 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1606 const char *filename ATTRIBUTE_UNUSED
)
1610 /* Revert to reading a previous source file. */
1613 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1617 /* Set up for SDB output at the start of compilation. */
1620 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1624 deferred_global_decls
= VEC_alloc (tree
, gc
, 12);
1626 /* Emit debug information which was queued by sdbout_symbol before
1628 sdbout_initialized
= true;
1630 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1631 sdbout_symbol (TREE_VALUE (t
), 0);
1632 preinit_symbols
= 0;
1635 #endif /* SDB_DEBUGGING_INFO */
1637 #include "gt-sdbout.h"