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) = (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 */
341 /* return the tag identifier for type
345 tag_of_ru_type (type
,link
)
348 if (TYPE_SYMTAB_ADDRESS (type
))
349 return TYPE_SYMTAB_ADDRESS (type
);
350 if (link
&& TREE_PURPOSE (link
)
351 && IDENTIFIER_POINTER (TREE_PURPOSE (link
)))
352 TYPE_SYMTAB_ADDRESS (type
) = IDENTIFIER_POINTER (TREE_PURPOSE (link
));
354 return (char *) TYPE_SYMTAB_ADDRESS (type
);
358 /* Return a unique string to name an anonymous type. */
365 SDB_GENERATE_FAKE (label
, unnamed_struct_number
);
366 unnamed_struct_number
++;
367 labelstr
= xstrdup (label
);
371 /* Return the number which describes TYPE for SDB.
372 For pointers, etc., this function is recursive.
373 Each record, union or enumeral type must already have had a
374 tag number output. */
376 /* The number is given by d6d5d4d3d2d1bbbb
377 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
378 Thus, char *foo () has bbbb=T_CHAR
381 N_BTMASK= 017 1111 basic type field.
382 N_TSHIFT= 2 derived type shift
383 N_BTSHFT= 4 Basic type shift */
385 /* Produce the number that describes a pointer, function or array type.
386 PREV is the number describing the target, value or element type.
387 DT_type describes how to transform that type. */
388 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
389 ((((PREV) & ~(int) N_BTMASK) << (int) N_TSHIFT) \
390 | ((int) DT_type << (int) N_BTSHFT) \
391 | ((PREV) & (int) N_BTMASK))
393 /* Number of elements used in sdb_dims. */
394 static int sdb_n_dims
= 0;
396 /* Table of array dimensions of current type. */
397 static int sdb_dims
[SDB_MAX_DIM
];
399 /* Size of outermost array currently being processed. */
400 static int sdb_type_size
= -1;
406 int val
= plain_type_1 (type
, 0);
408 /* If we have already saved up some array dimensions, print them now. */
413 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
414 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
415 PUT_SDB_LAST_DIM (sdb_dims
[0]);
418 sdb_type_size
= int_size_in_bytes (type
);
419 /* Don't kill sdb if type is not laid out or has variable size. */
420 if (sdb_type_size
< 0)
423 /* If we have computed the size of an array containing this type,
425 if (sdb_type_size
>= 0)
427 PUT_SDB_SIZE (sdb_type_size
);
434 template_name_p (name
)
437 const char *ptr
= IDENTIFIER_POINTER (name
);
438 while (*ptr
&& *ptr
!= '<')
445 sdbout_record_type_name (type
)
448 const char *name
= 0;
451 if (KNOWN_TYPE_TAG (type
))
454 if (TYPE_NAME (type
) != 0)
458 /* Find the IDENTIFIER_NODE for the type name. */
459 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
460 t
= TYPE_NAME (type
);
461 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
463 t
= DECL_NAME (TYPE_NAME (type
));
464 /* The DECL_NAME for templates includes "<>", which breaks
465 most assemblers. Use its assembler name instead, which
466 has been mangled into being safe. */
467 if (t
&& template_name_p (t
))
468 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
471 /* Now get the name as a string, or invent one. */
473 name
= IDENTIFIER_POINTER (t
);
476 no_name
= (name
== 0 || *name
== 0);
478 name
= gen_fake_label ();
480 SET_KNOWN_TYPE_TAG (type
, name
);
481 #ifdef SDB_ALLOW_FORWARD_REFERENCES
483 sdbout_queue_anonymous_type (type
);
487 /* Return the .type value for type TYPE.
489 LEVEL indicates how many levels deep we have recursed into the type.
490 The SDB debug format can only represent 6 derived levels of types.
491 After that, we must output inaccurate debug info. We deliberately
492 stop before the 7th level, so that ADA recursive types will not give an
496 plain_type_1 (type
, level
)
501 type
= void_type_node
;
502 else if (type
== error_mark_node
)
503 type
= integer_type_node
;
505 type
= TYPE_MAIN_VARIANT (type
);
507 switch (TREE_CODE (type
))
514 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
516 /* Carefully distinguish all the standard types of C,
517 without messing up if the language is not C.
518 Note that we check only for the names that contain spaces;
519 other names might occur by coincidence in other languages. */
520 if (TYPE_NAME (type
) != 0
521 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
522 && DECL_NAME (TYPE_NAME (type
)) != 0
523 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
525 const char *const name
526 = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
528 if (!strcmp (name
, "char"))
530 if (!strcmp (name
, "unsigned char"))
532 if (!strcmp (name
, "signed char"))
534 if (!strcmp (name
, "int"))
536 if (!strcmp (name
, "unsigned int"))
538 if (!strcmp (name
, "short int"))
540 if (!strcmp (name
, "short unsigned int"))
542 if (!strcmp (name
, "long int"))
544 if (!strcmp (name
, "long unsigned int"))
548 if (size
== INT_TYPE_SIZE
)
549 return (TREE_UNSIGNED (type
) ? T_UINT
: T_INT
);
550 if (size
== CHAR_TYPE_SIZE
)
551 return (TREE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
552 if (size
== SHORT_TYPE_SIZE
)
553 return (TREE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
554 if (size
== LONG_TYPE_SIZE
)
555 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
556 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
557 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
563 int precision
= TYPE_PRECISION (type
);
564 if (precision
== FLOAT_TYPE_SIZE
)
566 if (precision
== DOUBLE_TYPE_SIZE
)
568 #ifdef EXTENDED_SDB_BASIC_TYPES
569 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
572 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
573 return T_DOUBLE
; /* better than nothing */
584 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
585 if (sdb_n_dims
< SDB_MAX_DIM
)
586 sdb_dims
[sdb_n_dims
++]
587 = (TYPE_DOMAIN (type
)
588 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
589 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
590 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
591 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
592 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
593 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
596 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
601 case QUAL_UNION_TYPE
:
605 #ifdef SDB_ALLOW_FORWARD_REFERENCES
606 sdbout_record_type_name (type
);
608 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
609 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
610 #ifdef SDB_ALLOW_FORWARD_REFERENCES
611 || TYPE_MODE (type
) != VOIDmode
616 /* Output the referenced structure tag name
617 only if the .def has already been finished.
618 At least on 386, the Unix assembler
619 cannot handle forward references to tags. */
620 /* But the 88100, it requires them, sigh... */
621 /* And the MIPS requires unknown refs as well... */
622 tag
= KNOWN_TYPE_TAG (type
);
624 /* These 3 lines used to follow the close brace.
625 However, a size of 0 without a tag implies a tag of 0,
626 so if we don't know a tag, we can't mention the size. */
627 sdb_type_size
= int_size_in_bytes (type
);
628 if (sdb_type_size
< 0)
631 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
632 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
633 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
643 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
644 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
653 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
654 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
661 /* Output the symbols defined in block number DO_BLOCK.
663 This function works by walking the tree structure of blocks,
664 counting blocks until it finds the desired block. */
666 static int do_block
= 0;
674 /* Ignore blocks never expanded or otherwise marked as real. */
675 if (TREE_USED (block
))
677 /* When we reach the specified block, output its symbols. */
678 if (BLOCK_NUMBER (block
) == do_block
)
679 sdbout_syms (BLOCK_VARS (block
));
681 /* If we are past the specified block, stop the scan. */
682 if (BLOCK_NUMBER (block
) > do_block
)
685 /* Scan the blocks within this block. */
686 sdbout_block (BLOCK_SUBBLOCKS (block
));
689 block
= BLOCK_CHAIN (block
);
693 /* Call sdbout_symbol on each decl in the chain SYMS. */
701 if (TREE_CODE (syms
) != LABEL_DECL
)
702 sdbout_symbol (syms
, 1);
703 syms
= TREE_CHAIN (syms
);
707 /* Output SDB information for a symbol described by DECL.
708 LOCAL is nonzero if the symbol is not file-scope. */
711 sdbout_symbol (decl
, local
)
715 tree type
= TREE_TYPE (decl
);
716 tree context
= NULL_TREE
;
721 sdbout_one_type (type
);
723 #if 0 /* This loses when functions are marked to be ignored,
724 which happens in the C++ front end. */
725 if (DECL_IGNORED_P (decl
))
729 switch (TREE_CODE (decl
))
732 /* Enum values are defined by defining the enum type. */
736 /* Don't mention a nested function under its parent. */
737 context
= decl_function_context (decl
);
738 if (context
== current_function_decl
)
740 /* Check DECL_INITIAL to distinguish declarations from definitions.
741 Don't output debug info here for declarations; they will have
742 a DECL_INITIAL value of 0. */
743 if (! DECL_INITIAL (decl
))
745 if (GET_CODE (DECL_RTL (decl
)) != MEM
746 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
748 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
749 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
750 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
754 /* Done with tagged types. */
755 if (DECL_NAME (decl
) == 0)
757 if (DECL_IGNORED_P (decl
))
760 /* Output typedef name. */
761 if (template_name_p (DECL_NAME (decl
)))
762 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
764 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
765 PUT_SDB_SCL (C_TPDEF
);
769 /* Parm decls go in their own separate chains
770 and are output by sdbout_reg_parms and sdbout_parms. */
774 /* Don't mention a variable that is external.
775 Let the file that defines it describe it. */
776 if (DECL_EXTERNAL (decl
))
779 /* Ignore __FUNCTION__, etc. */
780 if (DECL_IGNORED_P (decl
))
783 /* If there was an error in the declaration, don't dump core
784 if there is no RTL associated with the variable doesn't
786 if (!DECL_RTL_SET_P (decl
))
790 eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
791 #ifdef LEAF_REG_REMAP
792 if (current_function_uses_only_leaf_regs
)
793 leaf_renumber_regs_insn (DECL_RTL (decl
));
795 value
= DECL_RTL (decl
);
797 /* Don't mention a variable at all
798 if it was completely optimized into nothingness.
800 If DECL was from an inline function, then its rtl
801 is not identically the rtl that was used in this
802 particular compilation. */
803 if (GET_CODE (value
) == REG
)
805 regno
= REGNO (value
);
806 if (regno
>= FIRST_PSEUDO_REGISTER
)
809 else if (GET_CODE (value
) == SUBREG
)
811 while (GET_CODE (value
) == SUBREG
)
812 value
= SUBREG_REG (value
);
813 if (GET_CODE (value
) == REG
)
815 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
818 regno
= REGNO (alter_subreg (&value
));
819 SET_DECL_RTL (decl
, value
);
821 /* Don't output anything if an auto variable
822 gets RTL that is static.
823 GAS version 2.2 can't handle such output. */
824 else if (GET_CODE (value
) == MEM
&& CONSTANT_P (XEXP (value
, 0))
825 && ! TREE_STATIC (decl
))
828 /* Emit any structure, union, or enum type that has not been output.
829 This occurs for tag-less structs (et al) used to declare variables
831 if (TREE_CODE (type
) == ENUMERAL_TYPE
832 || TREE_CODE (type
) == RECORD_TYPE
833 || TREE_CODE (type
) == UNION_TYPE
834 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
836 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
837 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
838 sdbout_one_type (type
);
841 /* Defer SDB information for top-level initialized variables! */
843 && GET_CODE (value
) == MEM
844 && DECL_INITIAL (decl
))
847 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
848 For now, avoid crashing. */
849 if (DECL_NAME (decl
) == NULL_TREE
)
852 /* Record the name for, starting a symtab entry. */
854 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
856 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
858 if (GET_CODE (value
) == MEM
859 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
862 if (TREE_PUBLIC (decl
))
864 PUT_SDB_VAL (XEXP (value
, 0));
869 PUT_SDB_VAL (XEXP (value
, 0));
870 PUT_SDB_SCL (C_STAT
);
876 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
879 else if (GET_CODE (value
) == MEM
880 && (GET_CODE (XEXP (value
, 0)) == MEM
881 || (GET_CODE (XEXP (value
, 0)) == REG
882 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
883 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
884 /* If the value is indirect by memory or by a register
885 that isn't the frame pointer
886 then it means the object is variable-sized and address through
887 that register or stack slot. COFF has no way to represent this
888 so all we can do is output the variable as a pointer. */
891 if (GET_CODE (XEXP (value
, 0)) == REG
)
893 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
898 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
900 We want the value of that CONST_INT. */
901 /* Encore compiler hates a newline in a macro arg, it seems. */
902 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
903 (XEXP (XEXP (value
, 0), 0)));
904 PUT_SDB_SCL (C_AUTO
);
907 /* Effectively do build_pointer_type, but don't cache this type,
908 since it might be temporary whereas the type it points to
909 might have been saved for inlining. */
910 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
911 type
= make_node (POINTER_TYPE
);
912 TREE_TYPE (type
) = TREE_TYPE (decl
);
914 else if (GET_CODE (value
) == MEM
915 && ((GET_CODE (XEXP (value
, 0)) == PLUS
916 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
917 && GET_CODE (XEXP (XEXP (value
, 0), 1)) == CONST_INT
)
918 /* This is for variables which are at offset zero from
919 the frame pointer. This happens on the Alpha.
920 Non-frame pointer registers are excluded above. */
921 || (GET_CODE (XEXP (value
, 0)) == REG
)))
923 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
924 or (MEM (REG...)). We want the value of that CONST_INT
927 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
928 PUT_SDB_SCL (C_AUTO
);
932 /* It is something we don't know how to represent for SDB. */
940 PUT_SDB_TYPE (plain_type (type
));
944 /* Output SDB information for a top-level initialized variable
945 that has been delayed. */
948 sdbout_toplevel_data (decl
)
951 tree type
= TREE_TYPE (decl
);
953 if (DECL_IGNORED_P (decl
))
956 if (! (TREE_CODE (decl
) == VAR_DECL
957 && GET_CODE (DECL_RTL (decl
)) == MEM
958 && DECL_INITIAL (decl
)))
961 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
962 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
963 if (TREE_PUBLIC (decl
))
969 PUT_SDB_SCL (C_STAT
);
971 PUT_SDB_TYPE (plain_type (type
));
975 #ifdef SDB_ALLOW_FORWARD_REFERENCES
977 /* Machinery to record and output anonymous types. */
980 sdbout_queue_anonymous_type (type
)
983 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
987 sdbout_dequeue_anonymous_types ()
991 while (anonymous_types
)
993 types
= nreverse (anonymous_types
);
994 anonymous_types
= NULL_TREE
;
996 for (link
= types
; link
; link
= TREE_CHAIN (link
))
998 tree type
= TREE_VALUE (link
);
1000 if (type
&& ! TREE_ASM_WRITTEN (type
))
1001 sdbout_one_type (type
);
1008 /* Given a chain of ..._TYPE nodes, all of which have names,
1009 output definitions of those names, as typedefs. */
1012 sdbout_types (types
)
1017 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1018 sdbout_one_type (link
);
1020 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1021 sdbout_dequeue_anonymous_types ();
1029 if (type
== error_mark_node
)
1030 type
= integer_type_node
;
1031 PUT_SDB_TYPE (plain_type (type
));
1034 /* Output types of the fields of type TYPE, if they are structs.
1036 Formerly did not chase through pointer types, since that could be circular.
1037 They must come before TYPE, since forward refs are not allowed.
1038 Now james@bigtex.cactus.org says to try them. */
1041 sdbout_field_types (type
)
1046 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1047 /* This condition should match the one for emitting the actual
1049 if (TREE_CODE (tail
) == FIELD_DECL
1052 && host_integerp (DECL_SIZE (tail
), 1)
1053 && host_integerp (bit_position (tail
), 0))
1055 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1056 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1058 sdbout_one_type (TREE_TYPE (tail
));
1062 /* Use this to put out the top level defined record and union types
1063 for later reference. If this is a struct with a name, then put that
1064 name out. Other unnamed structs will have .xxfake labels generated so
1065 that they may be referred to later.
1066 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1067 It may NOT be called recursively. */
1070 sdbout_one_type (type
)
1073 if (current_function_decl
!= NULL_TREE
1074 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1075 ; /* Don't change section amid function. */
1079 switch (TREE_CODE (type
))
1083 case QUAL_UNION_TYPE
:
1085 type
= TYPE_MAIN_VARIANT (type
);
1086 /* Don't output a type twice. */
1087 if (TREE_ASM_WRITTEN (type
))
1088 /* James said test TREE_ASM_BEING_WRITTEN here. */
1091 /* Output nothing if type is not yet defined. */
1092 if (!COMPLETE_TYPE_P (type
))
1095 TREE_ASM_WRITTEN (type
) = 1;
1097 /* This is reputed to cause trouble with the following case,
1098 but perhaps checking TYPE_SIZE above will fix it. */
1100 /* Here is a test case:
1106 typedef struct intermediate {
1110 typedef struct badstr {
1115 TREE_ASM_BEING_WRITTEN (type
) = 1;
1117 /* This change, which ought to make better output,
1118 used to make the COFF assembler unhappy.
1119 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1120 /* Before really doing anything, output types we want to refer to. */
1121 /* Note that in version 1 the following two lines
1122 are not used if forward references are in use. */
1123 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1124 sdbout_field_types (type
);
1126 TREE_ASM_WRITTEN (type
) = 1;
1130 /* Output a structure type. */
1132 int size
= int_size_in_bytes (type
);
1135 int i
, n_baseclasses
= 0;
1137 /* Record the type tag, but not in its permanent place just yet. */
1138 sdbout_record_type_name (type
);
1140 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1142 switch (TREE_CODE (type
))
1145 case QUAL_UNION_TYPE
:
1146 PUT_SDB_SCL (C_UNTAG
);
1147 PUT_SDB_TYPE (T_UNION
);
1152 PUT_SDB_SCL (C_STRTAG
);
1153 PUT_SDB_TYPE (T_STRUCT
);
1158 PUT_SDB_SCL (C_ENTAG
);
1159 PUT_SDB_TYPE (T_ENUM
);
1167 PUT_SDB_SIZE (size
);
1170 /* Print out the base class information with fields
1171 named after the types they hold. */
1172 /* This is only relevant to aggregate types. TYPE_BINFO is used
1173 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1175 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1177 if (TYPE_BINFO (type
)
1178 && TYPE_BINFO_BASETYPES (type
))
1179 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1180 for (i
= 0; i
< n_baseclasses
; i
++)
1182 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)),
1184 tree child_type
= BINFO_TYPE (child
);
1185 tree child_type_name
;
1186 if (TYPE_NAME (child_type
) == 0)
1188 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1189 child_type_name
= TYPE_NAME (child_type
);
1190 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1192 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1193 if (child_type_name
&& template_name_p (child_type_name
))
1195 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1201 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1202 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1203 PUT_SDB_SCL (member_scl
);
1204 sdbout_type (BINFO_TYPE (child
));
1209 /* output the individual fields */
1211 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1213 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1214 if (host_integerp (TREE_VALUE (tem
), 0))
1216 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1217 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1218 PUT_SDB_SCL (C_MOE
);
1219 PUT_SDB_TYPE (T_MOE
);
1223 else /* record or union type */
1224 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1225 /* Output the name, type, position (in bits), size (in bits)
1228 /* Omit here the nameless fields that are used to skip bits.
1229 Also omit fields with variable size or position.
1230 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1231 if (TREE_CODE (tem
) == FIELD_DECL
1234 && host_integerp (DECL_SIZE (tem
), 1)
1235 && host_integerp (bit_position (tem
), 0))
1240 name
= IDENTIFIER_POINTER (DECL_NAME (tem
));
1242 if (DECL_BIT_FIELD_TYPE (tem
))
1244 PUT_SDB_INT_VAL (int_bit_position (tem
));
1245 PUT_SDB_SCL (C_FIELD
);
1246 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1247 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1251 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1252 PUT_SDB_SCL (member_scl
);
1253 sdbout_type (TREE_TYPE (tem
));
1257 /* output end of a structure,union, or enumeral definition */
1259 PUT_SDB_PLAIN_DEF ("eos");
1260 PUT_SDB_INT_VAL (size
);
1261 PUT_SDB_SCL (C_EOS
);
1262 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1263 PUT_SDB_SIZE (size
);
1273 /* The following two functions output definitions of function parameters.
1274 Each parameter gets a definition locating it in the parameter list.
1275 Each parameter that is a register variable gets a second definition
1276 locating it in the register.
1278 Printing or argument lists in gdb uses the definitions that
1279 locate in the parameter list. But reference to the variable in
1280 expressions uses preferentially the definition as a register. */
1282 /* Output definitions, referring to storage in the parmlist,
1283 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1286 sdbout_parms (parms
)
1289 for (; parms
; parms
= TREE_CHAIN (parms
))
1290 if (DECL_NAME (parms
))
1292 int current_sym_value
= 0;
1293 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1295 if (name
== 0 || *name
== 0)
1296 name
= gen_fake_label ();
1298 /* Perform any necessary register eliminations on the parameter's rtl,
1299 so that the debugging output will be accurate. */
1300 DECL_INCOMING_RTL (parms
)
1301 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1302 SET_DECL_RTL (parms
,
1303 eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
1305 if (PARM_PASSED_IN_MEMORY (parms
))
1307 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1310 /* ??? Here we assume that the parm address is indexed
1311 off the frame pointer or arg pointer.
1312 If that is not true, we produce meaningless results,
1313 but do not crash. */
1314 if (GET_CODE (addr
) == PLUS
1315 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1316 current_sym_value
= INTVAL (XEXP (addr
, 1));
1318 current_sym_value
= 0;
1320 if (GET_CODE (DECL_RTL (parms
)) == REG
1321 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1322 type
= DECL_ARG_TYPE (parms
);
1325 int original_sym_value
= current_sym_value
;
1327 /* This is the case where the parm is passed as an int or
1328 double and it is converted to a char, short or float
1329 and stored back in the parmlist. In this case, describe
1330 the parm with the variable's declared type, and adjust
1331 the address if the least significant bytes (which we are
1332 using) are not the first ones. */
1333 if (BYTES_BIG_ENDIAN
1334 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1335 current_sym_value
+=
1336 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1337 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1339 if (GET_CODE (DECL_RTL (parms
)) == MEM
1340 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1341 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1343 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1344 == current_sym_value
))
1345 type
= TREE_TYPE (parms
);
1348 current_sym_value
= original_sym_value
;
1349 type
= DECL_ARG_TYPE (parms
);
1354 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1355 PUT_SDB_SCL (C_ARG
);
1356 PUT_SDB_TYPE (plain_type (type
));
1359 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
1362 /* Parm passed in registers and lives in registers or nowhere. */
1364 /* If parm lives in a register, use that register;
1365 pretend the parm was passed there. It would be more consistent
1366 to describe the register where the parm was passed,
1367 but in practice that register usually holds something else. */
1368 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1369 best_rtl
= DECL_RTL (parms
);
1370 /* If the parm lives nowhere,
1371 use the register where it was passed. */
1373 best_rtl
= DECL_INCOMING_RTL (parms
);
1376 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1377 PUT_SDB_SCL (C_REGPARM
);
1378 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1381 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1382 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1384 /* Parm was passed in registers but lives on the stack. */
1386 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1387 in which case we want the value of that CONST_INT,
1388 or (MEM (REG ...)) or (MEM (MEM ...)),
1389 in which case we use a value of zero. */
1390 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
1391 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
1392 current_sym_value
= 0;
1394 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1396 /* Again, this assumes the offset is based on the arg pointer. */
1398 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1399 XEXP (DECL_RTL (parms
), 0)));
1400 PUT_SDB_SCL (C_ARG
);
1401 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1407 /* Output definitions for the places where parms live during the function,
1408 when different from where they were passed, when the parms were passed
1411 It is not useful to do this for parms passed in registers
1412 that live during the function in different registers, because it is
1413 impossible to look in the passed register for the passed value,
1414 so we use the within-the-function register to begin with.
1416 PARMS is a chain of PARM_DECL nodes. */
1419 sdbout_reg_parms (parms
)
1422 for (; parms
; parms
= TREE_CHAIN (parms
))
1423 if (DECL_NAME (parms
))
1425 const char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1427 /* Report parms that live in registers during the function
1428 but were passed in memory. */
1429 if (GET_CODE (DECL_RTL (parms
)) == REG
1430 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1431 && PARM_PASSED_IN_MEMORY (parms
))
1433 if (name
== 0 || *name
== 0)
1434 name
= gen_fake_label ();
1436 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1437 PUT_SDB_SCL (C_REG
);
1438 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1441 /* Report parms that live in memory but not where they were passed. */
1442 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1443 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1444 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1445 && PARM_PASSED_IN_MEMORY (parms
)
1446 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1448 #if 0 /* ??? It is not clear yet what should replace this. */
1449 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1450 /* A parm declared char is really passed as an int,
1451 so it occupies the least significant bytes.
1452 On a big-endian machine those are not the low-numbered ones. */
1453 if (BYTES_BIG_ENDIAN
1455 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1456 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1457 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1458 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1461 if (name
== 0 || *name
== 0)
1462 name
= gen_fake_label ();
1464 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1465 (XEXP (DECL_RTL (parms
), 0)));
1466 PUT_SDB_SCL (C_AUTO
);
1467 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1474 /* Output debug information for a global DECL. Called from toplev.c
1475 after compilation proper has finished. */
1478 sdbout_global_decl (decl
)
1481 if (TREE_CODE (decl
) == VAR_DECL
1482 && !DECL_EXTERNAL (decl
)
1483 && DECL_RTL_SET_P (decl
))
1485 /* The COFF linker can move initialized global vars to the end.
1486 And that can screw up the symbol ordering. Defer those for
1487 sdbout_finish (). */
1488 if (!DECL_INITIAL (decl
) || !TREE_PUBLIC (decl
))
1489 sdbout_symbol (decl
, 0);
1491 /* Output COFF information for non-global file-scope initialized
1493 if (DECL_INITIAL (decl
) && GET_CODE (DECL_RTL (decl
)) == MEM
)
1494 sdbout_toplevel_data (decl
);
1498 /* Output initialized global vars at the end, in the order of
1499 definition. See comment in sdbout_global_decl. */
1502 sdbout_finish (main_filename
)
1503 const char *main_filename ATTRIBUTE_UNUSED
;
1505 tree decl
= (*lang_hooks
.decls
.getdecls
) ();
1506 unsigned int len
= list_length (decl
);
1507 tree
*vec
= (tree
*) xmalloc (sizeof (tree
) * len
);
1510 /* Process the decls in reverse order--earliest first. Put them
1511 into VEC from back to front, then take out from front. */
1513 for (i
= 0; i
< len
; i
++, decl
= TREE_CHAIN (decl
))
1514 vec
[len
- i
- 1] = decl
;
1516 for (i
= 0; i
< len
; i
++)
1519 if (TREE_CODE (decl
) == VAR_DECL
1520 && ! DECL_EXTERNAL (decl
)
1521 && DECL_INITIAL (decl
)
1522 && TREE_PUBLIC (decl
)
1523 && DECL_RTL_SET_P (decl
))
1524 sdbout_symbol (decl
, 0);
1530 /* Describe the beginning of an internal block within a function.
1531 Also output descriptions of variables defined in this block.
1533 N is the number of the block, by order of beginning, counting from 1,
1534 and not counting the outermost (function top-level) block.
1535 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1536 if the count starts at 0 for the outermost one. */
1539 sdbout_begin_block (line
, n
)
1543 tree decl
= current_function_decl
;
1544 MAKE_LINE_SAFE (line
);
1546 /* The SCO compiler does not emit a separate block for the function level
1547 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1548 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1549 #ifndef MIPS_DEBUGGING_INFO
1552 PUT_SDB_BLOCK_START (line
- sdb_begin_function_line
);
1556 /* Include the outermost BLOCK's variables in block 1. */
1557 do_block
= BLOCK_NUMBER (DECL_INITIAL (decl
));
1558 sdbout_block (DECL_INITIAL (decl
));
1560 /* If -g1, suppress all the internal symbols of functions
1561 except for arguments. */
1562 if (debug_info_level
!= DINFO_LEVEL_TERSE
)
1565 sdbout_block (DECL_INITIAL (decl
));
1568 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1569 sdbout_dequeue_anonymous_types ();
1573 /* Describe the end line-number of an internal block within a function. */
1576 sdbout_end_block (line
, n
)
1578 unsigned int n ATTRIBUTE_UNUSED
;
1580 MAKE_LINE_SAFE (line
);
1582 /* The SCO compiler does not emit a separate block for the function level
1583 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1584 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1585 #ifndef MIPS_DEBUGGING_INFO
1588 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1592 sdbout_source_line (line
, filename
)
1594 const char *filename ATTRIBUTE_UNUSED
;
1596 /* COFF relative line numbers must be positive. */
1597 if ((int) line
> sdb_begin_function_line
)
1599 #ifdef ASM_OUTPUT_SOURCE_LINE
1600 ASM_OUTPUT_SOURCE_LINE (asm_out_file
, line
);
1602 fprintf (asm_out_file
, "\t.ln\t%d\n",
1603 ((sdb_begin_function_line
> -1)
1604 ? line
- sdb_begin_function_line
: 1));
1609 /* Output sdb info for the current function name.
1610 Called from assemble_start_function. */
1613 sdbout_begin_function (decl
)
1614 tree decl ATTRIBUTE_UNUSED
;
1616 sdbout_symbol (current_function_decl
, 0);
1619 /* Called at beginning of function body (before or after prologue,
1620 depending on MIPS_DEBUGGING_INFO). Record the function's starting
1621 line number, so we can output relative line numbers for the other
1622 lines. Describe beginning of outermost block. Also describe the
1625 #ifndef MIPS_DEBUGGING_INFO
1627 sdbout_begin_prologue (line
, file
)
1629 const char *file ATTRIBUTE_UNUSED
;
1631 sdbout_end_prologue (line
, file
);
1636 sdbout_end_prologue (line
, file
)
1638 const char *file ATTRIBUTE_UNUSED
;
1640 sdb_begin_function_line
= line
- 1;
1641 PUT_SDB_FUNCTION_START (line
);
1642 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1643 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1646 /* Called at end of function (before epilogue).
1647 Describe end of outermost block. */
1650 sdbout_end_function (line
)
1653 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1654 sdbout_dequeue_anonymous_types ();
1657 MAKE_LINE_SAFE (line
);
1658 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1660 /* Indicate we are between functions, for line-number output. */
1661 sdb_begin_function_line
= -1;
1664 /* Output sdb info for the absolute end of a function.
1665 Called after the epilogue is output. */
1668 sdbout_end_epilogue (line
, file
)
1669 unsigned int line ATTRIBUTE_UNUSED
;
1670 const char *file ATTRIBUTE_UNUSED
;
1672 const char *const name ATTRIBUTE_UNUSED
1673 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1675 #ifdef PUT_SDB_EPILOGUE_END
1676 PUT_SDB_EPILOGUE_END (name
);
1678 fprintf (asm_out_file
, "\t.def\t");
1679 assemble_name (asm_out_file
, name
);
1680 fprintf (asm_out_file
, "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n",
1681 SDB_DELIM
, SDB_DELIM
, SDB_DELIM
);
1685 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1692 PUT_SDB_DEF (LABEL_NAME (insn
));
1694 PUT_SDB_SCL (C_LABEL
);
1695 PUT_SDB_TYPE (T_NULL
);
1699 /* Change to reading from a new source file. */
1702 sdbout_start_source_file (line
, filename
)
1703 unsigned int line ATTRIBUTE_UNUSED
;
1704 const char *filename ATTRIBUTE_UNUSED
;
1706 #ifdef MIPS_DEBUGGING_INFO
1707 struct sdb_file
*n
= (struct sdb_file
*) xmalloc (sizeof *n
);
1709 n
->next
= current_file
;
1712 PUT_SDB_SRC_FILE (filename
);
1716 /* Revert to reading a previous source file. */
1719 sdbout_end_source_file (line
)
1720 unsigned int line ATTRIBUTE_UNUSED
;
1722 #ifdef MIPS_DEBUGGING_INFO
1723 struct sdb_file
*next
;
1725 next
= current_file
->next
;
1726 free (current_file
);
1727 current_file
= next
;
1728 PUT_SDB_SRC_FILE (current_file
->name
);
1732 /* Set up for SDB output at the start of compilation. */
1735 sdbout_init (input_file_name
)
1736 const char *input_file_name ATTRIBUTE_UNUSED
;
1738 #ifdef MIPS_DEBUGGING_INFO
1739 current_file
= (struct sdb_file
*) xmalloc (sizeof *current_file
);
1740 current_file
->next
= NULL
;
1741 current_file
->name
= input_file_name
;
1744 #ifdef RMS_QUICK_HACK_1
1746 for (t
= (*lang_hooks
.decls
.getdecls
) (); t
; t
= TREE_CHAIN (t
))
1747 if (DECL_NAME (t
) && IDENTIFIER_POINTER (DECL_NAME (t
)) != 0
1748 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t
)), "__vtbl_ptr_type"))
1749 sdbout_symbol (t
, 0);
1753 #else /* SDB_DEBUGGING_INFO */
1755 /* This should never be used, but its address is needed for comparisons. */
1756 const struct gcc_debug_hooks sdb_debug_hooks
;
1758 #endif /* SDB_DEBUGGING_INFO */
1760 #include "gt-sdbout.h"