1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988-2015 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"
55 #include "stor-layout.h"
59 static GTY(()) tree anonymous_types
;
61 /* Counter to generate unique "names" for nameless struct members. */
63 static GTY(()) int unnamed_struct_number
;
65 /* Declarations whose debug info was deferred till end of compilation. */
67 static GTY(()) vec
<tree
, va_gc
> *deferred_global_decls
;
69 /* The C front end may call sdbout_symbol before sdbout_init runs.
70 We save all such decls in this list and output them when we get
73 static GTY(()) tree preinit_symbols
;
74 static GTY(()) bool sdbout_initialized
;
76 #ifdef SDB_DEBUGGING_INFO
81 #include "insn-config.h"
84 #include "diagnostic-core.h"
87 #include "langhooks.h"
90 /* 1 if PARM is passed to this function in memory. */
92 #define PARM_PASSED_IN_MEMORY(PARM) \
93 (MEM_P (DECL_INCOMING_RTL (PARM)))
95 /* A C expression for the integer offset value of an automatic variable
96 (C_AUTO) having address X (an RTX). */
97 #ifndef DEBUGGER_AUTO_OFFSET
98 #define DEBUGGER_AUTO_OFFSET(X) \
99 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
102 /* A C expression for the integer offset value of an argument (C_ARG)
103 having address X (an RTX). The nominal offset is OFFSET. */
104 #ifndef DEBUGGER_ARG_OFFSET
105 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
108 /* Line number of beginning of current function, minus one.
109 Negative means not in a function or not using sdb. */
111 int sdb_begin_function_line
= -1;
114 extern FILE *asm_out_file
;
116 extern tree current_function_decl
;
120 static void sdbout_init (const char *);
121 static void sdbout_finish (const char *);
122 static void sdbout_start_source_file (unsigned int, const char *);
123 static void sdbout_end_source_file (unsigned int);
124 static void sdbout_begin_block (unsigned int, unsigned int);
125 static void sdbout_end_block (unsigned int, unsigned int);
126 static void sdbout_source_line (unsigned int, const char *, int, bool);
127 static void sdbout_end_epilogue (unsigned int, const char *);
128 static void sdbout_early_global_decl (tree
);
129 static void sdbout_late_global_decl (tree
);
130 static void sdbout_begin_prologue (unsigned int, const char *);
131 static void sdbout_end_prologue (unsigned int, const char *);
132 static void sdbout_begin_function (tree
);
133 static void sdbout_end_function (unsigned int);
134 static void sdbout_toplevel_data (tree
);
135 static void sdbout_label (rtx_code_label
*);
136 static char *gen_fake_label (void);
137 static int plain_type (tree
);
138 static int template_name_p (tree
);
139 static void sdbout_record_type_name (tree
);
140 static int plain_type_1 (tree
, int);
141 static void sdbout_block (tree
);
142 static void sdbout_syms (tree
);
143 #ifdef SDB_ALLOW_FORWARD_REFERENCES
144 static void sdbout_queue_anonymous_type (tree
);
145 static void sdbout_dequeue_anonymous_types (void);
147 static void sdbout_type (tree
);
148 static void sdbout_field_types (tree
);
149 static void sdbout_one_type (tree
);
150 static void sdbout_parms (tree
);
151 static void sdbout_reg_parms (tree
);
153 /* Random macros describing parts of SDB data. */
155 /* Default value of delimiter is ";". */
157 #define SDB_DELIM ";"
160 /* Maximum number of dimensions the assembler will allow. */
162 #define SDB_MAX_DIM 4
166 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
169 #ifndef PUT_SDB_INT_VAL
170 #define PUT_SDB_INT_VAL(a) \
172 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
173 (HOST_WIDE_INT) (a), SDB_DELIM); \
179 #define PUT_SDB_VAL(a) \
180 ( fputs ("\t.val\t", asm_out_file), \
181 output_addr_const (asm_out_file, (a)), \
182 fprintf (asm_out_file, SDB_DELIM))
186 #define PUT_SDB_DEF(a) \
187 do { fprintf (asm_out_file, "\t.def\t"); \
188 assemble_name (asm_out_file, a); \
189 fprintf (asm_out_file, SDB_DELIM); } while (0)
192 #ifndef PUT_SDB_PLAIN_DEF
193 #define PUT_SDB_PLAIN_DEF(a) \
194 fprintf (asm_out_file, "\t.def\t.%s%s", a, SDB_DELIM)
197 #ifndef PUT_SDB_ENDEF
198 #define PUT_SDB_ENDEF fputs ("\t.endef\n", asm_out_file)
202 #define PUT_SDB_TYPE(a) fprintf (asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
206 #define PUT_SDB_SIZE(a) \
208 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
209 (HOST_WIDE_INT) (a), SDB_DELIM); \
213 #ifndef PUT_SDB_START_DIM
214 #define PUT_SDB_START_DIM fprintf (asm_out_file, "\t.dim\t")
217 #ifndef PUT_SDB_NEXT_DIM
218 #define PUT_SDB_NEXT_DIM(a) fprintf (asm_out_file, "%d,", a)
221 #ifndef PUT_SDB_LAST_DIM
222 #define PUT_SDB_LAST_DIM(a) fprintf (asm_out_file, "%d%s", a, SDB_DELIM)
226 #define PUT_SDB_TAG(a) \
227 do { fprintf (asm_out_file, "\t.tag\t"); \
228 assemble_name (asm_out_file, a); \
229 fprintf (asm_out_file, SDB_DELIM); } while (0)
232 #ifndef PUT_SDB_BLOCK_START
233 #define PUT_SDB_BLOCK_START(LINE) \
234 fprintf (asm_out_file, \
235 "\t.def\t.bb%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_BLOCK_END
240 #define PUT_SDB_BLOCK_END(LINE) \
241 fprintf (asm_out_file, \
242 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
243 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
246 #ifndef PUT_SDB_FUNCTION_START
247 #define PUT_SDB_FUNCTION_START(LINE) \
248 fprintf (asm_out_file, \
249 "\t.def\t.bf%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 #ifndef PUT_SDB_FUNCTION_END
254 #define PUT_SDB_FUNCTION_END(LINE) \
255 fprintf (asm_out_file, \
256 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
257 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
260 /* Return the sdb tag identifier string for TYPE
261 if TYPE has already been defined; otherwise return a null pointer. */
263 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
265 /* Set the sdb tag identifier string for TYPE to NAME. */
267 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
268 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
270 /* Return the name (a string) of the struct, union or enum tag
271 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
273 #define TAG_NAME(link) \
274 (((link) && TREE_PURPOSE ((link)) \
275 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
276 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
278 /* Ensure we don't output a negative line number. */
279 #define MAKE_LINE_SAFE(line) \
280 if ((int) line <= sdb_begin_function_line) \
281 line = sdb_begin_function_line + 1
283 /* The debug hooks structure. */
284 const struct gcc_debug_hooks sdb_debug_hooks
=
286 sdbout_init
, /* init */
287 sdbout_finish
, /* finish */
288 debug_nothing_void
, /* early_finish */
289 debug_nothing_void
, /* assembly_start */
290 debug_nothing_int_charstar
, /* define */
291 debug_nothing_int_charstar
, /* undef */
292 sdbout_start_source_file
, /* start_source_file */
293 sdbout_end_source_file
, /* end_source_file */
294 sdbout_begin_block
, /* begin_block */
295 sdbout_end_block
, /* end_block */
296 debug_true_const_tree
, /* ignore_block */
297 sdbout_source_line
, /* source_line */
298 sdbout_begin_prologue
, /* begin_prologue */
299 debug_nothing_int_charstar
, /* end_prologue */
300 debug_nothing_int_charstar
, /* begin_epilogue */
301 sdbout_end_epilogue
, /* end_epilogue */
302 sdbout_begin_function
, /* begin_function */
303 sdbout_end_function
, /* end_function */
304 debug_nothing_tree
, /* function_decl */
305 sdbout_early_global_decl
, /* early_global_decl */
306 sdbout_late_global_decl
, /* late_global_decl */
307 sdbout_symbol
, /* type_decl */
308 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
309 debug_nothing_tree
, /* deferred_inline_function */
310 debug_nothing_tree
, /* outlining_inline_function */
311 sdbout_label
, /* label */
312 debug_nothing_int
, /* handle_pch */
313 debug_nothing_rtx_insn
, /* var_location */
314 debug_nothing_void
, /* switch_text_section */
315 debug_nothing_tree_tree
, /* set_name */
316 0, /* start_end_main_source_file */
317 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
320 /* Return a unique string to name an anonymous type. */
323 gen_fake_label (void)
327 sprintf (label
, ".%dfake", unnamed_struct_number
);
328 unnamed_struct_number
++;
329 labelstr
= xstrdup (label
);
333 /* Return the number which describes TYPE for SDB.
334 For pointers, etc., this function is recursive.
335 Each record, union or enumeral type must already have had a
336 tag number output. */
338 /* The number is given by d6d5d4d3d2d1bbbb
339 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
340 Thus, char *foo () has bbbb=T_CHAR
343 N_BTMASK= 017 1111 basic type field.
344 N_TSHIFT= 2 derived type shift
345 N_BTSHFT= 4 Basic type shift */
347 /* Produce the number that describes a pointer, function or array type.
348 PREV is the number describing the target, value or element type.
349 DT_type describes how to transform that type. */
350 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
351 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
352 | ((int) DT_type << (int) N_BTSHFT) \
353 | ((PREV) & (int) N_BTMASK))
355 /* Number of elements used in sdb_dims. */
356 static int sdb_n_dims
= 0;
358 /* Table of array dimensions of current type. */
359 static int sdb_dims
[SDB_MAX_DIM
];
361 /* Size of outermost array currently being processed. */
362 static int sdb_type_size
= -1;
365 plain_type (tree type
)
367 int val
= plain_type_1 (type
, 0);
369 /* If we have already saved up some array dimensions, print them now. */
374 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
375 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
376 PUT_SDB_LAST_DIM (sdb_dims
[0]);
379 sdb_type_size
= int_size_in_bytes (type
);
380 /* Don't kill sdb if type is not laid out or has variable size. */
381 if (sdb_type_size
< 0)
384 /* If we have computed the size of an array containing this type,
386 if (sdb_type_size
>= 0)
388 PUT_SDB_SIZE (sdb_type_size
);
395 template_name_p (tree name
)
397 const char *ptr
= IDENTIFIER_POINTER (name
);
398 while (*ptr
&& *ptr
!= '<')
405 sdbout_record_type_name (tree type
)
407 const char *name
= 0;
410 if (KNOWN_TYPE_TAG (type
))
413 if (TYPE_NAME (type
) != 0)
417 /* Find the IDENTIFIER_NODE for the type name. */
418 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
419 t
= TYPE_NAME (type
);
420 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
422 t
= DECL_NAME (TYPE_NAME (type
));
423 /* The DECL_NAME for templates includes "<>", which breaks
424 most assemblers. Use its assembler name instead, which
425 has been mangled into being safe. */
426 if (t
&& template_name_p (t
))
427 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
430 /* Now get the name as a string, or invent one. */
432 name
= IDENTIFIER_POINTER (t
);
435 no_name
= (name
== 0 || *name
== 0);
437 name
= gen_fake_label ();
439 SET_KNOWN_TYPE_TAG (type
, name
);
440 #ifdef SDB_ALLOW_FORWARD_REFERENCES
442 sdbout_queue_anonymous_type (type
);
446 /* Return the .type value for type TYPE.
448 LEVEL indicates how many levels deep we have recursed into the type.
449 The SDB debug format can only represent 6 derived levels of types.
450 After that, we must output inaccurate debug info. We deliberately
451 stop before the 7th level, so that ADA recursive types will not give an
455 plain_type_1 (tree type
, int level
)
458 type
= void_type_node
;
459 else if (type
== error_mark_node
)
460 type
= integer_type_node
;
462 type
= TYPE_MAIN_VARIANT (type
);
464 switch (TREE_CODE (type
))
472 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
474 /* Carefully distinguish all the standard types of C,
475 without messing up if the language is not C.
476 Note that we check only for the names that contain spaces;
477 other names might occur by coincidence in other languages. */
478 if (TYPE_NAME (type
) != 0
479 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
480 && DECL_NAME (TYPE_NAME (type
)) != 0
481 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
483 const char *const name
484 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
486 if (!strcmp (name
, "char"))
488 if (!strcmp (name
, "unsigned char"))
490 if (!strcmp (name
, "signed char"))
492 if (!strcmp (name
, "int"))
494 if (!strcmp (name
, "unsigned int"))
496 if (!strcmp (name
, "short int"))
498 if (!strcmp (name
, "short unsigned int"))
500 if (!strcmp (name
, "long int"))
502 if (!strcmp (name
, "long unsigned int"))
506 if (size
== INT_TYPE_SIZE
)
507 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
508 if (size
== CHAR_TYPE_SIZE
)
509 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
510 if (size
== SHORT_TYPE_SIZE
)
511 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
512 if (size
== LONG_TYPE_SIZE
)
513 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
514 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
515 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
521 int precision
= TYPE_PRECISION (type
);
522 if (precision
== FLOAT_TYPE_SIZE
)
524 if (precision
== DOUBLE_TYPE_SIZE
)
526 #ifdef EXTENDED_SDB_BASIC_TYPES
527 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
530 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
531 return T_DOUBLE
; /* better than nothing */
542 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
543 if (sdb_n_dims
< SDB_MAX_DIM
)
544 sdb_dims
[sdb_n_dims
++]
545 = (TYPE_DOMAIN (type
)
546 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
547 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
548 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
549 && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)))
550 ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
551 - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type
))) + 1)
554 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
559 case QUAL_UNION_TYPE
:
563 #ifdef SDB_ALLOW_FORWARD_REFERENCES
564 sdbout_record_type_name (type
);
566 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
567 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
568 #ifdef SDB_ALLOW_FORWARD_REFERENCES
569 || TYPE_MODE (type
) != VOIDmode
574 /* Output the referenced structure tag name
575 only if the .def has already been finished.
576 At least on 386, the Unix assembler
577 cannot handle forward references to tags. */
578 /* But the 88100, it requires them, sigh... */
579 /* And the MIPS requires unknown refs as well... */
580 tag
= KNOWN_TYPE_TAG (type
);
582 /* These 3 lines used to follow the close brace.
583 However, a size of 0 without a tag implies a tag of 0,
584 so if we don't know a tag, we can't mention the size. */
585 sdb_type_size
= int_size_in_bytes (type
);
586 if (sdb_type_size
< 0)
589 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
590 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
591 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
601 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
602 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
611 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
612 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
619 /* Output the symbols defined in block number DO_BLOCK.
621 This function works by walking the tree structure of blocks,
622 counting blocks until it finds the desired block. */
624 static int do_block
= 0;
627 sdbout_block (tree block
)
631 /* Ignore blocks never expanded or otherwise marked as real. */
632 if (TREE_USED (block
))
634 /* When we reach the specified block, output its symbols. */
635 if (BLOCK_NUMBER (block
) == do_block
)
636 sdbout_syms (BLOCK_VARS (block
));
638 /* If we are past the specified block, stop the scan. */
639 if (BLOCK_NUMBER (block
) > do_block
)
642 /* Scan the blocks within this block. */
643 sdbout_block (BLOCK_SUBBLOCKS (block
));
646 block
= BLOCK_CHAIN (block
);
650 /* Call sdbout_symbol on each decl in the chain SYMS. */
653 sdbout_syms (tree syms
)
657 if (TREE_CODE (syms
) != LABEL_DECL
)
658 sdbout_symbol (syms
, 1);
659 syms
= TREE_CHAIN (syms
);
663 /* Output SDB information for a symbol described by DECL.
664 LOCAL is nonzero if the symbol is not file-scope. */
667 sdbout_symbol (tree decl
, int local
)
669 tree type
= TREE_TYPE (decl
);
670 tree context
= NULL_TREE
;
675 /* If we are called before sdbout_init is run, just save the symbol
677 if (!sdbout_initialized
)
679 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
683 sdbout_one_type (type
);
685 switch (TREE_CODE (decl
))
688 /* Enum values are defined by defining the enum type. */
692 /* Don't mention a nested function under its parent. */
693 context
= decl_function_context (decl
);
694 if (context
== current_function_decl
)
696 /* Check DECL_INITIAL to distinguish declarations from definitions.
697 Don't output debug info here for declarations; they will have
698 a DECL_INITIAL value of 0. */
699 if (! DECL_INITIAL (decl
))
701 if (!MEM_P (DECL_RTL (decl
))
702 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
704 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
705 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
706 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
710 /* Done with tagged types. */
711 if (DECL_NAME (decl
) == 0)
713 if (DECL_IGNORED_P (decl
))
715 /* Don't output intrinsic types. GAS chokes on SDB .def
716 statements that contain identifiers with embedded spaces
717 (eg "unsigned long"). */
718 if (DECL_IS_BUILTIN (decl
))
721 /* Output typedef name. */
722 if (template_name_p (DECL_NAME (decl
)))
723 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
725 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
726 PUT_SDB_SCL (C_TPDEF
);
730 /* Parm decls go in their own separate chains
731 and are output by sdbout_reg_parms and sdbout_parms. */
735 /* Don't mention a variable that is external.
736 Let the file that defines it describe it. */
737 if (DECL_EXTERNAL (decl
))
740 /* Ignore __FUNCTION__, etc. */
741 if (DECL_IGNORED_P (decl
))
744 /* If there was an error in the declaration, don't dump core
745 if there is no RTL associated with the variable doesn't
747 if (!DECL_RTL_SET_P (decl
))
750 value
= DECL_RTL (decl
);
752 if (!is_global_var (decl
))
753 value
= eliminate_regs (value
, VOIDmode
, NULL_RTX
);
755 SET_DECL_RTL (decl
, value
);
756 #ifdef LEAF_REG_REMAP
757 if (crtl
->uses_only_leaf_regs
)
758 leaf_renumber_regs_insn (value
);
761 /* Don't mention a variable at all
762 if it was completely optimized into nothingness.
764 If DECL was from an inline function, then its rtl
765 is not identically the rtl that was used in this
766 particular compilation. */
769 regno
= REGNO (value
);
770 if (regno
>= FIRST_PSEUDO_REGISTER
)
773 else if (GET_CODE (value
) == SUBREG
)
775 while (GET_CODE (value
) == SUBREG
)
776 value
= SUBREG_REG (value
);
779 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
782 regno
= REGNO (alter_subreg (&value
, true));
783 SET_DECL_RTL (decl
, value
);
785 /* Don't output anything if an auto variable
786 gets RTL that is static.
787 GAS version 2.2 can't handle such output. */
788 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
789 && ! TREE_STATIC (decl
))
792 /* Emit any structure, union, or enum type that has not been output.
793 This occurs for tag-less structs (et al) used to declare variables
795 if (TREE_CODE (type
) == ENUMERAL_TYPE
796 || TREE_CODE (type
) == RECORD_TYPE
797 || TREE_CODE (type
) == UNION_TYPE
798 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
800 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
801 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
802 sdbout_one_type (type
);
805 /* Defer SDB information for top-level initialized variables! */
808 && DECL_INITIAL (decl
))
811 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
812 For now, avoid crashing. */
813 if (DECL_NAME (decl
) == NULL_TREE
)
816 /* Record the name for, starting a symtab entry. */
818 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
820 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
823 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
826 if (TREE_PUBLIC (decl
))
828 PUT_SDB_VAL (XEXP (value
, 0));
833 PUT_SDB_VAL (XEXP (value
, 0));
834 PUT_SDB_SCL (C_STAT
);
840 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
843 else if (MEM_P (value
)
844 && (MEM_P (XEXP (value
, 0))
845 || (REG_P (XEXP (value
, 0))
846 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
847 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
848 /* If the value is indirect by memory or by a register
849 that isn't the frame pointer
850 then it means the object is variable-sized and address through
851 that register or stack slot. COFF has no way to represent this
852 so all we can do is output the variable as a pointer. */
855 if (REG_P (XEXP (value
, 0)))
857 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
862 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
864 We want the value of that CONST_INT. */
865 /* Encore compiler hates a newline in a macro arg, it seems. */
866 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
867 (XEXP (XEXP (value
, 0), 0)));
868 PUT_SDB_SCL (C_AUTO
);
871 /* Effectively do build_pointer_type, but don't cache this type,
872 since it might be temporary whereas the type it points to
873 might have been saved for inlining. */
874 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
875 type
= make_node (POINTER_TYPE
);
876 TREE_TYPE (type
) = TREE_TYPE (decl
);
878 else if (MEM_P (value
)
879 && ((GET_CODE (XEXP (value
, 0)) == PLUS
880 && REG_P (XEXP (XEXP (value
, 0), 0))
881 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
882 /* This is for variables which are at offset zero from
883 the frame pointer. This happens on the Alpha.
884 Non-frame pointer registers are excluded above. */
885 || (REG_P (XEXP (value
, 0)))))
887 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
888 or (MEM (REG...)). We want the value of that CONST_INT
891 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
892 PUT_SDB_SCL (C_AUTO
);
896 /* It is something we don't know how to represent for SDB. */
904 PUT_SDB_TYPE (plain_type (type
));
908 /* Output SDB information for a top-level initialized variable
909 that has been delayed. */
912 sdbout_toplevel_data (tree decl
)
914 tree type
= TREE_TYPE (decl
);
916 if (DECL_IGNORED_P (decl
))
919 gcc_assert (TREE_CODE (decl
) == VAR_DECL
);
920 gcc_assert (MEM_P (DECL_RTL (decl
)));
921 gcc_assert (DECL_INITIAL (decl
));
923 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
924 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
925 if (TREE_PUBLIC (decl
))
931 PUT_SDB_SCL (C_STAT
);
933 PUT_SDB_TYPE (plain_type (type
));
937 #ifdef SDB_ALLOW_FORWARD_REFERENCES
939 /* Machinery to record and output anonymous types. */
942 sdbout_queue_anonymous_type (tree type
)
944 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
948 sdbout_dequeue_anonymous_types (void)
952 while (anonymous_types
)
954 types
= nreverse (anonymous_types
);
955 anonymous_types
= NULL_TREE
;
957 for (link
= types
; link
; link
= TREE_CHAIN (link
))
959 tree type
= TREE_VALUE (link
);
961 if (type
&& ! TREE_ASM_WRITTEN (type
))
962 sdbout_one_type (type
);
969 /* Given a chain of ..._TYPE nodes, all of which have names,
970 output definitions of those names, as typedefs. */
973 sdbout_types (tree types
)
977 for (link
= types
; link
; link
= TREE_CHAIN (link
))
978 sdbout_one_type (link
);
980 #ifdef SDB_ALLOW_FORWARD_REFERENCES
981 sdbout_dequeue_anonymous_types ();
986 sdbout_type (tree type
)
988 if (type
== error_mark_node
)
989 type
= integer_type_node
;
990 PUT_SDB_TYPE (plain_type (type
));
993 /* Output types of the fields of type TYPE, if they are structs.
995 Formerly did not chase through pointer types, since that could be circular.
996 They must come before TYPE, since forward refs are not allowed.
997 Now james@bigtex.cactus.org says to try them. */
1000 sdbout_field_types (tree type
)
1004 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1005 /* This condition should match the one for emitting the actual
1007 if (TREE_CODE (tail
) == FIELD_DECL
1010 && tree_fits_uhwi_p (DECL_SIZE (tail
))
1011 && tree_fits_shwi_p (bit_position (tail
)))
1013 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1014 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1016 sdbout_one_type (TREE_TYPE (tail
));
1020 /* Use this to put out the top level defined record and union types
1021 for later reference. If this is a struct with a name, then put that
1022 name out. Other unnamed structs will have .xxfake labels generated so
1023 that they may be referred to later.
1024 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1025 It may NOT be called recursively. */
1028 sdbout_one_type (tree type
)
1030 if (current_function_decl
!= NULL_TREE
1031 && DECL_SECTION_NAME (current_function_decl
) != NULL
)
1032 ; /* Don't change section amid function. */
1034 switch_to_section (current_function_section ());
1036 switch (TREE_CODE (type
))
1040 case QUAL_UNION_TYPE
:
1042 type
= TYPE_MAIN_VARIANT (type
);
1043 /* Don't output a type twice. */
1044 if (TREE_ASM_WRITTEN (type
))
1045 /* James said test TREE_ASM_BEING_WRITTEN here. */
1048 /* Output nothing if type is not yet defined. */
1049 if (!COMPLETE_TYPE_P (type
))
1052 TREE_ASM_WRITTEN (type
) = 1;
1054 /* This is reputed to cause trouble with the following case,
1055 but perhaps checking TYPE_SIZE above will fix it. */
1057 /* Here is a testcase:
1063 typedef struct intermediate {
1067 typedef struct badstr {
1071 /* This change, which ought to make better output,
1072 used to make the COFF assembler unhappy.
1073 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1074 /* Before really doing anything, output types we want to refer to. */
1075 /* Note that in version 1 the following two lines
1076 are not used if forward references are in use. */
1077 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1078 sdbout_field_types (type
);
1080 /* Output a structure type. */
1082 int size
= int_size_in_bytes (type
);
1086 /* Record the type tag, but not in its permanent place just yet. */
1087 sdbout_record_type_name (type
);
1089 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1091 switch (TREE_CODE (type
))
1094 case QUAL_UNION_TYPE
:
1095 PUT_SDB_SCL (C_UNTAG
);
1096 PUT_SDB_TYPE (T_UNION
);
1101 PUT_SDB_SCL (C_STRTAG
);
1102 PUT_SDB_TYPE (T_STRUCT
);
1107 PUT_SDB_SCL (C_ENTAG
);
1108 PUT_SDB_TYPE (T_ENUM
);
1116 PUT_SDB_SIZE (size
);
1119 /* Print out the base class information with fields
1120 named after the types they hold. */
1121 /* This is only relevant to aggregate types. TYPE_BINFO is used
1122 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1124 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1129 for (binfo
= TYPE_BINFO (type
), i
= 0;
1130 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1132 tree child_type
= BINFO_TYPE (child
);
1133 tree child_type_name
;
1135 if (TYPE_NAME (child_type
) == 0)
1137 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1138 child_type_name
= TYPE_NAME (child_type
);
1139 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1141 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1142 if (child_type_name
&& template_name_p (child_type_name
))
1144 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1149 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1150 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child
)));
1151 PUT_SDB_SCL (member_scl
);
1152 sdbout_type (BINFO_TYPE (child
));
1157 /* Output the individual fields. */
1159 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1161 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1163 tree value
= TREE_VALUE (tem
);
1165 if (TREE_CODE (value
) == CONST_DECL
)
1166 value
= DECL_INITIAL (value
);
1168 if (tree_fits_shwi_p (value
))
1170 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1171 PUT_SDB_INT_VAL (tree_to_shwi (value
));
1172 PUT_SDB_SCL (C_MOE
);
1173 PUT_SDB_TYPE (T_MOE
);
1178 else /* record or union type */
1179 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1180 /* Output the name, type, position (in bits), size (in bits)
1183 /* Omit here the nameless fields that are used to skip bits.
1184 Also omit fields with variable size or position.
1185 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1186 if (TREE_CODE (tem
) == FIELD_DECL
1189 && tree_fits_uhwi_p (DECL_SIZE (tem
))
1190 && tree_fits_shwi_p (bit_position (tem
)))
1194 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1196 if (DECL_BIT_FIELD_TYPE (tem
))
1198 PUT_SDB_INT_VAL (int_bit_position (tem
));
1199 PUT_SDB_SCL (C_FIELD
);
1200 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1201 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem
)));
1205 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1206 PUT_SDB_SCL (member_scl
);
1207 sdbout_type (TREE_TYPE (tem
));
1211 /* Output end of a structure,union, or enumeral definition. */
1213 PUT_SDB_PLAIN_DEF ("eos");
1214 PUT_SDB_INT_VAL (size
);
1215 PUT_SDB_SCL (C_EOS
);
1216 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1217 PUT_SDB_SIZE (size
);
1227 /* The following two functions output definitions of function parameters.
1228 Each parameter gets a definition locating it in the parameter list.
1229 Each parameter that is a register variable gets a second definition
1230 locating it in the register.
1232 Printing or argument lists in gdb uses the definitions that
1233 locate in the parameter list. But reference to the variable in
1234 expressions uses preferentially the definition as a register. */
1236 /* Output definitions, referring to storage in the parmlist,
1237 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1240 sdbout_parms (tree parms
)
1242 for (; parms
; parms
= TREE_CHAIN (parms
))
1243 if (DECL_NAME (parms
)
1244 && TREE_TYPE (parms
) != error_mark_node
1245 && DECL_RTL_SET_P (parms
)
1246 && DECL_INCOMING_RTL (parms
))
1248 int current_sym_value
= 0;
1249 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1251 if (name
== 0 || *name
== 0)
1252 name
= gen_fake_label ();
1254 /* Perform any necessary register eliminations on the parameter's rtl,
1255 so that the debugging output will be accurate. */
1256 DECL_INCOMING_RTL (parms
)
1257 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1258 SET_DECL_RTL (parms
,
1259 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1261 if (PARM_PASSED_IN_MEMORY (parms
))
1263 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1266 /* ??? Here we assume that the parm address is indexed
1267 off the frame pointer or arg pointer.
1268 If that is not true, we produce meaningless results,
1269 but do not crash. */
1270 if (GET_CODE (addr
) == PLUS
1271 && CONST_INT_P (XEXP (addr
, 1)))
1272 current_sym_value
= INTVAL (XEXP (addr
, 1));
1274 current_sym_value
= 0;
1276 if (REG_P (DECL_RTL (parms
))
1277 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1278 type
= DECL_ARG_TYPE (parms
);
1281 int original_sym_value
= current_sym_value
;
1283 /* This is the case where the parm is passed as an int or
1284 double and it is converted to a char, short or float
1285 and stored back in the parmlist. In this case, describe
1286 the parm with the variable's declared type, and adjust
1287 the address if the least significant bytes (which we are
1288 using) are not the first ones. */
1289 if (BYTES_BIG_ENDIAN
1290 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1291 current_sym_value
+=
1292 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1293 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1295 if (MEM_P (DECL_RTL (parms
))
1296 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1297 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1299 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1300 == current_sym_value
))
1301 type
= TREE_TYPE (parms
);
1304 current_sym_value
= original_sym_value
;
1305 type
= DECL_ARG_TYPE (parms
);
1310 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1311 PUT_SDB_SCL (C_ARG
);
1312 PUT_SDB_TYPE (plain_type (type
));
1315 else if (REG_P (DECL_RTL (parms
)))
1318 /* Parm passed in registers and lives in registers or nowhere. */
1320 /* If parm lives in a register, use that register;
1321 pretend the parm was passed there. It would be more consistent
1322 to describe the register where the parm was passed,
1323 but in practice that register usually holds something else. */
1324 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1325 best_rtl
= DECL_RTL (parms
);
1326 /* If the parm lives nowhere,
1327 use the register where it was passed. */
1329 best_rtl
= DECL_INCOMING_RTL (parms
);
1332 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1333 PUT_SDB_SCL (C_REGPARM
);
1334 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1337 else if (MEM_P (DECL_RTL (parms
))
1338 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1340 /* Parm was passed in registers but lives on the stack. */
1342 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1343 in which case we want the value of that CONST_INT,
1344 or (MEM (REG ...)) or (MEM (MEM ...)),
1345 in which case we use a value of zero. */
1346 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1347 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1348 current_sym_value
= 0;
1350 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1352 /* Again, this assumes the offset is based on the arg pointer. */
1354 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1355 XEXP (DECL_RTL (parms
), 0)));
1356 PUT_SDB_SCL (C_ARG
);
1357 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1363 /* Output definitions for the places where parms live during the function,
1364 when different from where they were passed, when the parms were passed
1367 It is not useful to do this for parms passed in registers
1368 that live during the function in different registers, because it is
1369 impossible to look in the passed register for the passed value,
1370 so we use the within-the-function register to begin with.
1372 PARMS is a chain of PARM_DECL nodes. */
1375 sdbout_reg_parms (tree parms
)
1377 for (; parms
; parms
= TREE_CHAIN (parms
))
1378 if (DECL_NAME (parms
)
1379 && TREE_TYPE (parms
) != error_mark_node
1380 && DECL_RTL_SET_P (parms
)
1381 && DECL_INCOMING_RTL (parms
))
1383 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1385 /* Report parms that live in registers during the function
1386 but were passed in memory. */
1387 if (REG_P (DECL_RTL (parms
))
1388 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1389 && PARM_PASSED_IN_MEMORY (parms
))
1391 if (name
== 0 || *name
== 0)
1392 name
= gen_fake_label ();
1394 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1395 PUT_SDB_SCL (C_REG
);
1396 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1399 /* Report parms that live in memory but not where they were passed. */
1400 else if (MEM_P (DECL_RTL (parms
))
1401 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1402 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1403 && PARM_PASSED_IN_MEMORY (parms
)
1404 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1406 #if 0 /* ??? It is not clear yet what should replace this. */
1407 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1408 /* A parm declared char is really passed as an int,
1409 so it occupies the least significant bytes.
1410 On a big-endian machine those are not the low-numbered ones. */
1411 if (BYTES_BIG_ENDIAN
1413 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1414 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1415 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1416 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1419 if (name
== 0 || *name
== 0)
1420 name
= gen_fake_label ();
1422 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1423 (XEXP (DECL_RTL (parms
), 0)));
1424 PUT_SDB_SCL (C_AUTO
);
1425 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1432 /* Output early debug information for a global DECL. Called from
1433 rest_of_decl_compilation during parsing. */
1436 sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED
)
1438 /* NYI for non-dwarf. */
1441 /* Output late debug information for a global DECL after location
1442 information is available. */
1445 sdbout_late_global_decl (tree decl
)
1447 if (TREE_CODE (decl
) == VAR_DECL
1448 && !DECL_EXTERNAL (decl
)
1449 && DECL_RTL_SET_P (decl
))
1451 /* The COFF linker can move initialized global vars to the end.
1452 And that can screw up the symbol ordering. Defer those for
1453 sdbout_finish (). */
1454 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1455 sdbout_symbol (decl
, 0);
1457 vec_safe_push (deferred_global_decls
, decl
);
1459 /* Output COFF information for non-global file-scope initialized
1461 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1462 sdbout_toplevel_data (decl
);
1466 /* Output initialized global vars at the end, in the order of
1467 definition. See comment in sdbout_global_decl. */
1470 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1475 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls
, i
, decl
)
1476 sdbout_symbol (decl
, 0);
1479 /* Describe the beginning of an internal block within a function.
1480 Also output descriptions of variables defined in this block.
1482 N is the number of the block, by order of beginning, counting from 1,
1483 and not counting the outermost (function top-level) block.
1484 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1485 if the count starts at 0 for the outermost one. */
1488 sdbout_begin_block (unsigned int line
, unsigned int n
)
1490 tree decl
= current_function_decl
;
1491 MAKE_LINE_SAFE (line
);
1493 /* The SCO compiler does not emit a separate block for the function level
1494 scope, so we avoid it here also. */
1495 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1499 /* Include the outermost BLOCK's variables in block 1. */
1500 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1501 sdbout_block (DECL_INITIAL (decl
));
1503 /* If -g1, suppress all the internal symbols of functions
1504 except for arguments. */
1505 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1508 sdbout_block (DECL_INITIAL (decl
));
1511 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1512 sdbout_dequeue_anonymous_types ();
1516 /* Describe the end line-number of an internal block within a function. */
1519 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1521 MAKE_LINE_SAFE (line
);
1523 /* The SCO compiler does not emit a separate block for the function level
1524 scope, so we avoid it here also. */
1526 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1529 /* Output a line number symbol entry for source file FILENAME and line
1533 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1534 int discriminator ATTRIBUTE_UNUSED
,
1535 bool is_stmt ATTRIBUTE_UNUSED
)
1537 /* COFF relative line numbers must be positive. */
1538 if ((int) line
> sdb_begin_function_line
)
1540 #ifdef SDB_OUTPUT_SOURCE_LINE
1541 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1543 fprintf (asm_out_file
, "\t.ln\t%d\n",
1544 ((sdb_begin_function_line
> -1)
1545 ? line
- sdb_begin_function_line
: 1));
1550 /* Output sdb info for the current function name.
1551 Called from assemble_start_function. */
1554 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1556 sdbout_symbol (current_function_decl
, 0);
1559 /* Called at beginning of function body after prologue. Record the
1560 function's starting line number, so we can output relative line numbers
1561 for the other lines. Describe beginning of outermost block. Also
1562 describe the parameter list. */
1565 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1567 sdbout_end_prologue (line
, file
);
1571 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1573 sdb_begin_function_line
= line
- 1;
1574 PUT_SDB_FUNCTION_START (line
);
1575 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1576 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1579 /* Called at end of function (before epilogue).
1580 Describe end of outermost block. */
1583 sdbout_end_function (unsigned int line
)
1585 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1586 sdbout_dequeue_anonymous_types ();
1589 MAKE_LINE_SAFE (line
);
1590 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1592 /* Indicate we are between functions, for line-number output. */
1593 sdb_begin_function_line
= -1;
1596 /* Output sdb info for the absolute end of a function.
1597 Called after the epilogue is output. */
1600 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1601 const char *file ATTRIBUTE_UNUSED
)
1603 const char *const name ATTRIBUTE_UNUSED
1604 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1606 #ifdef PUT_SDB_EPILOGUE_END
1607 PUT_SDB_EPILOGUE_END (name
);
1609 fprintf (asm_out_file
, "\t.def\t");
1610 assemble_name (asm_out_file
, name
);
1611 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1612 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1616 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1620 sdbout_label (rtx_code_label
*insn
)
1622 PUT_SDB_DEF (LABEL_NAME (insn
));
1624 PUT_SDB_SCL (C_LABEL
);
1625 PUT_SDB_TYPE (T_NULL
);
1629 /* Change to reading from a new source file. */
1632 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1633 const char *filename ATTRIBUTE_UNUSED
)
1637 /* Revert to reading a previous source file. */
1640 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1644 /* Set up for SDB output at the start of compilation. */
1647 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1651 vec_alloc (deferred_global_decls
, 12);
1653 /* Emit debug information which was queued by sdbout_symbol before
1655 sdbout_initialized
= true;
1657 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1658 sdbout_symbol (TREE_VALUE (t
), 0);
1659 preinit_symbols
= 0;
1662 #endif /* SDB_DEBUGGING_INFO */
1664 #include "gt-sdbout.h"