1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988-2017 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, unsigned int,
120 const char *, int, bool);
121 static void sdbout_end_epilogue (unsigned int, const char *);
122 static void sdbout_early_global_decl (tree
);
123 static void sdbout_late_global_decl (tree
);
124 static void sdbout_begin_prologue (unsigned int, unsigned int,
126 static void sdbout_end_prologue (unsigned int, const char *);
127 static void sdbout_begin_function (tree
);
128 static void sdbout_end_function (unsigned int);
129 static void sdbout_toplevel_data (tree
);
130 static void sdbout_label (rtx_code_label
*);
131 static char *gen_fake_label (void);
132 static int plain_type (tree
);
133 static int template_name_p (tree
);
134 static void sdbout_record_type_name (tree
);
135 static int plain_type_1 (tree
, int);
136 static void sdbout_block (tree
);
137 static void sdbout_syms (tree
);
138 #ifdef SDB_ALLOW_FORWARD_REFERENCES
139 static void sdbout_queue_anonymous_type (tree
);
140 static void sdbout_dequeue_anonymous_types (void);
142 static void sdbout_type (tree
);
143 static void sdbout_field_types (tree
);
144 static void sdbout_one_type (tree
);
145 static void sdbout_parms (tree
);
146 static void sdbout_reg_parms (tree
);
148 /* Random macros describing parts of SDB data. */
150 /* Default value of delimiter is ";". */
152 #define SDB_DELIM ";"
155 /* Maximum number of dimensions the assembler will allow. */
157 #define SDB_MAX_DIM 4
161 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
164 #ifndef PUT_SDB_INT_VAL
165 #define PUT_SDB_INT_VAL(a) \
167 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
168 (HOST_WIDE_INT) (a), SDB_DELIM); \
174 #define PUT_SDB_VAL(a) \
175 ( fputs ("\t.val\t", asm_out_file), \
176 output_addr_const (asm_out_file, (a)), \
177 fprintf (asm_out_file, SDB_DELIM))
181 #define PUT_SDB_DEF(a) \
182 do { fprintf (asm_out_file, "\t.def\t"); \
183 assemble_name (asm_out_file, a); \
184 fprintf (asm_out_file, SDB_DELIM); } while (0)
187 #ifndef PUT_SDB_PLAIN_DEF
188 #define PUT_SDB_PLAIN_DEF(a) \
189 fprintf (asm_out_file, "\t.def\t.%s%s", a, SDB_DELIM)
192 #ifndef PUT_SDB_ENDEF
193 #define PUT_SDB_ENDEF fputs ("\t.endef\n", asm_out_file)
197 #define PUT_SDB_TYPE(a) fprintf (asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
201 #define PUT_SDB_SIZE(a) \
203 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
204 (HOST_WIDE_INT) (a), SDB_DELIM); \
208 #ifndef PUT_SDB_START_DIM
209 #define PUT_SDB_START_DIM fprintf (asm_out_file, "\t.dim\t")
212 #ifndef PUT_SDB_NEXT_DIM
213 #define PUT_SDB_NEXT_DIM(a) fprintf (asm_out_file, "%d,", a)
216 #ifndef PUT_SDB_LAST_DIM
217 #define PUT_SDB_LAST_DIM(a) fprintf (asm_out_file, "%d%s", a, SDB_DELIM)
221 #define PUT_SDB_TAG(a) \
222 do { fprintf (asm_out_file, "\t.tag\t"); \
223 assemble_name (asm_out_file, a); \
224 fprintf (asm_out_file, SDB_DELIM); } while (0)
227 #ifndef PUT_SDB_BLOCK_START
228 #define PUT_SDB_BLOCK_START(LINE) \
229 fprintf (asm_out_file, \
230 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
231 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
234 #ifndef PUT_SDB_BLOCK_END
235 #define PUT_SDB_BLOCK_END(LINE) \
236 fprintf (asm_out_file, \
237 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
238 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
241 #ifndef PUT_SDB_FUNCTION_START
242 #define PUT_SDB_FUNCTION_START(LINE) \
243 fprintf (asm_out_file, \
244 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
245 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
248 #ifndef PUT_SDB_FUNCTION_END
249 #define PUT_SDB_FUNCTION_END(LINE) \
250 fprintf (asm_out_file, \
251 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
252 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
255 /* Return the sdb tag identifier string for TYPE
256 if TYPE has already been defined; otherwise return a null pointer. */
258 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
260 /* Set the sdb tag identifier string for TYPE to NAME. */
262 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
263 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
265 /* Return the name (a string) of the struct, union or enum tag
266 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
268 #define TAG_NAME(link) \
269 (((link) && TREE_PURPOSE ((link)) \
270 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
271 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
273 /* Ensure we don't output a negative line number. */
274 #define MAKE_LINE_SAFE(line) \
275 if ((int) line <= sdb_begin_function_line) \
276 line = sdb_begin_function_line + 1
278 /* The debug hooks structure. */
279 const struct gcc_debug_hooks sdb_debug_hooks
=
281 sdbout_init
, /* init */
282 sdbout_finish
, /* finish */
283 debug_nothing_charstar
, /* early_finish */
284 debug_nothing_void
, /* assembly_start */
285 debug_nothing_int_charstar
, /* define */
286 debug_nothing_int_charstar
, /* undef */
287 sdbout_start_source_file
, /* start_source_file */
288 sdbout_end_source_file
, /* end_source_file */
289 sdbout_begin_block
, /* begin_block */
290 sdbout_end_block
, /* end_block */
291 debug_true_const_tree
, /* ignore_block */
292 sdbout_source_line
, /* source_line */
293 sdbout_begin_prologue
, /* begin_prologue */
294 debug_nothing_int_charstar
, /* end_prologue */
295 debug_nothing_int_charstar
, /* begin_epilogue */
296 sdbout_end_epilogue
, /* end_epilogue */
297 sdbout_begin_function
, /* begin_function */
298 sdbout_end_function
, /* end_function */
299 debug_nothing_tree
, /* register_main_translation_unit */
300 debug_nothing_tree
, /* function_decl */
301 sdbout_early_global_decl
, /* early_global_decl */
302 sdbout_late_global_decl
, /* late_global_decl */
303 sdbout_symbol
, /* type_decl */
304 debug_nothing_tree_tree_tree_bool_bool
,/* imported_module_or_decl */
305 debug_false_tree_charstarstar_uhwistar
,/* die_ref_for_decl */
306 debug_nothing_tree_charstar_uhwi
, /* register_external_die */
307 debug_nothing_tree
, /* deferred_inline_function */
308 debug_nothing_tree
, /* outlining_inline_function */
309 sdbout_label
, /* label */
310 debug_nothing_int
, /* handle_pch */
311 debug_nothing_rtx_insn
, /* var_location */
312 debug_nothing_tree
, /* size_function */
313 debug_nothing_void
, /* switch_text_section */
314 debug_nothing_tree_tree
, /* set_name */
315 0, /* start_end_main_source_file */
316 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
319 /* Return a unique string to name an anonymous type. */
322 gen_fake_label (void)
326 sprintf (label
, ".%dfake", unnamed_struct_number
);
327 unnamed_struct_number
++;
328 labelstr
= xstrdup (label
);
332 /* Return the number which describes TYPE for SDB.
333 For pointers, etc., this function is recursive.
334 Each record, union or enumeral type must already have had a
335 tag number output. */
337 /* The number is given by d6d5d4d3d2d1bbbb
338 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
339 Thus, char *foo () has bbbb=T_CHAR
342 N_BTMASK= 017 1111 basic type field.
343 N_TSHIFT= 2 derived type shift
344 N_BTSHFT= 4 Basic type shift */
346 /* Produce the number that describes a pointer, function or array type.
347 PREV is the number describing the target, value or element type.
348 DT_type describes how to transform that type. */
349 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
350 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
351 | ((int) DT_type << (int) N_BTSHFT) \
352 | ((PREV) & (int) N_BTMASK))
354 /* Number of elements used in sdb_dims. */
355 static int sdb_n_dims
= 0;
357 /* Table of array dimensions of current type. */
358 static int sdb_dims
[SDB_MAX_DIM
];
360 /* Size of outermost array currently being processed. */
361 static int sdb_type_size
= -1;
364 plain_type (tree type
)
366 int val
= plain_type_1 (type
, 0);
368 /* If we have already saved up some array dimensions, print them now. */
373 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
374 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
375 PUT_SDB_LAST_DIM (sdb_dims
[0]);
378 sdb_type_size
= int_size_in_bytes (type
);
379 /* Don't kill sdb if type is not laid out or has variable size. */
380 if (sdb_type_size
< 0)
383 /* If we have computed the size of an array containing this type,
385 if (sdb_type_size
>= 0)
387 PUT_SDB_SIZE (sdb_type_size
);
394 template_name_p (tree name
)
396 const char *ptr
= IDENTIFIER_POINTER (name
);
397 while (*ptr
&& *ptr
!= '<')
404 sdbout_record_type_name (tree type
)
406 const char *name
= 0;
409 if (KNOWN_TYPE_TAG (type
))
412 if (TYPE_NAME (type
) != 0)
416 /* Find the IDENTIFIER_NODE for the type name. */
417 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
418 t
= TYPE_NAME (type
);
419 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
421 t
= DECL_NAME (TYPE_NAME (type
));
422 /* The DECL_NAME for templates includes "<>", which breaks
423 most assemblers. Use its assembler name instead, which
424 has been mangled into being safe. */
425 if (t
&& template_name_p (t
))
426 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
429 /* Now get the name as a string, or invent one. */
431 name
= IDENTIFIER_POINTER (t
);
434 no_name
= (name
== 0 || *name
== 0);
436 name
= gen_fake_label ();
438 SET_KNOWN_TYPE_TAG (type
, name
);
439 #ifdef SDB_ALLOW_FORWARD_REFERENCES
441 sdbout_queue_anonymous_type (type
);
445 /* Return the .type value for type TYPE.
447 LEVEL indicates how many levels deep we have recursed into the type.
448 The SDB debug format can only represent 6 derived levels of types.
449 After that, we must output inaccurate debug info. We deliberately
450 stop before the 7th level, so that ADA recursive types will not give an
454 plain_type_1 (tree type
, int level
)
457 type
= void_type_node
;
458 else if (type
== error_mark_node
)
459 type
= integer_type_node
;
461 type
= TYPE_MAIN_VARIANT (type
);
463 switch (TREE_CODE (type
))
471 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
473 /* Carefully distinguish all the standard types of C,
474 without messing up if the language is not C.
475 Note that we check only for the names that contain spaces;
476 other names might occur by coincidence in other languages. */
477 if (TYPE_NAME (type
) != 0
478 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
479 && DECL_NAME (TYPE_NAME (type
)) != 0
480 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
482 const char *const name
483 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
485 if (!strcmp (name
, "char"))
487 if (!strcmp (name
, "unsigned char"))
489 if (!strcmp (name
, "signed char"))
491 if (!strcmp (name
, "int"))
493 if (!strcmp (name
, "unsigned int"))
495 if (!strcmp (name
, "short int"))
497 if (!strcmp (name
, "short unsigned int"))
499 if (!strcmp (name
, "long int"))
501 if (!strcmp (name
, "long unsigned int"))
505 if (size
== INT_TYPE_SIZE
)
506 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
507 if (size
== CHAR_TYPE_SIZE
)
508 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
509 if (size
== SHORT_TYPE_SIZE
)
510 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
511 if (size
== LONG_TYPE_SIZE
)
512 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
513 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
514 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
520 int precision
= TYPE_PRECISION (type
);
521 if (precision
== FLOAT_TYPE_SIZE
)
523 if (precision
== DOUBLE_TYPE_SIZE
)
525 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
526 return T_DOUBLE
; /* better than nothing */
537 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
538 if (sdb_n_dims
< SDB_MAX_DIM
)
539 sdb_dims
[sdb_n_dims
++]
540 = (TYPE_DOMAIN (type
)
541 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
542 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
543 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
544 && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)))
545 ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)))
546 - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type
))) + 1)
549 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
554 case QUAL_UNION_TYPE
:
558 #ifdef SDB_ALLOW_FORWARD_REFERENCES
559 sdbout_record_type_name (type
);
561 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
562 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
563 #ifdef SDB_ALLOW_FORWARD_REFERENCES
564 || TYPE_MODE (type
) != VOIDmode
569 /* Output the referenced structure tag name
570 only if the .def has already been finished.
571 At least on 386, the Unix assembler
572 cannot handle forward references to tags. */
573 /* But the 88100, it requires them, sigh... */
574 /* And the MIPS requires unknown refs as well... */
575 tag
= KNOWN_TYPE_TAG (type
);
577 /* These 3 lines used to follow the close brace.
578 However, a size of 0 without a tag implies a tag of 0,
579 so if we don't know a tag, we can't mention the size. */
580 sdb_type_size
= int_size_in_bytes (type
);
581 if (sdb_type_size
< 0)
584 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
585 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
586 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
596 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
597 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
606 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
607 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
614 /* Output the symbols defined in block number DO_BLOCK.
616 This function works by walking the tree structure of blocks,
617 counting blocks until it finds the desired block. */
619 static int do_block
= 0;
622 sdbout_block (tree block
)
626 /* Ignore blocks never expanded or otherwise marked as real. */
627 if (TREE_USED (block
))
629 /* When we reach the specified block, output its symbols. */
630 if (BLOCK_NUMBER (block
) == do_block
)
631 sdbout_syms (BLOCK_VARS (block
));
633 /* If we are past the specified block, stop the scan. */
634 if (BLOCK_NUMBER (block
) > do_block
)
637 /* Scan the blocks within this block. */
638 sdbout_block (BLOCK_SUBBLOCKS (block
));
641 block
= BLOCK_CHAIN (block
);
645 /* Call sdbout_symbol on each decl in the chain SYMS. */
648 sdbout_syms (tree syms
)
652 if (TREE_CODE (syms
) != LABEL_DECL
)
653 sdbout_symbol (syms
, 1);
654 syms
= TREE_CHAIN (syms
);
658 /* Output SDB information for a symbol described by DECL.
659 LOCAL is nonzero if the symbol is not file-scope. */
662 sdbout_symbol (tree decl
, int local
)
664 tree type
= TREE_TYPE (decl
);
665 tree context
= NULL_TREE
;
670 /* If we are called before sdbout_init is run, just save the symbol
672 if (!sdbout_initialized
)
674 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
678 sdbout_one_type (type
);
680 switch (TREE_CODE (decl
))
683 /* Enum values are defined by defining the enum type. */
687 /* Don't mention a nested function under its parent. */
688 context
= decl_function_context (decl
);
689 if (context
== current_function_decl
)
691 /* Check DECL_INITIAL to distinguish declarations from definitions.
692 Don't output debug info here for declarations; they will have
693 a DECL_INITIAL value of 0. */
694 if (! DECL_INITIAL (decl
))
696 if (!MEM_P (DECL_RTL (decl
))
697 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
699 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
700 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
701 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
705 /* Done with tagged types. */
706 if (DECL_NAME (decl
) == 0)
708 if (DECL_IGNORED_P (decl
))
710 /* Don't output intrinsic types. GAS chokes on SDB .def
711 statements that contain identifiers with embedded spaces
712 (eg "unsigned long"). */
713 if (DECL_IS_BUILTIN (decl
))
716 /* Output typedef name. */
717 if (template_name_p (DECL_NAME (decl
)))
718 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
720 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
721 PUT_SDB_SCL (C_TPDEF
);
725 /* Parm decls go in their own separate chains
726 and are output by sdbout_reg_parms and sdbout_parms. */
730 /* Don't mention a variable that is external.
731 Let the file that defines it describe it. */
732 if (DECL_EXTERNAL (decl
))
735 /* Ignore __FUNCTION__, etc. */
736 if (DECL_IGNORED_P (decl
))
739 /* If there was an error in the declaration, don't dump core
740 if there is no RTL associated with the variable doesn't
742 if (!DECL_RTL_SET_P (decl
))
745 value
= DECL_RTL (decl
);
747 if (!is_global_var (decl
))
748 value
= eliminate_regs (value
, VOIDmode
, NULL_RTX
);
750 SET_DECL_RTL (decl
, value
);
751 #ifdef LEAF_REG_REMAP
752 if (crtl
->uses_only_leaf_regs
)
753 leaf_renumber_regs_insn (value
);
756 /* Don't mention a variable at all
757 if it was completely optimized into nothingness.
759 If DECL was from an inline function, then its rtl
760 is not identically the rtl that was used in this
761 particular compilation. */
764 regno
= REGNO (value
);
765 if (regno
>= FIRST_PSEUDO_REGISTER
)
768 else if (GET_CODE (value
) == SUBREG
)
770 while (GET_CODE (value
) == SUBREG
)
771 value
= SUBREG_REG (value
);
774 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
777 regno
= REGNO (alter_subreg (&value
, true));
778 SET_DECL_RTL (decl
, value
);
780 /* Don't output anything if an auto variable
781 gets RTL that is static.
782 GAS version 2.2 can't handle such output. */
783 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
784 && ! TREE_STATIC (decl
))
787 /* Emit any structure, union, or enum type that has not been output.
788 This occurs for tag-less structs (et al) used to declare variables
790 if (TREE_CODE (type
) == ENUMERAL_TYPE
791 || TREE_CODE (type
) == RECORD_TYPE
792 || TREE_CODE (type
) == UNION_TYPE
793 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
795 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
796 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
797 sdbout_one_type (type
);
800 /* Defer SDB information for top-level initialized variables! */
803 && DECL_INITIAL (decl
))
806 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
807 For now, avoid crashing. */
808 if (DECL_NAME (decl
) == NULL_TREE
)
811 /* Record the name for, starting a symtab entry. */
813 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
815 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
818 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
821 if (TREE_PUBLIC (decl
))
823 PUT_SDB_VAL (XEXP (value
, 0));
828 PUT_SDB_VAL (XEXP (value
, 0));
829 PUT_SDB_SCL (C_STAT
);
835 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
838 else if (MEM_P (value
)
839 && (MEM_P (XEXP (value
, 0))
840 || (REG_P (XEXP (value
, 0))
841 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
842 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
843 /* If the value is indirect by memory or by a register
844 that isn't the frame pointer
845 then it means the object is variable-sized and address through
846 that register or stack slot. COFF has no way to represent this
847 so all we can do is output the variable as a pointer. */
850 if (REG_P (XEXP (value
, 0)))
852 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
857 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
859 We want the value of that CONST_INT. */
860 /* Encore compiler hates a newline in a macro arg, it seems. */
861 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
862 (XEXP (XEXP (value
, 0), 0)));
863 PUT_SDB_SCL (C_AUTO
);
866 /* Effectively do build_pointer_type, but don't cache this type,
867 since it might be temporary whereas the type it points to
868 might have been saved for inlining. */
869 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
870 type
= make_node (POINTER_TYPE
);
871 TREE_TYPE (type
) = TREE_TYPE (decl
);
873 else if (MEM_P (value
)
874 && ((GET_CODE (XEXP (value
, 0)) == PLUS
875 && REG_P (XEXP (XEXP (value
, 0), 0))
876 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
877 /* This is for variables which are at offset zero from
878 the frame pointer. This happens on the Alpha.
879 Non-frame pointer registers are excluded above. */
880 || (REG_P (XEXP (value
, 0)))))
882 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
883 or (MEM (REG...)). We want the value of that CONST_INT
886 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
887 PUT_SDB_SCL (C_AUTO
);
891 /* It is something we don't know how to represent for SDB. */
899 PUT_SDB_TYPE (plain_type (type
));
903 /* Output SDB information for a top-level initialized variable
904 that has been delayed. */
907 sdbout_toplevel_data (tree decl
)
909 tree type
= TREE_TYPE (decl
);
911 if (DECL_IGNORED_P (decl
))
914 gcc_assert (VAR_P (decl
));
915 gcc_assert (MEM_P (DECL_RTL (decl
)));
916 gcc_assert (DECL_INITIAL (decl
));
918 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
919 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
920 if (TREE_PUBLIC (decl
))
926 PUT_SDB_SCL (C_STAT
);
928 PUT_SDB_TYPE (plain_type (type
));
932 #ifdef SDB_ALLOW_FORWARD_REFERENCES
934 /* Machinery to record and output anonymous types. */
937 sdbout_queue_anonymous_type (tree type
)
939 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
943 sdbout_dequeue_anonymous_types (void)
947 while (anonymous_types
)
949 types
= nreverse (anonymous_types
);
950 anonymous_types
= NULL_TREE
;
952 for (link
= types
; link
; link
= TREE_CHAIN (link
))
954 tree type
= TREE_VALUE (link
);
956 if (type
&& ! TREE_ASM_WRITTEN (type
))
957 sdbout_one_type (type
);
964 /* Given a chain of ..._TYPE nodes, all of which have names,
965 output definitions of those names, as typedefs. */
968 sdbout_types (tree types
)
972 for (link
= types
; link
; link
= TREE_CHAIN (link
))
973 sdbout_one_type (link
);
975 #ifdef SDB_ALLOW_FORWARD_REFERENCES
976 sdbout_dequeue_anonymous_types ();
981 sdbout_type (tree type
)
983 if (type
== error_mark_node
)
984 type
= integer_type_node
;
985 PUT_SDB_TYPE (plain_type (type
));
988 /* Output types of the fields of type TYPE, if they are structs.
990 Formerly did not chase through pointer types, since that could be circular.
991 They must come before TYPE, since forward refs are not allowed.
992 Now james@bigtex.cactus.org says to try them. */
995 sdbout_field_types (tree type
)
999 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1000 /* This condition should match the one for emitting the actual
1002 if (TREE_CODE (tail
) == FIELD_DECL
1005 && tree_fits_uhwi_p (DECL_SIZE (tail
))
1006 && tree_fits_shwi_p (bit_position (tail
)))
1008 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1009 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1011 sdbout_one_type (TREE_TYPE (tail
));
1015 /* Use this to put out the top level defined record and union types
1016 for later reference. If this is a struct with a name, then put that
1017 name out. Other unnamed structs will have .xxfake labels generated so
1018 that they may be referred to later.
1019 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1020 It may NOT be called recursively. */
1023 sdbout_one_type (tree type
)
1025 if (current_function_decl
!= NULL_TREE
1026 && DECL_SECTION_NAME (current_function_decl
) != NULL
)
1027 ; /* Don't change section amid function. */
1029 switch_to_section (current_function_section ());
1031 switch (TREE_CODE (type
))
1035 case QUAL_UNION_TYPE
:
1037 type
= TYPE_MAIN_VARIANT (type
);
1038 /* Don't output a type twice. */
1039 if (TREE_ASM_WRITTEN (type
))
1040 /* James said test TREE_ASM_BEING_WRITTEN here. */
1043 /* Output nothing if type is not yet defined. */
1044 if (!COMPLETE_TYPE_P (type
))
1047 TREE_ASM_WRITTEN (type
) = 1;
1049 /* This is reputed to cause trouble with the following case,
1050 but perhaps checking TYPE_SIZE above will fix it. */
1052 /* Here is a testcase:
1058 typedef struct intermediate {
1062 typedef struct badstr {
1066 /* This change, which ought to make better output,
1067 used to make the COFF assembler unhappy.
1068 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1069 /* Before really doing anything, output types we want to refer to. */
1070 /* Note that in version 1 the following two lines
1071 are not used if forward references are in use. */
1072 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1073 sdbout_field_types (type
);
1075 /* Output a structure type. */
1077 int size
= int_size_in_bytes (type
);
1081 /* Record the type tag, but not in its permanent place just yet. */
1082 sdbout_record_type_name (type
);
1084 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1086 switch (TREE_CODE (type
))
1089 case QUAL_UNION_TYPE
:
1090 PUT_SDB_SCL (C_UNTAG
);
1091 PUT_SDB_TYPE (T_UNION
);
1096 PUT_SDB_SCL (C_STRTAG
);
1097 PUT_SDB_TYPE (T_STRUCT
);
1102 PUT_SDB_SCL (C_ENTAG
);
1103 PUT_SDB_TYPE (T_ENUM
);
1111 PUT_SDB_SIZE (size
);
1114 /* Print out the base class information with fields
1115 named after the types they hold. */
1116 /* This is only relevant to aggregate types. TYPE_BINFO is used
1117 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1119 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1124 for (binfo
= TYPE_BINFO (type
), i
= 0;
1125 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1127 tree child_type
= BINFO_TYPE (child
);
1128 tree child_type_name
;
1130 if (TYPE_NAME (child_type
) == 0)
1132 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1133 child_type_name
= TYPE_NAME (child_type
);
1134 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1136 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1137 if (child_type_name
&& template_name_p (child_type_name
))
1139 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1144 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1145 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child
)));
1146 PUT_SDB_SCL (member_scl
);
1147 sdbout_type (BINFO_TYPE (child
));
1152 /* Output the individual fields. */
1154 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1156 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1158 tree value
= TREE_VALUE (tem
);
1160 if (TREE_CODE (value
) == CONST_DECL
)
1161 value
= DECL_INITIAL (value
);
1163 if (tree_fits_shwi_p (value
))
1165 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1166 PUT_SDB_INT_VAL (tree_to_shwi (value
));
1167 PUT_SDB_SCL (C_MOE
);
1168 PUT_SDB_TYPE (T_MOE
);
1173 else /* record or union type */
1174 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1175 /* Output the name, type, position (in bits), size (in bits)
1178 /* Omit here the nameless fields that are used to skip bits.
1179 Also omit fields with variable size or position.
1180 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1181 if (TREE_CODE (tem
) == FIELD_DECL
1184 && tree_fits_uhwi_p (DECL_SIZE (tem
))
1185 && tree_fits_shwi_p (bit_position (tem
)))
1189 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1191 if (DECL_BIT_FIELD_TYPE (tem
))
1193 PUT_SDB_INT_VAL (int_bit_position (tem
));
1194 PUT_SDB_SCL (C_FIELD
);
1195 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1196 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem
)));
1200 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1201 PUT_SDB_SCL (member_scl
);
1202 sdbout_type (TREE_TYPE (tem
));
1206 /* Output end of a structure,union, or enumeral definition. */
1208 PUT_SDB_PLAIN_DEF ("eos");
1209 PUT_SDB_INT_VAL (size
);
1210 PUT_SDB_SCL (C_EOS
);
1211 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1212 PUT_SDB_SIZE (size
);
1222 /* The following two functions output definitions of function parameters.
1223 Each parameter gets a definition locating it in the parameter list.
1224 Each parameter that is a register variable gets a second definition
1225 locating it in the register.
1227 Printing or argument lists in gdb uses the definitions that
1228 locate in the parameter list. But reference to the variable in
1229 expressions uses preferentially the definition as a register. */
1231 /* Output definitions, referring to storage in the parmlist,
1232 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1235 sdbout_parms (tree parms
)
1237 for (; parms
; parms
= TREE_CHAIN (parms
))
1238 if (DECL_NAME (parms
)
1239 && TREE_TYPE (parms
) != error_mark_node
1240 && DECL_RTL_SET_P (parms
)
1241 && DECL_INCOMING_RTL (parms
))
1243 int current_sym_value
= 0;
1244 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1246 if (name
== 0 || *name
== 0)
1247 name
= gen_fake_label ();
1249 /* Perform any necessary register eliminations on the parameter's rtl,
1250 so that the debugging output will be accurate. */
1251 DECL_INCOMING_RTL (parms
)
1252 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1253 SET_DECL_RTL (parms
,
1254 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1256 if (PARM_PASSED_IN_MEMORY (parms
))
1258 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1261 /* ??? Here we assume that the parm address is indexed
1262 off the frame pointer or arg pointer.
1263 If that is not true, we produce meaningless results,
1264 but do not crash. */
1265 if (GET_CODE (addr
) == PLUS
1266 && CONST_INT_P (XEXP (addr
, 1)))
1267 current_sym_value
= INTVAL (XEXP (addr
, 1));
1269 current_sym_value
= 0;
1271 if (REG_P (DECL_RTL (parms
))
1272 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1273 type
= DECL_ARG_TYPE (parms
);
1276 int original_sym_value
= current_sym_value
;
1278 /* This is the case where the parm is passed as an int or
1279 double and it is converted to a char, short or float
1280 and stored back in the parmlist. In this case, describe
1281 the parm with the variable's declared type, and adjust
1282 the address if the least significant bytes (which we are
1283 using) are not the first ones. */
1284 if (BYTES_BIG_ENDIAN
1285 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1286 current_sym_value
+=
1287 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1288 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1290 if (MEM_P (DECL_RTL (parms
))
1291 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1292 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1294 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1295 == current_sym_value
))
1296 type
= TREE_TYPE (parms
);
1299 current_sym_value
= original_sym_value
;
1300 type
= DECL_ARG_TYPE (parms
);
1305 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1306 PUT_SDB_SCL (C_ARG
);
1307 PUT_SDB_TYPE (plain_type (type
));
1310 else if (REG_P (DECL_RTL (parms
)))
1313 /* Parm passed in registers and lives in registers or nowhere. */
1315 /* If parm lives in a register, use that register;
1316 pretend the parm was passed there. It would be more consistent
1317 to describe the register where the parm was passed,
1318 but in practice that register usually holds something else. */
1319 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1320 best_rtl
= DECL_RTL (parms
);
1321 /* If the parm lives nowhere,
1322 use the register where it was passed. */
1324 best_rtl
= DECL_INCOMING_RTL (parms
);
1327 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1328 PUT_SDB_SCL (C_REGPARM
);
1329 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1332 else if (MEM_P (DECL_RTL (parms
))
1333 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1335 /* Parm was passed in registers but lives on the stack. */
1337 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1338 in which case we want the value of that CONST_INT,
1339 or (MEM (REG ...)) or (MEM (MEM ...)),
1340 in which case we use a value of zero. */
1341 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1342 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1343 current_sym_value
= 0;
1345 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1347 /* Again, this assumes the offset is based on the arg pointer. */
1349 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1350 XEXP (DECL_RTL (parms
), 0)));
1351 PUT_SDB_SCL (C_ARG
);
1352 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1358 /* Output definitions for the places where parms live during the function,
1359 when different from where they were passed, when the parms were passed
1362 It is not useful to do this for parms passed in registers
1363 that live during the function in different registers, because it is
1364 impossible to look in the passed register for the passed value,
1365 so we use the within-the-function register to begin with.
1367 PARMS is a chain of PARM_DECL nodes. */
1370 sdbout_reg_parms (tree parms
)
1372 for (; parms
; parms
= TREE_CHAIN (parms
))
1373 if (DECL_NAME (parms
)
1374 && TREE_TYPE (parms
) != error_mark_node
1375 && DECL_RTL_SET_P (parms
)
1376 && DECL_INCOMING_RTL (parms
))
1378 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1380 /* Report parms that live in registers during the function
1381 but were passed in memory. */
1382 if (REG_P (DECL_RTL (parms
))
1383 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1384 && PARM_PASSED_IN_MEMORY (parms
))
1386 if (name
== 0 || *name
== 0)
1387 name
= gen_fake_label ();
1389 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1390 PUT_SDB_SCL (C_REG
);
1391 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1394 /* Report parms that live in memory but not where they were passed. */
1395 else if (MEM_P (DECL_RTL (parms
))
1396 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1397 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1398 && PARM_PASSED_IN_MEMORY (parms
)
1399 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1401 #if 0 /* ??? It is not clear yet what should replace this. */
1402 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1403 /* A parm declared char is really passed as an int,
1404 so it occupies the least significant bytes.
1405 On a big-endian machine those are not the low-numbered ones. */
1406 if (BYTES_BIG_ENDIAN
1408 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1409 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1410 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1411 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1414 if (name
== 0 || *name
== 0)
1415 name
= gen_fake_label ();
1417 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1418 (XEXP (DECL_RTL (parms
), 0)));
1419 PUT_SDB_SCL (C_AUTO
);
1420 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1427 /* Output early debug information for a global DECL. Called from
1428 rest_of_decl_compilation during parsing. */
1431 sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED
)
1433 /* NYI for non-dwarf. */
1436 /* Output late debug information for a global DECL after location
1437 information is available. */
1440 sdbout_late_global_decl (tree decl
)
1442 if (VAR_P (decl
) && !DECL_EXTERNAL (decl
) && DECL_RTL_SET_P (decl
))
1444 /* The COFF linker can move initialized global vars to the end.
1445 And that can screw up the symbol ordering. Defer those for
1446 sdbout_finish (). */
1447 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1448 sdbout_symbol (decl
, 0);
1450 vec_safe_push (deferred_global_decls
, decl
);
1452 /* Output COFF information for non-global file-scope initialized
1454 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1455 sdbout_toplevel_data (decl
);
1459 /* Output initialized global vars at the end, in the order of
1460 definition. See comment in sdbout_global_decl. */
1463 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1468 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls
, i
, decl
)
1469 sdbout_symbol (decl
, 0);
1472 /* Describe the beginning of an internal block within a function.
1473 Also output descriptions of variables defined in this block.
1475 N is the number of the block, by order of beginning, counting from 1,
1476 and not counting the outermost (function top-level) block.
1477 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1478 if the count starts at 0 for the outermost one. */
1481 sdbout_begin_block (unsigned int line
, unsigned int n
)
1483 tree decl
= current_function_decl
;
1484 MAKE_LINE_SAFE (line
);
1486 /* The SCO compiler does not emit a separate block for the function level
1487 scope, so we avoid it here also. */
1488 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1492 /* Include the outermost BLOCK's variables in block 1. */
1493 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1494 sdbout_block (DECL_INITIAL (decl
));
1496 /* If -g1, suppress all the internal symbols of functions
1497 except for arguments. */
1498 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1501 sdbout_block (DECL_INITIAL (decl
));
1504 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1505 sdbout_dequeue_anonymous_types ();
1509 /* Describe the end line-number of an internal block within a function. */
1512 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1514 MAKE_LINE_SAFE (line
);
1516 /* The SCO compiler does not emit a separate block for the function level
1517 scope, so we avoid it here also. */
1519 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1522 /* Output a line number symbol entry for source file FILENAME and line
1526 sdbout_source_line (unsigned int line
, unsigned int column ATTRIBUTE_UNUSED
,
1527 const char *filename ATTRIBUTE_UNUSED
,
1528 int discriminator ATTRIBUTE_UNUSED
,
1529 bool is_stmt ATTRIBUTE_UNUSED
)
1531 /* COFF relative line numbers must be positive. */
1532 if ((int) line
> sdb_begin_function_line
)
1534 #ifdef SDB_OUTPUT_SOURCE_LINE
1535 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1537 fprintf (asm_out_file
, "\t.ln\t%d\n",
1538 ((sdb_begin_function_line
> -1)
1539 ? line
- sdb_begin_function_line
: 1));
1544 /* Output sdb info for the current function name.
1545 Called from assemble_start_function. */
1548 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1550 sdbout_symbol (current_function_decl
, 0);
1553 /* Called at beginning of function body after prologue. Record the
1554 function's starting line number, so we can output relative line numbers
1555 for the other lines. Describe beginning of outermost block. Also
1556 describe the parameter list. */
1559 sdbout_begin_prologue (unsigned int line
, unsigned int column ATTRIBUTE_UNUSED
,
1560 const char *file ATTRIBUTE_UNUSED
)
1562 sdbout_end_prologue (line
, file
);
1566 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1568 sdb_begin_function_line
= line
- 1;
1569 PUT_SDB_FUNCTION_START (line
);
1570 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1571 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1574 /* Called at end of function (before epilogue).
1575 Describe end of outermost block. */
1578 sdbout_end_function (unsigned int line
)
1580 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1581 sdbout_dequeue_anonymous_types ();
1584 MAKE_LINE_SAFE (line
);
1585 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1587 /* Indicate we are between functions, for line-number output. */
1588 sdb_begin_function_line
= -1;
1591 /* Output sdb info for the absolute end of a function.
1592 Called after the epilogue is output. */
1595 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1596 const char *file ATTRIBUTE_UNUSED
)
1598 const char *const name ATTRIBUTE_UNUSED
1599 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1601 #ifdef PUT_SDB_EPILOGUE_END
1602 PUT_SDB_EPILOGUE_END (name
);
1604 fprintf (asm_out_file
, "\t.def\t");
1605 assemble_name (asm_out_file
, name
);
1606 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1607 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1611 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1615 sdbout_label (rtx_code_label
*insn
)
1617 PUT_SDB_DEF (LABEL_NAME (insn
));
1619 PUT_SDB_SCL (C_LABEL
);
1620 PUT_SDB_TYPE (T_NULL
);
1624 /* Change to reading from a new source file. */
1627 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1628 const char *filename ATTRIBUTE_UNUSED
)
1632 /* Revert to reading a previous source file. */
1635 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1639 /* Set up for SDB output at the start of compilation. */
1642 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1646 vec_alloc (deferred_global_decls
, 12);
1648 /* Emit debug information which was queued by sdbout_symbol before
1650 sdbout_initialized
= true;
1652 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1653 sdbout_symbol (TREE_VALUE (t
), 0);
1654 preinit_symbols
= 0;
1657 #include "gt-sdbout.h"