comparison gcc/sdbout.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Output sdb-format symbol table information from GNU compiler. 1 /* Output sdb-format symbol table information from GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2 Copyright (C) 1988-2017 Free Software Foundation, Inc.
3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 3
6 This file is part of GCC. 4 This file is part of GCC.
7 5
8 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
42 */ 40 */
43 41
44 #include "config.h" 42 #include "config.h"
45 #include "system.h" 43 #include "system.h"
46 #include "coretypes.h" 44 #include "coretypes.h"
45 #include "gsyms.h"
47 #include "tm.h" 46 #include "tm.h"
48 #include "debug.h" 47 #include "debug.h"
49 #include "tree.h" 48 #include "tree.h"
50 #include "ggc.h" 49 #include "varasm.h"
51 #include "vec.h" 50 #include "stor-layout.h"
52 51
53 static GTY(()) tree anonymous_types; 52 static GTY(()) tree anonymous_types;
54 53
55 /* Counter to generate unique "names" for nameless struct members. */ 54 /* Counter to generate unique "names" for nameless struct members. */
56 55
57 static GTY(()) int unnamed_struct_number; 56 static GTY(()) int unnamed_struct_number;
58 57
59 /* Declarations whose debug info was deferred till end of compilation. */ 58 /* Declarations whose debug info was deferred till end of compilation. */
60 59
61 static GTY(()) VEC(tree,gc) *deferred_global_decls; 60 static GTY(()) vec<tree, va_gc> *deferred_global_decls;
62 61
63 /* The C front end may call sdbout_symbol before sdbout_init runs. 62 /* The C front end may call sdbout_symbol before sdbout_init runs.
64 We save all such decls in this list and output them when we get 63 We save all such decls in this list and output them when we get
65 to sdbout_init. */ 64 to sdbout_init. */
66 65
67 static GTY(()) tree preinit_symbols; 66 static GTY(()) tree preinit_symbols;
68 static GTY(()) bool sdbout_initialized; 67 static GTY(()) bool sdbout_initialized;
69 68
70 #ifdef SDB_DEBUGGING_INFO
71
72 #include "rtl.h" 69 #include "rtl.h"
73 #include "regs.h" 70 #include "regs.h"
71 #include "function.h"
72 #include "memmodel.h"
73 #include "emit-rtl.h"
74 #include "flags.h" 74 #include "flags.h"
75 #include "insn-config.h" 75 #include "insn-config.h"
76 #include "reload.h" 76 #include "reload.h"
77 #include "output.h" 77 #include "output.h"
78 #include "diagnostic-core.h" 78 #include "diagnostic-core.h"
79 #include "tm_p.h" 79 #include "tm_p.h"
80 #include "gsyms.h"
81 #include "langhooks.h" 80 #include "langhooks.h"
82 #include "target.h" 81 #include "target.h"
83 82
84 /* 1 if PARM is passed to this function in memory. */ 83 /* 1 if PARM is passed to this function in memory. */
85 84
115 static void sdbout_finish (const char *); 114 static void sdbout_finish (const char *);
116 static void sdbout_start_source_file (unsigned int, const char *); 115 static void sdbout_start_source_file (unsigned int, const char *);
117 static void sdbout_end_source_file (unsigned int); 116 static void sdbout_end_source_file (unsigned int);
118 static void sdbout_begin_block (unsigned int, unsigned int); 117 static void sdbout_begin_block (unsigned int, unsigned int);
119 static void sdbout_end_block (unsigned int, unsigned int); 118 static void sdbout_end_block (unsigned int, unsigned int);
120 static void sdbout_source_line (unsigned int, const char *, int, bool); 119 static void sdbout_source_line (unsigned int, unsigned int,
120 const char *, int, bool);
121 static void sdbout_end_epilogue (unsigned int, const char *); 121 static void sdbout_end_epilogue (unsigned int, const char *);
122 static void sdbout_global_decl (tree); 122 static void sdbout_early_global_decl (tree);
123 #ifndef MIPS_DEBUGGING_INFO 123 static void sdbout_late_global_decl (tree);
124 static void sdbout_begin_prologue (unsigned int, const char *); 124 static void sdbout_begin_prologue (unsigned int, unsigned int,
125 #endif 125 const char *);
126 static void sdbout_end_prologue (unsigned int, const char *); 126 static void sdbout_end_prologue (unsigned int, const char *);
127 static void sdbout_begin_function (tree); 127 static void sdbout_begin_function (tree);
128 static void sdbout_end_function (unsigned int); 128 static void sdbout_end_function (unsigned int);
129 static void sdbout_toplevel_data (tree); 129 static void sdbout_toplevel_data (tree);
130 static void sdbout_label (rtx); 130 static void sdbout_label (rtx_code_label *);
131 static char *gen_fake_label (void); 131 static char *gen_fake_label (void);
132 static int plain_type (tree); 132 static int plain_type (tree);
133 static int template_name_p (tree); 133 static int template_name_p (tree);
134 static void sdbout_record_type_name (tree); 134 static void sdbout_record_type_name (tree);
135 static int plain_type_1 (tree, int); 135 static int plain_type_1 (tree, int);
142 static void sdbout_type (tree); 142 static void sdbout_type (tree);
143 static void sdbout_field_types (tree); 143 static void sdbout_field_types (tree);
144 static void sdbout_one_type (tree); 144 static void sdbout_one_type (tree);
145 static void sdbout_parms (tree); 145 static void sdbout_parms (tree);
146 static void sdbout_reg_parms (tree); 146 static void sdbout_reg_parms (tree);
147 static void sdbout_global_decl (tree);
148 147
149 /* Random macros describing parts of SDB data. */ 148 /* Random macros describing parts of SDB data. */
150 149
151 /* Default value of delimiter is ";". */ 150 /* Default value of delimiter is ";". */
152 #ifndef SDB_DELIM 151 #ifndef SDB_DELIM
157 #ifndef SDB_MAX_DIM 156 #ifndef SDB_MAX_DIM
158 #define SDB_MAX_DIM 4 157 #define SDB_MAX_DIM 4
159 #endif 158 #endif
160 159
161 #ifndef PUT_SDB_SCL 160 #ifndef PUT_SDB_SCL
162 #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM) 161 #define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM)
163 #endif 162 #endif
164 163
165 #ifndef PUT_SDB_INT_VAL 164 #ifndef PUT_SDB_INT_VAL
166 #define PUT_SDB_INT_VAL(a) \ 165 #define PUT_SDB_INT_VAL(a) \
167 do { \ 166 do { \
184 assemble_name (asm_out_file, a); \ 183 assemble_name (asm_out_file, a); \
185 fprintf (asm_out_file, SDB_DELIM); } while (0) 184 fprintf (asm_out_file, SDB_DELIM); } while (0)
186 #endif 185 #endif
187 186
188 #ifndef PUT_SDB_PLAIN_DEF 187 #ifndef PUT_SDB_PLAIN_DEF
189 #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM) 188 #define PUT_SDB_PLAIN_DEF(a) \
189 fprintf (asm_out_file, "\t.def\t.%s%s", a, SDB_DELIM)
190 #endif 190 #endif
191 191
192 #ifndef PUT_SDB_ENDEF 192 #ifndef PUT_SDB_ENDEF
193 #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file) 193 #define PUT_SDB_ENDEF fputs ("\t.endef\n", asm_out_file)
194 #endif 194 #endif
195 195
196 #ifndef PUT_SDB_TYPE 196 #ifndef PUT_SDB_TYPE
197 #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM) 197 #define PUT_SDB_TYPE(a) fprintf (asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM)
198 #endif 198 #endif
199 199
200 #ifndef PUT_SDB_SIZE 200 #ifndef PUT_SDB_SIZE
201 #define PUT_SDB_SIZE(a) \ 201 #define PUT_SDB_SIZE(a) \
202 do { \ 202 do { \
203 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \ 203 fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \
204 (HOST_WIDE_INT) (a), SDB_DELIM); \ 204 (HOST_WIDE_INT) (a), SDB_DELIM); \
205 } while(0) 205 } while (0)
206 #endif 206 #endif
207 207
208 #ifndef PUT_SDB_START_DIM 208 #ifndef PUT_SDB_START_DIM
209 #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t") 209 #define PUT_SDB_START_DIM fprintf (asm_out_file, "\t.dim\t")
210 #endif 210 #endif
211 211
212 #ifndef PUT_SDB_NEXT_DIM 212 #ifndef PUT_SDB_NEXT_DIM
213 #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a) 213 #define PUT_SDB_NEXT_DIM(a) fprintf (asm_out_file, "%d,", a)
214 #endif 214 #endif
215 215
216 #ifndef PUT_SDB_LAST_DIM 216 #ifndef PUT_SDB_LAST_DIM
217 #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM) 217 #define PUT_SDB_LAST_DIM(a) fprintf (asm_out_file, "%d%s", a, SDB_DELIM)
218 #endif 218 #endif
219 219
220 #ifndef PUT_SDB_TAG 220 #ifndef PUT_SDB_TAG
221 #define PUT_SDB_TAG(a) \ 221 #define PUT_SDB_TAG(a) \
222 do { fprintf (asm_out_file, "\t.tag\t"); \ 222 do { fprintf (asm_out_file, "\t.tag\t"); \
273 /* Ensure we don't output a negative line number. */ 273 /* Ensure we don't output a negative line number. */
274 #define MAKE_LINE_SAFE(line) \ 274 #define MAKE_LINE_SAFE(line) \
275 if ((int) line <= sdb_begin_function_line) \ 275 if ((int) line <= sdb_begin_function_line) \
276 line = sdb_begin_function_line + 1 276 line = sdb_begin_function_line + 1
277 277
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. */
283
284 #ifdef MIPS_DEBUGGING_INFO
285
286 /* ECOFF linkers have an optimization that does the same kind of thing as
287 N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the
288 executable. To achieve this, GCC must output a .file for each file
289 name change. */
290
291 /* This is a stack of input files. */
292
293 struct sdb_file
294 {
295 struct sdb_file *next;
296 const char *name;
297 };
298
299 /* This is the top of the stack. */
300
301 static struct sdb_file *current_file;
302
303 #endif /* MIPS_DEBUGGING_INFO */
304
305 /* The debug hooks structure. */ 278 /* The debug hooks structure. */
306 const struct gcc_debug_hooks sdb_debug_hooks = 279 const struct gcc_debug_hooks sdb_debug_hooks =
307 { 280 {
308 sdbout_init, /* init */ 281 sdbout_init, /* init */
309 sdbout_finish, /* finish */ 282 sdbout_finish, /* finish */
283 debug_nothing_charstar, /* early_finish */
310 debug_nothing_void, /* assembly_start */ 284 debug_nothing_void, /* assembly_start */
311 debug_nothing_int_charstar, /* define */ 285 debug_nothing_int_charstar, /* define */
312 debug_nothing_int_charstar, /* undef */ 286 debug_nothing_int_charstar, /* undef */
313 sdbout_start_source_file, /* start_source_file */ 287 sdbout_start_source_file, /* start_source_file */
314 sdbout_end_source_file, /* end_source_file */ 288 sdbout_end_source_file, /* end_source_file */
315 sdbout_begin_block, /* begin_block */ 289 sdbout_begin_block, /* begin_block */
316 sdbout_end_block, /* end_block */ 290 sdbout_end_block, /* end_block */
317 debug_true_const_tree, /* ignore_block */ 291 debug_true_const_tree, /* ignore_block */
318 sdbout_source_line, /* source_line */ 292 sdbout_source_line, /* source_line */
319 #ifdef MIPS_DEBUGGING_INFO
320 /* Defer on MIPS systems so that parameter descriptions follow
321 function entry. */
322 debug_nothing_int_charstar, /* begin_prologue */
323 sdbout_end_prologue, /* end_prologue */
324 #else
325 sdbout_begin_prologue, /* begin_prologue */ 293 sdbout_begin_prologue, /* begin_prologue */
326 debug_nothing_int_charstar, /* end_prologue */ 294 debug_nothing_int_charstar, /* end_prologue */
327 #endif
328 debug_nothing_int_charstar, /* begin_epilogue */ 295 debug_nothing_int_charstar, /* begin_epilogue */
329 sdbout_end_epilogue, /* end_epilogue */ 296 sdbout_end_epilogue, /* end_epilogue */
330 sdbout_begin_function, /* begin_function */ 297 sdbout_begin_function, /* begin_function */
331 sdbout_end_function, /* end_function */ 298 sdbout_end_function, /* end_function */
299 debug_nothing_tree, /* register_main_translation_unit */
332 debug_nothing_tree, /* function_decl */ 300 debug_nothing_tree, /* function_decl */
333 sdbout_global_decl, /* global_decl */ 301 sdbout_early_global_decl, /* early_global_decl */
302 sdbout_late_global_decl, /* late_global_decl */
334 sdbout_symbol, /* type_decl */ 303 sdbout_symbol, /* type_decl */
335 debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ 304 debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */
305 debug_false_tree_charstarstar_uhwistar,/* die_ref_for_decl */
306 debug_nothing_tree_charstar_uhwi, /* register_external_die */
336 debug_nothing_tree, /* deferred_inline_function */ 307 debug_nothing_tree, /* deferred_inline_function */
337 debug_nothing_tree, /* outlining_inline_function */ 308 debug_nothing_tree, /* outlining_inline_function */
338 sdbout_label, /* label */ 309 sdbout_label, /* label */
339 debug_nothing_int, /* handle_pch */ 310 debug_nothing_int, /* handle_pch */
340 debug_nothing_rtx, /* var_location */ 311 debug_nothing_rtx_insn, /* var_location */
312 debug_nothing_tree, /* size_function */
341 debug_nothing_void, /* switch_text_section */ 313 debug_nothing_void, /* switch_text_section */
342 debug_nothing_tree, /* direct_call */
343 debug_nothing_tree_int, /* virtual_call_token */
344 debug_nothing_rtx_rtx, /* copy_call_info */
345 debug_nothing_uid, /* virtual_call */
346 debug_nothing_tree_tree, /* set_name */ 314 debug_nothing_tree_tree, /* set_name */
347 0, /* start_end_main_source_file */ 315 0, /* start_end_main_source_file */
348 TYPE_SYMTAB_IS_POINTER /* tree_type_symtab_field */ 316 TYPE_SYMTAB_IS_POINTER /* tree_type_symtab_field */
349 }; 317 };
350 318
552 int precision = TYPE_PRECISION (type); 520 int precision = TYPE_PRECISION (type);
553 if (precision == FLOAT_TYPE_SIZE) 521 if (precision == FLOAT_TYPE_SIZE)
554 return T_FLOAT; 522 return T_FLOAT;
555 if (precision == DOUBLE_TYPE_SIZE) 523 if (precision == DOUBLE_TYPE_SIZE)
556 return T_DOUBLE; 524 return T_DOUBLE;
557 #ifdef EXTENDED_SDB_BASIC_TYPES
558 if (precision == LONG_DOUBLE_TYPE_SIZE)
559 return T_LNGDBL;
560 #else
561 if (precision == LONG_DOUBLE_TYPE_SIZE) 525 if (precision == LONG_DOUBLE_TYPE_SIZE)
562 return T_DOUBLE; /* better than nothing */ 526 return T_DOUBLE; /* better than nothing */
563 #endif 527
564 return 0; 528 return 0;
565 } 529 }
566 530
567 case ARRAY_TYPE: 531 case ARRAY_TYPE:
568 { 532 {
574 if (sdb_n_dims < SDB_MAX_DIM) 538 if (sdb_n_dims < SDB_MAX_DIM)
575 sdb_dims[sdb_n_dims++] 539 sdb_dims[sdb_n_dims++]
576 = (TYPE_DOMAIN (type) 540 = (TYPE_DOMAIN (type)
577 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0 541 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
578 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0 542 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
579 && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0) 543 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
580 && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) 544 && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type)))
581 ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0) 545 ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
582 - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1) 546 - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1)
583 : 0); 547 : 0);
584 548
585 return PUSH_DERIVED_LEVEL (DT_ARY, m); 549 return PUSH_DERIVED_LEVEL (DT_ARY, m);
586 } 550 }
587 551
776 if there is no RTL associated with the variable doesn't 740 if there is no RTL associated with the variable doesn't
777 exist. */ 741 exist. */
778 if (!DECL_RTL_SET_P (decl)) 742 if (!DECL_RTL_SET_P (decl))
779 return; 743 return;
780 744
781 SET_DECL_RTL (decl, 745 value = DECL_RTL (decl);
782 eliminate_regs (DECL_RTL (decl), VOIDmode, NULL_RTX)); 746
747 if (!is_global_var (decl))
748 value = eliminate_regs (value, VOIDmode, NULL_RTX);
749
750 SET_DECL_RTL (decl, value);
783 #ifdef LEAF_REG_REMAP 751 #ifdef LEAF_REG_REMAP
784 if (current_function_uses_only_leaf_regs) 752 if (crtl->uses_only_leaf_regs)
785 leaf_renumber_regs_insn (DECL_RTL (decl)); 753 leaf_renumber_regs_insn (value);
786 #endif 754 #endif
787 value = DECL_RTL (decl);
788 755
789 /* Don't mention a variable at all 756 /* Don't mention a variable at all
790 if it was completely optimized into nothingness. 757 if it was completely optimized into nothingness.
791 758
792 If DECL was from an inline function, then its rtl 759 If DECL was from an inline function, then its rtl
805 if (REG_P (value)) 772 if (REG_P (value))
806 { 773 {
807 if (REGNO (value) >= FIRST_PSEUDO_REGISTER) 774 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
808 return; 775 return;
809 } 776 }
810 regno = REGNO (alter_subreg (&value)); 777 regno = REGNO (alter_subreg (&value, true));
811 SET_DECL_RTL (decl, value); 778 SET_DECL_RTL (decl, value);
812 } 779 }
813 /* Don't output anything if an auto variable 780 /* Don't output anything if an auto variable
814 gets RTL that is static. 781 gets RTL that is static.
815 GAS version 2.2 can't handle such output. */ 782 GAS version 2.2 can't handle such output. */
942 tree type = TREE_TYPE (decl); 909 tree type = TREE_TYPE (decl);
943 910
944 if (DECL_IGNORED_P (decl)) 911 if (DECL_IGNORED_P (decl))
945 return; 912 return;
946 913
947 gcc_assert (TREE_CODE (decl) == VAR_DECL); 914 gcc_assert (VAR_P (decl));
948 gcc_assert (MEM_P (DECL_RTL (decl))); 915 gcc_assert (MEM_P (DECL_RTL (decl)));
949 gcc_assert (DECL_INITIAL (decl)); 916 gcc_assert (DECL_INITIAL (decl));
950 917
951 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); 918 PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
952 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0)); 919 PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0));
1033 /* This condition should match the one for emitting the actual 1000 /* This condition should match the one for emitting the actual
1034 members below. */ 1001 members below. */
1035 if (TREE_CODE (tail) == FIELD_DECL 1002 if (TREE_CODE (tail) == FIELD_DECL
1036 && DECL_NAME (tail) 1003 && DECL_NAME (tail)
1037 && DECL_SIZE (tail) 1004 && DECL_SIZE (tail)
1038 && host_integerp (DECL_SIZE (tail), 1) 1005 && tree_fits_uhwi_p (DECL_SIZE (tail))
1039 && host_integerp (bit_position (tail), 0)) 1006 && tree_fits_shwi_p (bit_position (tail)))
1040 { 1007 {
1041 if (POINTER_TYPE_P (TREE_TYPE (tail))) 1008 if (POINTER_TYPE_P (TREE_TYPE (tail)))
1042 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail))); 1009 sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
1043 else 1010 else
1044 sdbout_one_type (TREE_TYPE (tail)); 1011 sdbout_one_type (TREE_TYPE (tail));
1054 1021
1055 static void 1022 static void
1056 sdbout_one_type (tree type) 1023 sdbout_one_type (tree type)
1057 { 1024 {
1058 if (current_function_decl != NULL_TREE 1025 if (current_function_decl != NULL_TREE
1059 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE) 1026 && DECL_SECTION_NAME (current_function_decl) != NULL)
1060 ; /* Don't change section amid function. */ 1027 ; /* Don't change section amid function. */
1061 else 1028 else
1062 switch_to_section (text_section); 1029 switch_to_section (current_function_section ());
1063 1030
1064 switch (TREE_CODE (type)) 1031 switch (TREE_CODE (type))
1065 { 1032 {
1066 case RECORD_TYPE: 1033 case RECORD_TYPE:
1067 case UNION_TYPE: 1034 case UNION_TYPE:
1173 } 1140 }
1174 else 1141 else
1175 continue; 1142 continue;
1176 1143
1177 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name)); 1144 PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
1178 PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0)); 1145 PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child)));
1179 PUT_SDB_SCL (member_scl); 1146 PUT_SDB_SCL (member_scl);
1180 sdbout_type (BINFO_TYPE (child)); 1147 sdbout_type (BINFO_TYPE (child));
1181 PUT_SDB_ENDEF; 1148 PUT_SDB_ENDEF;
1182 } 1149 }
1183 } 1150 }
1191 tree value = TREE_VALUE (tem); 1158 tree value = TREE_VALUE (tem);
1192 1159
1193 if (TREE_CODE (value) == CONST_DECL) 1160 if (TREE_CODE (value) == CONST_DECL)
1194 value = DECL_INITIAL (value); 1161 value = DECL_INITIAL (value);
1195 1162
1196 if (host_integerp (value, 0)) 1163 if (tree_fits_shwi_p (value))
1197 { 1164 {
1198 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem))); 1165 PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1199 PUT_SDB_INT_VAL (tree_low_cst (value, 0)); 1166 PUT_SDB_INT_VAL (tree_to_shwi (value));
1200 PUT_SDB_SCL (C_MOE); 1167 PUT_SDB_SCL (C_MOE);
1201 PUT_SDB_TYPE (T_MOE); 1168 PUT_SDB_TYPE (T_MOE);
1202 PUT_SDB_ENDEF; 1169 PUT_SDB_ENDEF;
1203 } 1170 }
1204 } 1171 }
1212 Also omit fields with variable size or position. 1179 Also omit fields with variable size or position.
1213 Also omit non FIELD_DECL nodes that GNU C++ may put here. */ 1180 Also omit non FIELD_DECL nodes that GNU C++ may put here. */
1214 if (TREE_CODE (tem) == FIELD_DECL 1181 if (TREE_CODE (tem) == FIELD_DECL
1215 && DECL_NAME (tem) 1182 && DECL_NAME (tem)
1216 && DECL_SIZE (tem) 1183 && DECL_SIZE (tem)
1217 && host_integerp (DECL_SIZE (tem), 1) 1184 && tree_fits_uhwi_p (DECL_SIZE (tem))
1218 && host_integerp (bit_position (tem), 0)) 1185 && tree_fits_shwi_p (bit_position (tem)))
1219 { 1186 {
1220 const char *name; 1187 const char *name;
1221 1188
1222 name = IDENTIFIER_POINTER (DECL_NAME (tem)); 1189 name = IDENTIFIER_POINTER (DECL_NAME (tem));
1223 PUT_SDB_DEF (name); 1190 PUT_SDB_DEF (name);
1224 if (DECL_BIT_FIELD_TYPE (tem)) 1191 if (DECL_BIT_FIELD_TYPE (tem))
1225 { 1192 {
1226 PUT_SDB_INT_VAL (int_bit_position (tem)); 1193 PUT_SDB_INT_VAL (int_bit_position (tem));
1227 PUT_SDB_SCL (C_FIELD); 1194 PUT_SDB_SCL (C_FIELD);
1228 sdbout_type (DECL_BIT_FIELD_TYPE (tem)); 1195 sdbout_type (DECL_BIT_FIELD_TYPE (tem));
1229 PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1)); 1196 PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem)));
1230 } 1197 }
1231 else 1198 else
1232 { 1199 {
1233 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT); 1200 PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
1234 PUT_SDB_SCL (member_scl); 1201 PUT_SDB_SCL (member_scl);
1266 1233
1267 static void 1234 static void
1268 sdbout_parms (tree parms) 1235 sdbout_parms (tree parms)
1269 { 1236 {
1270 for (; parms; parms = TREE_CHAIN (parms)) 1237 for (; parms; parms = TREE_CHAIN (parms))
1271 if (DECL_NAME (parms)) 1238 if (DECL_NAME (parms)
1239 && TREE_TYPE (parms) != error_mark_node
1240 && DECL_RTL_SET_P (parms)
1241 && DECL_INCOMING_RTL (parms))
1272 { 1242 {
1273 int current_sym_value = 0; 1243 int current_sym_value = 0;
1274 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); 1244 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1275 1245
1276 if (name == 0 || *name == 0) 1246 if (name == 0 || *name == 0)
1309 double and it is converted to a char, short or float 1279 double and it is converted to a char, short or float
1310 and stored back in the parmlist. In this case, describe 1280 and stored back in the parmlist. In this case, describe
1311 the parm with the variable's declared type, and adjust 1281 the parm with the variable's declared type, and adjust
1312 the address if the least significant bytes (which we are 1282 the address if the least significant bytes (which we are
1313 using) are not the first ones. */ 1283 using) are not the first ones. */
1284 scalar_mode from_mode, to_mode;
1314 if (BYTES_BIG_ENDIAN 1285 if (BYTES_BIG_ENDIAN
1315 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) 1286 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)
1316 current_sym_value += 1287 && is_a <scalar_mode> (TYPE_MODE (DECL_ARG_TYPE (parms)),
1317 (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) 1288 &from_mode)
1318 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); 1289 && is_a <scalar_mode> (GET_MODE (DECL_RTL (parms)),
1290 &to_mode))
1291 current_sym_value += (GET_MODE_SIZE (from_mode)
1292 - GET_MODE_SIZE (to_mode));
1319 1293
1320 if (MEM_P (DECL_RTL (parms)) 1294 if (MEM_P (DECL_RTL (parms))
1321 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS 1295 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
1322 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) 1296 && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1))
1323 == CONST_INT) 1297 == CONST_INT)
1398 1372
1399 static void 1373 static void
1400 sdbout_reg_parms (tree parms) 1374 sdbout_reg_parms (tree parms)
1401 { 1375 {
1402 for (; parms; parms = TREE_CHAIN (parms)) 1376 for (; parms; parms = TREE_CHAIN (parms))
1403 if (DECL_NAME (parms)) 1377 if (DECL_NAME (parms)
1378 && TREE_TYPE (parms) != error_mark_node
1379 && DECL_RTL_SET_P (parms)
1380 && DECL_INCOMING_RTL (parms))
1404 { 1381 {
1405 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); 1382 const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));
1406 1383
1407 /* Report parms that live in registers during the function 1384 /* Report parms that live in registers during the function
1408 but were passed in memory. */ 1385 but were passed in memory. */
1449 } 1426 }
1450 } 1427 }
1451 } 1428 }
1452 } 1429 }
1453 1430
1454 /* Output debug information for a global DECL. Called from toplev.c 1431 /* Output early debug information for a global DECL. Called from
1455 after compilation proper has finished. */ 1432 rest_of_decl_compilation during parsing. */
1456 1433
1457 static void 1434 static void
1458 sdbout_global_decl (tree decl) 1435 sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED)
1459 { 1436 {
1460 if (TREE_CODE (decl) == VAR_DECL 1437 /* NYI for non-dwarf. */
1461 && !DECL_EXTERNAL (decl) 1438 }
1462 && DECL_RTL_SET_P (decl)) 1439
1440 /* Output late debug information for a global DECL after location
1441 information is available. */
1442
1443 static void
1444 sdbout_late_global_decl (tree decl)
1445 {
1446 if (VAR_P (decl) && !DECL_EXTERNAL (decl) && DECL_RTL_SET_P (decl))
1463 { 1447 {
1464 /* The COFF linker can move initialized global vars to the end. 1448 /* The COFF linker can move initialized global vars to the end.
1465 And that can screw up the symbol ordering. Defer those for 1449 And that can screw up the symbol ordering. Defer those for
1466 sdbout_finish (). */ 1450 sdbout_finish (). */
1467 if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl)) 1451 if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
1468 sdbout_symbol (decl, 0); 1452 sdbout_symbol (decl, 0);
1469 else 1453 else
1470 VEC_safe_push (tree, gc, deferred_global_decls, decl); 1454 vec_safe_push (deferred_global_decls, decl);
1471 1455
1472 /* Output COFF information for non-global file-scope initialized 1456 /* Output COFF information for non-global file-scope initialized
1473 variables. */ 1457 variables. */
1474 if (DECL_INITIAL (decl) && MEM_P (DECL_RTL (decl))) 1458 if (DECL_INITIAL (decl) && MEM_P (DECL_RTL (decl)))
1475 sdbout_toplevel_data (decl); 1459 sdbout_toplevel_data (decl);
1483 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED) 1467 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
1484 { 1468 {
1485 size_t i; 1469 size_t i;
1486 tree decl; 1470 tree decl;
1487 1471
1488 FOR_EACH_VEC_ELT (tree, deferred_global_decls, i, decl) 1472 FOR_EACH_VEC_SAFE_ELT (deferred_global_decls, i, decl)
1489 sdbout_symbol (decl, 0); 1473 sdbout_symbol (decl, 0);
1490 } 1474 }
1491 1475
1492 /* Describe the beginning of an internal block within a function. 1476 /* Describe the beginning of an internal block within a function.
1493 Also output descriptions of variables defined in this block. 1477 Also output descriptions of variables defined in this block.
1502 { 1486 {
1503 tree decl = current_function_decl; 1487 tree decl = current_function_decl;
1504 MAKE_LINE_SAFE (line); 1488 MAKE_LINE_SAFE (line);
1505 1489
1506 /* The SCO compiler does not emit a separate block for the function level 1490 /* The SCO compiler does not emit a separate block for the function level
1507 scope, so we avoid it here also. However, mips ECOFF compilers do emit 1491 scope, so we avoid it here also. */
1508 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */ 1492 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1509 #ifndef MIPS_DEBUGGING_INFO
1510 if (n != 1)
1511 #endif
1512 PUT_SDB_BLOCK_START (line - sdb_begin_function_line);
1513 1493
1514 if (n == 1) 1494 if (n == 1)
1515 { 1495 {
1516 /* Include the outermost BLOCK's variables in block 1. */ 1496 /* Include the outermost BLOCK's variables in block 1. */
1517 do_block = BLOCK_NUMBER (DECL_INITIAL (decl)); 1497 do_block = BLOCK_NUMBER (DECL_INITIAL (decl));
1536 sdbout_end_block (unsigned int line, unsigned int n ATTRIBUTE_UNUSED) 1516 sdbout_end_block (unsigned int line, unsigned int n ATTRIBUTE_UNUSED)
1537 { 1517 {
1538 MAKE_LINE_SAFE (line); 1518 MAKE_LINE_SAFE (line);
1539 1519
1540 /* The SCO compiler does not emit a separate block for the function level 1520 /* The SCO compiler does not emit a separate block for the function level
1541 scope, so we avoid it here also. However, mips ECOFF compilers do emit 1521 scope, so we avoid it here also. */
1542 a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */
1543 #ifndef MIPS_DEBUGGING_INFO
1544 if (n != 1) 1522 if (n != 1)
1545 #endif 1523 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1546 PUT_SDB_BLOCK_END (line - sdb_begin_function_line);
1547 } 1524 }
1548 1525
1549 /* Output a line number symbol entry for source file FILENAME and line 1526 /* Output a line number symbol entry for source file FILENAME and line
1550 number LINE. */ 1527 number LINE. */
1551 1528
1552 static void 1529 static void
1553 sdbout_source_line (unsigned int line, const char *filename ATTRIBUTE_UNUSED, 1530 sdbout_source_line (unsigned int line, unsigned int column ATTRIBUTE_UNUSED,
1531 const char *filename ATTRIBUTE_UNUSED,
1554 int discriminator ATTRIBUTE_UNUSED, 1532 int discriminator ATTRIBUTE_UNUSED,
1555 bool is_stmt ATTRIBUTE_UNUSED) 1533 bool is_stmt ATTRIBUTE_UNUSED)
1556 { 1534 {
1557 /* COFF relative line numbers must be positive. */ 1535 /* COFF relative line numbers must be positive. */
1558 if ((int) line > sdb_begin_function_line) 1536 if ((int) line > sdb_begin_function_line)
1574 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED) 1552 sdbout_begin_function (tree decl ATTRIBUTE_UNUSED)
1575 { 1553 {
1576 sdbout_symbol (current_function_decl, 0); 1554 sdbout_symbol (current_function_decl, 0);
1577 } 1555 }
1578 1556
1579 /* Called at beginning of function body (before or after prologue, 1557 /* Called at beginning of function body after prologue. Record the
1580 depending on MIPS_DEBUGGING_INFO). Record the function's starting 1558 function's starting line number, so we can output relative line numbers
1581 line number, so we can output relative line numbers for the other 1559 for the other lines. Describe beginning of outermost block. Also
1582 lines. Describe beginning of outermost block. Also describe the 1560 describe the parameter list. */
1583 parameter list. */ 1561
1584 1562 static void
1585 #ifndef MIPS_DEBUGGING_INFO 1563 sdbout_begin_prologue (unsigned int line, unsigned int column ATTRIBUTE_UNUSED,
1586 static void 1564 const char *file ATTRIBUTE_UNUSED)
1587 sdbout_begin_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1588 { 1565 {
1589 sdbout_end_prologue (line, file); 1566 sdbout_end_prologue (line, file);
1590 } 1567 }
1591 #endif
1592 1568
1593 static void 1569 static void
1594 sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED) 1570 sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED)
1595 { 1571 {
1596 sdb_begin_function_line = line - 1; 1572 sdb_begin_function_line = line - 1;
1638 1614
1639 /* Output sdb info for the given label. Called only if LABEL_NAME (insn) 1615 /* Output sdb info for the given label. Called only if LABEL_NAME (insn)
1640 is present. */ 1616 is present. */
1641 1617
1642 static void 1618 static void
1643 sdbout_label (rtx insn) 1619 sdbout_label (rtx_code_label *insn)
1644 { 1620 {
1645 PUT_SDB_DEF (LABEL_NAME (insn)); 1621 PUT_SDB_DEF (LABEL_NAME (insn));
1646 PUT_SDB_VAL (insn); 1622 PUT_SDB_VAL (insn);
1647 PUT_SDB_SCL (C_LABEL); 1623 PUT_SDB_SCL (C_LABEL);
1648 PUT_SDB_TYPE (T_NULL); 1624 PUT_SDB_TYPE (T_NULL);
1653 1629
1654 static void 1630 static void
1655 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED, 1631 sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
1656 const char *filename ATTRIBUTE_UNUSED) 1632 const char *filename ATTRIBUTE_UNUSED)
1657 { 1633 {
1658 #ifdef MIPS_DEBUGGING_INFO
1659 struct sdb_file *n = XNEW (struct sdb_file);
1660
1661 n->next = current_file;
1662 n->name = filename;
1663 current_file = n;
1664 output_file_directive (asm_out_file, filename);
1665 #endif
1666 } 1634 }
1667 1635
1668 /* Revert to reading a previous source file. */ 1636 /* Revert to reading a previous source file. */
1669 1637
1670 static void 1638 static void
1671 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED) 1639 sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
1672 { 1640 {
1673 #ifdef MIPS_DEBUGGING_INFO
1674 struct sdb_file *next;
1675
1676 next = current_file->next;
1677 free (current_file);
1678 current_file = next;
1679 output_file_directive (asm_out_file, current_file->name);
1680 #endif
1681 } 1641 }
1682 1642
1683 /* Set up for SDB output at the start of compilation. */ 1643 /* Set up for SDB output at the start of compilation. */
1684 1644
1685 static void 1645 static void
1686 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED) 1646 sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED)
1687 { 1647 {
1688 tree t; 1648 tree t;
1689 1649
1690 #ifdef MIPS_DEBUGGING_INFO 1650 vec_alloc (deferred_global_decls, 12);
1691 current_file = XNEW (struct sdb_file);
1692 current_file->next = NULL;
1693 current_file->name = input_file_name;
1694 #endif
1695
1696 deferred_global_decls = VEC_alloc (tree, gc, 12);
1697 1651
1698 /* Emit debug information which was queued by sdbout_symbol before 1652 /* Emit debug information which was queued by sdbout_symbol before
1699 we got here. */ 1653 we got here. */
1700 sdbout_initialized = true; 1654 sdbout_initialized = true;
1701 1655
1702 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t)) 1656 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
1703 sdbout_symbol (TREE_VALUE (t), 0); 1657 sdbout_symbol (TREE_VALUE (t), 0);
1704 preinit_symbols = 0; 1658 preinit_symbols = 0;
1705 } 1659 }
1706 1660
1707 #endif /* SDB_DEBUGGING_INFO */
1708
1709 #include "gt-sdbout.h" 1661 #include "gt-sdbout.h"