1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988-2013 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"
51 static GTY(()) tree anonymous_types
;
53 /* Counter to generate unique "names" for nameless struct members. */
55 static GTY(()) int unnamed_struct_number
;
57 /* Declarations whose debug info was deferred till end of compilation. */
59 static GTY(()) vec
<tree
, va_gc
> *deferred_global_decls
;
61 /* The C front end may call sdbout_symbol before sdbout_init runs.
62 We save all such decls in this list and output them when we get
65 static GTY(()) tree preinit_symbols
;
66 static GTY(()) bool sdbout_initialized
;
68 #ifdef SDB_DEBUGGING_INFO
73 #include "insn-config.h"
76 #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_global_decl (tree
);
121 static void sdbout_begin_prologue (unsigned int, const char *);
122 static void sdbout_end_prologue (unsigned int, const char *);
123 static void sdbout_begin_function (tree
);
124 static void sdbout_end_function (unsigned int);
125 static void sdbout_toplevel_data (tree
);
126 static void sdbout_label (rtx
);
127 static char *gen_fake_label (void);
128 static int plain_type (tree
);
129 static int template_name_p (tree
);
130 static void sdbout_record_type_name (tree
);
131 static int plain_type_1 (tree
, int);
132 static void sdbout_block (tree
);
133 static void sdbout_syms (tree
);
134 #ifdef SDB_ALLOW_FORWARD_REFERENCES
135 static void sdbout_queue_anonymous_type (tree
);
136 static void sdbout_dequeue_anonymous_types (void);
138 static void sdbout_type (tree
);
139 static void sdbout_field_types (tree
);
140 static void sdbout_one_type (tree
);
141 static void sdbout_parms (tree
);
142 static void sdbout_reg_parms (tree
);
143 static void sdbout_global_decl (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
, /* assembly_start */
281 debug_nothing_int_charstar
, /* define */
282 debug_nothing_int_charstar
, /* undef */
283 sdbout_start_source_file
, /* start_source_file */
284 sdbout_end_source_file
, /* end_source_file */
285 sdbout_begin_block
, /* begin_block */
286 sdbout_end_block
, /* end_block */
287 debug_true_const_tree
, /* ignore_block */
288 sdbout_source_line
, /* source_line */
289 sdbout_begin_prologue
, /* begin_prologue */
290 debug_nothing_int_charstar
, /* end_prologue */
291 debug_nothing_int_charstar
, /* begin_epilogue */
292 sdbout_end_epilogue
, /* end_epilogue */
293 sdbout_begin_function
, /* begin_function */
294 sdbout_end_function
, /* end_function */
295 debug_nothing_tree
, /* function_decl */
296 sdbout_global_decl
, /* global_decl */
297 sdbout_symbol
, /* type_decl */
298 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
299 debug_nothing_tree
, /* deferred_inline_function */
300 debug_nothing_tree
, /* outlining_inline_function */
301 sdbout_label
, /* label */
302 debug_nothing_int
, /* handle_pch */
303 debug_nothing_rtx
, /* var_location */
304 debug_nothing_void
, /* switch_text_section */
305 debug_nothing_tree_tree
, /* set_name */
306 0, /* start_end_main_source_file */
307 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
310 /* Return a unique string to name an anonymous type. */
313 gen_fake_label (void)
317 sprintf (label
, ".%dfake", unnamed_struct_number
);
318 unnamed_struct_number
++;
319 labelstr
= xstrdup (label
);
323 /* Return the number which describes TYPE for SDB.
324 For pointers, etc., this function is recursive.
325 Each record, union or enumeral type must already have had a
326 tag number output. */
328 /* The number is given by d6d5d4d3d2d1bbbb
329 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
330 Thus, char *foo () has bbbb=T_CHAR
333 N_BTMASK= 017 1111 basic type field.
334 N_TSHIFT= 2 derived type shift
335 N_BTSHFT= 4 Basic type shift */
337 /* Produce the number that describes a pointer, function or array type.
338 PREV is the number describing the target, value or element type.
339 DT_type describes how to transform that type. */
340 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
341 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
342 | ((int) DT_type << (int) N_BTSHFT) \
343 | ((PREV) & (int) N_BTMASK))
345 /* Number of elements used in sdb_dims. */
346 static int sdb_n_dims
= 0;
348 /* Table of array dimensions of current type. */
349 static int sdb_dims
[SDB_MAX_DIM
];
351 /* Size of outermost array currently being processed. */
352 static int sdb_type_size
= -1;
355 plain_type (tree type
)
357 int val
= plain_type_1 (type
, 0);
359 /* If we have already saved up some array dimensions, print them now. */
364 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
365 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
366 PUT_SDB_LAST_DIM (sdb_dims
[0]);
369 sdb_type_size
= int_size_in_bytes (type
);
370 /* Don't kill sdb if type is not laid out or has variable size. */
371 if (sdb_type_size
< 0)
374 /* If we have computed the size of an array containing this type,
376 if (sdb_type_size
>= 0)
378 PUT_SDB_SIZE (sdb_type_size
);
385 template_name_p (tree name
)
387 const char *ptr
= IDENTIFIER_POINTER (name
);
388 while (*ptr
&& *ptr
!= '<')
395 sdbout_record_type_name (tree type
)
397 const char *name
= 0;
400 if (KNOWN_TYPE_TAG (type
))
403 if (TYPE_NAME (type
) != 0)
407 /* Find the IDENTIFIER_NODE for the type name. */
408 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
409 t
= TYPE_NAME (type
);
410 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
412 t
= DECL_NAME (TYPE_NAME (type
));
413 /* The DECL_NAME for templates includes "<>", which breaks
414 most assemblers. Use its assembler name instead, which
415 has been mangled into being safe. */
416 if (t
&& template_name_p (t
))
417 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
420 /* Now get the name as a string, or invent one. */
422 name
= IDENTIFIER_POINTER (t
);
425 no_name
= (name
== 0 || *name
== 0);
427 name
= gen_fake_label ();
429 SET_KNOWN_TYPE_TAG (type
, name
);
430 #ifdef SDB_ALLOW_FORWARD_REFERENCES
432 sdbout_queue_anonymous_type (type
);
436 /* Return the .type value for type TYPE.
438 LEVEL indicates how many levels deep we have recursed into the type.
439 The SDB debug format can only represent 6 derived levels of types.
440 After that, we must output inaccurate debug info. We deliberately
441 stop before the 7th level, so that ADA recursive types will not give an
445 plain_type_1 (tree type
, int level
)
448 type
= void_type_node
;
449 else if (type
== error_mark_node
)
450 type
= integer_type_node
;
452 type
= TYPE_MAIN_VARIANT (type
);
454 switch (TREE_CODE (type
))
462 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
464 /* Carefully distinguish all the standard types of C,
465 without messing up if the language is not C.
466 Note that we check only for the names that contain spaces;
467 other names might occur by coincidence in other languages. */
468 if (TYPE_NAME (type
) != 0
469 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
470 && DECL_NAME (TYPE_NAME (type
)) != 0
471 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
473 const char *const name
474 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
476 if (!strcmp (name
, "char"))
478 if (!strcmp (name
, "unsigned char"))
480 if (!strcmp (name
, "signed char"))
482 if (!strcmp (name
, "int"))
484 if (!strcmp (name
, "unsigned int"))
486 if (!strcmp (name
, "short int"))
488 if (!strcmp (name
, "short unsigned int"))
490 if (!strcmp (name
, "long int"))
492 if (!strcmp (name
, "long unsigned int"))
496 if (size
== INT_TYPE_SIZE
)
497 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
498 if (size
== CHAR_TYPE_SIZE
)
499 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
500 if (size
== SHORT_TYPE_SIZE
)
501 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
502 if (size
== LONG_TYPE_SIZE
)
503 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
504 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
505 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
511 int precision
= TYPE_PRECISION (type
);
512 if (precision
== FLOAT_TYPE_SIZE
)
514 if (precision
== DOUBLE_TYPE_SIZE
)
516 #ifdef EXTENDED_SDB_BASIC_TYPES
517 if (precision
== LONG_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
))
741 eliminate_regs (DECL_RTL (decl
), VOIDmode
, NULL_RTX
));
742 #ifdef LEAF_REG_REMAP
743 if (crtl
->uses_only_leaf_regs
)
744 leaf_renumber_regs_insn (DECL_RTL (decl
));
746 value
= DECL_RTL (decl
);
748 /* Don't mention a variable at all
749 if it was completely optimized into nothingness.
751 If DECL was from an inline function, then its rtl
752 is not identically the rtl that was used in this
753 particular compilation. */
756 regno
= REGNO (value
);
757 if (regno
>= FIRST_PSEUDO_REGISTER
)
760 else if (GET_CODE (value
) == SUBREG
)
762 while (GET_CODE (value
) == SUBREG
)
763 value
= SUBREG_REG (value
);
766 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
769 regno
= REGNO (alter_subreg (&value
, true));
770 SET_DECL_RTL (decl
, value
);
772 /* Don't output anything if an auto variable
773 gets RTL that is static.
774 GAS version 2.2 can't handle such output. */
775 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
776 && ! TREE_STATIC (decl
))
779 /* Emit any structure, union, or enum type that has not been output.
780 This occurs for tag-less structs (et al) used to declare variables
782 if (TREE_CODE (type
) == ENUMERAL_TYPE
783 || TREE_CODE (type
) == RECORD_TYPE
784 || TREE_CODE (type
) == UNION_TYPE
785 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
787 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
788 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
789 sdbout_one_type (type
);
792 /* Defer SDB information for top-level initialized variables! */
795 && DECL_INITIAL (decl
))
798 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
799 For now, avoid crashing. */
800 if (DECL_NAME (decl
) == NULL_TREE
)
803 /* Record the name for, starting a symtab entry. */
805 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
807 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
810 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
813 if (TREE_PUBLIC (decl
))
815 PUT_SDB_VAL (XEXP (value
, 0));
820 PUT_SDB_VAL (XEXP (value
, 0));
821 PUT_SDB_SCL (C_STAT
);
827 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
830 else if (MEM_P (value
)
831 && (MEM_P (XEXP (value
, 0))
832 || (REG_P (XEXP (value
, 0))
833 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
834 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
835 /* If the value is indirect by memory or by a register
836 that isn't the frame pointer
837 then it means the object is variable-sized and address through
838 that register or stack slot. COFF has no way to represent this
839 so all we can do is output the variable as a pointer. */
842 if (REG_P (XEXP (value
, 0)))
844 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
849 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
851 We want the value of that CONST_INT. */
852 /* Encore compiler hates a newline in a macro arg, it seems. */
853 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
854 (XEXP (XEXP (value
, 0), 0)));
855 PUT_SDB_SCL (C_AUTO
);
858 /* Effectively do build_pointer_type, but don't cache this type,
859 since it might be temporary whereas the type it points to
860 might have been saved for inlining. */
861 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
862 type
= make_node (POINTER_TYPE
);
863 TREE_TYPE (type
) = TREE_TYPE (decl
);
865 else if (MEM_P (value
)
866 && ((GET_CODE (XEXP (value
, 0)) == PLUS
867 && REG_P (XEXP (XEXP (value
, 0), 0))
868 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
869 /* This is for variables which are at offset zero from
870 the frame pointer. This happens on the Alpha.
871 Non-frame pointer registers are excluded above. */
872 || (REG_P (XEXP (value
, 0)))))
874 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
875 or (MEM (REG...)). We want the value of that CONST_INT
878 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
879 PUT_SDB_SCL (C_AUTO
);
883 /* It is something we don't know how to represent for SDB. */
891 PUT_SDB_TYPE (plain_type (type
));
895 /* Output SDB information for a top-level initialized variable
896 that has been delayed. */
899 sdbout_toplevel_data (tree decl
)
901 tree type
= TREE_TYPE (decl
);
903 if (DECL_IGNORED_P (decl
))
906 gcc_assert (TREE_CODE (decl
) == VAR_DECL
);
907 gcc_assert (MEM_P (DECL_RTL (decl
)));
908 gcc_assert (DECL_INITIAL (decl
));
910 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
911 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
912 if (TREE_PUBLIC (decl
))
918 PUT_SDB_SCL (C_STAT
);
920 PUT_SDB_TYPE (plain_type (type
));
924 #ifdef SDB_ALLOW_FORWARD_REFERENCES
926 /* Machinery to record and output anonymous types. */
929 sdbout_queue_anonymous_type (tree type
)
931 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
935 sdbout_dequeue_anonymous_types (void)
939 while (anonymous_types
)
941 types
= nreverse (anonymous_types
);
942 anonymous_types
= NULL_TREE
;
944 for (link
= types
; link
; link
= TREE_CHAIN (link
))
946 tree type
= TREE_VALUE (link
);
948 if (type
&& ! TREE_ASM_WRITTEN (type
))
949 sdbout_one_type (type
);
956 /* Given a chain of ..._TYPE nodes, all of which have names,
957 output definitions of those names, as typedefs. */
960 sdbout_types (tree types
)
964 for (link
= types
; link
; link
= TREE_CHAIN (link
))
965 sdbout_one_type (link
);
967 #ifdef SDB_ALLOW_FORWARD_REFERENCES
968 sdbout_dequeue_anonymous_types ();
973 sdbout_type (tree type
)
975 if (type
== error_mark_node
)
976 type
= integer_type_node
;
977 PUT_SDB_TYPE (plain_type (type
));
980 /* Output types of the fields of type TYPE, if they are structs.
982 Formerly did not chase through pointer types, since that could be circular.
983 They must come before TYPE, since forward refs are not allowed.
984 Now james@bigtex.cactus.org says to try them. */
987 sdbout_field_types (tree type
)
991 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
992 /* This condition should match the one for emitting the actual
994 if (TREE_CODE (tail
) == FIELD_DECL
997 && tree_fits_uhwi_p (DECL_SIZE (tail
))
998 && tree_fits_shwi_p (bit_position (tail
)))
1000 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1001 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1003 sdbout_one_type (TREE_TYPE (tail
));
1007 /* Use this to put out the top level defined record and union types
1008 for later reference. If this is a struct with a name, then put that
1009 name out. Other unnamed structs will have .xxfake labels generated so
1010 that they may be referred to later.
1011 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1012 It may NOT be called recursively. */
1015 sdbout_one_type (tree type
)
1017 if (current_function_decl
!= NULL_TREE
1018 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1019 ; /* Don't change section amid function. */
1021 switch_to_section (current_function_section ());
1023 switch (TREE_CODE (type
))
1027 case QUAL_UNION_TYPE
:
1029 type
= TYPE_MAIN_VARIANT (type
);
1030 /* Don't output a type twice. */
1031 if (TREE_ASM_WRITTEN (type
))
1032 /* James said test TREE_ASM_BEING_WRITTEN here. */
1035 /* Output nothing if type is not yet defined. */
1036 if (!COMPLETE_TYPE_P (type
))
1039 TREE_ASM_WRITTEN (type
) = 1;
1041 /* This is reputed to cause trouble with the following case,
1042 but perhaps checking TYPE_SIZE above will fix it. */
1044 /* Here is a testcase:
1050 typedef struct intermediate {
1054 typedef struct badstr {
1058 /* This change, which ought to make better output,
1059 used to make the COFF assembler unhappy.
1060 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1061 /* Before really doing anything, output types we want to refer to. */
1062 /* Note that in version 1 the following two lines
1063 are not used if forward references are in use. */
1064 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1065 sdbout_field_types (type
);
1067 /* Output a structure type. */
1069 int size
= int_size_in_bytes (type
);
1073 /* Record the type tag, but not in its permanent place just yet. */
1074 sdbout_record_type_name (type
);
1076 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1078 switch (TREE_CODE (type
))
1081 case QUAL_UNION_TYPE
:
1082 PUT_SDB_SCL (C_UNTAG
);
1083 PUT_SDB_TYPE (T_UNION
);
1088 PUT_SDB_SCL (C_STRTAG
);
1089 PUT_SDB_TYPE (T_STRUCT
);
1094 PUT_SDB_SCL (C_ENTAG
);
1095 PUT_SDB_TYPE (T_ENUM
);
1103 PUT_SDB_SIZE (size
);
1106 /* Print out the base class information with fields
1107 named after the types they hold. */
1108 /* This is only relevant to aggregate types. TYPE_BINFO is used
1109 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1111 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1116 for (binfo
= TYPE_BINFO (type
), i
= 0;
1117 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1119 tree child_type
= BINFO_TYPE (child
);
1120 tree child_type_name
;
1122 if (TYPE_NAME (child_type
) == 0)
1124 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1125 child_type_name
= TYPE_NAME (child_type
);
1126 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1128 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1129 if (child_type_name
&& template_name_p (child_type_name
))
1131 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1136 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1137 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child
)));
1138 PUT_SDB_SCL (member_scl
);
1139 sdbout_type (BINFO_TYPE (child
));
1144 /* Output the individual fields. */
1146 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1148 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1150 tree value
= TREE_VALUE (tem
);
1152 if (TREE_CODE (value
) == CONST_DECL
)
1153 value
= DECL_INITIAL (value
);
1155 if (tree_fits_shwi_p (value
))
1157 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1158 PUT_SDB_INT_VAL (tree_to_shwi (value
));
1159 PUT_SDB_SCL (C_MOE
);
1160 PUT_SDB_TYPE (T_MOE
);
1165 else /* record or union type */
1166 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1167 /* Output the name, type, position (in bits), size (in bits)
1170 /* Omit here the nameless fields that are used to skip bits.
1171 Also omit fields with variable size or position.
1172 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1173 if (TREE_CODE (tem
) == FIELD_DECL
1176 && tree_fits_uhwi_p (DECL_SIZE (tem
))
1177 && tree_fits_shwi_p (bit_position (tem
)))
1181 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1183 if (DECL_BIT_FIELD_TYPE (tem
))
1185 PUT_SDB_INT_VAL (int_bit_position (tem
));
1186 PUT_SDB_SCL (C_FIELD
);
1187 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1188 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem
)));
1192 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1193 PUT_SDB_SCL (member_scl
);
1194 sdbout_type (TREE_TYPE (tem
));
1198 /* Output end of a structure,union, or enumeral definition. */
1200 PUT_SDB_PLAIN_DEF ("eos");
1201 PUT_SDB_INT_VAL (size
);
1202 PUT_SDB_SCL (C_EOS
);
1203 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1204 PUT_SDB_SIZE (size
);
1214 /* The following two functions output definitions of function parameters.
1215 Each parameter gets a definition locating it in the parameter list.
1216 Each parameter that is a register variable gets a second definition
1217 locating it in the register.
1219 Printing or argument lists in gdb uses the definitions that
1220 locate in the parameter list. But reference to the variable in
1221 expressions uses preferentially the definition as a register. */
1223 /* Output definitions, referring to storage in the parmlist,
1224 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1227 sdbout_parms (tree parms
)
1229 for (; parms
; parms
= TREE_CHAIN (parms
))
1230 if (DECL_NAME (parms
))
1232 int current_sym_value
= 0;
1233 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1235 if (name
== 0 || *name
== 0)
1236 name
= gen_fake_label ();
1238 /* Perform any necessary register eliminations on the parameter's rtl,
1239 so that the debugging output will be accurate. */
1240 DECL_INCOMING_RTL (parms
)
1241 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1242 SET_DECL_RTL (parms
,
1243 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1245 if (PARM_PASSED_IN_MEMORY (parms
))
1247 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1250 /* ??? Here we assume that the parm address is indexed
1251 off the frame pointer or arg pointer.
1252 If that is not true, we produce meaningless results,
1253 but do not crash. */
1254 if (GET_CODE (addr
) == PLUS
1255 && CONST_INT_P (XEXP (addr
, 1)))
1256 current_sym_value
= INTVAL (XEXP (addr
, 1));
1258 current_sym_value
= 0;
1260 if (REG_P (DECL_RTL (parms
))
1261 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1262 type
= DECL_ARG_TYPE (parms
);
1265 int original_sym_value
= current_sym_value
;
1267 /* This is the case where the parm is passed as an int or
1268 double and it is converted to a char, short or float
1269 and stored back in the parmlist. In this case, describe
1270 the parm with the variable's declared type, and adjust
1271 the address if the least significant bytes (which we are
1272 using) are not the first ones. */
1273 if (BYTES_BIG_ENDIAN
1274 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1275 current_sym_value
+=
1276 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1277 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1279 if (MEM_P (DECL_RTL (parms
))
1280 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1281 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1283 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1284 == current_sym_value
))
1285 type
= TREE_TYPE (parms
);
1288 current_sym_value
= original_sym_value
;
1289 type
= DECL_ARG_TYPE (parms
);
1294 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1295 PUT_SDB_SCL (C_ARG
);
1296 PUT_SDB_TYPE (plain_type (type
));
1299 else if (REG_P (DECL_RTL (parms
)))
1302 /* Parm passed in registers and lives in registers or nowhere. */
1304 /* If parm lives in a register, use that register;
1305 pretend the parm was passed there. It would be more consistent
1306 to describe the register where the parm was passed,
1307 but in practice that register usually holds something else. */
1308 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1309 best_rtl
= DECL_RTL (parms
);
1310 /* If the parm lives nowhere,
1311 use the register where it was passed. */
1313 best_rtl
= DECL_INCOMING_RTL (parms
);
1316 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1317 PUT_SDB_SCL (C_REGPARM
);
1318 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1321 else if (MEM_P (DECL_RTL (parms
))
1322 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1324 /* Parm was passed in registers but lives on the stack. */
1326 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1327 in which case we want the value of that CONST_INT,
1328 or (MEM (REG ...)) or (MEM (MEM ...)),
1329 in which case we use a value of zero. */
1330 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1331 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1332 current_sym_value
= 0;
1334 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1336 /* Again, this assumes the offset is based on the arg pointer. */
1338 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1339 XEXP (DECL_RTL (parms
), 0)));
1340 PUT_SDB_SCL (C_ARG
);
1341 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1347 /* Output definitions for the places where parms live during the function,
1348 when different from where they were passed, when the parms were passed
1351 It is not useful to do this for parms passed in registers
1352 that live during the function in different registers, because it is
1353 impossible to look in the passed register for the passed value,
1354 so we use the within-the-function register to begin with.
1356 PARMS is a chain of PARM_DECL nodes. */
1359 sdbout_reg_parms (tree parms
)
1361 for (; parms
; parms
= TREE_CHAIN (parms
))
1362 if (DECL_NAME (parms
))
1364 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1366 /* Report parms that live in registers during the function
1367 but were passed in memory. */
1368 if (REG_P (DECL_RTL (parms
))
1369 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1370 && PARM_PASSED_IN_MEMORY (parms
))
1372 if (name
== 0 || *name
== 0)
1373 name
= gen_fake_label ();
1375 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1376 PUT_SDB_SCL (C_REG
);
1377 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1380 /* Report parms that live in memory but not where they were passed. */
1381 else if (MEM_P (DECL_RTL (parms
))
1382 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1383 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1384 && PARM_PASSED_IN_MEMORY (parms
)
1385 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1387 #if 0 /* ??? It is not clear yet what should replace this. */
1388 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1389 /* A parm declared char is really passed as an int,
1390 so it occupies the least significant bytes.
1391 On a big-endian machine those are not the low-numbered ones. */
1392 if (BYTES_BIG_ENDIAN
1394 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1395 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1396 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1397 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1400 if (name
== 0 || *name
== 0)
1401 name
= gen_fake_label ();
1403 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1404 (XEXP (DECL_RTL (parms
), 0)));
1405 PUT_SDB_SCL (C_AUTO
);
1406 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1413 /* Output debug information for a global DECL. Called from toplev.c
1414 after compilation proper has finished. */
1417 sdbout_global_decl (tree decl
)
1419 if (TREE_CODE (decl
) == VAR_DECL
1420 && !DECL_EXTERNAL (decl
)
1421 && DECL_RTL_SET_P (decl
))
1423 /* The COFF linker can move initialized global vars to the end.
1424 And that can screw up the symbol ordering. Defer those for
1425 sdbout_finish (). */
1426 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1427 sdbout_symbol (decl
, 0);
1429 vec_safe_push (deferred_global_decls
, decl
);
1431 /* Output COFF information for non-global file-scope initialized
1433 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1434 sdbout_toplevel_data (decl
);
1438 /* Output initialized global vars at the end, in the order of
1439 definition. See comment in sdbout_global_decl. */
1442 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1447 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls
, i
, decl
)
1448 sdbout_symbol (decl
, 0);
1451 /* Describe the beginning of an internal block within a function.
1452 Also output descriptions of variables defined in this block.
1454 N is the number of the block, by order of beginning, counting from 1,
1455 and not counting the outermost (function top-level) block.
1456 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1457 if the count starts at 0 for the outermost one. */
1460 sdbout_begin_block (unsigned int line
, unsigned int n
)
1462 tree decl
= current_function_decl
;
1463 MAKE_LINE_SAFE (line
);
1465 /* The SCO compiler does not emit a separate block for the function level
1466 scope, so we avoid it here also. */
1467 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1471 /* Include the outermost BLOCK's variables in block 1. */
1472 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1473 sdbout_block (DECL_INITIAL (decl
));
1475 /* If -g1, suppress all the internal symbols of functions
1476 except for arguments. */
1477 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1480 sdbout_block (DECL_INITIAL (decl
));
1483 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1484 sdbout_dequeue_anonymous_types ();
1488 /* Describe the end line-number of an internal block within a function. */
1491 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1493 MAKE_LINE_SAFE (line
);
1495 /* The SCO compiler does not emit a separate block for the function level
1496 scope, so we avoid it here also. */
1498 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1501 /* Output a line number symbol entry for source file FILENAME and line
1505 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1506 int discriminator ATTRIBUTE_UNUSED
,
1507 bool is_stmt ATTRIBUTE_UNUSED
)
1509 /* COFF relative line numbers must be positive. */
1510 if ((int) line
> sdb_begin_function_line
)
1512 #ifdef SDB_OUTPUT_SOURCE_LINE
1513 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1515 fprintf (asm_out_file
, "\t.ln\t%d\n",
1516 ((sdb_begin_function_line
> -1)
1517 ? line
- sdb_begin_function_line
: 1));
1522 /* Output sdb info for the current function name.
1523 Called from assemble_start_function. */
1526 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1528 sdbout_symbol (current_function_decl
, 0);
1531 /* Called at beginning of function body after prologue. Record the
1532 function's starting line number, so we can output relative line numbers
1533 for the other lines. Describe beginning of outermost block. Also
1534 describe the parameter list. */
1537 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1539 sdbout_end_prologue (line
, file
);
1543 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1545 sdb_begin_function_line
= line
- 1;
1546 PUT_SDB_FUNCTION_START (line
);
1547 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1548 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1551 /* Called at end of function (before epilogue).
1552 Describe end of outermost block. */
1555 sdbout_end_function (unsigned int line
)
1557 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1558 sdbout_dequeue_anonymous_types ();
1561 MAKE_LINE_SAFE (line
);
1562 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1564 /* Indicate we are between functions, for line-number output. */
1565 sdb_begin_function_line
= -1;
1568 /* Output sdb info for the absolute end of a function.
1569 Called after the epilogue is output. */
1572 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1573 const char *file ATTRIBUTE_UNUSED
)
1575 const char *const name ATTRIBUTE_UNUSED
1576 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1578 #ifdef PUT_SDB_EPILOGUE_END
1579 PUT_SDB_EPILOGUE_END (name
);
1581 fprintf (asm_out_file
, "\t.def\t");
1582 assemble_name (asm_out_file
, name
);
1583 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1584 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1588 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1592 sdbout_label (rtx insn
)
1594 PUT_SDB_DEF (LABEL_NAME (insn
));
1596 PUT_SDB_SCL (C_LABEL
);
1597 PUT_SDB_TYPE (T_NULL
);
1601 /* Change to reading from a new source file. */
1604 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1605 const char *filename ATTRIBUTE_UNUSED
)
1609 /* Revert to reading a previous source file. */
1612 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1616 /* Set up for SDB output at the start of compilation. */
1619 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1623 vec_alloc (deferred_global_decls
, 12);
1625 /* Emit debug information which was queued by sdbout_symbol before
1627 sdbout_initialized
= true;
1629 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1630 sdbout_symbol (TREE_VALUE (t
), 0);
1631 preinit_symbols
= 0;
1634 #endif /* SDB_DEBUGGING_INFO */
1636 #include "gt-sdbout.h"