Mercurial > hg > CbC > CbC_gcc
diff gcc/sdbout.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children |
line wrap: on
line diff
--- a/gcc/sdbout.c Sun Aug 21 07:07:55 2011 +0900 +++ b/gcc/sdbout.c Fri Oct 27 22:46:09 2017 +0900 @@ -1,7 +1,5 @@ /* Output sdb-format symbol table information from GNU compiler. - Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1988-2017 Free Software Foundation, Inc. This file is part of GCC. @@ -44,11 +42,12 @@ #include "config.h" #include "system.h" #include "coretypes.h" +#include "gsyms.h" #include "tm.h" #include "debug.h" #include "tree.h" -#include "ggc.h" -#include "vec.h" +#include "varasm.h" +#include "stor-layout.h" static GTY(()) tree anonymous_types; @@ -58,7 +57,7 @@ /* Declarations whose debug info was deferred till end of compilation. */ -static GTY(()) VEC(tree,gc) *deferred_global_decls; +static GTY(()) vec<tree, va_gc> *deferred_global_decls; /* The C front end may call sdbout_symbol before sdbout_init runs. We save all such decls in this list and output them when we get @@ -67,17 +66,17 @@ static GTY(()) tree preinit_symbols; static GTY(()) bool sdbout_initialized; -#ifdef SDB_DEBUGGING_INFO - #include "rtl.h" #include "regs.h" +#include "function.h" +#include "memmodel.h" +#include "emit-rtl.h" #include "flags.h" #include "insn-config.h" #include "reload.h" #include "output.h" #include "diagnostic-core.h" #include "tm_p.h" -#include "gsyms.h" #include "langhooks.h" #include "target.h" @@ -117,17 +116,18 @@ static void sdbout_end_source_file (unsigned int); static void sdbout_begin_block (unsigned int, unsigned int); static void sdbout_end_block (unsigned int, unsigned int); -static void sdbout_source_line (unsigned int, const char *, int, bool); +static void sdbout_source_line (unsigned int, unsigned int, + const char *, int, bool); static void sdbout_end_epilogue (unsigned int, const char *); -static void sdbout_global_decl (tree); -#ifndef MIPS_DEBUGGING_INFO -static void sdbout_begin_prologue (unsigned int, const char *); -#endif +static void sdbout_early_global_decl (tree); +static void sdbout_late_global_decl (tree); +static void sdbout_begin_prologue (unsigned int, unsigned int, + const char *); static void sdbout_end_prologue (unsigned int, const char *); static void sdbout_begin_function (tree); static void sdbout_end_function (unsigned int); static void sdbout_toplevel_data (tree); -static void sdbout_label (rtx); +static void sdbout_label (rtx_code_label *); static char *gen_fake_label (void); static int plain_type (tree); static int template_name_p (tree); @@ -144,7 +144,6 @@ static void sdbout_one_type (tree); static void sdbout_parms (tree); static void sdbout_reg_parms (tree); -static void sdbout_global_decl (tree); /* Random macros describing parts of SDB data. */ @@ -159,7 +158,7 @@ #endif #ifndef PUT_SDB_SCL -#define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM) +#define PUT_SDB_SCL(a) fprintf (asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM) #endif #ifndef PUT_SDB_INT_VAL @@ -186,15 +185,16 @@ #endif #ifndef PUT_SDB_PLAIN_DEF -#define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM) +#define PUT_SDB_PLAIN_DEF(a) \ + fprintf (asm_out_file, "\t.def\t.%s%s", a, SDB_DELIM) #endif #ifndef PUT_SDB_ENDEF -#define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file) +#define PUT_SDB_ENDEF fputs ("\t.endef\n", asm_out_file) #endif #ifndef PUT_SDB_TYPE -#define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM) +#define PUT_SDB_TYPE(a) fprintf (asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM) #endif #ifndef PUT_SDB_SIZE @@ -202,19 +202,19 @@ do { \ fprintf (asm_out_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC "%s", \ (HOST_WIDE_INT) (a), SDB_DELIM); \ - } while(0) + } while (0) #endif #ifndef PUT_SDB_START_DIM -#define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t") +#define PUT_SDB_START_DIM fprintf (asm_out_file, "\t.dim\t") #endif #ifndef PUT_SDB_NEXT_DIM -#define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a) +#define PUT_SDB_NEXT_DIM(a) fprintf (asm_out_file, "%d,", a) #endif #ifndef PUT_SDB_LAST_DIM -#define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM) +#define PUT_SDB_LAST_DIM(a) fprintf (asm_out_file, "%d%s", a, SDB_DELIM) #endif #ifndef PUT_SDB_TAG @@ -275,38 +275,12 @@ if ((int) line <= sdb_begin_function_line) \ line = sdb_begin_function_line + 1 -/* Perform linker optimization of merging header file definitions together - for targets with MIPS_DEBUGGING_INFO defined. This won't work without a - post 960826 version of GAS. Nothing breaks with earlier versions of GAS, - the optimization just won't be done. The native assembler already has the - necessary support. */ - -#ifdef MIPS_DEBUGGING_INFO - -/* ECOFF linkers have an optimization that does the same kind of thing as - N_BINCL/E_INCL in stabs: eliminate duplicate debug information in the - executable. To achieve this, GCC must output a .file for each file - name change. */ - -/* This is a stack of input files. */ - -struct sdb_file -{ - struct sdb_file *next; - const char *name; -}; - -/* This is the top of the stack. */ - -static struct sdb_file *current_file; - -#endif /* MIPS_DEBUGGING_INFO */ - /* The debug hooks structure. */ const struct gcc_debug_hooks sdb_debug_hooks = { sdbout_init, /* init */ sdbout_finish, /* finish */ + debug_nothing_charstar, /* early_finish */ debug_nothing_void, /* assembly_start */ debug_nothing_int_charstar, /* define */ debug_nothing_int_charstar, /* undef */ @@ -316,33 +290,27 @@ sdbout_end_block, /* end_block */ debug_true_const_tree, /* ignore_block */ sdbout_source_line, /* source_line */ -#ifdef MIPS_DEBUGGING_INFO - /* Defer on MIPS systems so that parameter descriptions follow - function entry. */ - debug_nothing_int_charstar, /* begin_prologue */ - sdbout_end_prologue, /* end_prologue */ -#else sdbout_begin_prologue, /* begin_prologue */ debug_nothing_int_charstar, /* end_prologue */ -#endif debug_nothing_int_charstar, /* begin_epilogue */ sdbout_end_epilogue, /* end_epilogue */ sdbout_begin_function, /* begin_function */ sdbout_end_function, /* end_function */ + debug_nothing_tree, /* register_main_translation_unit */ debug_nothing_tree, /* function_decl */ - sdbout_global_decl, /* global_decl */ + sdbout_early_global_decl, /* early_global_decl */ + sdbout_late_global_decl, /* late_global_decl */ sdbout_symbol, /* type_decl */ - debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */ + debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */ + debug_false_tree_charstarstar_uhwistar,/* die_ref_for_decl */ + debug_nothing_tree_charstar_uhwi, /* register_external_die */ debug_nothing_tree, /* deferred_inline_function */ debug_nothing_tree, /* outlining_inline_function */ sdbout_label, /* label */ debug_nothing_int, /* handle_pch */ - debug_nothing_rtx, /* var_location */ + debug_nothing_rtx_insn, /* var_location */ + debug_nothing_tree, /* size_function */ debug_nothing_void, /* switch_text_section */ - debug_nothing_tree, /* direct_call */ - debug_nothing_tree_int, /* virtual_call_token */ - debug_nothing_rtx_rtx, /* copy_call_info */ - debug_nothing_uid, /* virtual_call */ debug_nothing_tree_tree, /* set_name */ 0, /* start_end_main_source_file */ TYPE_SYMTAB_IS_POINTER /* tree_type_symtab_field */ @@ -554,13 +522,9 @@ return T_FLOAT; if (precision == DOUBLE_TYPE_SIZE) return T_DOUBLE; -#ifdef EXTENDED_SDB_BASIC_TYPES - if (precision == LONG_DOUBLE_TYPE_SIZE) - return T_LNGDBL; -#else if (precision == LONG_DOUBLE_TYPE_SIZE) return T_DOUBLE; /* better than nothing */ -#endif + return 0; } @@ -576,10 +540,10 @@ = (TYPE_DOMAIN (type) && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0 - && host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0) - && host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) - ? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0) - - tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1) + && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) + && tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + ? (tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) + - tree_to_shwi (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1) : 0); return PUSH_DERIVED_LEVEL (DT_ARY, m); @@ -778,13 +742,16 @@ if (!DECL_RTL_SET_P (decl)) return; - SET_DECL_RTL (decl, - eliminate_regs (DECL_RTL (decl), VOIDmode, NULL_RTX)); + value = DECL_RTL (decl); + + if (!is_global_var (decl)) + value = eliminate_regs (value, VOIDmode, NULL_RTX); + + SET_DECL_RTL (decl, value); #ifdef LEAF_REG_REMAP - if (current_function_uses_only_leaf_regs) - leaf_renumber_regs_insn (DECL_RTL (decl)); + if (crtl->uses_only_leaf_regs) + leaf_renumber_regs_insn (value); #endif - value = DECL_RTL (decl); /* Don't mention a variable at all if it was completely optimized into nothingness. @@ -807,7 +774,7 @@ if (REGNO (value) >= FIRST_PSEUDO_REGISTER) return; } - regno = REGNO (alter_subreg (&value)); + regno = REGNO (alter_subreg (&value, true)); SET_DECL_RTL (decl, value); } /* Don't output anything if an auto variable @@ -944,7 +911,7 @@ if (DECL_IGNORED_P (decl)) return; - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); gcc_assert (MEM_P (DECL_RTL (decl))); gcc_assert (DECL_INITIAL (decl)); @@ -1035,8 +1002,8 @@ if (TREE_CODE (tail) == FIELD_DECL && DECL_NAME (tail) && DECL_SIZE (tail) - && host_integerp (DECL_SIZE (tail), 1) - && host_integerp (bit_position (tail), 0)) + && tree_fits_uhwi_p (DECL_SIZE (tail)) + && tree_fits_shwi_p (bit_position (tail))) { if (POINTER_TYPE_P (TREE_TYPE (tail))) sdbout_one_type (TREE_TYPE (TREE_TYPE (tail))); @@ -1056,10 +1023,10 @@ sdbout_one_type (tree type) { if (current_function_decl != NULL_TREE - && DECL_SECTION_NAME (current_function_decl) != NULL_TREE) + && DECL_SECTION_NAME (current_function_decl) != NULL) ; /* Don't change section amid function. */ else - switch_to_section (text_section); + switch_to_section (current_function_section ()); switch (TREE_CODE (type)) { @@ -1175,7 +1142,7 @@ continue; PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name)); - PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0)); + PUT_SDB_INT_VAL (tree_to_shwi (BINFO_OFFSET (child))); PUT_SDB_SCL (member_scl); sdbout_type (BINFO_TYPE (child)); PUT_SDB_ENDEF; @@ -1193,10 +1160,10 @@ if (TREE_CODE (value) == CONST_DECL) value = DECL_INITIAL (value); - if (host_integerp (value, 0)) + if (tree_fits_shwi_p (value)) { PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem))); - PUT_SDB_INT_VAL (tree_low_cst (value, 0)); + PUT_SDB_INT_VAL (tree_to_shwi (value)); PUT_SDB_SCL (C_MOE); PUT_SDB_TYPE (T_MOE); PUT_SDB_ENDEF; @@ -1214,8 +1181,8 @@ if (TREE_CODE (tem) == FIELD_DECL && DECL_NAME (tem) && DECL_SIZE (tem) - && host_integerp (DECL_SIZE (tem), 1) - && host_integerp (bit_position (tem), 0)) + && tree_fits_uhwi_p (DECL_SIZE (tem)) + && tree_fits_shwi_p (bit_position (tem))) { const char *name; @@ -1226,7 +1193,7 @@ PUT_SDB_INT_VAL (int_bit_position (tem)); PUT_SDB_SCL (C_FIELD); sdbout_type (DECL_BIT_FIELD_TYPE (tem)); - PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1)); + PUT_SDB_SIZE (tree_to_uhwi (DECL_SIZE (tem))); } else { @@ -1268,7 +1235,10 @@ sdbout_parms (tree parms) { for (; parms; parms = TREE_CHAIN (parms)) - if (DECL_NAME (parms)) + if (DECL_NAME (parms) + && TREE_TYPE (parms) != error_mark_node + && DECL_RTL_SET_P (parms) + && DECL_INCOMING_RTL (parms)) { int current_sym_value = 0; const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); @@ -1311,11 +1281,15 @@ the parm with the variable's declared type, and adjust the address if the least significant bytes (which we are using) are not the first ones. */ + scalar_mode from_mode, to_mode; if (BYTES_BIG_ENDIAN - && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) - current_sym_value += - (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms) + && is_a <scalar_mode> (TYPE_MODE (DECL_ARG_TYPE (parms)), + &from_mode) + && is_a <scalar_mode> (GET_MODE (DECL_RTL (parms)), + &to_mode)) + current_sym_value += (GET_MODE_SIZE (from_mode) + - GET_MODE_SIZE (to_mode)); if (MEM_P (DECL_RTL (parms)) && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS @@ -1400,7 +1374,10 @@ sdbout_reg_parms (tree parms) { for (; parms; parms = TREE_CHAIN (parms)) - if (DECL_NAME (parms)) + if (DECL_NAME (parms) + && TREE_TYPE (parms) != error_mark_node + && DECL_RTL_SET_P (parms) + && DECL_INCOMING_RTL (parms)) { const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); @@ -1451,15 +1428,22 @@ } } -/* Output debug information for a global DECL. Called from toplev.c - after compilation proper has finished. */ +/* Output early debug information for a global DECL. Called from + rest_of_decl_compilation during parsing. */ static void -sdbout_global_decl (tree decl) +sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED) { - if (TREE_CODE (decl) == VAR_DECL - && !DECL_EXTERNAL (decl) - && DECL_RTL_SET_P (decl)) + /* NYI for non-dwarf. */ +} + +/* Output late debug information for a global DECL after location + information is available. */ + +static void +sdbout_late_global_decl (tree decl) +{ + if (VAR_P (decl) && !DECL_EXTERNAL (decl) && DECL_RTL_SET_P (decl)) { /* The COFF linker can move initialized global vars to the end. And that can screw up the symbol ordering. Defer those for @@ -1467,7 +1451,7 @@ if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl)) sdbout_symbol (decl, 0); else - VEC_safe_push (tree, gc, deferred_global_decls, decl); + vec_safe_push (deferred_global_decls, decl); /* Output COFF information for non-global file-scope initialized variables. */ @@ -1485,7 +1469,7 @@ size_t i; tree decl; - FOR_EACH_VEC_ELT (tree, deferred_global_decls, i, decl) + FOR_EACH_VEC_SAFE_ELT (deferred_global_decls, i, decl) sdbout_symbol (decl, 0); } @@ -1504,12 +1488,8 @@ MAKE_LINE_SAFE (line); /* The SCO compiler does not emit a separate block for the function level - scope, so we avoid it here also. However, mips ECOFF compilers do emit - a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */ -#ifndef MIPS_DEBUGGING_INFO - if (n != 1) -#endif - PUT_SDB_BLOCK_START (line - sdb_begin_function_line); + scope, so we avoid it here also. */ + PUT_SDB_BLOCK_START (line - sdb_begin_function_line); if (n == 1) { @@ -1538,19 +1518,17 @@ MAKE_LINE_SAFE (line); /* The SCO compiler does not emit a separate block for the function level - scope, so we avoid it here also. However, mips ECOFF compilers do emit - a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */ -#ifndef MIPS_DEBUGGING_INFO + scope, so we avoid it here also. */ if (n != 1) -#endif - PUT_SDB_BLOCK_END (line - sdb_begin_function_line); + PUT_SDB_BLOCK_END (line - sdb_begin_function_line); } /* Output a line number symbol entry for source file FILENAME and line number LINE. */ static void -sdbout_source_line (unsigned int line, const char *filename ATTRIBUTE_UNUSED, +sdbout_source_line (unsigned int line, unsigned int column ATTRIBUTE_UNUSED, + const char *filename ATTRIBUTE_UNUSED, int discriminator ATTRIBUTE_UNUSED, bool is_stmt ATTRIBUTE_UNUSED) { @@ -1576,19 +1554,17 @@ sdbout_symbol (current_function_decl, 0); } -/* Called at beginning of function body (before or after prologue, - depending on MIPS_DEBUGGING_INFO). Record the function's starting - line number, so we can output relative line numbers for the other - lines. Describe beginning of outermost block. Also describe the - parameter list. */ +/* Called at beginning of function body after prologue. Record the + function's starting line number, so we can output relative line numbers + for the other lines. Describe beginning of outermost block. Also + describe the parameter list. */ -#ifndef MIPS_DEBUGGING_INFO static void -sdbout_begin_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED) +sdbout_begin_prologue (unsigned int line, unsigned int column ATTRIBUTE_UNUSED, + const char *file ATTRIBUTE_UNUSED) { sdbout_end_prologue (line, file); } -#endif static void sdbout_end_prologue (unsigned int line, const char *file ATTRIBUTE_UNUSED) @@ -1640,7 +1616,7 @@ is present. */ static void -sdbout_label (rtx insn) +sdbout_label (rtx_code_label *insn) { PUT_SDB_DEF (LABEL_NAME (insn)); PUT_SDB_VAL (insn); @@ -1655,14 +1631,6 @@ sdbout_start_source_file (unsigned int line ATTRIBUTE_UNUSED, const char *filename ATTRIBUTE_UNUSED) { -#ifdef MIPS_DEBUGGING_INFO - struct sdb_file *n = XNEW (struct sdb_file); - - n->next = current_file; - n->name = filename; - current_file = n; - output_file_directive (asm_out_file, filename); -#endif } /* Revert to reading a previous source file. */ @@ -1670,14 +1638,6 @@ static void sdbout_end_source_file (unsigned int line ATTRIBUTE_UNUSED) { -#ifdef MIPS_DEBUGGING_INFO - struct sdb_file *next; - - next = current_file->next; - free (current_file); - current_file = next; - output_file_directive (asm_out_file, current_file->name); -#endif } /* Set up for SDB output at the start of compilation. */ @@ -1687,13 +1647,7 @@ { tree t; -#ifdef MIPS_DEBUGGING_INFO - current_file = XNEW (struct sdb_file); - current_file->next = NULL; - current_file->name = input_file_name; -#endif - - deferred_global_decls = VEC_alloc (tree, gc, 12); + vec_alloc (deferred_global_decls, 12); /* Emit debug information which was queued by sdbout_symbol before we got here. */ @@ -1704,6 +1658,4 @@ preinit_symbols = 0; } -#endif /* SDB_DEBUGGING_INFO */ - #include "gt-sdbout.h"