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 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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"
52 static GTY(()) tree anonymous_types
;
54 #ifdef SDB_DEBUGGING_INFO
59 #include "insn-config.h"
65 #include "langhooks.h"
68 /* 1 if PARM is passed to this function in memory. */
70 #define PARM_PASSED_IN_MEMORY(PARM) \
71 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
73 /* A C expression for the integer offset value of an automatic variable
74 (C_AUTO) having address X (an RTX). */
75 #ifndef DEBUGGER_AUTO_OFFSET
76 #define DEBUGGER_AUTO_OFFSET(X) \
77 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
80 /* A C expression for the integer offset value of an argument (C_ARG)
81 having address X (an RTX). The nominal offset is OFFSET. */
82 #ifndef DEBUGGER_ARG_OFFSET
83 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
86 /* Line number of beginning of current function, minus one.
87 Negative means not in a function or not using sdb. */
89 int sdb_begin_function_line
= -1;
91 /* Counter to generate unique "names" for nameless struct members. */
93 static int unnamed_struct_number
= 0;
95 extern FILE *asm_out_file
;
97 extern tree current_function_decl
;
101 static void sdbout_init
PARAMS ((const char *));
102 static void sdbout_finish
PARAMS ((const char *));
103 static void sdbout_start_source_file
PARAMS ((unsigned int, const char *));
104 static void sdbout_end_source_file
PARAMS ((unsigned int));
105 static void sdbout_begin_block
PARAMS ((unsigned int, unsigned int));
106 static void sdbout_end_block
PARAMS ((unsigned int, unsigned int));
107 static void sdbout_source_line
PARAMS ((unsigned int, const char *));
108 static void sdbout_end_epilogue
PARAMS ((unsigned int, const char *));
109 static void sdbout_global_decl
PARAMS ((tree
));
110 #ifndef MIPS_DEBUGGING_INFO
111 static void sdbout_begin_prologue
PARAMS ((unsigned int, const char *));
113 static void sdbout_end_prologue
PARAMS ((unsigned int, const char *));
114 static void sdbout_begin_function
PARAMS ((tree
));
115 static void sdbout_end_function
PARAMS ((unsigned int));
116 static void sdbout_toplevel_data
PARAMS ((tree
));
117 static void sdbout_label
PARAMS ((rtx
));
118 static char *gen_fake_label
PARAMS ((void));
119 static int plain_type
PARAMS ((tree
));
120 static int template_name_p
PARAMS ((tree
));
121 static void sdbout_record_type_name
PARAMS ((tree
));
122 static int plain_type_1
PARAMS ((tree
, int));
123 static void sdbout_block
PARAMS ((tree
));
124 static void sdbout_syms
PARAMS ((tree
));
125 #ifdef SDB_ALLOW_FORWARD_REFERENCES
126 static void sdbout_queue_anonymous_type
PARAMS ((tree
));
127 static void sdbout_dequeue_anonymous_types
PARAMS ((void));
129 static void sdbout_type
PARAMS ((tree
));
130 static void sdbout_field_types
PARAMS ((tree
));
131 static void sdbout_one_type
PARAMS ((tree
));
132 static void sdbout_parms
PARAMS ((tree
));
133 static void sdbout_reg_parms
PARAMS ((tree
));
134 static void sdbout_global_decl
PARAMS ((tree
));
136 /* Random macros describing parts of SDB data. */
138 /* Put something here if lines get too long */
141 /* Default value of delimiter is ";". */
143 #define SDB_DELIM ";"
146 /* Maximum number of dimensions the assembler will allow. */
148 #define SDB_MAX_DIM 4
152 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
155 #ifndef PUT_SDB_INT_VAL
156 #define PUT_SDB_INT_VAL(a) \
158 fputs ("\t.val\t", asm_out_file); \
159 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) (a)); \
160 fprintf (asm_out_file, "%s", SDB_DELIM); \
166 #define PUT_SDB_VAL(a) \
167 ( fputs ("\t.val\t", asm_out_file), \
168 output_addr_const (asm_out_file, (a)), \
169 fprintf (asm_out_file, SDB_DELIM))
173 #define PUT_SDB_DEF(a) \
174 do { fprintf (asm_out_file, "\t.def\t"); \
175 assemble_name (asm_out_file, a); \
176 fprintf (asm_out_file, SDB_DELIM); } while (0)
179 #ifndef PUT_SDB_PLAIN_DEF
180 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
183 #ifndef PUT_SDB_ENDEF
184 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
188 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
192 #define PUT_SDB_SIZE(a) \
194 fputs ("\t.size\t", asm_out_file); \
195 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) (a)); \
196 fprintf (asm_out_file, "%s", SDB_DELIM); \
200 #ifndef PUT_SDB_START_DIM
201 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
204 #ifndef PUT_SDB_NEXT_DIM
205 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
208 #ifndef PUT_SDB_LAST_DIM
209 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
213 #define PUT_SDB_TAG(a) \
214 do { fprintf (asm_out_file, "\t.tag\t"); \
215 assemble_name (asm_out_file, a); \
216 fprintf (asm_out_file, SDB_DELIM); } while (0)
219 #ifndef PUT_SDB_BLOCK_START
220 #define PUT_SDB_BLOCK_START(LINE) \
221 fprintf (asm_out_file, \
222 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
223 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
226 #ifndef PUT_SDB_BLOCK_END
227 #define PUT_SDB_BLOCK_END(LINE) \
228 fprintf (asm_out_file, \
229 "\t.def\t.eb%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_FUNCTION_START
234 #define PUT_SDB_FUNCTION_START(LINE) \
235 fprintf (asm_out_file, \
236 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
237 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
240 #ifndef PUT_SDB_FUNCTION_END
241 #define PUT_SDB_FUNCTION_END(LINE) \
242 fprintf (asm_out_file, \
243 "\t.def\t.ef%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 SDB_GENERATE_FAKE
248 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
249 sprintf ((BUFFER), ".%dfake", (NUMBER));
252 /* Return the sdb tag identifier string for TYPE
253 if TYPE has already been defined; otherwise return a null pointer. */
255 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
257 /* Set the sdb tag identifier string for TYPE to NAME. */
259 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
260 TYPE_SYMTAB_POINTER (TYPE) = (char *)(NAME)
262 /* Return the name (a string) of the struct, union or enum tag
263 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
265 #define TAG_NAME(link) \
266 (((link) && TREE_PURPOSE ((link)) \
267 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
268 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
270 /* Ensure we don't output a negative line number. */
271 #define MAKE_LINE_SAFE(line) \
272 if ((int) line <= sdb_begin_function_line) \
273 line = sdb_begin_function_line + 1
275 /* Perform linker optimization of merging header file definitions together
276 for targets with MIPS_DEBUGGING_INFO defined. This won't work without a
277 post 960826 version of GAS. Nothing breaks with earlier versions of GAS,
278 the optimization just won't be done. The native assembler already has the
279 necessary support. */
281 #ifdef MIPS_DEBUGGING_INFO
283 #ifndef PUT_SDB_SRC_FILE
284 #define PUT_SDB_SRC_FILE(FILENAME) \
285 output_file_directive (asm_out_file, (FILENAME))
288 /* ECOFF linkers have an optimization that does the same kind of thing as
289 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
290 executable. To achieve this, GCC must output a .file for each file
293 /* This is a stack of input files. */
297 struct sdb_file
*next
;
301 /* This is the top of the stack. */
303 static struct sdb_file
*current_file
;
305 #endif /* MIPS_DEBUGGING_INFO */
307 /* The debug hooks structure. */
308 const struct gcc_debug_hooks sdb_debug_hooks
=
310 sdbout_init
, /* init */
311 sdbout_finish
, /* finish */
312 debug_nothing_int_charstar
, /* define */
313 debug_nothing_int_charstar
, /* undef */
314 sdbout_start_source_file
, /* start_source_file */
315 sdbout_end_source_file
, /* end_source_file */
316 sdbout_begin_block
, /* begin_block */
317 sdbout_end_block
, /* end_block */
318 debug_true_tree
, /* ignore_block */
319 sdbout_source_line
, /* source_line */
320 #ifdef MIPS_DEBUGGING_INFO
321 /* Defer on MIPS systems so that parameter descriptions follow
323 debug_nothing_int_charstar
, /* begin_prologue */
324 sdbout_end_prologue
, /* end_prologue */
326 sdbout_begin_prologue
, /* begin_prologue */
327 debug_nothing_int_charstar
, /* end_prologue */
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 debug_nothing_tree
, /* deferred_inline_function */
335 debug_nothing_tree
, /* outlining_inline_function */
336 sdbout_label
, /* label */
337 debug_nothing_int
/* handle_pch */
342 /* return the tag identifier for type
346 tag_of_ru_type (type
,link
)
349 if (TYPE_SYMTAB_ADDRESS (type
))
350 return TYPE_SYMTAB_ADDRESS (type
);
351 if (link
&& TREE_PURPOSE (link
)
352 && IDENTIFIER_POINTER (TREE_PURPOSE (link
)))
353 TYPE_SYMTAB_ADDRESS (type
) = IDENTIFIER_POINTER (TREE_PURPOSE (link
));
355 return (char *) TYPE_SYMTAB_ADDRESS (type
);
359 /* Return a unique string to name an anonymous type. */
366 SDB_GENERATE_FAKE (label
, unnamed_struct_number
);
367 unnamed_struct_number
++;
368 labelstr
= xstrdup (label
);
372 /* Return the number which describes TYPE for SDB.
373 For pointers, etc., this function is recursive.
374 Each record, union or enumeral type must already have had a
375 tag number output. */
377 /* The number is given by d6d5d4d3d2d1bbbb
378 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
379 Thus, char *foo () has bbbb=T_CHAR
382 N_BTMASK= 017 1111 basic type field.
383 N_TSHIFT= 2 derived type shift
384 N_BTSHFT= 4 Basic type shift */
386 /* Produce the number that describes a pointer, function or array type.
387 PREV is the number describing the target, value or element type.
388 DT_type describes how to transform that type. */
389 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
390 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
391 | ((int) DT_type << (int) N_BTSHFT) \
392 | ((PREV) & (int) N_BTMASK))
394 /* Number of elements used in sdb_dims. */
395 static int sdb_n_dims
= 0;
397 /* Table of array dimensions of current type. */
398 static int sdb_dims
[SDB_MAX_DIM
];
400 /* Size of outermost array currently being processed. */
401 static int sdb_type_size
= -1;
407 int val
= plain_type_1 (type
, 0);
409 /* If we have already saved up some array dimensions, print them now. */
414 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
415 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
416 PUT_SDB_LAST_DIM (sdb_dims
[0]);
419 sdb_type_size
= int_size_in_bytes (type
);
420 /* Don't kill sdb if type is not laid out or has variable size. */
421 if (sdb_type_size
< 0)
424 /* If we have computed the size of an array containing this type,
426 if (sdb_type_size
>= 0)
428 PUT_SDB_SIZE (sdb_type_size
);
435 template_name_p (name
)
438 const char *ptr
= IDENTIFIER_POINTER (name
);
439 while (*ptr
&& *ptr
!= '<')
446 sdbout_record_type_name (type
)
449 const char *name
= 0;
452 if (KNOWN_TYPE_TAG (type
))
455 if (TYPE_NAME (type
) != 0)
459 /* Find the IDENTIFIER_NODE for the type name. */
460 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
461 t
= TYPE_NAME (type
);
462 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
464 t
= DECL_NAME (TYPE_NAME (type
));
465 /* The DECL_NAME for templates includes "<>", which breaks
466 most assemblers. Use its assembler name instead, which
467 has been mangled into being safe. */
468 if (t
&& template_name_p (t
))
469 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
472 /* Now get the name as a string, or invent one. */
474 name
= IDENTIFIER_POINTER (t
);
477 no_name
= (name
== 0 || *name
== 0);
479 name
= gen_fake_label ();
481 SET_KNOWN_TYPE_TAG (type
, name
);
482 #ifdef SDB_ALLOW_FORWARD_REFERENCES
484 sdbout_queue_anonymous_type (type
);
488 /* Return the .type value for type TYPE.
490 LEVEL indicates how many levels deep we have recursed into the type.
491 The SDB debug format can only represent 6 derived levels of types.
492 After that, we must output inaccurate debug info. We deliberately
493 stop before the 7th level, so that ADA recursive types will not give an
497 plain_type_1 (type
, level
)
502 type
= void_type_node
;
503 else if (type
== error_mark_node
)
504 type
= integer_type_node
;
506 type
= TYPE_MAIN_VARIANT (type
);
508 switch (TREE_CODE (type
))
515 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
517 /* Carefully distinguish all the standard types of C,
518 without messing up if the language is not C.
519 Note that we check only for the names that contain spaces;
520 other names might occur by coincidence in other languages. */
521 if (TYPE_NAME (type
) != 0
522 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
523 && DECL_NAME (TYPE_NAME (type
)) != 0
524 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
526 const char *const name
527 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
529 if (!strcmp (name
, "char"))
531 if (!strcmp (name
, "unsigned char"))
533 if (!strcmp (name
, "signed char"))
535 if (!strcmp (name
, "int"))
537 if (!strcmp (name
, "unsigned int"))
539 if (!strcmp (name
, "short int"))
541 if (!strcmp (name
, "short unsigned int"))
543 if (!strcmp (name
, "long int"))
545 if (!strcmp (name
, "long unsigned int"))
549 if (size
== INT_TYPE_SIZE
)
550 return (TREE_UNSIGNED (type
) ? T_UINT
: T_INT
);
551 if (size
== CHAR_TYPE_SIZE
)
552 return (TREE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
553 if (size
== SHORT_TYPE_SIZE
)
554 return (TREE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
555 if (size
== LONG_TYPE_SIZE
)
556 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
557 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
558 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
564 int precision
= TYPE_PRECISION (type
);
565 if (precision
== FLOAT_TYPE_SIZE
)
567 if (precision
== DOUBLE_TYPE_SIZE
)
569 #ifdef EXTENDED_SDB_BASIC_TYPES
570 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
573 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
574 return T_DOUBLE
; /* better than nothing */
585 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
586 if (sdb_n_dims
< SDB_MAX_DIM
)
587 sdb_dims
[sdb_n_dims
++]
588 = (TYPE_DOMAIN (type
)
589 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
590 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
591 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
592 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
593 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
594 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
597 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
602 case QUAL_UNION_TYPE
:
606 #ifdef SDB_ALLOW_FORWARD_REFERENCES
607 sdbout_record_type_name (type
);
609 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
610 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
611 #ifdef SDB_ALLOW_FORWARD_REFERENCES
612 || TYPE_MODE (type
) != VOIDmode
617 /* Output the referenced structure tag name
618 only if the .def has already been finished.
619 At least on 386, the Unix assembler
620 cannot handle forward references to tags. */
621 /* But the 88100, it requires them, sigh... */
622 /* And the MIPS requires unknown refs as well... */
623 tag
= KNOWN_TYPE_TAG (type
);
625 /* These 3 lines used to follow the close brace.
626 However, a size of 0 without a tag implies a tag of 0,
627 so if we don't know a tag, we can't mention the size. */
628 sdb_type_size
= int_size_in_bytes (type
);
629 if (sdb_type_size
< 0)
632 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
633 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
634 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
644 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
645 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
654 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
655 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
662 /* Output the symbols defined in block number DO_BLOCK.
664 This function works by walking the tree structure of blocks,
665 counting blocks until it finds the desired block. */
667 static int do_block
= 0;
675 /* Ignore blocks never expanded or otherwise marked as real. */
676 if (TREE_USED (block
))
678 /* When we reach the specified block, output its symbols. */
679 if (BLOCK_NUMBER (block
) == do_block
)
680 sdbout_syms (BLOCK_VARS (block
));
682 /* If we are past the specified block, stop the scan. */
683 if (BLOCK_NUMBER (block
) > do_block
)
686 /* Scan the blocks within this block. */
687 sdbout_block (BLOCK_SUBBLOCKS (block
));
690 block
= BLOCK_CHAIN (block
);
694 /* Call sdbout_symbol on each decl in the chain SYMS. */
702 if (TREE_CODE (syms
) != LABEL_DECL
)
703 sdbout_symbol (syms
, 1);
704 syms
= TREE_CHAIN (syms
);
708 /* Output SDB information for a symbol described by DECL.
709 LOCAL is nonzero if the symbol is not file-scope. */
712 sdbout_symbol (decl
, local
)
716 tree type
= TREE_TYPE (decl
);
717 tree context
= NULL_TREE
;
722 sdbout_one_type (type
);
724 #if 0 /* This loses when functions are marked to be ignored,
725 which happens in the C++ front end. */
726 if (DECL_IGNORED_P (decl
))
730 switch (TREE_CODE (decl
))
733 /* Enum values are defined by defining the enum type. */
737 /* Don't mention a nested function under its parent. */
738 context
= decl_function_context (decl
);
739 if (context
== current_function_decl
)
741 /* Check DECL_INITIAL to distinguish declarations from definitions.
742 Don't output debug info here for declarations; they will have
743 a DECL_INITIAL value of 0. */
744 if (! DECL_INITIAL (decl
))
746 if (GET_CODE (DECL_RTL (decl
)) != MEM
747 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
749 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
750 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
751 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
755 /* Done with tagged types. */
756 if (DECL_NAME (decl
) == 0)
758 if (DECL_IGNORED_P (decl
))
761 /* Output typedef name. */
762 if (template_name_p (DECL_NAME (decl
)))
763 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
765 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
766 PUT_SDB_SCL (C_TPDEF
);
770 /* Parm decls go in their own separate chains
771 and are output by sdbout_reg_parms and sdbout_parms. */
775 /* Don't mention a variable that is external.
776 Let the file that defines it describe it. */
777 if (DECL_EXTERNAL (decl
))
780 /* Ignore __FUNCTION__, etc. */
781 if (DECL_IGNORED_P (decl
))
784 /* If there was an error in the declaration, don't dump core
785 if there is no RTL associated with the variable doesn't
787 if (!DECL_RTL_SET_P (decl
))
791 eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
792 #ifdef LEAF_REG_REMAP
793 if (current_function_uses_only_leaf_regs
)
794 leaf_renumber_regs_insn (DECL_RTL (decl
));
796 value
= DECL_RTL (decl
);
798 /* Don't mention a variable at all
799 if it was completely optimized into nothingness.
801 If DECL was from an inline function, then its rtl
802 is not identically the rtl that was used in this
803 particular compilation. */
804 if (GET_CODE (value
) == REG
)
806 regno
= REGNO (value
);
807 if (regno
>= FIRST_PSEUDO_REGISTER
)
810 else if (GET_CODE (value
) == SUBREG
)
812 while (GET_CODE (value
) == SUBREG
)
813 value
= SUBREG_REG (value
);
814 if (GET_CODE (value
) == REG
)
816 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
819 regno
= REGNO (alter_subreg (&value
));
820 SET_DECL_RTL (decl
, value
);
822 /* Don't output anything if an auto variable
823 gets RTL that is static.
824 GAS version 2.2 can't handle such output. */
825 else if (GET_CODE (value
) == MEM
&& CONSTANT_P (XEXP (value
, 0))
826 && ! TREE_STATIC (decl
))
829 /* Emit any structure, union, or enum type that has not been output.
830 This occurs for tag-less structs (et al) used to declare variables
832 if (TREE_CODE (type
) == ENUMERAL_TYPE
833 || TREE_CODE (type
) == RECORD_TYPE
834 || TREE_CODE (type
) == UNION_TYPE
835 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
837 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
838 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
839 sdbout_one_type (type
);
842 /* Defer SDB information for top-level initialized variables! */
844 && GET_CODE (value
) == MEM
845 && DECL_INITIAL (decl
))
848 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
849 For now, avoid crashing. */
850 if (DECL_NAME (decl
) == NULL_TREE
)
853 /* Record the name for, starting a symtab entry. */
855 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
857 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
859 if (GET_CODE (value
) == MEM
860 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
863 if (TREE_PUBLIC (decl
))
865 PUT_SDB_VAL (XEXP (value
, 0));
870 PUT_SDB_VAL (XEXP (value
, 0));
871 PUT_SDB_SCL (C_STAT
);
877 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
880 else if (GET_CODE (value
) == MEM
881 && (GET_CODE (XEXP (value
, 0)) == MEM
882 || (GET_CODE (XEXP (value
, 0)) == REG
883 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
884 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
885 /* If the value is indirect by memory or by a register
886 that isn't the frame pointer
887 then it means the object is variable-sized and address through
888 that register or stack slot. COFF has no way to represent this
889 so all we can do is output the variable as a pointer. */
892 if (GET_CODE (XEXP (value
, 0)) == REG
)
894 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
899 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
901 We want the value of that CONST_INT. */
902 /* Encore compiler hates a newline in a macro arg, it seems. */
903 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
904 (XEXP (XEXP (value
, 0), 0)));
905 PUT_SDB_SCL (C_AUTO
);
908 /* Effectively do build_pointer_type, but don't cache this type,
909 since it might be temporary whereas the type it points to
910 might have been saved for inlining. */
911 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
912 type
= make_node (POINTER_TYPE
);
913 TREE_TYPE (type
) = TREE_TYPE (decl
);
915 else if (GET_CODE (value
) == MEM
916 && ((GET_CODE (XEXP (value
, 0)) == PLUS
917 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
918 && GET_CODE (XEXP (XEXP (value
, 0), 1)) == CONST_INT
)
919 /* This is for variables which are at offset zero from
920 the frame pointer. This happens on the Alpha.
921 Non-frame pointer registers are excluded above. */
922 || (GET_CODE (XEXP (value
, 0)) == REG
)))
924 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
925 or (MEM (REG...)). We want the value of that CONST_INT
928 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
929 PUT_SDB_SCL (C_AUTO
);
933 /* It is something we don't know how to represent for SDB. */
941 PUT_SDB_TYPE (plain_type (type
));
945 /* Output SDB information for a top-level initialized variable
946 that has been delayed. */
949 sdbout_toplevel_data (decl
)
952 tree type
= TREE_TYPE (decl
);
954 if (DECL_IGNORED_P (decl
))
957 if (! (TREE_CODE (decl
) == VAR_DECL
958 && GET_CODE (DECL_RTL (decl
)) == MEM
959 && DECL_INITIAL (decl
)))
962 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
963 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
964 if (TREE_PUBLIC (decl
))
970 PUT_SDB_SCL (C_STAT
);
972 PUT_SDB_TYPE (plain_type (type
));
976 #ifdef SDB_ALLOW_FORWARD_REFERENCES
978 /* Machinery to record and output anonymous types. */
981 sdbout_queue_anonymous_type (type
)
984 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
988 sdbout_dequeue_anonymous_types ()
992 while (anonymous_types
)
994 types
= nreverse (anonymous_types
);
995 anonymous_types
= NULL_TREE
;
997 for (link
= types
; link
; link
= TREE_CHAIN (link
))
999 tree type
= TREE_VALUE (link
);
1001 if (type
&& ! TREE_ASM_WRITTEN (type
))
1002 sdbout_one_type (type
);
1009 /* Given a chain of ..._TYPE nodes, all of which have names,
1010 output definitions of those names, as typedefs. */
1013 sdbout_types (types
)
1018 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1019 sdbout_one_type (link
);
1021 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1022 sdbout_dequeue_anonymous_types ();
1030 if (type
== error_mark_node
)
1031 type
= integer_type_node
;
1032 PUT_SDB_TYPE (plain_type (type
));
1035 /* Output types of the fields of type TYPE, if they are structs.
1037 Formerly did not chase through pointer types, since that could be circular.
1038 They must come before TYPE, since forward refs are not allowed.
1039 Now james@bigtex.cactus.org says to try them. */
1042 sdbout_field_types (type
)
1047 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1048 /* This condition should match the one for emitting the actual
1050 if (TREE_CODE (tail
) == FIELD_DECL
1053 && host_integerp (DECL_SIZE (tail
), 1)
1054 && host_integerp (bit_position (tail
), 0))
1056 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1057 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1059 sdbout_one_type (TREE_TYPE (tail
));
1063 /* Use this to put out the top level defined record and union types
1064 for later reference. If this is a struct with a name, then put that
1065 name out. Other unnamed structs will have .xxfake labels generated so
1066 that they may be referred to later.
1067 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1068 It may NOT be called recursively. */
1071 sdbout_one_type (type
)
1074 if (current_function_decl
!= NULL_TREE
1075 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1076 ; /* Don't change section amid function. */
1080 switch (TREE_CODE (type
))
1084 case QUAL_UNION_TYPE
:
1086 type
= TYPE_MAIN_VARIANT (type
);
1087 /* Don't output a type twice. */
1088 if (TREE_ASM_WRITTEN (type
))
1089 /* James said test TREE_ASM_BEING_WRITTEN here. */
1092 /* Output nothing if type is not yet defined. */
1093 if (!COMPLETE_TYPE_P (type
))
1096 TREE_ASM_WRITTEN (type
) = 1;
1098 /* This is reputed to cause trouble with the following case,
1099 but perhaps checking TYPE_SIZE above will fix it. */
1101 /* Here is a test case:
1107 typedef struct intermediate {
1111 typedef struct badstr {
1116 TREE_ASM_BEING_WRITTEN (type
) = 1;
1118 /* This change, which ought to make better output,
1119 used to make the COFF assembler unhappy.
1120 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1121 /* Before really doing anything, output types we want to refer to. */
1122 /* Note that in version 1 the following two lines
1123 are not used if forward references are in use. */
1124 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1125 sdbout_field_types (type
);
1127 TREE_ASM_WRITTEN (type
) = 1;
1131 /* Output a structure type. */
1133 int size
= int_size_in_bytes (type
);
1136 int i
, n_baseclasses
= 0;
1138 /* Record the type tag, but not in its permanent place just yet. */
1139 sdbout_record_type_name (type
);
1141 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1143 switch (TREE_CODE (type
))
1146 case QUAL_UNION_TYPE
:
1147 PUT_SDB_SCL (C_UNTAG
);
1148 PUT_SDB_TYPE (T_UNION
);
1153 PUT_SDB_SCL (C_STRTAG
);
1154 PUT_SDB_TYPE (T_STRUCT
);
1159 PUT_SDB_SCL (C_ENTAG
);
1160 PUT_SDB_TYPE (T_ENUM
);
1168 PUT_SDB_SIZE (size
);
1171 /* Print out the base class information with fields
1172 named after the types they hold. */
1173 /* This is only relevant to aggregate types. TYPE_BINFO is used
1174 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1176 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1178 if (TYPE_BINFO (type
)
1179 && TYPE_BINFO_BASETYPES (type
))
1180 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1181 for (i
= 0; i
< n_baseclasses
; i
++)
1183 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)),
1185 tree child_type
= BINFO_TYPE (child
);
1186 tree child_type_name
;
1187 if (TYPE_NAME (child_type
) == 0)
1189 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1190 child_type_name
= TYPE_NAME (child_type
);
1191 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1193 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1194 if (child_type_name
&& template_name_p (child_type_name
))
1196 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1202 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1203 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1204 PUT_SDB_SCL (member_scl
);
1205 sdbout_type (BINFO_TYPE (child
));
1210 /* output the individual fields */
1212 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1214 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1215 if (host_integerp (TREE_VALUE (tem
), 0))
1217 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1218 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1219 PUT_SDB_SCL (C_MOE
);
1220 PUT_SDB_TYPE (T_MOE
);
1224 else /* record or union type */
1225 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1226 /* Output the name, type, position (in bits), size (in bits)
1229 /* Omit here the nameless fields that are used to skip bits.
1230 Also omit fields with variable size or position.
1231 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1232 if (TREE_CODE (tem
) == FIELD_DECL
1235 && host_integerp (DECL_SIZE (tem
), 1)
1236 && host_integerp (bit_position (tem
), 0))
1241 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1243 if (DECL_BIT_FIELD_TYPE (tem
))
1245 PUT_SDB_INT_VAL (int_bit_position (tem
));
1246 PUT_SDB_SCL (C_FIELD
);
1247 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1248 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1252 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1253 PUT_SDB_SCL (member_scl
);
1254 sdbout_type (TREE_TYPE (tem
));
1258 /* output end of a structure,union, or enumeral definition */
1260 PUT_SDB_PLAIN_DEF ("eos");
1261 PUT_SDB_INT_VAL (size
);
1262 PUT_SDB_SCL (C_EOS
);
1263 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1264 PUT_SDB_SIZE (size
);
1274 /* The following two functions output definitions of function parameters.
1275 Each parameter gets a definition locating it in the parameter list.
1276 Each parameter that is a register variable gets a second definition
1277 locating it in the register.
1279 Printing or argument lists in gdb uses the definitions that
1280 locate in the parameter list. But reference to the variable in
1281 expressions uses preferentially the definition as a register. */
1283 /* Output definitions, referring to storage in the parmlist,
1284 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1287 sdbout_parms (parms
)
1290 for (; parms
; parms
= TREE_CHAIN (parms
))
1291 if (DECL_NAME (parms
))
1293 int current_sym_value
= 0;
1294 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1296 if (name
== 0 || *name
== 0)
1297 name
= gen_fake_label ();
1299 /* Perform any necessary register eliminations on the parameter's rtl,
1300 so that the debugging output will be accurate. */
1301 DECL_INCOMING_RTL (parms
)
1302 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1303 SET_DECL_RTL (parms
,
1304 eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
1306 if (PARM_PASSED_IN_MEMORY (parms
))
1308 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1311 /* ??? Here we assume that the parm address is indexed
1312 off the frame pointer or arg pointer.
1313 If that is not true, we produce meaningless results,
1314 but do not crash. */
1315 if (GET_CODE (addr
) == PLUS
1316 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1317 current_sym_value
= INTVAL (XEXP (addr
, 1));
1319 current_sym_value
= 0;
1321 if (GET_CODE (DECL_RTL (parms
)) == REG
1322 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1323 type
= DECL_ARG_TYPE (parms
);
1326 int original_sym_value
= current_sym_value
;
1328 /* This is the case where the parm is passed as an int or
1329 double and it is converted to a char, short or float
1330 and stored back in the parmlist. In this case, describe
1331 the parm with the variable's declared type, and adjust
1332 the address if the least significant bytes (which we are
1333 using) are not the first ones. */
1334 if (BYTES_BIG_ENDIAN
1335 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1336 current_sym_value
+=
1337 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1338 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1340 if (GET_CODE (DECL_RTL (parms
)) == MEM
1341 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1342 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1344 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1345 == current_sym_value
))
1346 type
= TREE_TYPE (parms
);
1349 current_sym_value
= original_sym_value
;
1350 type
= DECL_ARG_TYPE (parms
);
1355 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1356 PUT_SDB_SCL (C_ARG
);
1357 PUT_SDB_TYPE (plain_type (type
));
1360 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
1363 /* Parm passed in registers and lives in registers or nowhere. */
1365 /* If parm lives in a register, use that register;
1366 pretend the parm was passed there. It would be more consistent
1367 to describe the register where the parm was passed,
1368 but in practice that register usually holds something else. */
1369 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1370 best_rtl
= DECL_RTL (parms
);
1371 /* If the parm lives nowhere,
1372 use the register where it was passed. */
1374 best_rtl
= DECL_INCOMING_RTL (parms
);
1377 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1378 PUT_SDB_SCL (C_REGPARM
);
1379 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1382 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1383 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1385 /* Parm was passed in registers but lives on the stack. */
1387 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1388 in which case we want the value of that CONST_INT,
1389 or (MEM (REG ...)) or (MEM (MEM ...)),
1390 in which case we use a value of zero. */
1391 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
1392 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
1393 current_sym_value
= 0;
1395 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1397 /* Again, this assumes the offset is based on the arg pointer. */
1399 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1400 XEXP (DECL_RTL (parms
), 0)));
1401 PUT_SDB_SCL (C_ARG
);
1402 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1408 /* Output definitions for the places where parms live during the function,
1409 when different from where they were passed, when the parms were passed
1412 It is not useful to do this for parms passed in registers
1413 that live during the function in different registers, because it is
1414 impossible to look in the passed register for the passed value,
1415 so we use the within-the-function register to begin with.
1417 PARMS is a chain of PARM_DECL nodes. */
1420 sdbout_reg_parms (parms
)
1423 for (; parms
; parms
= TREE_CHAIN (parms
))
1424 if (DECL_NAME (parms
))
1426 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1428 /* Report parms that live in registers during the function
1429 but were passed in memory. */
1430 if (GET_CODE (DECL_RTL (parms
)) == REG
1431 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1432 && PARM_PASSED_IN_MEMORY (parms
))
1434 if (name
== 0 || *name
== 0)
1435 name
= gen_fake_label ();
1437 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1438 PUT_SDB_SCL (C_REG
);
1439 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1442 /* Report parms that live in memory but not where they were passed. */
1443 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1444 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1445 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1446 && PARM_PASSED_IN_MEMORY (parms
)
1447 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1449 #if 0 /* ??? It is not clear yet what should replace this. */
1450 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1451 /* A parm declared char is really passed as an int,
1452 so it occupies the least significant bytes.
1453 On a big-endian machine those are not the low-numbered ones. */
1454 if (BYTES_BIG_ENDIAN
1456 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1457 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1458 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1459 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1462 if (name
== 0 || *name
== 0)
1463 name
= gen_fake_label ();
1465 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1466 (XEXP (DECL_RTL (parms
), 0)));
1467 PUT_SDB_SCL (C_AUTO
);
1468 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1475 /* Output debug information for a global DECL. Called from toplev.c
1476 after compilation proper has finished. */
1479 sdbout_global_decl (decl
)
1482 if (TREE_CODE (decl
) == VAR_DECL
1483 && !DECL_EXTERNAL (decl
)
1484 && DECL_RTL_SET_P (decl
))
1486 /* The COFF linker can move initialized global vars to the end.
1487 And that can screw up the symbol ordering. Defer those for
1488 sdbout_finish (). */
1489 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1490 sdbout_symbol (decl
, 0);
1492 /* Output COFF information for non-global file-scope initialized
1494 if (DECL_INITIAL (decl
) && GET_CODE (DECL_RTL (decl
)) == MEM
)
1495 sdbout_toplevel_data (decl
);
1499 /* Output initialized global vars at the end, in the order of
1500 definition. See comment in sdbout_global_decl. */
1503 sdbout_finish (main_filename
)
1504 const char *main_filename ATTRIBUTE_UNUSED
;
1506 tree decl
= (*lang_hooks
.decls
.getdecls
) ();
1507 unsigned int len
= list_length (decl
);
1508 tree
*vec
= (tree
*) xmalloc (sizeof (tree
) * len
);
1511 /* Process the decls in reverse order--earliest first. Put them
1512 into VEC from back to front, then take out from front. */
1514 for (i
= 0; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
1515 vec
[len
- i
- 1] = decl
;
1517 for (i
= 0; i
< len
; i
++)
1520 if (TREE_CODE (decl
) == VAR_DECL
1521 && ! DECL_EXTERNAL (decl
)
1522 && DECL_INITIAL (decl
)
1523 && TREE_PUBLIC (decl
)
1524 && DECL_RTL_SET_P (decl
))
1525 sdbout_symbol (decl
, 0);
1531 /* Describe the beginning of an internal block within a function.
1532 Also output descriptions of variables defined in this block.
1534 N is the number of the block, by order of beginning, counting from 1,
1535 and not counting the outermost (function top-level) block.
1536 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1537 if the count starts at 0 for the outermost one. */
1540 sdbout_begin_block (line
, n
)
1544 tree decl
= current_function_decl
;
1545 MAKE_LINE_SAFE (line
);
1547 /* The SCO compiler does not emit a separate block for the function level
1548 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1549 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1550 #ifndef MIPS_DEBUGGING_INFO
1553 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1557 /* Include the outermost BLOCK's variables in block 1. */
1558 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1559 sdbout_block (DECL_INITIAL (decl
));
1561 /* If -g1, suppress all the internal symbols of functions
1562 except for arguments. */
1563 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1566 sdbout_block (DECL_INITIAL (decl
));
1569 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1570 sdbout_dequeue_anonymous_types ();
1574 /* Describe the end line-number of an internal block within a function. */
1577 sdbout_end_block (line
, n
)
1579 unsigned int n ATTRIBUTE_UNUSED
;
1581 MAKE_LINE_SAFE (line
);
1583 /* The SCO compiler does not emit a separate block for the function level
1584 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1585 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1586 #ifndef MIPS_DEBUGGING_INFO
1589 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1593 sdbout_source_line (line
, filename
)
1595 const char *filename ATTRIBUTE_UNUSED
;
1597 /* COFF relative line numbers must be positive. */
1598 if ((int) line
> sdb_begin_function_line
)
1600 #ifdef ASM_OUTPUT_SOURCE_LINE
1601 ASM_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1603 fprintf (asm_out_file
, "\t.ln\t%d\n",
1604 ((sdb_begin_function_line
> -1)
1605 ? line
- sdb_begin_function_line
: 1));
1610 /* Output sdb info for the current function name.
1611 Called from assemble_start_function. */
1614 sdbout_begin_function (decl
)
1615 tree decl ATTRIBUTE_UNUSED
;
1617 sdbout_symbol (current_function_decl
, 0);
1620 /* Called at beginning of function body (before or after prologue,
1621 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1622 line number, so we can output relative line numbers for the other
1623 lines. Describe beginning of outermost block. Also describe the
1626 #ifndef MIPS_DEBUGGING_INFO
1628 sdbout_begin_prologue (line
, file
)
1630 const char *file ATTRIBUTE_UNUSED
;
1632 sdbout_end_prologue (line
, file
);
1637 sdbout_end_prologue (line
, file
)
1639 const char *file ATTRIBUTE_UNUSED
;
1641 sdb_begin_function_line
= line
- 1;
1642 PUT_SDB_FUNCTION_START (line
);
1643 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1644 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1647 /* Called at end of function (before epilogue).
1648 Describe end of outermost block. */
1651 sdbout_end_function (line
)
1654 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1655 sdbout_dequeue_anonymous_types ();
1658 MAKE_LINE_SAFE (line
);
1659 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1661 /* Indicate we are between functions, for line-number output. */
1662 sdb_begin_function_line
= -1;
1665 /* Output sdb info for the absolute end of a function.
1666 Called after the epilogue is output. */
1669 sdbout_end_epilogue (line
, file
)
1670 unsigned int line ATTRIBUTE_UNUSED
;
1671 const char *file ATTRIBUTE_UNUSED
;
1673 const char *const name ATTRIBUTE_UNUSED
1674 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1676 #ifdef PUT_SDB_EPILOGUE_END
1677 PUT_SDB_EPILOGUE_END (name
);
1679 fprintf (asm_out_file
, "\t.def\t");
1680 assemble_name (asm_out_file
, name
);
1681 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1682 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1686 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1693 PUT_SDB_DEF (LABEL_NAME (insn
));
1695 PUT_SDB_SCL (C_LABEL
);
1696 PUT_SDB_TYPE (T_NULL
);
1700 /* Change to reading from a new source file. */
1703 sdbout_start_source_file (line
, filename
)
1704 unsigned int line ATTRIBUTE_UNUSED
;
1705 const char *filename ATTRIBUTE_UNUSED
;
1707 #ifdef MIPS_DEBUGGING_INFO
1708 struct sdb_file
*n
= (struct sdb_file
*) xmalloc (sizeof *n
);
1710 n
->next
= current_file
;
1713 PUT_SDB_SRC_FILE (filename
);
1717 /* Revert to reading a previous source file. */
1720 sdbout_end_source_file (line
)
1721 unsigned int line ATTRIBUTE_UNUSED
;
1723 #ifdef MIPS_DEBUGGING_INFO
1724 struct sdb_file
*next
;
1726 next
= current_file
->next
;
1727 free (current_file
);
1728 current_file
= next
;
1729 PUT_SDB_SRC_FILE (current_file
->name
);
1733 /* Set up for SDB output at the start of compilation. */
1736 sdbout_init (input_file_name
)
1737 const char *input_file_name ATTRIBUTE_UNUSED
;
1739 #ifdef MIPS_DEBUGGING_INFO
1740 current_file
= (struct sdb_file
*) xmalloc (sizeof *current_file
);
1741 current_file
->next
= NULL
;
1742 current_file
->name
= input_file_name
;
1745 #ifdef RMS_QUICK_HACK_1
1747 for (t
= (*lang_hooks
.decls
.getdecls
) (); t
; t
= TREE_CHAIN (t
))
1748 if (DECL_NAME (t
) && IDENTIFIER_POINTER (DECL_NAME (t
)) != 0
1749 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t
)), "__vtbl_ptr_type"))
1750 sdbout_symbol (t
, 0);
1754 #else /* SDB_DEBUGGING_INFO */
1756 /* This should never be used, but its address is needed for comparisons. */
1757 const struct gcc_debug_hooks sdb_debug_hooks
;
1759 #endif /* SDB_DEBUGGING_INFO */
1761 #include "gt-sdbout.h"