1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* mike@tredysvr.Tredydev.Unisys.COM says:
23 I modified the struct.c example and have a nm of a .o resulting from the
24 AT&T C compiler. From the example below I would conclude the following:
26 1. All .defs from structures are emitted as scanned. The example below
27 clearly shows the symbol table entries for BoxRec2 are after the first
30 2. All functions and their locals (including statics) are emitted as scanned.
32 3. All nested unnamed union and structure .defs must be emitted before
33 the structure in which they are nested. The AT&T assembler is a
34 one pass beast as far as symbolics are concerned.
36 4. All structure .defs are emitted before the typedefs that refer to them.
38 5. All top level static and external variable definitions are moved to the
39 end of file with all top level statics occurring first before externs.
41 6. All undefined references are at the end of the file.
46 #include "coretypes.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
,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_global_decl (tree
);
123 #ifndef MIPS_DEBUGGING_INFO
124 static void sdbout_begin_prologue (unsigned int, const char *);
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
);
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
);
147 static void sdbout_global_decl (tree
);
149 /* Random macros describing parts of SDB data. */
151 /* Default value of delimiter is ";". */
153 #define SDB_DELIM ";"
156 /* Maximum number of dimensions the assembler will allow. */
158 #define SDB_MAX_DIM 4
162 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
165 #ifndef PUT_SDB_INT_VAL
166 #define PUT_SDB_INT_VAL(a) \
168 fprintf (asm_out_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC "%s", \
169 (HOST_WIDE_INT) (a), SDB_DELIM); \
175 #define PUT_SDB_VAL(a) \
176 ( fputs ("\t.val\t", asm_out_file), \
177 output_addr_const (asm_out_file, (a)), \
178 fprintf (asm_out_file, SDB_DELIM))
182 #define PUT_SDB_DEF(a) \
183 do { fprintf (asm_out_file, "\t.def\t"); \
184 assemble_name (asm_out_file, a); \
185 fprintf (asm_out_file, SDB_DELIM); } while (0)
188 #ifndef PUT_SDB_PLAIN_DEF
189 #define PUT_SDB_PLAIN_DEF(a) 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 /* Perform linker optimization of merging header file definitions together
279 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
280 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
281 the optimization just won't be done. The native assembler already has the
282 necessary support. */
284 #ifdef MIPS_DEBUGGING_INFO
286 /* ECOFF linkers have an optimization that does the same kind of thing as
287 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
288 executable. To achieve this, GCC must output a .file for each file
291 /* This is a stack of input files. */
295 struct sdb_file
*next
;
299 /* This is the top of the stack. */
301 static struct sdb_file
*current_file
;
303 #endif /* MIPS_DEBUGGING_INFO */
305 /* The debug hooks structure. */
306 const struct gcc_debug_hooks sdb_debug_hooks
=
308 sdbout_init
, /* init */
309 sdbout_finish
, /* finish */
310 debug_nothing_void
, /* assembly_start */
311 debug_nothing_int_charstar
, /* define */
312 debug_nothing_int_charstar
, /* undef */
313 sdbout_start_source_file
, /* start_source_file */
314 sdbout_end_source_file
, /* end_source_file */
315 sdbout_begin_block
, /* begin_block */
316 sdbout_end_block
, /* end_block */
317 debug_true_const_tree
, /* ignore_block */
318 sdbout_source_line
, /* source_line */
319 #ifdef MIPS_DEBUGGING_INFO
320 /* Defer on MIPS systems so that parameter descriptions follow
322 debug_nothing_int_charstar
, /* begin_prologue */
323 sdbout_end_prologue
, /* end_prologue */
325 sdbout_begin_prologue
, /* begin_prologue */
326 debug_nothing_int_charstar
, /* end_prologue */
328 debug_nothing_int_charstar
, /* begin_epilogue */
329 sdbout_end_epilogue
, /* end_epilogue */
330 sdbout_begin_function
, /* begin_function */
331 sdbout_end_function
, /* end_function */
332 debug_nothing_tree
, /* function_decl */
333 sdbout_global_decl
, /* global_decl */
334 sdbout_symbol
, /* type_decl */
335 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
336 debug_nothing_tree
, /* deferred_inline_function */
337 debug_nothing_tree
, /* outlining_inline_function */
338 sdbout_label
, /* label */
339 debug_nothing_int
, /* handle_pch */
340 debug_nothing_rtx
, /* var_location */
341 debug_nothing_void
, /* switch_text_section */
342 debug_nothing_tree_tree
, /* set_name */
343 0, /* start_end_main_source_file */
344 TYPE_SYMTAB_IS_POINTER
/* tree_type_symtab_field */
347 /* Return a unique string to name an anonymous type. */
350 gen_fake_label (void)
354 sprintf (label
, ".%dfake", unnamed_struct_number
);
355 unnamed_struct_number
++;
356 labelstr
= xstrdup (label
);
360 /* Return the number which describes TYPE for SDB.
361 For pointers, etc., this function is recursive.
362 Each record, union or enumeral type must already have had a
363 tag number output. */
365 /* The number is given by d6d5d4d3d2d1bbbb
366 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
367 Thus, char *foo () has bbbb=T_CHAR
370 N_BTMASK= 017 1111 basic type field.
371 N_TSHIFT= 2 derived type shift
372 N_BTSHFT= 4 Basic type shift */
374 /* Produce the number that describes a pointer, function or array type.
375 PREV is the number describing the target, value or element type.
376 DT_type describes how to transform that type. */
377 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
378 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
379 | ((int) DT_type << (int) N_BTSHFT) \
380 | ((PREV) & (int) N_BTMASK))
382 /* Number of elements used in sdb_dims. */
383 static int sdb_n_dims
= 0;
385 /* Table of array dimensions of current type. */
386 static int sdb_dims
[SDB_MAX_DIM
];
388 /* Size of outermost array currently being processed. */
389 static int sdb_type_size
= -1;
392 plain_type (tree type
)
394 int val
= plain_type_1 (type
, 0);
396 /* If we have already saved up some array dimensions, print them now. */
401 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
402 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
403 PUT_SDB_LAST_DIM (sdb_dims
[0]);
406 sdb_type_size
= int_size_in_bytes (type
);
407 /* Don't kill sdb if type is not laid out or has variable size. */
408 if (sdb_type_size
< 0)
411 /* If we have computed the size of an array containing this type,
413 if (sdb_type_size
>= 0)
415 PUT_SDB_SIZE (sdb_type_size
);
422 template_name_p (tree name
)
424 const char *ptr
= IDENTIFIER_POINTER (name
);
425 while (*ptr
&& *ptr
!= '<')
432 sdbout_record_type_name (tree type
)
434 const char *name
= 0;
437 if (KNOWN_TYPE_TAG (type
))
440 if (TYPE_NAME (type
) != 0)
444 /* Find the IDENTIFIER_NODE for the type name. */
445 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
446 t
= TYPE_NAME (type
);
447 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
449 t
= DECL_NAME (TYPE_NAME (type
));
450 /* The DECL_NAME for templates includes "<>", which breaks
451 most assemblers. Use its assembler name instead, which
452 has been mangled into being safe. */
453 if (t
&& template_name_p (t
))
454 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
457 /* Now get the name as a string, or invent one. */
459 name
= IDENTIFIER_POINTER (t
);
462 no_name
= (name
== 0 || *name
== 0);
464 name
= gen_fake_label ();
466 SET_KNOWN_TYPE_TAG (type
, name
);
467 #ifdef SDB_ALLOW_FORWARD_REFERENCES
469 sdbout_queue_anonymous_type (type
);
473 /* Return the .type value for type TYPE.
475 LEVEL indicates how many levels deep we have recursed into the type.
476 The SDB debug format can only represent 6 derived levels of types.
477 After that, we must output inaccurate debug info. We deliberately
478 stop before the 7th level, so that ADA recursive types will not give an
482 plain_type_1 (tree type
, int level
)
485 type
= void_type_node
;
486 else if (type
== error_mark_node
)
487 type
= integer_type_node
;
489 type
= TYPE_MAIN_VARIANT (type
);
491 switch (TREE_CODE (type
))
499 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
501 /* Carefully distinguish all the standard types of C,
502 without messing up if the language is not C.
503 Note that we check only for the names that contain spaces;
504 other names might occur by coincidence in other languages. */
505 if (TYPE_NAME (type
) != 0
506 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
507 && DECL_NAME (TYPE_NAME (type
)) != 0
508 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
510 const char *const name
511 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
513 if (!strcmp (name
, "char"))
515 if (!strcmp (name
, "unsigned char"))
517 if (!strcmp (name
, "signed char"))
519 if (!strcmp (name
, "int"))
521 if (!strcmp (name
, "unsigned int"))
523 if (!strcmp (name
, "short int"))
525 if (!strcmp (name
, "short unsigned int"))
527 if (!strcmp (name
, "long int"))
529 if (!strcmp (name
, "long unsigned int"))
533 if (size
== INT_TYPE_SIZE
)
534 return (TYPE_UNSIGNED (type
) ? T_UINT
: T_INT
);
535 if (size
== CHAR_TYPE_SIZE
)
536 return (TYPE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
537 if (size
== SHORT_TYPE_SIZE
)
538 return (TYPE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
539 if (size
== LONG_TYPE_SIZE
)
540 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
541 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
542 return (TYPE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
548 int precision
= TYPE_PRECISION (type
);
549 if (precision
== FLOAT_TYPE_SIZE
)
551 if (precision
== DOUBLE_TYPE_SIZE
)
553 #ifdef EXTENDED_SDB_BASIC_TYPES
554 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
557 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
558 return T_DOUBLE
; /* better than nothing */
569 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
570 if (sdb_n_dims
< SDB_MAX_DIM
)
571 sdb_dims
[sdb_n_dims
++]
572 = (TYPE_DOMAIN (type
)
573 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
574 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
575 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
576 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
577 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
578 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
581 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
586 case QUAL_UNION_TYPE
:
590 #ifdef SDB_ALLOW_FORWARD_REFERENCES
591 sdbout_record_type_name (type
);
593 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
594 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
595 #ifdef SDB_ALLOW_FORWARD_REFERENCES
596 || TYPE_MODE (type
) != VOIDmode
601 /* Output the referenced structure tag name
602 only if the .def has already been finished.
603 At least on 386, the Unix assembler
604 cannot handle forward references to tags. */
605 /* But the 88100, it requires them, sigh... */
606 /* And the MIPS requires unknown refs as well... */
607 tag
= KNOWN_TYPE_TAG (type
);
609 /* These 3 lines used to follow the close brace.
610 However, a size of 0 without a tag implies a tag of 0,
611 so if we don't know a tag, we can't mention the size. */
612 sdb_type_size
= int_size_in_bytes (type
);
613 if (sdb_type_size
< 0)
616 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
617 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
618 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
628 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
629 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
638 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
639 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
646 /* Output the symbols defined in block number DO_BLOCK.
648 This function works by walking the tree structure of blocks,
649 counting blocks until it finds the desired block. */
651 static int do_block
= 0;
654 sdbout_block (tree block
)
658 /* Ignore blocks never expanded or otherwise marked as real. */
659 if (TREE_USED (block
))
661 /* When we reach the specified block, output its symbols. */
662 if (BLOCK_NUMBER (block
) == do_block
)
663 sdbout_syms (BLOCK_VARS (block
));
665 /* If we are past the specified block, stop the scan. */
666 if (BLOCK_NUMBER (block
) > do_block
)
669 /* Scan the blocks within this block. */
670 sdbout_block (BLOCK_SUBBLOCKS (block
));
673 block
= BLOCK_CHAIN (block
);
677 /* Call sdbout_symbol on each decl in the chain SYMS. */
680 sdbout_syms (tree syms
)
684 if (TREE_CODE (syms
) != LABEL_DECL
)
685 sdbout_symbol (syms
, 1);
686 syms
= TREE_CHAIN (syms
);
690 /* Output SDB information for a symbol described by DECL.
691 LOCAL is nonzero if the symbol is not file-scope. */
694 sdbout_symbol (tree decl
, int local
)
696 tree type
= TREE_TYPE (decl
);
697 tree context
= NULL_TREE
;
702 /* If we are called before sdbout_init is run, just save the symbol
704 if (!sdbout_initialized
)
706 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
710 sdbout_one_type (type
);
712 switch (TREE_CODE (decl
))
715 /* Enum values are defined by defining the enum type. */
719 /* Don't mention a nested function under its parent. */
720 context
= decl_function_context (decl
);
721 if (context
== current_function_decl
)
723 /* Check DECL_INITIAL to distinguish declarations from definitions.
724 Don't output debug info here for declarations; they will have
725 a DECL_INITIAL value of 0. */
726 if (! DECL_INITIAL (decl
))
728 if (!MEM_P (DECL_RTL (decl
))
729 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
731 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
732 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
733 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
737 /* Done with tagged types. */
738 if (DECL_NAME (decl
) == 0)
740 if (DECL_IGNORED_P (decl
))
742 /* Don't output intrinsic types. GAS chokes on SDB .def
743 statements that contain identifiers with embedded spaces
744 (eg "unsigned long"). */
745 if (DECL_IS_BUILTIN (decl
))
748 /* Output typedef name. */
749 if (template_name_p (DECL_NAME (decl
)))
750 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
752 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
753 PUT_SDB_SCL (C_TPDEF
);
757 /* Parm decls go in their own separate chains
758 and are output by sdbout_reg_parms and sdbout_parms. */
762 /* Don't mention a variable that is external.
763 Let the file that defines it describe it. */
764 if (DECL_EXTERNAL (decl
))
767 /* Ignore __FUNCTION__, etc. */
768 if (DECL_IGNORED_P (decl
))
771 /* If there was an error in the declaration, don't dump core
772 if there is no RTL associated with the variable doesn't
774 if (!DECL_RTL_SET_P (decl
))
778 eliminate_regs (DECL_RTL (decl
), VOIDmode
, NULL_RTX
));
779 #ifdef LEAF_REG_REMAP
780 if (current_function_uses_only_leaf_regs
)
781 leaf_renumber_regs_insn (DECL_RTL (decl
));
783 value
= DECL_RTL (decl
);
785 /* Don't mention a variable at all
786 if it was completely optimized into nothingness.
788 If DECL was from an inline function, then its rtl
789 is not identically the rtl that was used in this
790 particular compilation. */
793 regno
= REGNO (value
);
794 if (regno
>= FIRST_PSEUDO_REGISTER
)
797 else if (GET_CODE (value
) == SUBREG
)
799 while (GET_CODE (value
) == SUBREG
)
800 value
= SUBREG_REG (value
);
803 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
806 regno
= REGNO (alter_subreg (&value
));
807 SET_DECL_RTL (decl
, value
);
809 /* Don't output anything if an auto variable
810 gets RTL that is static.
811 GAS version 2.2 can't handle such output. */
812 else if (MEM_P (value
) && CONSTANT_P (XEXP (value
, 0))
813 && ! TREE_STATIC (decl
))
816 /* Emit any structure, union, or enum type that has not been output.
817 This occurs for tag-less structs (et al) used to declare variables
819 if (TREE_CODE (type
) == ENUMERAL_TYPE
820 || TREE_CODE (type
) == RECORD_TYPE
821 || TREE_CODE (type
) == UNION_TYPE
822 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
824 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
825 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
826 sdbout_one_type (type
);
829 /* Defer SDB information for top-level initialized variables! */
832 && DECL_INITIAL (decl
))
835 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
836 For now, avoid crashing. */
837 if (DECL_NAME (decl
) == NULL_TREE
)
840 /* Record the name for, starting a symtab entry. */
842 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
844 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
847 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
850 if (TREE_PUBLIC (decl
))
852 PUT_SDB_VAL (XEXP (value
, 0));
857 PUT_SDB_VAL (XEXP (value
, 0));
858 PUT_SDB_SCL (C_STAT
);
864 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
867 else if (MEM_P (value
)
868 && (MEM_P (XEXP (value
, 0))
869 || (REG_P (XEXP (value
, 0))
870 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
871 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
872 /* If the value is indirect by memory or by a register
873 that isn't the frame pointer
874 then it means the object is variable-sized and address through
875 that register or stack slot. COFF has no way to represent this
876 so all we can do is output the variable as a pointer. */
879 if (REG_P (XEXP (value
, 0)))
881 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
886 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
888 We want the value of that CONST_INT. */
889 /* Encore compiler hates a newline in a macro arg, it seems. */
890 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
891 (XEXP (XEXP (value
, 0), 0)));
892 PUT_SDB_SCL (C_AUTO
);
895 /* Effectively do build_pointer_type, but don't cache this type,
896 since it might be temporary whereas the type it points to
897 might have been saved for inlining. */
898 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
899 type
= make_node (POINTER_TYPE
);
900 TREE_TYPE (type
) = TREE_TYPE (decl
);
902 else if (MEM_P (value
)
903 && ((GET_CODE (XEXP (value
, 0)) == PLUS
904 && REG_P (XEXP (XEXP (value
, 0), 0))
905 && CONST_INT_P (XEXP (XEXP (value
, 0), 1)))
906 /* This is for variables which are at offset zero from
907 the frame pointer. This happens on the Alpha.
908 Non-frame pointer registers are excluded above. */
909 || (REG_P (XEXP (value
, 0)))))
911 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
912 or (MEM (REG...)). We want the value of that CONST_INT
915 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
916 PUT_SDB_SCL (C_AUTO
);
920 /* It is something we don't know how to represent for SDB. */
928 PUT_SDB_TYPE (plain_type (type
));
932 /* Output SDB information for a top-level initialized variable
933 that has been delayed. */
936 sdbout_toplevel_data (tree decl
)
938 tree type
= TREE_TYPE (decl
);
940 if (DECL_IGNORED_P (decl
))
943 gcc_assert (TREE_CODE (decl
) == VAR_DECL
);
944 gcc_assert (MEM_P (DECL_RTL (decl
)));
945 gcc_assert (DECL_INITIAL (decl
));
947 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
948 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
949 if (TREE_PUBLIC (decl
))
955 PUT_SDB_SCL (C_STAT
);
957 PUT_SDB_TYPE (plain_type (type
));
961 #ifdef SDB_ALLOW_FORWARD_REFERENCES
963 /* Machinery to record and output anonymous types. */
966 sdbout_queue_anonymous_type (tree type
)
968 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
972 sdbout_dequeue_anonymous_types (void)
976 while (anonymous_types
)
978 types
= nreverse (anonymous_types
);
979 anonymous_types
= NULL_TREE
;
981 for (link
= types
; link
; link
= TREE_CHAIN (link
))
983 tree type
= TREE_VALUE (link
);
985 if (type
&& ! TREE_ASM_WRITTEN (type
))
986 sdbout_one_type (type
);
993 /* Given a chain of ..._TYPE nodes, all of which have names,
994 output definitions of those names, as typedefs. */
997 sdbout_types (tree types
)
1001 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1002 sdbout_one_type (link
);
1004 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1005 sdbout_dequeue_anonymous_types ();
1010 sdbout_type (tree type
)
1012 if (type
== error_mark_node
)
1013 type
= integer_type_node
;
1014 PUT_SDB_TYPE (plain_type (type
));
1017 /* Output types of the fields of type TYPE, if they are structs.
1019 Formerly did not chase through pointer types, since that could be circular.
1020 They must come before TYPE, since forward refs are not allowed.
1021 Now james@bigtex.cactus.org says to try them. */
1024 sdbout_field_types (tree type
)
1028 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1029 /* This condition should match the one for emitting the actual
1031 if (TREE_CODE (tail
) == FIELD_DECL
1034 && host_integerp (DECL_SIZE (tail
), 1)
1035 && host_integerp (bit_position (tail
), 0))
1037 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1038 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1040 sdbout_one_type (TREE_TYPE (tail
));
1044 /* Use this to put out the top level defined record and union types
1045 for later reference. If this is a struct with a name, then put that
1046 name out. Other unnamed structs will have .xxfake labels generated so
1047 that they may be referred to later.
1048 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1049 It may NOT be called recursively. */
1052 sdbout_one_type (tree type
)
1054 if (current_function_decl
!= NULL_TREE
1055 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1056 ; /* Don't change section amid function. */
1058 switch_to_section (text_section
);
1060 switch (TREE_CODE (type
))
1064 case QUAL_UNION_TYPE
:
1066 type
= TYPE_MAIN_VARIANT (type
);
1067 /* Don't output a type twice. */
1068 if (TREE_ASM_WRITTEN (type
))
1069 /* James said test TREE_ASM_BEING_WRITTEN here. */
1072 /* Output nothing if type is not yet defined. */
1073 if (!COMPLETE_TYPE_P (type
))
1076 TREE_ASM_WRITTEN (type
) = 1;
1078 /* This is reputed to cause trouble with the following case,
1079 but perhaps checking TYPE_SIZE above will fix it. */
1081 /* Here is a testcase:
1087 typedef struct intermediate {
1091 typedef struct badstr {
1095 /* This change, which ought to make better output,
1096 used to make the COFF assembler unhappy.
1097 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1098 /* Before really doing anything, output types we want to refer to. */
1099 /* Note that in version 1 the following two lines
1100 are not used if forward references are in use. */
1101 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1102 sdbout_field_types (type
);
1104 /* Output a structure type. */
1106 int size
= int_size_in_bytes (type
);
1110 /* Record the type tag, but not in its permanent place just yet. */
1111 sdbout_record_type_name (type
);
1113 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1115 switch (TREE_CODE (type
))
1118 case QUAL_UNION_TYPE
:
1119 PUT_SDB_SCL (C_UNTAG
);
1120 PUT_SDB_TYPE (T_UNION
);
1125 PUT_SDB_SCL (C_STRTAG
);
1126 PUT_SDB_TYPE (T_STRUCT
);
1131 PUT_SDB_SCL (C_ENTAG
);
1132 PUT_SDB_TYPE (T_ENUM
);
1140 PUT_SDB_SIZE (size
);
1143 /* Print out the base class information with fields
1144 named after the types they hold. */
1145 /* This is only relevant to aggregate types. TYPE_BINFO is used
1146 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1148 if (TREE_CODE (type
) != ENUMERAL_TYPE
&& TYPE_BINFO (type
))
1153 for (binfo
= TYPE_BINFO (type
), i
= 0;
1154 BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1156 tree child_type
= BINFO_TYPE (child
);
1157 tree child_type_name
;
1159 if (TYPE_NAME (child_type
) == 0)
1161 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1162 child_type_name
= TYPE_NAME (child_type
);
1163 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1165 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1166 if (child_type_name
&& template_name_p (child_type_name
))
1168 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1173 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1174 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1175 PUT_SDB_SCL (member_scl
);
1176 sdbout_type (BINFO_TYPE (child
));
1181 /* Output the individual fields. */
1183 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1185 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1187 tree value
= TREE_VALUE (tem
);
1189 if (TREE_CODE (value
) == CONST_DECL
)
1190 value
= DECL_INITIAL (value
);
1192 if (host_integerp (value
, 0))
1194 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1195 PUT_SDB_INT_VAL (tree_low_cst (value
, 0));
1196 PUT_SDB_SCL (C_MOE
);
1197 PUT_SDB_TYPE (T_MOE
);
1202 else /* record or union type */
1203 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1204 /* Output the name, type, position (in bits), size (in bits)
1207 /* Omit here the nameless fields that are used to skip bits.
1208 Also omit fields with variable size or position.
1209 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1210 if (TREE_CODE (tem
) == FIELD_DECL
1213 && host_integerp (DECL_SIZE (tem
), 1)
1214 && host_integerp (bit_position (tem
), 0))
1218 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1220 if (DECL_BIT_FIELD_TYPE (tem
))
1222 PUT_SDB_INT_VAL (int_bit_position (tem
));
1223 PUT_SDB_SCL (C_FIELD
);
1224 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1225 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1229 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1230 PUT_SDB_SCL (member_scl
);
1231 sdbout_type (TREE_TYPE (tem
));
1235 /* Output end of a structure,union, or enumeral definition. */
1237 PUT_SDB_PLAIN_DEF ("eos");
1238 PUT_SDB_INT_VAL (size
);
1239 PUT_SDB_SCL (C_EOS
);
1240 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1241 PUT_SDB_SIZE (size
);
1251 /* The following two functions output definitions of function parameters.
1252 Each parameter gets a definition locating it in the parameter list.
1253 Each parameter that is a register variable gets a second definition
1254 locating it in the register.
1256 Printing or argument lists in gdb uses the definitions that
1257 locate in the parameter list. But reference to the variable in
1258 expressions uses preferentially the definition as a register. */
1260 /* Output definitions, referring to storage in the parmlist,
1261 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1264 sdbout_parms (tree parms
)
1266 for (; parms
; parms
= TREE_CHAIN (parms
))
1267 if (DECL_NAME (parms
))
1269 int current_sym_value
= 0;
1270 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1272 if (name
== 0 || *name
== 0)
1273 name
= gen_fake_label ();
1275 /* Perform any necessary register eliminations on the parameter's rtl,
1276 so that the debugging output will be accurate. */
1277 DECL_INCOMING_RTL (parms
)
1278 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
1279 SET_DECL_RTL (parms
,
1280 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
1282 if (PARM_PASSED_IN_MEMORY (parms
))
1284 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1287 /* ??? Here we assume that the parm address is indexed
1288 off the frame pointer or arg pointer.
1289 If that is not true, we produce meaningless results,
1290 but do not crash. */
1291 if (GET_CODE (addr
) == PLUS
1292 && CONST_INT_P (XEXP (addr
, 1)))
1293 current_sym_value
= INTVAL (XEXP (addr
, 1));
1295 current_sym_value
= 0;
1297 if (REG_P (DECL_RTL (parms
))
1298 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1299 type
= DECL_ARG_TYPE (parms
);
1302 int original_sym_value
= current_sym_value
;
1304 /* This is the case where the parm is passed as an int or
1305 double and it is converted to a char, short or float
1306 and stored back in the parmlist. In this case, describe
1307 the parm with the variable's declared type, and adjust
1308 the address if the least significant bytes (which we are
1309 using) are not the first ones. */
1310 if (BYTES_BIG_ENDIAN
1311 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1312 current_sym_value
+=
1313 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1314 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1316 if (MEM_P (DECL_RTL (parms
))
1317 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1318 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1320 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1321 == current_sym_value
))
1322 type
= TREE_TYPE (parms
);
1325 current_sym_value
= original_sym_value
;
1326 type
= DECL_ARG_TYPE (parms
);
1331 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1332 PUT_SDB_SCL (C_ARG
);
1333 PUT_SDB_TYPE (plain_type (type
));
1336 else if (REG_P (DECL_RTL (parms
)))
1339 /* Parm passed in registers and lives in registers or nowhere. */
1341 /* If parm lives in a register, use that register;
1342 pretend the parm was passed there. It would be more consistent
1343 to describe the register where the parm was passed,
1344 but in practice that register usually holds something else. */
1345 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1346 best_rtl
= DECL_RTL (parms
);
1347 /* If the parm lives nowhere,
1348 use the register where it was passed. */
1350 best_rtl
= DECL_INCOMING_RTL (parms
);
1353 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1354 PUT_SDB_SCL (C_REGPARM
);
1355 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1358 else if (MEM_P (DECL_RTL (parms
))
1359 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1361 /* Parm was passed in registers but lives on the stack. */
1363 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1364 in which case we want the value of that CONST_INT,
1365 or (MEM (REG ...)) or (MEM (MEM ...)),
1366 in which case we use a value of zero. */
1367 if (REG_P (XEXP (DECL_RTL (parms
), 0))
1368 || MEM_P (XEXP (DECL_RTL (parms
), 0)))
1369 current_sym_value
= 0;
1371 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1373 /* Again, this assumes the offset is based on the arg pointer. */
1375 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1376 XEXP (DECL_RTL (parms
), 0)));
1377 PUT_SDB_SCL (C_ARG
);
1378 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1384 /* Output definitions for the places where parms live during the function,
1385 when different from where they were passed, when the parms were passed
1388 It is not useful to do this for parms passed in registers
1389 that live during the function in different registers, because it is
1390 impossible to look in the passed register for the passed value,
1391 so we use the within-the-function register to begin with.
1393 PARMS is a chain of PARM_DECL nodes. */
1396 sdbout_reg_parms (tree parms
)
1398 for (; parms
; parms
= TREE_CHAIN (parms
))
1399 if (DECL_NAME (parms
))
1401 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1403 /* Report parms that live in registers during the function
1404 but were passed in memory. */
1405 if (REG_P (DECL_RTL (parms
))
1406 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1407 && PARM_PASSED_IN_MEMORY (parms
))
1409 if (name
== 0 || *name
== 0)
1410 name
= gen_fake_label ();
1412 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1413 PUT_SDB_SCL (C_REG
);
1414 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1417 /* Report parms that live in memory but not where they were passed. */
1418 else if (MEM_P (DECL_RTL (parms
))
1419 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1420 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1421 && PARM_PASSED_IN_MEMORY (parms
)
1422 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1424 #if 0 /* ??? It is not clear yet what should replace this. */
1425 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1426 /* A parm declared char is really passed as an int,
1427 so it occupies the least significant bytes.
1428 On a big-endian machine those are not the low-numbered ones. */
1429 if (BYTES_BIG_ENDIAN
1431 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1432 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1433 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1434 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1437 if (name
== 0 || *name
== 0)
1438 name
= gen_fake_label ();
1440 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1441 (XEXP (DECL_RTL (parms
), 0)));
1442 PUT_SDB_SCL (C_AUTO
);
1443 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1450 /* Output debug information for a global DECL. Called from toplev.c
1451 after compilation proper has finished. */
1454 sdbout_global_decl (tree decl
)
1456 if (TREE_CODE (decl
) == VAR_DECL
1457 && !DECL_EXTERNAL (decl
)
1458 && DECL_RTL_SET_P (decl
))
1460 /* The COFF linker can move initialized global vars to the end.
1461 And that can screw up the symbol ordering. Defer those for
1462 sdbout_finish (). */
1463 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1464 sdbout_symbol (decl
, 0);
1466 VEC_safe_push (tree
, gc
, deferred_global_decls
, decl
);
1468 /* Output COFF information for non-global file-scope initialized
1470 if (DECL_INITIAL (decl
) && MEM_P (DECL_RTL (decl
)))
1471 sdbout_toplevel_data (decl
);
1475 /* Output initialized global vars at the end, in the order of
1476 definition. See comment in sdbout_global_decl. */
1479 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED
)
1484 FOR_EACH_VEC_ELT (tree
, deferred_global_decls
, i
, decl
)
1485 sdbout_symbol (decl
, 0);
1488 /* Describe the beginning of an internal block within a function.
1489 Also output descriptions of variables defined in this block.
1491 N is the number of the block, by order of beginning, counting from 1,
1492 and not counting the outermost (function top-level) block.
1493 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1494 if the count starts at 0 for the outermost one. */
1497 sdbout_begin_block (unsigned int line
, unsigned int n
)
1499 tree decl
= current_function_decl
;
1500 MAKE_LINE_SAFE (line
);
1502 /* The SCO compiler does not emit a separate block for the function level
1503 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1504 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1505 #ifndef MIPS_DEBUGGING_INFO
1508 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1512 /* Include the outermost BLOCK's variables in block 1. */
1513 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1514 sdbout_block (DECL_INITIAL (decl
));
1516 /* If -g1, suppress all the internal symbols of functions
1517 except for arguments. */
1518 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1521 sdbout_block (DECL_INITIAL (decl
));
1524 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1525 sdbout_dequeue_anonymous_types ();
1529 /* Describe the end line-number of an internal block within a function. */
1532 sdbout_end_block (unsigned int line
, unsigned int n ATTRIBUTE_UNUSED
)
1534 MAKE_LINE_SAFE (line
);
1536 /* The SCO compiler does not emit a separate block for the function level
1537 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1538 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1539 #ifndef MIPS_DEBUGGING_INFO
1542 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1545 /* Output a line number symbol entry for source file FILENAME and line
1549 sdbout_source_line (unsigned int line
, const char *filename ATTRIBUTE_UNUSED
,
1550 int discriminator ATTRIBUTE_UNUSED
,
1551 bool is_stmt ATTRIBUTE_UNUSED
)
1553 /* COFF relative line numbers must be positive. */
1554 if ((int) line
> sdb_begin_function_line
)
1556 #ifdef SDB_OUTPUT_SOURCE_LINE
1557 SDB_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1559 fprintf (asm_out_file
, "\t.ln\t%d\n",
1560 ((sdb_begin_function_line
> -1)
1561 ? line
- sdb_begin_function_line
: 1));
1566 /* Output sdb info for the current function name.
1567 Called from assemble_start_function. */
1570 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED
)
1572 sdbout_symbol (current_function_decl
, 0);
1575 /* Called at beginning of function body (before or after prologue,
1576 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1577 line number, so we can output relative line numbers for the other
1578 lines. Describe beginning of outermost block. Also describe the
1581 #ifndef MIPS_DEBUGGING_INFO
1583 sdbout_begin_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1585 sdbout_end_prologue (line
, file
);
1590 sdbout_end_prologue (unsigned int line
, const char *file ATTRIBUTE_UNUSED
)
1592 sdb_begin_function_line
= line
- 1;
1593 PUT_SDB_FUNCTION_START (line
);
1594 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1595 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1598 /* Called at end of function (before epilogue).
1599 Describe end of outermost block. */
1602 sdbout_end_function (unsigned int line
)
1604 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1605 sdbout_dequeue_anonymous_types ();
1608 MAKE_LINE_SAFE (line
);
1609 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1611 /* Indicate we are between functions, for line-number output. */
1612 sdb_begin_function_line
= -1;
1615 /* Output sdb info for the absolute end of a function.
1616 Called after the epilogue is output. */
1619 sdbout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED
,
1620 const char *file ATTRIBUTE_UNUSED
)
1622 const char *const name ATTRIBUTE_UNUSED
1623 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1625 #ifdef PUT_SDB_EPILOGUE_END
1626 PUT_SDB_EPILOGUE_END (name
);
1628 fprintf (asm_out_file
, "\t.def\t");
1629 assemble_name (asm_out_file
, name
);
1630 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1631 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1635 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1639 sdbout_label (rtx insn
)
1641 PUT_SDB_DEF (LABEL_NAME (insn
));
1643 PUT_SDB_SCL (C_LABEL
);
1644 PUT_SDB_TYPE (T_NULL
);
1648 /* Change to reading from a new source file. */
1651 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1652 const char *filename ATTRIBUTE_UNUSED
)
1654 #ifdef MIPS_DEBUGGING_INFO
1655 struct sdb_file
*n
= XNEW (struct sdb_file
);
1657 n
->next
= current_file
;
1660 output_file_directive (asm_out_file
, filename
);
1664 /* Revert to reading a previous source file. */
1667 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1669 #ifdef MIPS_DEBUGGING_INFO
1670 struct sdb_file
*next
;
1672 next
= current_file
->next
;
1673 free (current_file
);
1674 current_file
= next
;
1675 output_file_directive (asm_out_file
, current_file
->name
);
1679 /* Set up for SDB output at the start of compilation. */
1682 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED
)
1686 #ifdef MIPS_DEBUGGING_INFO
1687 current_file
= XNEW (struct sdb_file
);
1688 current_file
->next
= NULL
;
1689 current_file
->name
= input_file_name
;
1692 deferred_global_decls
= VEC_alloc (tree
, gc
, 12);
1694 /* Emit debug information which was queued by sdbout_symbol before
1696 sdbout_initialized
= true;
1698 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1699 sdbout_symbol (TREE_VALUE (t
), 0);
1700 preinit_symbols
= 0;
1703 #endif /* SDB_DEBUGGING_INFO */
1705 #include "gt-sdbout.h"