1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* mike@tredysvr.Tredydev.Unisys.COM says:
21 I modified the struct.c example and have a nm of a .o resulting from the
22 AT&T C compiler. From the example below I would conclude the following:
24 1. All .defs from structures are emitted as scanned. The example below
25 clearly shows the symbol table entries for BoxRec2 are after the first
28 2. All functions and their locals (including statics) are emitted as scanned.
30 3. All nested unnamed union and structure .defs must be emitted before
31 the structure in which they are nested. The AT&T assembler is a
32 one pass beast as far as symbolics are concerned.
34 4. All structure .defs are emitted before the typedefs that refer to them.
36 5. All top level static and external variable definitions are moved to the
37 end of file with all top level statics occurring first before externs.
39 6. All undefined references are at the end of the file.
44 #include "coretypes.h"
50 #include "stor-layout.h"
52 static GTY(()) tree anonymous_types
;
54 /* Counter to generate unique "names" for nameless struct members. */
56 static GTY(()) int unnamed_struct_number
;
58 /* Declarations whose debug info was deferred till end of compilation. */
60 static GTY(()) vec
<tree
, va_gc
> *deferred_global_decls
;
62 /* The C front end may call sdbout_symbol before sdbout_init runs.
63 We save all such decls in this list and output them when we get
66 static GTY(()) tree preinit_symbols
;
67 static GTY(()) bool sdbout_initialized
;
75 #include "insn-config.h"
78 #include "diagnostic-core.h"
80 #include "langhooks.h"
83 /* 1 if PARM is passed to this function in memory. */
85 #define PARM_PASSED_IN_MEMORY(PARM) \
86 (MEM_P (DECL_INCOMING_RTL (PARM)))
88 /* A C expression for the integer offset value of an automatic variable
89 (C_AUTO) having address X (an RTX). */
90 #ifndef DEBUGGER_AUTO_OFFSET
91 #define DEBUGGER_AUTO_OFFSET(X) \
92 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
95 /* A C expression for the integer offset value of an argument (C_ARG)
96 having address X (an RTX). The nominal offset is OFFSET. */
97 #ifndef DEBUGGER_ARG_OFFSET
98 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
101 /* Line number of beginning of current function, minus one.
102 Negative means not in a function or not using sdb. */
104 int sdb_begin_function_line
= -1;
107 extern FILE *asm_out_file
;
109 extern tree current_function_decl
;
113 static void sdbout_init (const char *);
114 static void sdbout_finish (const char *);
115 static void sdbout_start_source_file (unsigned int, const char *);
116 static void sdbout_end_source_file (unsigned int);
117 static void sdbout_begin_block (unsigned int, unsigned int);
118 static void sdbout_end_block (unsigned int, unsigned int);
119 static void sdbout_source_line (unsigned int, const char *, int, bool);
120 static void sdbout_end_epilogue (unsigned int, const char *);
121 static void sdbout_early_global_decl (tree
);
122 static void sdbout_late_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_code_label
*);
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
);
146 /* Random macros describing parts of SDB data. */
148 /* Default value of delimiter is ";". */
150 #define SDB_DELIM ";"
153 /* Maximum number of dimensions the assembler will allow. */
155 #define SDB_MAX_DIM 4
159 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
162 #ifndef PUT_SDB_INT_VAL
163 #define PUT_SDB_INT_VAL(a) \
165 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
166 (HOST_WIDE_INT) (a), SDB_DELIM); \
172 #define PUT_SDB_VAL(a) \
173 ( fputs ("\t.val\t", asm_out_file), \
174 output_addr_const (asm_out_file, (a)), \
175 fprintf (asm_out_file, SDB_DELIM))
179 #define PUT_SDB_DEF(a) \
180 do { fprintf (asm_out_file, "\t.def\t"); \
181 assemble_name (asm_out_file, a); \
182 fprintf (asm_out_file, SDB_DELIM); } while (0)
185 #ifndef PUT_SDB_PLAIN_DEF
186 #define PUT_SDB_PLAIN_DEF(a) \
187 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_charstar
, /* early_finish */
282 debug_nothing_void
, /* assembly_start */
283 debug_nothing_int_charstar
, /* define */
284 debug_nothing_int_charstar
, /* undef */
285 sdbout_start_source_file
, /* start_source_file */
286 sdbout_end_source_file
, /* end_source_file */
287 sdbout_begin_block
, /* begin_block */
288 sdbout_end_block
, /* end_block */
289 debug_true_const_tree
, /* ignore_block */
290 sdbout_source_line
, /* source_line */
291 sdbout_begin_prologue
, /* begin_prologue */
292 debug_nothing_int_charstar
, /* end_prologue */
293 debug_nothing_int_charstar
, /* begin_epilogue */
294 sdbout_end_epilogue
, /* end_epilogue */
295 sdbout_begin_function
, /* begin_function */
296 sdbout_end_function
, /* end_function */
297 debug_nothing_tree
, /* register_main_translation_unit */
298 debug_nothing_tree
, /* function_decl */
299 sdbout_early_global_decl
, /* early_global_decl */
300 sdbout_late_global_decl
, /* late_global_decl */
301 sdbout_symbol
, /* type_decl */
302 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
303 debug_nothing_tree
, /* deferred_inline_function */
304 debug_nothing_tree
, /* outlining_inline_function */
305 sdbout_label
, /* label */
306 debug_nothing_int
, /* handle_pch */
307 debug_nothing_rtx_insn
, /* var_location */
308 debug_nothing_tree
, /* size_function */
309 debug_nothing_void
, /* switch_text_section */
310 debug_nothing_tree_tree
, /* set_name */
311 0, /* start_end_main_source_file */
312 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
315 /* Return a unique string to name an anonymous type. */
318 gen_fake_label (void)
322 sprintf (label
, ".%dfake", unnamed_struct_number
);
323 unnamed_struct_number
++;
324 labelstr
= xstrdup (label
);
328 /* Return the number which describes TYPE for SDB.
329 For pointers, etc., this function is recursive.
330 Each record, union or enumeral type must already have had a
331 tag number output. */
333 /* The number is given by d6d5d4d3d2d1bbbb
334 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
335 Thus, char *foo () has bbbb=T_CHAR
338 N_BTMASK= 017 1111 basic type field.
339 N_TSHIFT= 2 derived type shift
340 N_BTSHFT= 4 Basic type shift */
342 /* Produce the number that describes a pointer, function or array type.
343 PREV is the number describing the target, value or element type.
344 DT_type describes how to transform that type. */
345 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
346 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
347 | ((int) DT_type << (int) N_BTSHFT) \
348 | ((PREV) & (int) N_BTMASK))
350 /* Number of elements used in sdb_dims. */
351 static int sdb_n_dims
= 0;
353 /* Table of array dimensions of current type. */
354 static int sdb_dims
[SDB_MAX_DIM
];
356 /* Size of outermost array currently being processed. */
357 static int sdb_type_size
= -1;
360 plain_type (tree type
)
362 int val
= plain_type_1 (type
, 0);
364 /* If we have already saved up some array dimensions, print them now. */
369 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
370 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
371 PUT_SDB_LAST_DIM (sdb_dims
[0]);
374 sdb_type_size
= int_size_in_bytes (type
);
375 /* Don't kill sdb if type is not laid out or has variable size. */
376 if (sdb_type_size
< 0)
379 /* If we have computed the size of an array containing this type,
381 if (sdb_type_size
>= 0)
383 PUT_SDB_SIZE (sdb_type_size
);
390 template_name_p (tree name
)
392 const char *ptr
= IDENTIFIER_POINTER (name
);
393 while (*ptr
&& *ptr
!= '<')
400 sdbout_record_type_name (tree type
)
402 const char *name
= 0;
405 if (KNOWN_TYPE_TAG (type
))
408 if (TYPE_NAME (type
) != 0)
412 /* Find the IDENTIFIER_NODE for the type name. */
413 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
414 t
= TYPE_NAME (type
);
415 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
417 t
= DECL_NAME (TYPE_NAME (type
));
418 /* The DECL_NAME for templates includes "<>", which breaks
419 most assemblers. Use its assembler name instead, which
420 has been mangled into being safe. */
421 if (t
&& template_name_p (t
))
422 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
425 /* Now get the name as a string, or invent one. */
427 name
= IDENTIFIER_POINTER (t
);
430 no_name
= (name
== 0 || *name
== 0);
432 name
= gen_fake_label ();
434 SET_KNOWN_TYPE_TAG (type
, name
);
435 #ifdef SDB_ALLOW_FORWARD_REFERENCES
437 sdbout_queue_anonymous_type (type
);
441 /* Return the .type value for type TYPE.
443 LEVEL indicates how many levels deep we have recursed into the type.
444 The SDB debug format can only represent 6 derived levels of types.
445 After that, we must output inaccurate debug info. We deliberately
446 stop before the 7th level, so that ADA recursive types will not give an
450 plain_type_1 (tree type
, int level
)
453 type
= void_type_node
;
454 else if (type
== error_mark_node
)
455 type
= integer_type_node
;
457 type
= TYPE_MAIN_VARIANT (type
);
459 switch (TREE_CODE (type
))
467 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
469 /* Carefully distinguish all the standard types of C,
470 without messing up if the language is not C.
471 Note that we check only for the names that contain spaces;
472 other names might occur by coincidence in other languages. */
473 if (TYPE_NAME (type
) != 0
474 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
475 && DECL_NAME (TYPE_NAME (type
)) != 0
476 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
478 const char *const name
479 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
481 if (!strcmp (name
, "char"))
483 if (!strcmp (name
, "unsigned char"))
485 if (!strcmp (name
, "signed char"))
487 if (!strcmp (name
, "int"))
489 if (!strcmp (name
, "unsigned int"))
491 if (!strcmp (name
, "short int"))
493 if (!strcmp (name
, "short unsigned int"))
495 if (!strcmp (name
, "long int"))
497 if (!strcmp (name
, "long unsigned int"))
501 if (size
== INT_TYPE_SIZE
)
502 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
503 if (size
== CHAR_TYPE_SIZE
)
504 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
505 if (size
== SHORT_TYPE_SIZE
)
506 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
507 if (size
== LONG_TYPE_SIZE
)
508 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
509 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
510 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
516 int precision
= TYPE_PRECISION (type
);
517 if (precision
== FLOAT_TYPE_SIZE
)
519 if (precision
== 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 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
540 && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)))
541 ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
542 - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type
))) + 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
))
741 value
= DECL_RTL (decl
);
743 if (!is_global_var (decl
))
744 value
= eliminate_regs (value
, VOIDmode
, NULL_RTX
);
746 SET_DECL_RTL (decl
, value
);
747 #ifdef LEAF_REG_REMAP
748 if (crtl
->uses_only_leaf_regs
)
749 leaf_renumber_regs_insn (value
);
752 /* Don't mention a variable at all
753 if it was completely optimized into nothingness.
755 If DECL was from an inline function, then its rtl
756 is not identically the rtl that was used in this
757 particular compilation. */
760 regno
= REGNO (value
);
761 if (regno
>= FIRST_PSEUDO_REGISTER
)
764 else if (GET_CODE (value
) == SUBREG
)
766 while (GET_CODE (value
) == SUBREG
)
767 value
= SUBREG_REG (value
);
770 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
773 regno
= REGNO (alter_subreg (&value
, true));
774 SET_DECL_RTL (decl
, value
);
776 /* Don't output anything if an auto variable
777 gets RTL that is static.
778 GAS version 2.2 can't handle such output. */
779 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
780 && ! TREE_STATIC (decl
))
783 /* Emit any structure, union, or enum type that has not been output.
784 This occurs for tag-less structs (et al) used to declare variables
786 if (TREE_CODE (type
) == ENUMERAL_TYPE
787 || TREE_CODE (type
) == RECORD_TYPE
788 || TREE_CODE (type
) == UNION_TYPE
789 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
791 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
792 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
793 sdbout_one_type (type
);
796 /* Defer SDB information for top-level initialized variables! */
799 && DECL_INITIAL (decl
))
802 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
803 For now, avoid crashing. */
804 if (DECL_NAME (decl
) == NULL_TREE
)
807 /* Record the name for, starting a symtab entry. */
809 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
811 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
814 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
817 if (TREE_PUBLIC (decl
))
819 PUT_SDB_VAL (XEXP (value
, 0));
824 PUT_SDB_VAL (XEXP (value
, 0));
825 PUT_SDB_SCL (C_STAT
);
831 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
834 else if (MEM_P (value
)
835 && (MEM_P (XEXP (value
, 0))
836 || (REG_P (XEXP (value
, 0))
837 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
838 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
839 /* If the value is indirect by memory or by a register
840 that isn't the frame pointer
841 then it means the object is variable-sized and address through
842 that register or stack slot. COFF has no way to represent this
843 so all we can do is output the variable as a pointer. */
846 if (REG_P (XEXP (value
, 0)))
848 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
853 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
855 We want the value of that CONST_INT. */
856 /* Encore compiler hates a newline in a macro arg, it seems. */
857 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
858 (XEXP (XEXP (value
, 0), 0)));
859 PUT_SDB_SCL (C_AUTO
);
862 /* Effectively do build_pointer_type, but don't cache this type,
863 since it might be temporary whereas the type it points to
864 might have been saved for inlining. */
865 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
866 type
= make_node (POINTER_TYPE
);
867 TREE_TYPE (type
) = TREE_TYPE (decl
);
869 else if (MEM_P (value
)
870 && ((GET_CODE (XEXP (value
, 0)) == PLUS
871 && REG_P (XEXP (XEXP (value
, 0), 0))
872 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
873 /* This is for variables which are at offset zero from
874 the frame pointer. This happens on the Alpha.
875 Non-frame pointer registers are excluded above. */
876 || (REG_P (XEXP (value
, 0)))))
878 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
879 or (MEM (REG...)). We want the value of that CONST_INT
882 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
883 PUT_SDB_SCL (C_AUTO
);
887 /* It is something we don't know how to represent for SDB. */
895 PUT_SDB_TYPE (plain_type (type
));
899 /* Output SDB information for a top-level initialized variable
900 that has been delayed. */
903 sdbout_toplevel_data (tree decl
)
905 tree type
= TREE_TYPE (decl
);
907 if (DECL_IGNORED_P (decl
))
910 gcc_assert (VAR_P (decl
));
911 gcc_assert (MEM_P (DECL_RTL (decl
)));
912 gcc_assert (DECL_INITIAL (decl
));
914 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
915 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
916 if (TREE_PUBLIC (decl
))
922 PUT_SDB_SCL (C_STAT
);
924 PUT_SDB_TYPE (plain_type (type
));
928 #ifdef SDB_ALLOW_FORWARD_REFERENCES
930 /* Machinery to record and output anonymous types. */
933 sdbout_queue_anonymous_type (tree type
)
935 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
939 sdbout_dequeue_anonymous_types (void)
943 while (anonymous_types
)
945 types
= nreverse (anonymous_types
);
946 anonymous_types
= NULL_TREE
;
948 for (link
= types
; link
; link
= TREE_CHAIN (link
))
950 tree type
= TREE_VALUE (link
);
952 if (type
&& ! TREE_ASM_WRITTEN (type
))
953 sdbout_one_type (type
);
960 /* Given a chain of ..._TYPE nodes, all of which have names,
961 output definitions of those names, as typedefs. */
964 sdbout_types (tree types
)
968 for (link
= types
; link
; link
= TREE_CHAIN (link
))
969 sdbout_one_type (link
);
971 #ifdef SDB_ALLOW_FORWARD_REFERENCES
972 sdbout_dequeue_anonymous_types ();
977 sdbout_type (tree type
)
979 if (type
== error_mark_node
)
980 type
= integer_type_node
;
981 PUT_SDB_TYPE (plain_type (type
));
984 /* Output types of the fields of type TYPE, if they are structs.
986 Formerly did not chase through pointer types, since that could be circular.
987 They must come before TYPE, since forward refs are not allowed.
988 Now james@bigtex.cactus.org says to try them. */
991 sdbout_field_types (tree type
)
995 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
996 /* This condition should match the one for emitting the actual
998 if (TREE_CODE (tail
) == FIELD_DECL
1001 && tree_fits_uhwi_p (DECL_SIZE (tail
))
1002 && tree_fits_shwi_p (bit_position (tail
)))
1004 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1005 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1007 sdbout_one_type (TREE_TYPE (tail
));
1011 /* Use this to put out the top level defined record and union types
1012 for later reference. If this is a struct with a name, then put that
1013 name out. Other unnamed structs will have .xxfake labels generated so
1014 that they may be referred to later.
1015 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1016 It may NOT be called recursively. */
1019 sdbout_one_type (tree type
)
1021 if (current_function_decl
!= NULL_TREE
1022 && DECL_SECTION_NAME (current_function_decl
) != NULL
)
1023 ; /* Don't change section amid function. */
1025 switch_to_section (current_function_section ());
1027 switch (TREE_CODE (type
))
1031 case QUAL_UNION_TYPE
:
1033 type
= TYPE_MAIN_VARIANT (type
);
1034 /* Don't output a type twice. */
1035 if (TREE_ASM_WRITTEN (type
))
1036 /* James said test TREE_ASM_BEING_WRITTEN here. */
1039 /* Output nothing if type is not yet defined. */
1040 if (!COMPLETE_TYPE_P (type
))
1043 TREE_ASM_WRITTEN (type
) = 1;
1045 /* This is reputed to cause trouble with the following case,
1046 but perhaps checking TYPE_SIZE above will fix it. */
1048 /* Here is a testcase:
1054 typedef struct intermediate {
1058 typedef struct badstr {
1062 /* This change, which ought to make better output,
1063 used to make the COFF assembler unhappy.
1064 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1065 /* Before really doing anything, output types we want to refer to. */
1066 /* Note that in version 1 the following two lines
1067 are not used if forward references are in use. */
1068 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1069 sdbout_field_types (type
);
1071 /* Output a structure type. */
1073 int size
= int_size_in_bytes (type
);
1077 /* Record the type tag, but not in its permanent place just yet. */
1078 sdbout_record_type_name (type
);
1080 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1082 switch (TREE_CODE (type
))
1085 case QUAL_UNION_TYPE
:
1086 PUT_SDB_SCL (C_UNTAG
);
1087 PUT_SDB_TYPE (T_UNION
);
1092 PUT_SDB_SCL (C_STRTAG
);
1093 PUT_SDB_TYPE (T_STRUCT
);
1098 PUT_SDB_SCL (C_ENTAG
);
1099 PUT_SDB_TYPE (T_ENUM
);
1107 PUT_SDB_SIZE (size
);
1110 /* Print out the base class information with fields
1111 named after the types they hold. */
1112 /* This is only relevant to aggregate types. TYPE_BINFO is used
1113 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1115 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1120 for (binfo
= TYPE_BINFO (type
), i
= 0;
1121 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1123 tree child_type
= BINFO_TYPE (child
);
1124 tree child_type_name
;
1126 if (TYPE_NAME (child_type
) == 0)
1128 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1129 child_type_name
= TYPE_NAME (child_type
);
1130 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1132 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1133 if (child_type_name
&& template_name_p (child_type_name
))
1135 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1140 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1141 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child
)));
1142 PUT_SDB_SCL (member_scl
);
1143 sdbout_type (BINFO_TYPE (child
));
1148 /* Output the individual fields. */
1150 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1152 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1154 tree value
= TREE_VALUE (tem
);
1156 if (TREE_CODE (value
) == CONST_DECL
)
1157 value
= DECL_INITIAL (value
);
1159 if (tree_fits_shwi_p (value
))
1161 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1162 PUT_SDB_INT_VAL (tree_to_shwi (value
));
1163 PUT_SDB_SCL (C_MOE
);
1164 PUT_SDB_TYPE (T_MOE
);
1169 else /* record or union type */
1170 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1171 /* Output the name, type, position (in bits), size (in bits)
1174 /* Omit here the nameless fields that are used to skip bits.
1175 Also omit fields with variable size or position.
1176 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1177 if (TREE_CODE (tem
) == FIELD_DECL
1180 && tree_fits_uhwi_p (DECL_SIZE (tem
))
1181 && tree_fits_shwi_p (bit_position (tem
)))
1185 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1187 if (DECL_BIT_FIELD_TYPE (tem
))
1189 PUT_SDB_INT_VAL (int_bit_position (tem
));
1190 PUT_SDB_SCL (C_FIELD
);
1191 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1192 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem
)));
1196 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1197 PUT_SDB_SCL (member_scl
);
1198 sdbout_type (TREE_TYPE (tem
));
1202 /* Output end of a structure,union, or enumeral definition. */
1204 PUT_SDB_PLAIN_DEF ("eos");
1205 PUT_SDB_INT_VAL (size
);
1206 PUT_SDB_SCL (C_EOS
);
1207 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1208 PUT_SDB_SIZE (size
);
1218 /* The following two functions output definitions of function parameters.
1219 Each parameter gets a definition locating it in the parameter list.
1220 Each parameter that is a register variable gets a second definition
1221 locating it in the register.
1223 Printing or argument lists in gdb uses the definitions that
1224 locate in the parameter list. But reference to the variable in
1225 expressions uses preferentially the definition as a register. */
1227 /* Output definitions, referring to storage in the parmlist,
1228 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1231 sdbout_parms (tree parms
)
1233 for (; parms
; parms
= TREE_CHAIN (parms
))
1234 if (DECL_NAME (parms
)
1235 && TREE_TYPE (parms
) != error_mark_node
1236 && DECL_RTL_SET_P (parms
)
1237 && DECL_INCOMING_RTL (parms
))
1239 int current_sym_value
= 0;
1240 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1242 if (name
== 0 || *name
== 0)
1243 name
= gen_fake_label ();
1245 /* Perform any necessary register eliminations on the parameter's rtl,
1246 so that the debugging output will be accurate. */
1247 DECL_INCOMING_RTL (parms
)
1248 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1249 SET_DECL_RTL (parms
,
1250 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1252 if (PARM_PASSED_IN_MEMORY (parms
))
1254 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1257 /* ??? Here we assume that the parm address is indexed
1258 off the frame pointer or arg pointer.
1259 If that is not true, we produce meaningless results,
1260 but do not crash. */
1261 if (GET_CODE (addr
) == PLUS
1262 && CONST_INT_P (XEXP (addr
, 1)))
1263 current_sym_value
= INTVAL (XEXP (addr
, 1));
1265 current_sym_value
= 0;
1267 if (REG_P (DECL_RTL (parms
))
1268 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1269 type
= DECL_ARG_TYPE (parms
);
1272 int original_sym_value
= current_sym_value
;
1274 /* This is the case where the parm is passed as an int or
1275 double and it is converted to a char, short or float
1276 and stored back in the parmlist. In this case, describe
1277 the parm with the variable's declared type, and adjust
1278 the address if the least significant bytes (which we are
1279 using) are not the first ones. */
1280 if (BYTES_BIG_ENDIAN
1281 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1282 current_sym_value
+=
1283 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1284 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1286 if (MEM_P (DECL_RTL (parms
))
1287 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1288 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1290 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1291 == current_sym_value
))
1292 type
= TREE_TYPE (parms
);
1295 current_sym_value
= original_sym_value
;
1296 type
= DECL_ARG_TYPE (parms
);
1301 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1302 PUT_SDB_SCL (C_ARG
);
1303 PUT_SDB_TYPE (plain_type (type
));
1306 else if (REG_P (DECL_RTL (parms
)))
1309 /* Parm passed in registers and lives in registers or nowhere. */
1311 /* If parm lives in a register, use that register;
1312 pretend the parm was passed there. It would be more consistent
1313 to describe the register where the parm was passed,
1314 but in practice that register usually holds something else. */
1315 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1316 best_rtl
= DECL_RTL (parms
);
1317 /* If the parm lives nowhere,
1318 use the register where it was passed. */
1320 best_rtl
= DECL_INCOMING_RTL (parms
);
1323 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1324 PUT_SDB_SCL (C_REGPARM
);
1325 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1328 else if (MEM_P (DECL_RTL (parms
))
1329 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1331 /* Parm was passed in registers but lives on the stack. */
1333 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1334 in which case we want the value of that CONST_INT,
1335 or (MEM (REG ...)) or (MEM (MEM ...)),
1336 in which case we use a value of zero. */
1337 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1338 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1339 current_sym_value
= 0;
1341 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1343 /* Again, this assumes the offset is based on the arg pointer. */
1345 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1346 XEXP (DECL_RTL (parms
), 0)));
1347 PUT_SDB_SCL (C_ARG
);
1348 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1354 /* Output definitions for the places where parms live during the function,
1355 when different from where they were passed, when the parms were passed
1358 It is not useful to do this for parms passed in registers
1359 that live during the function in different registers, because it is
1360 impossible to look in the passed register for the passed value,
1361 so we use the within-the-function register to begin with.
1363 PARMS is a chain of PARM_DECL nodes. */
1366 sdbout_reg_parms (tree parms
)
1368 for (; parms
; parms
= TREE_CHAIN (parms
))
1369 if (DECL_NAME (parms
)
1370 && TREE_TYPE (parms
) != error_mark_node
1371 && DECL_RTL_SET_P (parms
)
1372 && DECL_INCOMING_RTL (parms
))
1374 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1376 /* Report parms that live in registers during the function
1377 but were passed in memory. */
1378 if (REG_P (DECL_RTL (parms
))
1379 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1380 && PARM_PASSED_IN_MEMORY (parms
))
1382 if (name
== 0 || *name
== 0)
1383 name
= gen_fake_label ();
1385 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1386 PUT_SDB_SCL (C_REG
);
1387 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1390 /* Report parms that live in memory but not where they were passed. */
1391 else if (MEM_P (DECL_RTL (parms
))
1392 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1393 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1394 && PARM_PASSED_IN_MEMORY (parms
)
1395 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1397 #if 0 /* ??? It is not clear yet what should replace this. */
1398 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1399 /* A parm declared char is really passed as an int,
1400 so it occupies the least significant bytes.
1401 On a big-endian machine those are not the low-numbered ones. */
1402 if (BYTES_BIG_ENDIAN
1404 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1405 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1406 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1407 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1410 if (name
== 0 || *name
== 0)
1411 name
= gen_fake_label ();
1413 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1414 (XEXP (DECL_RTL (parms
), 0)));
1415 PUT_SDB_SCL (C_AUTO
);
1416 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1423 /* Output early debug information for a global DECL. Called from
1424 rest_of_decl_compilation during parsing. */
1427 sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED
)
1429 /* NYI for non-dwarf. */
1432 /* Output late debug information for a global DECL after location
1433 information is available. */
1436 sdbout_late_global_decl (tree decl
)
1438 if (VAR_P (decl
) && !DECL_EXTERNAL (decl
) && DECL_RTL_SET_P (decl
))
1440 /* The COFF linker can move initialized global vars to the end.
1441 And that can screw up the symbol ordering. Defer those for
1442 sdbout_finish (). */
1443 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1444 sdbout_symbol (decl
, 0);
1446 vec_safe_push (deferred_global_decls
, decl
);
1448 /* Output COFF information for non-global file-scope initialized
1450 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1451 sdbout_toplevel_data (decl
);
1455 /* Output initialized global vars at the end, in the order of
1456 definition. See comment in sdbout_global_decl. */
1459 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1464 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls
, i
, decl
)
1465 sdbout_symbol (decl
, 0);
1468 /* Describe the beginning of an internal block within a function.
1469 Also output descriptions of variables defined in this block.
1471 N is the number of the block, by order of beginning, counting from 1,
1472 and not counting the outermost (function top-level) block.
1473 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1474 if the count starts at 0 for the outermost one. */
1477 sdbout_begin_block (unsigned int line
, unsigned int n
)
1479 tree decl
= current_function_decl
;
1480 MAKE_LINE_SAFE (line
);
1482 /* The SCO compiler does not emit a separate block for the function level
1483 scope, so we avoid it here also. */
1484 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1488 /* Include the outermost BLOCK's variables in block 1. */
1489 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1490 sdbout_block (DECL_INITIAL (decl
));
1492 /* If -g1, suppress all the internal symbols of functions
1493 except for arguments. */
1494 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1497 sdbout_block (DECL_INITIAL (decl
));
1500 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1501 sdbout_dequeue_anonymous_types ();
1505 /* Describe the end line-number of an internal block within a function. */
1508 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1510 MAKE_LINE_SAFE (line
);
1512 /* The SCO compiler does not emit a separate block for the function level
1513 scope, so we avoid it here also. */
1515 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1518 /* Output a line number symbol entry for source file FILENAME and line
1522 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1523 int discriminator ATTRIBUTE_UNUSED
,
1524 bool is_stmt ATTRIBUTE_UNUSED
)
1526 /* COFF relative line numbers must be positive. */
1527 if ((int) line
> sdb_begin_function_line
)
1529 #ifdef SDB_OUTPUT_SOURCE_LINE
1530 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1532 fprintf (asm_out_file
, "\t.ln\t%d\n",
1533 ((sdb_begin_function_line
> -1)
1534 ? line
- sdb_begin_function_line
: 1));
1539 /* Output sdb info for the current function name.
1540 Called from assemble_start_function. */
1543 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1545 sdbout_symbol (current_function_decl
, 0);
1548 /* Called at beginning of function body after prologue. Record the
1549 function's starting line number, so we can output relative line numbers
1550 for the other lines. Describe beginning of outermost block. Also
1551 describe the parameter list. */
1554 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1556 sdbout_end_prologue (line
, file
);
1560 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1562 sdb_begin_function_line
= line
- 1;
1563 PUT_SDB_FUNCTION_START (line
);
1564 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1565 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1568 /* Called at end of function (before epilogue).
1569 Describe end of outermost block. */
1572 sdbout_end_function (unsigned int line
)
1574 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1575 sdbout_dequeue_anonymous_types ();
1578 MAKE_LINE_SAFE (line
);
1579 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1581 /* Indicate we are between functions, for line-number output. */
1582 sdb_begin_function_line
= -1;
1585 /* Output sdb info for the absolute end of a function.
1586 Called after the epilogue is output. */
1589 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1590 const char *file ATTRIBUTE_UNUSED
)
1592 const char *const name ATTRIBUTE_UNUSED
1593 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1595 #ifdef PUT_SDB_EPILOGUE_END
1596 PUT_SDB_EPILOGUE_END (name
);
1598 fprintf (asm_out_file
, "\t.def\t");
1599 assemble_name (asm_out_file
, name
);
1600 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1601 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1605 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1609 sdbout_label (rtx_code_label
*insn
)
1611 PUT_SDB_DEF (LABEL_NAME (insn
));
1613 PUT_SDB_SCL (C_LABEL
);
1614 PUT_SDB_TYPE (T_NULL
);
1618 /* Change to reading from a new source file. */
1621 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1622 const char *filename ATTRIBUTE_UNUSED
)
1626 /* Revert to reading a previous source file. */
1629 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1633 /* Set up for SDB output at the start of compilation. */
1636 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1640 vec_alloc (deferred_global_decls
, 12);
1642 /* Emit debug information which was queued by sdbout_symbol before
1644 sdbout_initialized
= true;
1646 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1647 sdbout_symbol (TREE_VALUE (t
), 0);
1648 preinit_symbols
= 0;
1651 #include "gt-sdbout.h"