1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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 #ifdef SDB_DEBUGGING_INFO
54 #include "insn-config.h"
60 /* Mips systems use the SDB functions to dump out symbols, but do not
61 supply usable syms.h include files. Which syms.h file to use is a
62 target parameter so don't use the native one if we're cross compiling. */
64 #if defined(USG) && !defined(MIPS) && !defined (hpux) && !defined(_WIN32) && !defined(__linux__) && !defined(__INTERIX) && !defined(CROSS_COMPILE)
66 /* Use T_INT if we don't have T_VOID. */
74 /* #include <storclass.h> used to be this instead of syms.h. */
76 /* 1 if PARM is passed to this function in memory. */
78 #define PARM_PASSED_IN_MEMORY(PARM) \
79 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
81 /* A C expression for the integer offset value of an automatic variable
82 (C_AUTO) having address X (an RTX). */
83 #ifndef DEBUGGER_AUTO_OFFSET
84 #define DEBUGGER_AUTO_OFFSET(X) \
85 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
88 /* A C expression for the integer offset value of an argument (C_ARG)
89 having address X (an RTX). The nominal offset is OFFSET. */
90 #ifndef DEBUGGER_ARG_OFFSET
91 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
94 /* Line number of beginning of current function, minus one.
95 Negative means not in a function or not using sdb. */
97 int sdb_begin_function_line
= -1;
99 /* Counter to generate unique "names" for nameless struct members. */
101 static int unnamed_struct_number
= 0;
103 extern FILE *asm_out_file
;
105 extern tree current_function_decl
;
109 static char *gen_fake_label
PARAMS ((void));
110 static int plain_type
PARAMS ((tree
));
111 static int template_name_p
PARAMS ((tree
));
112 static void sdbout_record_type_name
PARAMS ((tree
));
113 static int plain_type_1
PARAMS ((tree
, int));
114 static void sdbout_block
PARAMS ((tree
));
115 static void sdbout_syms
PARAMS ((tree
));
116 #ifdef SDB_ALLOW_FORWARD_REFERENCES
117 static void sdbout_queue_anonymous_type
PARAMS ((tree
));
118 static void sdbout_dequeue_anonymous_types
PARAMS ((void));
120 static void sdbout_type
PARAMS ((tree
));
121 static void sdbout_field_types
PARAMS ((tree
));
122 static void sdbout_one_type
PARAMS ((tree
));
123 static void sdbout_parms
PARAMS ((tree
));
124 static void sdbout_reg_parms
PARAMS ((tree
));
126 /* Random macros describing parts of SDB data. */
128 /* Put something here if lines get too long */
131 /* Default value of delimiter is ";". */
133 #define SDB_DELIM ";"
136 /* Maximum number of dimensions the assembler will allow. */
138 #define SDB_MAX_DIM 4
142 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
145 #ifndef PUT_SDB_INT_VAL
146 #define PUT_SDB_INT_VAL(a) \
148 fputs ("\t.val\t", asm_out_file); \
149 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
150 fprintf (asm_out_file, "%s", SDB_DELIM); \
156 #define PUT_SDB_VAL(a) \
157 ( fputs ("\t.val\t", asm_out_file), \
158 output_addr_const (asm_out_file, (a)), \
159 fprintf (asm_out_file, SDB_DELIM))
163 #define PUT_SDB_DEF(a) \
168 do { fprintf (asm_out_file
, "\t.def\t"); \
169 assemble_name (asm_out_file
, a
); \
170 fprintf (asm_out_file
, SDB_DELIM
); } while (0)
174 #ifndef PUT_SDB_PLAIN_DEF
175 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM)
178 #ifndef PUT_SDB_ENDEF
179 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file)
183 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
187 #define PUT_SDB_SIZE(a) \
189 fputs ("\t.size\t", asm_out_file); \
190 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(a)); \
191 fprintf (asm_out_file, "%s", SDB_DELIM); \
195 #ifndef PUT_SDB_START_DIM
196 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t")
199 #ifndef PUT_SDB_NEXT_DIM
200 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a)
203 #ifndef PUT_SDB_LAST_DIM
204 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM)
208 #define PUT_SDB_TAG(a) \
209 do { fprintf (asm_out_file, "\t.tag\t"); \
210 assemble_name (asm_out_file, a); \
211 fprintf (asm_out_file, SDB_DELIM); } while (0)
214 #ifndef PUT_SDB_BLOCK_START
215 #define PUT_SDB_BLOCK_START(LINE) \
216 fprintf (asm_out_file, \
217 "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
218 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
221 #ifndef PUT_SDB_BLOCK_END
222 #define PUT_SDB_BLOCK_END(LINE) \
223 fprintf (asm_out_file, \
224 "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \
225 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
228 #ifndef PUT_SDB_FUNCTION_START
229 #define PUT_SDB_FUNCTION_START(LINE) \
230 fprintf (asm_out_file, \
231 "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
232 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
235 #ifndef PUT_SDB_FUNCTION_END
236 #define PUT_SDB_FUNCTION_END(LINE) \
237 fprintf (asm_out_file, \
238 "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \
239 SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM)
242 #ifndef PUT_SDB_EPILOGUE_END
243 #define PUT_SDB_EPILOGUE_END(NAME) \
244 do { fprintf (asm_out_file, "\t.def\t"); \
245 assemble_name (asm_out_file, NAME); \
246 fprintf (asm_out_file, \
247 "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n", \
248 SDB_DELIM, SDB_DELIM, SDB_DELIM); } while (0)
251 #ifndef SDB_GENERATE_FAKE
252 #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
253 sprintf ((BUFFER), ".%dfake", (NUMBER));
256 /* Return the sdb tag identifier string for TYPE
257 if TYPE has already been defined; otherwise return a null pointer. */
259 #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type)
261 /* Set the sdb tag identifier string for TYPE to NAME. */
263 #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \
264 TYPE_SYMTAB_POINTER (TYPE) = (NAME)
266 /* Return the name (a string) of the struct, union or enum tag
267 described by the TREE_LIST node LINK. This is 0 for an anonymous one. */
269 #define TAG_NAME(link) \
270 (((link) && TREE_PURPOSE ((link)) \
271 && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \
272 ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0)
274 /* Ensure we don't output a negative line number. */
275 #define MAKE_LINE_SAFE(line) \
276 if (line <= sdb_begin_function_line) 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 #ifndef PUT_SDB_SRC_FILE
287 #define PUT_SDB_SRC_FILE(FILENAME) \
288 output_file_directive (asm_out_file, (FILENAME))
291 /* ECOFF linkers have an optimization that does the same kind of thing as
292 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
293 executable. To achieve this, GCC must output a .file for each file
296 /* This is a stack of input files. */
300 struct sdb_file
*next
;
304 /* This is the top of the stack. */
306 static struct sdb_file
*current_file
;
308 #endif /* MIPS_DEBUGGING_INFO */
310 /* Set up for SDB output at the start of compilation. */
313 sdbout_init (asm_file
, input_file_name
, syms
)
314 FILE *asm_file ATTRIBUTE_UNUSED
;
315 const char *input_file_name ATTRIBUTE_UNUSED
;
316 tree syms ATTRIBUTE_UNUSED
;
318 #ifdef MIPS_DEBUGGING_INFO
319 current_file
= (struct sdb_file
*) xmalloc (sizeof *current_file
);
320 current_file
->next
= NULL
;
321 current_file
->name
= input_file_name
;
324 #ifdef RMS_QUICK_HACK_1
326 for (t
= syms
; t
; t
= TREE_CHAIN (t
))
327 if (DECL_NAME (t
) && IDENTIFIER_POINTER (DECL_NAME (t
)) != 0
328 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t
)), "__vtbl_ptr_type"))
329 sdbout_symbol (t
, 0);
335 /* return the tag identifier for type
339 tag_of_ru_type (type
,link
)
342 if (TYPE_SYMTAB_ADDRESS (type
))
343 return TYPE_SYMTAB_ADDRESS (type
);
344 if (link
&& TREE_PURPOSE (link
)
345 && IDENTIFIER_POINTER (TREE_PURPOSE (link
)))
346 TYPE_SYMTAB_ADDRESS (type
) = IDENTIFIER_POINTER (TREE_PURPOSE (link
));
348 return (char *) TYPE_SYMTAB_ADDRESS (type
);
352 /* Return a unique string to name an anonymous type. */
359 SDB_GENERATE_FAKE (label
, unnamed_struct_number
);
360 unnamed_struct_number
++;
361 labelstr
= (char *) permalloc (strlen (label
) + 1);
362 strcpy (labelstr
, label
);
366 /* Return the number which describes TYPE for SDB.
367 For pointers, etc., this function is recursive.
368 Each record, union or enumeral type must already have had a
369 tag number output. */
371 /* The number is given by d6d5d4d3d2d1bbbb
372 where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array.
373 Thus, char *foo () has bbbb=T_CHAR
376 N_BTMASK= 017 1111 basic type field.
377 N_TSHIFT= 2 derived type shift
378 N_BTSHFT= 4 Basic type shift */
380 /* Produce the number that describes a pointer, function or array type.
381 PREV is the number describing the target, value or element type.
382 DT_type describes how to transform that type. */
383 #define PUSH_DERIVED_LEVEL(DT_type,PREV) \
384 ((((PREV) & ~(int)N_BTMASK) << (int)N_TSHIFT) \
385 | ((int)DT_type << (int)N_BTSHFT) \
386 | ((PREV) & (int)N_BTMASK))
388 /* Number of elements used in sdb_dims. */
389 static int sdb_n_dims
= 0;
391 /* Table of array dimensions of current type. */
392 static int sdb_dims
[SDB_MAX_DIM
];
394 /* Size of outermost array currently being processed. */
395 static int sdb_type_size
= -1;
401 int val
= plain_type_1 (type
, 0);
403 /* If we have already saved up some array dimensions, print them now. */
408 for (i
= sdb_n_dims
- 1; i
> 0; i
--)
409 PUT_SDB_NEXT_DIM (sdb_dims
[i
]);
410 PUT_SDB_LAST_DIM (sdb_dims
[0]);
413 sdb_type_size
= int_size_in_bytes (type
);
414 /* Don't kill sdb if type is not laid out or has variable size. */
415 if (sdb_type_size
< 0)
418 /* If we have computed the size of an array containing this type,
420 if (sdb_type_size
>= 0)
422 PUT_SDB_SIZE (sdb_type_size
);
429 template_name_p (name
)
432 register char *ptr
= IDENTIFIER_POINTER (name
);
433 while (*ptr
&& *ptr
!= '<')
440 sdbout_record_type_name (type
)
446 if (KNOWN_TYPE_TAG (type
))
449 if (TYPE_NAME (type
) != 0)
452 /* Find the IDENTIFIER_NODE for the type name. */
453 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
454 t
= TYPE_NAME (type
);
455 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
457 t
= DECL_NAME (TYPE_NAME (type
));
458 /* The DECL_NAME for templates includes "<>", which breaks
459 most assemblers. Use its assembler name instead, which
460 has been mangled into being safe. */
461 if (t
&& template_name_p (t
))
462 t
= DECL_ASSEMBLER_NAME (TYPE_NAME (type
));
465 /* Now get the name as a string, or invent one. */
467 name
= IDENTIFIER_POINTER (t
);
470 no_name
= (name
== 0 || *name
== 0);
472 name
= gen_fake_label ();
474 SET_KNOWN_TYPE_TAG (type
, name
);
475 #ifdef SDB_ALLOW_FORWARD_REFERENCES
477 sdbout_queue_anonymous_type (type
);
481 /* Return the .type value for type TYPE.
483 LEVEL indicates how many levels deep we have recursed into the type.
484 The SDB debug format can only represent 6 derived levels of types.
485 After that, we must output inaccurate debug info. We deliberately
486 stop before the 7th level, so that ADA recursive types will not give an
490 plain_type_1 (type
, level
)
495 type
= void_type_node
;
496 else if (type
== error_mark_node
)
497 type
= integer_type_node
;
499 type
= TYPE_MAIN_VARIANT (type
);
501 switch (TREE_CODE (type
))
508 int size
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
510 /* Carefully distinguish all the standard types of C,
511 without messing up if the language is not C.
512 Note that we check only for the names that contain spaces;
513 other names might occur by coincidence in other languages. */
514 if (TYPE_NAME (type
) != 0
515 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
516 && DECL_NAME (TYPE_NAME (type
)) != 0
517 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
519 char *name
= IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
521 if (!strcmp (name
, "char"))
523 if (!strcmp (name
, "unsigned char"))
525 if (!strcmp (name
, "signed char"))
527 if (!strcmp (name
, "int"))
529 if (!strcmp (name
, "unsigned int"))
531 if (!strcmp (name
, "short int"))
533 if (!strcmp (name
, "short unsigned int"))
535 if (!strcmp (name
, "long int"))
537 if (!strcmp (name
, "long unsigned int"))
541 if (size
== INT_TYPE_SIZE
)
542 return (TREE_UNSIGNED (type
) ? T_UINT
: T_INT
);
543 if (size
== CHAR_TYPE_SIZE
)
544 return (TREE_UNSIGNED (type
) ? T_UCHAR
: T_CHAR
);
545 if (size
== SHORT_TYPE_SIZE
)
546 return (TREE_UNSIGNED (type
) ? T_USHORT
: T_SHORT
);
547 if (size
== LONG_TYPE_SIZE
)
548 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
549 if (size
== LONG_LONG_TYPE_SIZE
) /* better than nothing */
550 return (TREE_UNSIGNED (type
) ? T_ULONG
: T_LONG
);
556 int precision
= TYPE_PRECISION (type
);
557 if (precision
== FLOAT_TYPE_SIZE
)
559 if (precision
== DOUBLE_TYPE_SIZE
)
561 #ifdef EXTENDED_SDB_BASIC_TYPES
562 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
565 if (precision
== LONG_DOUBLE_TYPE_SIZE
)
566 return T_DOUBLE
; /* better than nothing */
577 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
578 if (sdb_n_dims
< SDB_MAX_DIM
)
579 sdb_dims
[sdb_n_dims
++]
580 = (TYPE_DOMAIN (type
)
581 && TYPE_MIN_VALUE (TYPE_DOMAIN (type
)) != 0
582 && TYPE_MAX_VALUE (TYPE_DOMAIN (type
)) != 0
583 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
584 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0)
585 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type
)), 0)
586 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type
)), 0) + 1)
589 return PUSH_DERIVED_LEVEL (DT_ARY
, m
);
594 case QUAL_UNION_TYPE
:
598 #ifdef SDB_ALLOW_FORWARD_REFERENCES
599 sdbout_record_type_name (type
);
601 #ifndef SDB_ALLOW_UNKNOWN_REFERENCES
602 if ((TREE_ASM_WRITTEN (type
) && KNOWN_TYPE_TAG (type
) != 0)
603 #ifdef SDB_ALLOW_FORWARD_REFERENCES
604 || TYPE_MODE (type
) != VOIDmode
609 /* Output the referenced structure tag name
610 only if the .def has already been finished.
611 At least on 386, the Unix assembler
612 cannot handle forward references to tags. */
613 /* But the 88100, it requires them, sigh... */
614 /* And the MIPS requires unknown refs as well... */
615 tag
= KNOWN_TYPE_TAG (type
);
617 /* These 3 lines used to follow the close brace.
618 However, a size of 0 without a tag implies a tag of 0,
619 so if we don't know a tag, we can't mention the size. */
620 sdb_type_size
= int_size_in_bytes (type
);
621 if (sdb_type_size
< 0)
624 return ((TREE_CODE (type
) == RECORD_TYPE
) ? T_STRUCT
625 : (TREE_CODE (type
) == UNION_TYPE
) ? T_UNION
626 : (TREE_CODE (type
) == QUAL_UNION_TYPE
) ? T_UNION
636 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
637 return PUSH_DERIVED_LEVEL (DT_PTR
, m
);
646 m
= plain_type_1 (TREE_TYPE (type
), level
+1);
647 return PUSH_DERIVED_LEVEL (DT_FCN
, m
);
654 /* Output the symbols defined in block number DO_BLOCK.
656 This function works by walking the tree structure of blocks,
657 counting blocks until it finds the desired block. */
659 static int do_block
= 0;
667 /* Ignore blocks never expanded or otherwise marked as real. */
668 if (TREE_USED (block
))
670 /* When we reach the specified block, output its symbols. */
671 if (BLOCK_NUMBER (block
) == do_block
)
672 sdbout_syms (BLOCK_VARS (block
));
674 /* If we are past the specified block, stop the scan. */
675 if (BLOCK_NUMBER (block
) > do_block
)
678 /* Scan the blocks within this block. */
679 sdbout_block (BLOCK_SUBBLOCKS (block
));
682 block
= BLOCK_CHAIN (block
);
686 /* Call sdbout_symbol on each decl in the chain SYMS. */
694 if (TREE_CODE (syms
) != LABEL_DECL
)
695 sdbout_symbol (syms
, 1);
696 syms
= TREE_CHAIN (syms
);
700 /* Output SDB information for a symbol described by DECL.
701 LOCAL is nonzero if the symbol is not file-scope. */
704 sdbout_symbol (decl
, local
)
708 tree type
= TREE_TYPE (decl
);
709 tree context
= NULL_TREE
;
714 sdbout_one_type (type
);
716 #if 0 /* This loses when functions are marked to be ignored,
717 which happens in the C++ front end. */
718 if (DECL_IGNORED_P (decl
))
722 switch (TREE_CODE (decl
))
725 /* Enum values are defined by defining the enum type. */
729 /* Don't mention a nested function under its parent. */
730 context
= decl_function_context (decl
);
731 if (context
== current_function_decl
)
733 /* Check DECL_INITIAL to distinguish declarations from definitions.
734 Don't output debug info here for declarations; they will have
735 a DECL_INITIAL value of 0. */
736 if (! DECL_INITIAL (decl
))
738 if (GET_CODE (DECL_RTL (decl
)) != MEM
739 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
741 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
742 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
743 PUT_SDB_SCL (TREE_PUBLIC (decl
) ? C_EXT
: C_STAT
);
747 /* Done with tagged types. */
748 if (DECL_NAME (decl
) == 0)
750 if (DECL_IGNORED_P (decl
))
753 /* Output typedef name. */
754 if (template_name_p (DECL_NAME (decl
)))
755 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
757 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl
)));
758 PUT_SDB_SCL (C_TPDEF
);
762 /* Parm decls go in their own separate chains
763 and are output by sdbout_reg_parms and sdbout_parms. */
767 /* Don't mention a variable that is external.
768 Let the file that defines it describe it. */
769 if (DECL_EXTERNAL (decl
))
772 /* Ignore __FUNCTION__, etc. */
773 if (DECL_IGNORED_P (decl
))
776 /* If there was an error in the declaration, don't dump core
777 if there is no RTL associated with the variable doesn't
779 if (DECL_RTL (decl
) == 0)
782 DECL_RTL (decl
) = eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
);
783 #ifdef LEAF_REG_REMAP
784 if (current_function_uses_only_leaf_regs
)
785 leaf_renumber_regs_insn (DECL_RTL (decl
));
787 value
= DECL_RTL (decl
);
789 /* Don't mention a variable at all
790 if it was completely optimized into nothingness.
792 If DECL was from an inline function, then its rtl
793 is not identically the rtl that was used in this
794 particular compilation. */
795 if (GET_CODE (value
) == REG
)
797 regno
= REGNO (DECL_RTL (decl
));
798 if (regno
>= FIRST_PSEUDO_REGISTER
)
801 else if (GET_CODE (value
) == SUBREG
)
804 while (GET_CODE (value
) == SUBREG
)
806 offset
+= SUBREG_WORD (value
);
807 value
= SUBREG_REG (value
);
809 if (GET_CODE (value
) == REG
)
811 regno
= REGNO (value
);
812 if (regno
>= FIRST_PSEUDO_REGISTER
)
816 alter_subreg (DECL_RTL (decl
));
817 value
= DECL_RTL (decl
);
819 /* Don't output anything if an auto variable
820 gets RTL that is static.
821 GAS version 2.2 can't handle such output. */
822 else if (GET_CODE (value
) == MEM
&& CONSTANT_P (XEXP (value
, 0))
823 && ! TREE_STATIC (decl
))
826 /* Emit any structure, union, or enum type that has not been output.
827 This occurs for tag-less structs (et al) used to declare variables
829 if (TREE_CODE (type
) == ENUMERAL_TYPE
830 || TREE_CODE (type
) == RECORD_TYPE
831 || TREE_CODE (type
) == UNION_TYPE
832 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
834 if (COMPLETE_TYPE_P (type
) /* not a forward reference */
835 && KNOWN_TYPE_TAG (type
) == 0) /* not yet declared */
836 sdbout_one_type (type
);
839 /* Defer SDB information for top-level initialized variables! */
841 && GET_CODE (value
) == MEM
842 && DECL_INITIAL (decl
))
845 /* C++ in 2.3 makes nameless symbols. That will be fixed later.
846 For now, avoid crashing. */
847 if (DECL_NAME (decl
) == NULL_TREE
)
850 /* Record the name for, starting a symtab entry. */
851 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
853 if (GET_CODE (value
) == MEM
854 && GET_CODE (XEXP (value
, 0)) == SYMBOL_REF
)
857 if (TREE_PUBLIC (decl
))
859 PUT_SDB_VAL (XEXP (value
, 0));
864 PUT_SDB_VAL (XEXP (value
, 0));
865 PUT_SDB_SCL (C_STAT
);
871 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno
));
874 else if (GET_CODE (value
) == MEM
875 && (GET_CODE (XEXP (value
, 0)) == MEM
876 || (GET_CODE (XEXP (value
, 0)) == REG
877 && REGNO (XEXP (value
, 0)) != HARD_FRAME_POINTER_REGNUM
878 && REGNO (XEXP (value
, 0)) != STACK_POINTER_REGNUM
)))
879 /* If the value is indirect by memory or by a register
880 that isn't the frame pointer
881 then it means the object is variable-sized and address through
882 that register or stack slot. COFF has no way to represent this
883 so all we can do is output the variable as a pointer. */
886 if (GET_CODE (XEXP (value
, 0)) == REG
)
888 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value
, 0))));
893 /* DECL_RTL looks like (MEM (MEM (PLUS (REG...)
895 We want the value of that CONST_INT. */
896 /* Encore compiler hates a newline in a macro arg, it seems. */
897 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
898 (XEXP (XEXP (value
, 0), 0)));
899 PUT_SDB_SCL (C_AUTO
);
902 /* Effectively do build_pointer_type, but don't cache this type,
903 since it might be temporary whereas the type it points to
904 might have been saved for inlining. */
905 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
906 type
= make_node (POINTER_TYPE
);
907 TREE_TYPE (type
) = TREE_TYPE (decl
);
909 else if (GET_CODE (value
) == MEM
910 && ((GET_CODE (XEXP (value
, 0)) == PLUS
911 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
912 && GET_CODE (XEXP (XEXP (value
, 0), 1)) == CONST_INT
)
913 /* This is for variables which are at offset zero from
914 the frame pointer. This happens on the Alpha.
915 Non-frame pointer registers are excluded above. */
916 || (GET_CODE (XEXP (value
, 0)) == REG
)))
918 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
919 or (MEM (REG...)). We want the value of that CONST_INT
922 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value
, 0)));
923 PUT_SDB_SCL (C_AUTO
);
925 else if (GET_CODE (value
) == MEM
&& GET_CODE (XEXP (value
, 0)) == CONST
)
927 /* Handle an obscure case which can arise when optimizing and
928 when there are few available registers. (This is *always*
929 the case for i386/i486 targets). The DECL_RTL looks like
930 (MEM (CONST ...)) even though this variable is a local `auto'
931 or a local `register' variable. In effect, what has happened
932 is that the reload pass has seen that all assignments and
933 references for one such a local variable can be replaced by
934 equivalent assignments and references to some static storage
935 variable, thereby avoiding the need for a register. In such
936 cases we're forced to lie to debuggers and tell them that
937 this variable was itself `static'. */
939 PUT_SDB_VAL (XEXP (XEXP (value
, 0), 0));
940 PUT_SDB_SCL (C_STAT
);
944 /* It is something we don't know how to represent for SDB. */
952 PUT_SDB_TYPE (plain_type (type
));
956 /* Output SDB information for a top-level initialized variable
957 that has been delayed. */
960 sdbout_toplevel_data (decl
)
963 tree type
= TREE_TYPE (decl
);
965 if (DECL_IGNORED_P (decl
))
968 if (! (TREE_CODE (decl
) == VAR_DECL
969 && GET_CODE (DECL_RTL (decl
)) == MEM
970 && DECL_INITIAL (decl
)))
973 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
974 PUT_SDB_VAL (XEXP (DECL_RTL (decl
), 0));
975 if (TREE_PUBLIC (decl
))
981 PUT_SDB_SCL (C_STAT
);
983 PUT_SDB_TYPE (plain_type (type
));
987 #ifdef SDB_ALLOW_FORWARD_REFERENCES
989 /* Machinery to record and output anonymous types. */
991 static tree anonymous_types
;
994 sdbout_queue_anonymous_type (type
)
997 anonymous_types
= tree_cons (NULL_TREE
, type
, anonymous_types
);
1001 sdbout_dequeue_anonymous_types ()
1003 register tree types
, link
;
1005 while (anonymous_types
)
1007 types
= nreverse (anonymous_types
);
1008 anonymous_types
= NULL_TREE
;
1010 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1012 register tree type
= TREE_VALUE (link
);
1014 if (type
&& ! TREE_ASM_WRITTEN (type
))
1015 sdbout_one_type (type
);
1022 /* Given a chain of ..._TYPE nodes, all of which have names,
1023 output definitions of those names, as typedefs. */
1026 sdbout_types (types
)
1027 register tree types
;
1031 for (link
= types
; link
; link
= TREE_CHAIN (link
))
1032 sdbout_one_type (link
);
1034 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1035 sdbout_dequeue_anonymous_types ();
1043 if (type
== error_mark_node
)
1044 type
= integer_type_node
;
1045 PUT_SDB_TYPE (plain_type (type
));
1048 /* Output types of the fields of type TYPE, if they are structs.
1050 Formerly did not chase through pointer types, since that could be circular.
1051 They must come before TYPE, since forward refs are not allowed.
1052 Now james@bigtex.cactus.org says to try them. */
1055 sdbout_field_types (type
)
1060 for (tail
= TYPE_FIELDS (type
); tail
; tail
= TREE_CHAIN (tail
))
1061 /* This condition should match the one for emitting the actual members
1063 if (TREE_CODE (tail
) == FIELD_DECL
1064 && DECL_NAME (tail
) != 0
1065 && ! host_integerp (DECL_SIZE (tail
), 1)
1066 && ! host_integerp (bit_position (tail
), 0))
1068 if (POINTER_TYPE_P (TREE_TYPE (tail
)))
1069 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail
)));
1071 sdbout_one_type (TREE_TYPE (tail
));
1075 /* Use this to put out the top level defined record and union types
1076 for later reference. If this is a struct with a name, then put that
1077 name out. Other unnamed structs will have .xxfake labels generated so
1078 that they may be referred to later.
1079 The label will be stored in the KNOWN_TYPE_TAG slot of a type.
1080 It may NOT be called recursively. */
1083 sdbout_one_type (type
)
1086 if (current_function_decl
!= NULL_TREE
1087 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
1088 ; /* Don't change section amid function. */
1092 switch (TREE_CODE (type
))
1096 case QUAL_UNION_TYPE
:
1098 type
= TYPE_MAIN_VARIANT (type
);
1099 /* Don't output a type twice. */
1100 if (TREE_ASM_WRITTEN (type
))
1101 /* James said test TREE_ASM_BEING_WRITTEN here. */
1104 /* Output nothing if type is not yet defined. */
1105 if (!COMPLETE_TYPE_P (type
))
1108 TREE_ASM_WRITTEN (type
) = 1;
1110 /* This is reputed to cause trouble with the following case,
1111 but perhaps checking TYPE_SIZE above will fix it. */
1113 /* Here is a test case:
1119 typedef struct intermediate {
1123 typedef struct badstr {
1128 TREE_ASM_BEING_WRITTEN (type
) = 1;
1130 /* This change, which ought to make better output,
1131 used to make the COFF assembler unhappy.
1132 Changes involving KNOWN_TYPE_TAG may fix the problem. */
1133 /* Before really doing anything, output types we want to refer to. */
1134 /* Note that in version 1 the following two lines
1135 are not used if forward references are in use. */
1136 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1137 sdbout_field_types (type
);
1139 TREE_ASM_WRITTEN (type
) = 1;
1143 /* Output a structure type. */
1145 int size
= int_size_in_bytes (type
);
1148 int i
, n_baseclasses
= 0;
1150 /* Record the type tag, but not in its permanent place just yet. */
1151 sdbout_record_type_name (type
);
1153 PUT_SDB_DEF (KNOWN_TYPE_TAG (type
));
1155 switch (TREE_CODE (type
))
1158 case QUAL_UNION_TYPE
:
1159 PUT_SDB_SCL (C_UNTAG
);
1160 PUT_SDB_TYPE (T_UNION
);
1165 PUT_SDB_SCL (C_STRTAG
);
1166 PUT_SDB_TYPE (T_STRUCT
);
1171 PUT_SDB_SCL (C_ENTAG
);
1172 PUT_SDB_TYPE (T_ENUM
);
1180 PUT_SDB_SIZE (size
);
1183 /* Print out the base class information with fields
1184 named after the types they hold. */
1185 /* This is only relevent to aggregate types. TYPE_BINFO is used
1186 for other purposes in an ENUMERAL_TYPE, so we must exclude that
1188 if (TREE_CODE (type
) != ENUMERAL_TYPE
)
1190 if (TYPE_BINFO (type
)
1191 && TYPE_BINFO_BASETYPES (type
))
1192 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1193 for (i
= 0; i
< n_baseclasses
; i
++)
1195 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)),
1197 tree child_type
= BINFO_TYPE (child
);
1198 tree child_type_name
;
1199 if (TYPE_NAME (child_type
) == 0)
1201 if (TREE_CODE (TYPE_NAME (child_type
)) == IDENTIFIER_NODE
)
1202 child_type_name
= TYPE_NAME (child_type
);
1203 else if (TREE_CODE (TYPE_NAME (child_type
)) == TYPE_DECL
)
1205 child_type_name
= DECL_NAME (TYPE_NAME (child_type
));
1206 if (child_type_name
&& template_name_p (child_type_name
))
1208 = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type
));
1214 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name
));
1215 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child
), 0));
1216 PUT_SDB_SCL (member_scl
);
1217 sdbout_type (BINFO_TYPE (child
));
1222 /* output the individual fields */
1224 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1226 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1227 if (host_integerp (TREE_VALUE (tem
), 0))
1229 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1230 PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem
), 0));
1231 PUT_SDB_SCL (C_MOE
);
1232 PUT_SDB_TYPE (T_MOE
);
1236 else /* record or union type */
1237 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1238 /* Output the name, type, position (in bits), size (in bits)
1241 /* Omit here the nameless fields that are used to skip bits.
1242 Also omit fields with variable size or position.
1243 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1244 if (TREE_CODE (tem
) == FIELD_DECL
1245 && DECL_NAME (tem
) != 0
1246 && host_integerp (DECL_SIZE (tem
), 1)
1247 && host_integerp (bit_position (tem
), 0))
1252 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
));
1254 if (DECL_BIT_FIELD_TYPE (tem
))
1256 PUT_SDB_INT_VAL (int_bit_position (tem
));
1257 PUT_SDB_SCL (C_FIELD
);
1258 sdbout_type (DECL_BIT_FIELD_TYPE (tem
));
1259 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem
), 1));
1263 PUT_SDB_INT_VAL (int_bit_position (tem
) / BITS_PER_UNIT
);
1264 PUT_SDB_SCL (member_scl
);
1265 sdbout_type (TREE_TYPE (tem
));
1269 /* output end of a structure,union, or enumeral definition */
1271 PUT_SDB_PLAIN_DEF ("eos");
1272 PUT_SDB_INT_VAL (size
);
1273 PUT_SDB_SCL (C_EOS
);
1274 PUT_SDB_TAG (KNOWN_TYPE_TAG (type
));
1275 PUT_SDB_SIZE (size
);
1285 /* The following two functions output definitions of function parameters.
1286 Each parameter gets a definition locating it in the parameter list.
1287 Each parameter that is a register variable gets a second definition
1288 locating it in the register.
1290 Printing or argument lists in gdb uses the definitions that
1291 locate in the parameter list. But reference to the variable in
1292 expressions uses preferentially the definition as a register. */
1294 /* Output definitions, referring to storage in the parmlist,
1295 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1298 sdbout_parms (parms
)
1301 for (; parms
; parms
= TREE_CHAIN (parms
))
1302 if (DECL_NAME (parms
))
1304 int current_sym_value
= 0;
1305 char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1307 if (name
== 0 || *name
== 0)
1308 name
= gen_fake_label ();
1310 /* Perform any necessary register eliminations on the parameter's rtl,
1311 so that the debugging output will be accurate. */
1312 DECL_INCOMING_RTL (parms
)
1313 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
1314 DECL_RTL (parms
) = eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
);
1316 if (PARM_PASSED_IN_MEMORY (parms
))
1318 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
1321 /* ??? Here we assume that the parm address is indexed
1322 off the frame pointer or arg pointer.
1323 If that is not true, we produce meaningless results,
1324 but do not crash. */
1325 if (GET_CODE (addr
) == PLUS
1326 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
1327 current_sym_value
= INTVAL (XEXP (addr
, 1));
1329 current_sym_value
= 0;
1331 if (GET_CODE (DECL_RTL (parms
)) == REG
1332 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1333 type
= DECL_ARG_TYPE (parms
);
1336 int original_sym_value
= current_sym_value
;
1338 /* This is the case where the parm is passed as an int or
1339 double and it is converted to a char, short or float
1340 and stored back in the parmlist. In this case, describe
1341 the parm with the variable's declared type, and adjust
1342 the address if the least significant bytes (which we are
1343 using) are not the first ones. */
1344 if (BYTES_BIG_ENDIAN
1345 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1346 current_sym_value
+=
1347 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1348 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1350 if (GET_CODE (DECL_RTL (parms
)) == MEM
1351 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1352 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1354 && (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1))
1355 == current_sym_value
))
1356 type
= TREE_TYPE (parms
);
1359 current_sym_value
= original_sym_value
;
1360 type
= DECL_ARG_TYPE (parms
);
1365 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
, addr
));
1366 PUT_SDB_SCL (C_ARG
);
1367 PUT_SDB_TYPE (plain_type (type
));
1370 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
1373 /* Parm passed in registers and lives in registers or nowhere. */
1375 /* If parm lives in a register, use that register;
1376 pretend the parm was passed there. It would be more consistent
1377 to describe the register where the parm was passed,
1378 but in practice that register usually holds something else. */
1379 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
1380 best_rtl
= DECL_RTL (parms
);
1381 /* If the parm lives nowhere,
1382 use the register where it was passed. */
1384 best_rtl
= DECL_INCOMING_RTL (parms
);
1387 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl
)));
1388 PUT_SDB_SCL (C_REGPARM
);
1389 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1392 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1393 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
)
1395 /* Parm was passed in registers but lives on the stack. */
1397 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
1398 in which case we want the value of that CONST_INT,
1399 or (MEM (REG ...)) or (MEM (MEM ...)),
1400 in which case we use a value of zero. */
1401 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
1402 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
1403 current_sym_value
= 0;
1405 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
1407 /* Again, this assumes the offset is based on the arg pointer. */
1409 PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value
,
1410 XEXP (DECL_RTL (parms
), 0)));
1411 PUT_SDB_SCL (C_ARG
);
1412 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1418 /* Output definitions for the places where parms live during the function,
1419 when different from where they were passed, when the parms were passed
1422 It is not useful to do this for parms passed in registers
1423 that live during the function in different registers, because it is
1424 impossible to look in the passed register for the passed value,
1425 so we use the within-the-function register to begin with.
1427 PARMS is a chain of PARM_DECL nodes. */
1430 sdbout_reg_parms (parms
)
1433 for (; parms
; parms
= TREE_CHAIN (parms
))
1434 if (DECL_NAME (parms
))
1436 char *name
= IDENTIFIER_POINTER (DECL_NAME (parms
));
1438 /* Report parms that live in registers during the function
1439 but were passed in memory. */
1440 if (GET_CODE (DECL_RTL (parms
)) == REG
1441 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
1442 && PARM_PASSED_IN_MEMORY (parms
))
1444 if (name
== 0 || *name
== 0)
1445 name
= gen_fake_label ();
1447 PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms
))));
1448 PUT_SDB_SCL (C_REG
);
1449 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1452 /* Report parms that live in memory but not where they were passed. */
1453 else if (GET_CODE (DECL_RTL (parms
)) == MEM
1454 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == PLUS
1455 && GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) == CONST_INT
1456 && PARM_PASSED_IN_MEMORY (parms
)
1457 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
1459 #if 0 /* ??? It is not clear yet what should replace this. */
1460 int offset
= DECL_OFFSET (parms
) / BITS_PER_UNIT
;
1461 /* A parm declared char is really passed as an int,
1462 so it occupies the least significant bytes.
1463 On a big-endian machine those are not the low-numbered ones. */
1464 if (BYTES_BIG_ENDIAN
1466 && TREE_TYPE (parms
) != DECL_ARG_TYPE (parms
))
1467 offset
+= (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms
)))
1468 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
))));
1469 if (INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1)) != offset
) {...}
1472 if (name
== 0 || *name
== 0)
1473 name
= gen_fake_label ();
1475 PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
1476 (XEXP (DECL_RTL (parms
), 0)));
1477 PUT_SDB_SCL (C_AUTO
);
1478 PUT_SDB_TYPE (plain_type (TREE_TYPE (parms
)));
1485 /* Describe the beginning of an internal block within a function.
1486 Also output descriptions of variables defined in this block.
1488 N is the number of the block, by order of beginning, counting from 1,
1489 and not counting the outermost (function top-level) block.
1490 The blocks match the BLOCKs in DECL_INITIAL (current_function_decl),
1491 if the count starts at 0 for the outermost one. */
1494 sdbout_begin_block (file
, line
, n
)
1495 FILE *file ATTRIBUTE_UNUSED
;
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 (file
, line
, n
)
1533 FILE *file ATTRIBUTE_UNUSED
;
1535 int n ATTRIBUTE_UNUSED
;
1537 MAKE_LINE_SAFE (line
);
1539 /* The SCO compiler does not emit a separate block for the function level
1540 scope, so we avoid it here also. However, mips ECOFF compilers do emit
1541 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1542 #ifndef MIPS_DEBUGGING_INFO
1545 PUT_SDB_BLOCK_END (line
- sdb_begin_function_line
);
1548 /* Output sdb info for the current function name.
1549 Called from assemble_start_function. */
1552 sdbout_mark_begin_function ()
1554 sdbout_symbol (current_function_decl
, 0);
1557 /* Called at beginning of function body (after prologue).
1558 Record the function's starting line number, so we can output
1559 relative line numbers for the other lines.
1560 Describe beginning of outermost block.
1561 Also describe the parameter list. */
1564 sdbout_begin_function (line
)
1567 sdb_begin_function_line
= line
- 1;
1568 PUT_SDB_FUNCTION_START (line
);
1569 sdbout_parms (DECL_ARGUMENTS (current_function_decl
));
1570 sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl
));
1573 /* Called at end of function (before epilogue).
1574 Describe end of outermost block. */
1577 sdbout_end_function (line
)
1580 #ifdef SDB_ALLOW_FORWARD_REFERENCES
1581 sdbout_dequeue_anonymous_types ();
1584 MAKE_LINE_SAFE (line
);
1585 PUT_SDB_FUNCTION_END (line
- sdb_begin_function_line
);
1587 /* Indicate we are between functions, for line-number output. */
1588 sdb_begin_function_line
= -1;
1591 /* Output sdb info for the absolute end of a function.
1592 Called after the epilogue is output. */
1595 sdbout_end_epilogue ()
1597 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl
));
1598 PUT_SDB_EPILOGUE_END (name
);
1601 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1608 PUT_SDB_DEF (LABEL_NAME (insn
));
1610 PUT_SDB_SCL (C_LABEL
);
1611 PUT_SDB_TYPE (T_NULL
);
1615 /* Change to reading from a new source file. */
1618 sdbout_start_new_source_file (filename
)
1619 const char *filename ATTRIBUTE_UNUSED
;
1621 #ifdef MIPS_DEBUGGING_INFO
1622 struct sdb_file
*n
= (struct sdb_file
*) xmalloc (sizeof *n
);
1624 n
->next
= current_file
;
1627 PUT_SDB_SRC_FILE (filename
);
1631 /* Revert to reading a previous source file. */
1634 sdbout_resume_previous_source_file ()
1636 #ifdef MIPS_DEBUGGING_INFO
1637 struct sdb_file
*next
;
1639 next
= current_file
->next
;
1640 free (current_file
);
1641 current_file
= next
;
1642 PUT_SDB_SRC_FILE (current_file
->name
);
1646 #endif /* SDB_DEBUGGING_INFO */