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"
51 #include "stor-layout.h"
53 static GTY(()) tree anonymous_types
;
55 /* Counter to generate unique "names" for nameless struct members. */
57 static GTY(()) int unnamed_struct_number
;
59 /* Declarations whose debug info was deferred till end of compilation. */
61 static GTY(()) vec
<tree
, va_gc
> *deferred_global_decls
;
63 /* The C front end may call sdbout_symbol before sdbout_init runs.
64 We save all such decls in this list and output them when we get
67 static GTY(()) tree preinit_symbols
;
68 static GTY(()) bool sdbout_initialized
;
70 #ifdef SDB_DEBUGGING_INFO
75 #include "insn-config.h"
78 #include "diagnostic-core.h"
81 #include "langhooks.h"
84 /* 1 if PARM is passed to this function in memory. */
86 #define PARM_PASSED_IN_MEMORY(PARM) \
87 (MEM_P (DECL_INCOMING_RTL (PARM)))
89 /* A C expression for the integer offset value of an automatic variable
90 (C_AUTO) having address X (an RTX). */
91 #ifndef DEBUGGER_AUTO_OFFSET
92 #define DEBUGGER_AUTO_OFFSET(X) \
93 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
96 /* A C expression for the integer offset value of an argument (C_ARG)
97 having address X (an RTX). The nominal offset is OFFSET. */
98 #ifndef DEBUGGER_ARG_OFFSET
99 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
102 /* Line number of beginning of current function, minus one.
103 Negative means not in a function or not using sdb. */
105 int sdb_begin_function_line
= -1;
108 extern FILE *asm_out_file
;
110 extern tree current_function_decl
;
114 static void sdbout_init (const char *);
115 static void sdbout_finish (const char *);
116 static void sdbout_start_source_file (unsigned int, const char *);
117 static void sdbout_end_source_file (unsigned int);
118 static void sdbout_begin_block (unsigned int, unsigned int);
119 static void sdbout_end_block (unsigned int, unsigned int);
120 static void sdbout_source_line (unsigned int, const char *, int, bool);
121 static void sdbout_end_epilogue (unsigned int, const char *);
122 static void sdbout_early_global_decl (tree
);
123 static void sdbout_late_global_decl (tree
);
124 static void sdbout_begin_prologue (unsigned int, const char *);
125 static void sdbout_end_prologue (unsigned int, const char *);
126 static void sdbout_begin_function (tree
);
127 static void sdbout_end_function (unsigned int);
128 static void sdbout_toplevel_data (tree
);
129 static void sdbout_label (rtx_code_label
*);
130 static char *gen_fake_label (void);
131 static int plain_type (tree
);
132 static int template_name_p (tree
);
133 static void sdbout_record_type_name (tree
);
134 static int plain_type_1 (tree
, int);
135 static void sdbout_block (tree
);
136 static void sdbout_syms (tree
);
137 #ifdef SDB_ALLOW_FORWARD_REFERENCES
138 static void sdbout_queue_anonymous_type (tree
);
139 static void sdbout_dequeue_anonymous_types (void);
141 static void sdbout_type (tree
);
142 static void sdbout_field_types (tree
);
143 static void sdbout_one_type (tree
);
144 static void sdbout_parms (tree
);
145 static void sdbout_reg_parms (tree
);
147 /* Random macros describing parts of SDB data. */
149 /* Default value of delimiter is ";". */
151 #define SDB_DELIM ";"
154 /* Maximum number of dimensions the assembler will allow. */
156 #define SDB_MAX_DIM 4
160 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
163 #ifndef PUT_SDB_INT_VAL
164 #define PUT_SDB_INT_VAL(a) \
166 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
167 (HOST_WIDE_INT) (a), SDB_DELIM); \
173 #define PUT_SDB_VAL(a) \
174 ( fputs ("\t.val\t", asm_out_file), \
175 output_addr_const (asm_out_file, (a)), \
176 fprintf (asm_out_file, SDB_DELIM))
180 #define PUT_SDB_DEF(a) \
181 do { fprintf (asm_out_file, "\t.def\t"); \
182 assemble_name (asm_out_file, a); \
183 fprintf (asm_out_file, SDB_DELIM); } while (0)
186 #ifndef PUT_SDB_PLAIN_DEF
187 #define PUT_SDB_PLAIN_DEF(a) \
188 fprintf (asm_out_file, "\t.def\t.%s%s", a, SDB_DELIM)
191 #ifndef PUT_SDB_ENDEF
192 #define PUT_SDB_ENDEF fputs ("\t.endef\n", asm_out_file)
196 #define PUT_SDB_TYPE(a) fprintf (asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
200 #define PUT_SDB_SIZE(a) \
202 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
203 (HOST_WIDE_INT) (a), SDB_DELIM); \
207 #ifndef PUT_SDB_START_DIM
208 #define PUT_SDB_START_DIM fprintf (asm_out_file, "\t.dim\t")
211 #ifndef PUT_SDB_NEXT_DIM
212 #define PUT_SDB_NEXT_DIM(a) fprintf (asm_out_file, "%d,", a)
215 #ifndef PUT_SDB_LAST_DIM
216 #define PUT_SDB_LAST_DIM(a) fprintf (asm_out_file, "%d%s", a, SDB_DELIM)
220 #define PUT_SDB_TAG(a) \
221 do { fprintf (asm_out_file, "\t.tag\t"); \
222 assemble_name (asm_out_file, a); \
223 fprintf (asm_out_file, SDB_DELIM); } while (0)
226 #ifndef PUT_SDB_BLOCK_START
227 #define PUT_SDB_BLOCK_START(LINE) \
228 fprintf (asm_out_file, \
229 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
230 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
233 #ifndef PUT_SDB_BLOCK_END
234 #define PUT_SDB_BLOCK_END(LINE) \
235 fprintf (asm_out_file, \
236 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
237 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
240 #ifndef PUT_SDB_FUNCTION_START
241 #define PUT_SDB_FUNCTION_START(LINE) \
242 fprintf (asm_out_file, \
243 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
244 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
247 #ifndef PUT_SDB_FUNCTION_END
248 #define PUT_SDB_FUNCTION_END(LINE) \
249 fprintf (asm_out_file, \
250 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
251 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
254 /* Return the sdb tag identifier string for TYPE
255 if TYPE has already been defined; otherwise return a null pointer. */
257 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
259 /* Set the sdb tag identifier string for TYPE to NAME. */
261 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
262 TYPE_SYMTAB_POINTER (TYPE) = (const char *)(NAME)
264 /* Return the name (a string) of the struct, union or enum tag
265 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
267 #define TAG_NAME(link) \
268 (((link) && TREE_PURPOSE ((link)) \
269 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
270 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
272 /* Ensure we don't output a negative line number. */
273 #define MAKE_LINE_SAFE(line) \
274 if ((int) line <= sdb_begin_function_line) \
275 line = sdb_begin_function_line + 1
277 /* The debug hooks structure. */
278 const struct gcc_debug_hooks sdb_debug_hooks
=
280 sdbout_init
, /* init */
281 sdbout_finish
, /* finish */
282 debug_nothing_void
, /* early_finish */
283 debug_nothing_void
, /* assembly_start */
284 debug_nothing_int_charstar
, /* define */
285 debug_nothing_int_charstar
, /* undef */
286 sdbout_start_source_file
, /* start_source_file */
287 sdbout_end_source_file
, /* end_source_file */
288 sdbout_begin_block
, /* begin_block */
289 sdbout_end_block
, /* end_block */
290 debug_true_const_tree
, /* ignore_block */
291 sdbout_source_line
, /* source_line */
292 sdbout_begin_prologue
, /* begin_prologue */
293 debug_nothing_int_charstar
, /* end_prologue */
294 debug_nothing_int_charstar
, /* begin_epilogue */
295 sdbout_end_epilogue
, /* end_epilogue */
296 sdbout_begin_function
, /* begin_function */
297 sdbout_end_function
, /* end_function */
298 debug_nothing_tree
, /* register_main_translation_unit */
299 debug_nothing_tree
, /* function_decl */
300 sdbout_early_global_decl
, /* early_global_decl */
301 sdbout_late_global_decl
, /* late_global_decl */
302 sdbout_symbol
, /* type_decl */
303 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
304 debug_nothing_tree
, /* deferred_inline_function */
305 debug_nothing_tree
, /* outlining_inline_function */
306 sdbout_label
, /* label */
307 debug_nothing_int
, /* handle_pch */
308 debug_nothing_rtx_insn
, /* var_location */
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 #ifdef EXTENDED_SDB_BASIC_TYPES
522 if (precision
== LONG_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 (TREE_CODE (decl
) == VAR_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 (TREE_CODE (decl
) == VAR_DECL
1443 && !DECL_EXTERNAL (decl
)
1444 && DECL_RTL_SET_P (decl
))
1446 /* The COFF linker can move initialized global vars to the end.
1447 And that can screw up the symbol ordering. Defer those for
1448 sdbout_finish (). */
1449 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1450 sdbout_symbol (decl
, 0);
1452 vec_safe_push (deferred_global_decls
, decl
);
1454 /* Output COFF information for non-global file-scope initialized
1456 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1457 sdbout_toplevel_data (decl
);
1461 /* Output initialized global vars at the end, in the order of
1462 definition. See comment in sdbout_global_decl. */
1465 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1470 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls
, i
, decl
)
1471 sdbout_symbol (decl
, 0);
1474 /* Describe the beginning of an internal block within a function.
1475 Also output descriptions of variables defined in this block.
1477 N is the number of the block, by order of beginning, counting from 1,
1478 and not counting the outermost (function top-level) block.
1479 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1480 if the count starts at 0 for the outermost one. */
1483 sdbout_begin_block (unsigned int line
, unsigned int n
)
1485 tree decl
= current_function_decl
;
1486 MAKE_LINE_SAFE (line
);
1488 /* The SCO compiler does not emit a separate block for the function level
1489 scope, so we avoid it here also. */
1490 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1494 /* Include the outermost BLOCK's variables in block 1. */
1495 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1496 sdbout_block (DECL_INITIAL (decl
));
1498 /* If -g1, suppress all the internal symbols of functions
1499 except for arguments. */
1500 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1503 sdbout_block (DECL_INITIAL (decl
));
1506 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1507 sdbout_dequeue_anonymous_types ();
1511 /* Describe the end line-number of an internal block within a function. */
1514 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1516 MAKE_LINE_SAFE (line
);
1518 /* The SCO compiler does not emit a separate block for the function level
1519 scope, so we avoid it here also. */
1521 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1524 /* Output a line number symbol entry for source file FILENAME and line
1528 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1529 int discriminator ATTRIBUTE_UNUSED
,
1530 bool is_stmt ATTRIBUTE_UNUSED
)
1532 /* COFF relative line numbers must be positive. */
1533 if ((int) line
> sdb_begin_function_line
)
1535 #ifdef SDB_OUTPUT_SOURCE_LINE
1536 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1538 fprintf (asm_out_file
, "\t.ln\t%d\n",
1539 ((sdb_begin_function_line
> -1)
1540 ? line
- sdb_begin_function_line
: 1));
1545 /* Output sdb info for the current function name.
1546 Called from assemble_start_function. */
1549 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1551 sdbout_symbol (current_function_decl
, 0);
1554 /* Called at beginning of function body after prologue. Record the
1555 function's starting line number, so we can output relative line numbers
1556 for the other lines. Describe beginning of outermost block. Also
1557 describe the parameter list. */
1560 sdbout_begin_prologue (unsigned int line
, 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 #endif /* SDB_DEBUGGING_INFO */
1659 #include "gt-sdbout.h"