OSDN Git Service

* gcc.dg/const-elim-1.c: Remove xfail for xtensa-*-*.
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
index a8486f5..c4cae3f 100644 (file)
@@ -1,6 +1,6 @@
 /* Output dbx-format symbol table information from GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -241,13 +241,6 @@ static GTY(()) int scope_labelno;
 
 static GTY(()) int dbxout_source_line_counter;
 
-/* Nonzero if we have actually used any of the GDB extensions
-   to the debugging format.  The idea is that we use them for the
-   first time only if there's a strong reason, but once we have done that,
-   we use them whenever convenient.  */
-
-static GTY(()) int have_used_extensions = 0;
-
 /* Number for the next N_SOL filename stabs label.  The number 0 is reserved
    for the N_SO filename stabs label.  */
 
@@ -275,7 +268,7 @@ static int pending_bincls = 0;
 static const char *base_input_file;
 
 #ifdef DEBUG_SYMS_TEXT
-#define FORCE_TEXT function_section (current_function_decl);
+#define FORCE_TEXT current_function_section (current_function_decl);
 #else
 #define FORCE_TEXT
 #endif
@@ -343,7 +336,7 @@ static void dbxout_handle_pch (unsigned);
 static void dbxout_source_line (unsigned int, const char *);
 static void dbxout_begin_prologue (unsigned int, const char *);
 static void dbxout_source_file (const char *);
-static void dbxout_function_end (void);
+static void dbxout_function_end (tree);
 static void dbxout_begin_function (tree);
 static void dbxout_begin_block (unsigned, unsigned);
 static void dbxout_end_block (unsigned, unsigned);
@@ -378,7 +371,9 @@ const struct gcc_debug_hooks dbx_debug_hooks =
   debug_nothing_tree,                   /* outlining_inline_function */
   debug_nothing_rtx,                    /* label */
   dbxout_handle_pch,                    /* handle_pch */
-  debug_nothing_rtx                     /* var_location */
+  debug_nothing_rtx,                    /* var_location */
+  debug_nothing_void,                    /* switch_text_section */
+  0                                      /* start_end_main_source_file */
 };
 #endif /* DBX_DEBUGGING_INFO  */
 
@@ -408,7 +403,9 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
   debug_nothing_tree,                   /* outlining_inline_function */
   debug_nothing_rtx,                    /* label */
   dbxout_handle_pch,                    /* handle_pch */
-  debug_nothing_rtx                     /* var_location */
+  debug_nothing_rtx,                    /* var_location */
+  debug_nothing_void,                    /* switch_text_section */
+  0                                      /* start_end_main_source_file */
 };
 #endif /* XCOFF_DEBUGGING_INFO  */
 \f
@@ -619,6 +616,16 @@ dbxout_begin_complex_stabs (void)
   gcc_assert (stabstr_last_contin_point == 0);
 }
 
+/* As above, but do not force text or emit pending bincls.  This is
+   used by dbxout_symbol_location, which needs to do something else.  */
+static void
+dbxout_begin_complex_stabs_noforcetext (void)
+{
+  fputs (ASM_STABS_OP, asm_out_file);
+  putc ('"', asm_out_file);
+  gcc_assert (stabstr_last_contin_point == 0);
+}
+
 /* Add CHR, a single character, to the string being built.  */
 #define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
 
@@ -786,7 +793,7 @@ stabstr_continue (void)
    all of the arguments to the .stabs directive after the string.
    Overridden by xcoffout.h.  CODE is the stabs code for this symbol;
    LINE is the source line to write into the desc field (in extended
-   mode).
+   mode); SYM is the symbol itself.
 
    ADDR, LABEL, and NUMBER are three different ways to represent the
    stabs value field.  At most one of these should be nonzero.
@@ -802,7 +809,8 @@ stabstr_continue (void)
      register variable).  It represents the value as a decimal integer.  */
 
 #ifndef DBX_FINISH_STABS
-#define DBX_FINISH_STABS(CODE, LINE, ADDR, LABEL, NUMBER) do { \
+#define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
+do {                                                           \
   int line_ = use_gnu_debug_info_extensions ? LINE : 0;                \
                                                                \
   dbxout_int (CODE);                                           \
@@ -864,7 +872,8 @@ dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
          len   -= chunklen + 1;
 
          /* Only put a line number on the last stab in the sequence.  */
-         DBX_FINISH_STABS (code, len == 0 ? line : 0, addr, label, number);
+         DBX_FINISH_STABS (sym, code, len == 0 ? line : 0,
+                           addr, label, number);
          if (len == 0)
            break;
 
@@ -883,7 +892,7 @@ dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
       str = obstack_finish (&stabstr_ob);
       
       fwrite (str, 1, len, asm_out_file);
-      DBX_FINISH_STABS (code, line, addr, label, number);
+      DBX_FINISH_STABS (sym, code, line, addr, label, number);
     }
   obstack_free (&stabstr_ob, str);
 }
@@ -891,7 +900,7 @@ dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
 #if defined (DBX_DEBUGGING_INFO)
 
 static void
-dbxout_function_end (void)
+dbxout_function_end (tree decl)
 {
   char lscope_label_name[100];
 
@@ -911,7 +920,8 @@ dbxout_function_end (void)
      named sections.  */
   if (!use_gnu_debug_info_extensions
       || NO_DBX_FUNCTION_END
-      || !targetm.have_named_sections)
+      || !targetm.have_named_sections
+      || DECL_IGNORED_P (decl))
     return;
 
   /* By convention, GCC will mark the end of a function with an N_FUN
@@ -919,9 +929,22 @@ dbxout_function_end (void)
 #ifdef DBX_OUTPUT_NFUN
   DBX_OUTPUT_NFUN (asm_out_file, lscope_label_name, current_function_decl);
 #else
-  dbxout_begin_empty_stabs (N_FUN);
-  dbxout_stab_value_label_diff (lscope_label_name,
-                               XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
+  if (flag_reorder_blocks_and_partition)
+    {
+      dbxout_begin_empty_stabs (N_FUN);
+      dbxout_stab_value_label_diff (cfun->hot_section_end_label, 
+                                   cfun->hot_section_label);
+      dbxout_begin_empty_stabs (N_FUN);
+      dbxout_stab_value_label_diff (cfun->cold_section_end_label, 
+                                   cfun->cold_section_label);
+    }
+  else
+    {
+      dbxout_begin_empty_stabs (N_FUN);
+      dbxout_stab_value_label_diff (lscope_label_name,
+                                   XSTR (XEXP (DECL_RTL (current_function_decl), 
+                                               0), 0));
+    }
                                
 #endif
 
@@ -1234,8 +1257,6 @@ dbxout_begin_prologue (unsigned int lineno, const char *filename)
 static void
 dbxout_source_line (unsigned int lineno, const char *filename)
 {
-  const char *begin_label = XSTR(XEXP(DECL_RTL(current_function_decl), 0), 0);
-
   dbxout_source_file (filename);
 
 #ifdef DBX_OUTPUT_SOURCE_LINE
@@ -1243,9 +1264,10 @@ dbxout_source_line (unsigned int lineno, const char *filename)
 #else
   if (DBX_LINES_FUNCTION_RELATIVE)
     {
+      rtx begin_label = XEXP (DECL_RTL (current_function_decl), 0);
       dbxout_begin_stabn_sline (lineno);
       dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter,
-                                            begin_label);
+                                            XSTR (begin_label, 0));
 
     }
   else
@@ -1285,7 +1307,7 @@ dbxout_function_decl (tree decl)
   dbxout_begin_function (decl);
 #endif
   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
-  dbxout_function_end ();
+  dbxout_function_end (decl);
 }
 
 #endif /* DBX_DEBUGGING_INFO  */
@@ -1376,14 +1398,14 @@ dbxout_type_fields (tree type)
 
       /* Omit here local type decls until we know how to support them.  */
       if (TREE_CODE (tem) == TYPE_DECL
+         /* Omit here the nameless fields that are used to skip bits.  */
+         || DECL_IGNORED_P (tem)
          /* Omit fields whose position or size are variable or too large to
             represent.  */
          || (TREE_CODE (tem) == FIELD_DECL
              && (! host_integerp (bit_position (tem), 0)
                  || ! DECL_SIZE (tem)
-                 || ! host_integerp (DECL_SIZE (tem), 1)))
-         /* Omit here the nameless fields that are used to skip bits.  */
-          || DECL_IGNORED_P (tem))
+                 || ! host_integerp (DECL_SIZE (tem), 1))))
        continue;
 
       else if (TREE_CODE (tem) != CONST_DECL)
@@ -1401,7 +1423,6 @@ dbxout_type_fields (tree type)
              && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
                  || TREE_CODE (tem) != FIELD_DECL))
            {
-             have_used_extensions = 1;
              stabstr_C ('/');
              stabstr_C (DECL_ACCESSIBILITY_CHAR (tem));
            }
@@ -1416,7 +1437,6 @@ dbxout_type_fields (tree type)
                {
                  tree name = DECL_ASSEMBLER_NAME (tem);
 
-                 have_used_extensions = 1;
                  stabstr_C (':');
                  stabstr_I (name);
                  stabstr_C (';');
@@ -1624,11 +1644,15 @@ dbxout_type (tree type, int full)
   tree tem;
   tree main_variant;
   static int anonymous_type_number = 0;
+  bool vector_type = false;
 
   if (TREE_CODE (type) == VECTOR_TYPE)
-    /* The frontend feeds us a representation for the vector as a struct
-       containing an array.  Pull out the array type.  */
-    type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
+    {
+      /* The frontend feeds us a representation for the vector as a struct
+        containing an array.  Pull out the array type.  */
+      type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
+      vector_type = true;
+    }
 
   /* If there was an input error and we don't really have a type,
      avoid crashing and write something that is at least valid
@@ -1827,7 +1851,6 @@ dbxout_type (tree type, int full)
          if (use_gnu_debug_info_extensions
              && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
            {
-             have_used_extensions = 1;
              stabstr_S ("@s");
              stabstr_D (TYPE_PRECISION (type));
              stabstr_C (';');
@@ -1844,7 +1867,6 @@ dbxout_type (tree type, int full)
          if (use_gnu_debug_info_extensions
              && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
            {
-             have_used_extensions = 1;
              stabstr_S ("@s");
              stabstr_D (TYPE_PRECISION (type));
              stabstr_C (';');
@@ -1891,7 +1913,6 @@ dbxout_type (tree type, int full)
     case CHAR_TYPE:
       if (use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_S ("@s");
          stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
          stabstr_S (";-20;");
@@ -1909,7 +1930,6 @@ dbxout_type (tree type, int full)
     case BOOLEAN_TYPE:
       if (use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_S ("@s");
          stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
          stabstr_S (";-16;");
@@ -1918,11 +1938,6 @@ dbxout_type (tree type, int full)
        stabstr_S ("eFalse:0,True:1,;");
       break;
 
-    case FILE_TYPE:
-      stabstr_C ('d');
-      dbxout_type (TREE_TYPE (type), 0);
-      break;
-
     case COMPLEX_TYPE:
       /* Differs from the REAL_TYPE by its new data type number.
         R3 is NF_COMPLEX.  We don't try to use any of the other NF_*
@@ -1956,28 +1971,10 @@ dbxout_type (tree type, int full)
        }
       break;
 
-    case SET_TYPE:
-      if (use_gnu_debug_info_extensions)
-       {
-         have_used_extensions = 1;
-         stabstr_S ("@s");
-         stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
-         stabstr_C (';');
-
-         /* Check if a bitstring type, which in Chill is
-            different from a [power]set.  */
-         if (TYPE_STRING_FLAG (type))
-           stabstr_S ("@S;");
-       }
-      stabstr_C ('S');
-      dbxout_type (TYPE_DOMAIN (type), 0);
-      break;
-
     case ARRAY_TYPE:
       /* Make arrays of packed bits look like bitstrings for chill.  */
       if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_S ("@s");
          stabstr_D (BITS_PER_UNIT * int_size_in_bytes (type));
          stabstr_S (";@S;S");
@@ -1985,6 +1982,9 @@ dbxout_type (tree type, int full)
          break;
        }
 
+      if (use_gnu_debug_info_extensions && vector_type)
+       stabstr_S ("@V;");
+
       /* Output "a" followed by a range type definition
         for the index type of the array
         followed by a reference to the target-type.
@@ -1993,7 +1993,6 @@ dbxout_type (tree type, int full)
         different from an array of characters.  */
       if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_S ("@S;");
        }
       tem = TYPE_DOMAIN (type);
@@ -2057,13 +2056,12 @@ dbxout_type (tree type, int full)
          {
            int i;
            tree child;
-           VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo);
+           VEC(tree,gc) *accesses = BINFO_BASE_ACCESSES (binfo);
            
            if (use_gnu_debug_info_extensions)
              {
                if (BINFO_N_BASE_BINFOS (binfo))
                  {
-                   have_used_extensions = 1;
                    stabstr_C ('!');
                    stabstr_U (BINFO_N_BASE_BINFOS (binfo));
                    stabstr_C (',');
@@ -2076,7 +2074,6 @@ dbxout_type (tree type, int full)
 
                if (use_gnu_debug_info_extensions)
                  {
-                   have_used_extensions = 1;
                    stabstr_C (BINFO_VIRTUAL_P (child) ? '1' : '0');
                    stabstr_C (access == access_public_node ? '2' :
                                   access == access_protected_node
@@ -2121,7 +2118,6 @@ dbxout_type (tree type, int full)
       dbxout_type_fields (type);
       if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
        {
-         have_used_extensions = 1;
          dbxout_type_methods (type);
        }
 
@@ -2131,7 +2127,6 @@ dbxout_type (tree type, int full)
          /* Avoid the ~ if we don't really need it--it confuses dbx.  */
          && TYPE_VFIELD (type))
        {
-         have_used_extensions = 1;
 
          /* We need to write out info about what field this class
             uses as its "main" vtable pointer field, because if this
@@ -2162,7 +2157,6 @@ dbxout_type (tree type, int full)
       if (use_gnu_debug_info_extensions
          && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
        {
-         have_used_extensions = 1;
          stabstr_S ("@s");
          stabstr_D (TYPE_PRECISION (type));
          stabstr_C (';');
@@ -2198,7 +2192,6 @@ dbxout_type (tree type, int full)
     case METHOD_TYPE:
       if (use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_C ('#');
 
          /* Write the argument types out longhand.  */
@@ -2216,7 +2209,6 @@ dbxout_type (tree type, int full)
     case OFFSET_TYPE:
       if (use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_C ('@');
          dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
          stabstr_C (',');
@@ -2230,7 +2222,6 @@ dbxout_type (tree type, int full)
     case REFERENCE_TYPE:
       if (use_gnu_debug_info_extensions)
        {
-         have_used_extensions = 1;
          stabstr_C ('&');
        }
       else
@@ -2354,7 +2345,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
     DBXOUT_DECR_NESTING_AND_RETURN (0);
 
   /* If we are to generate only the symbols actually used then such
-     symbol nodees are flagged with TREE_USED.  Ignore any that
+     symbol nodes are flagged with TREE_USED.  Ignore any that
      aren't flaged as TREE_USED.  */
 
   if (flag_debug_only_used_symbols
@@ -2435,6 +2426,9 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
       context = decl_function_context (decl);
       if (context == current_function_decl)
        break;
+      /* Don't mention an inline instance of a nested function.  */
+      if (context && DECL_FROM_INLINE (decl))
+       break;
       if (!MEM_P (DECL_RTL (decl))
          || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
        break;
@@ -2503,7 +2497,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
                 || TREE_CODE (type) == UNION_TYPE
                 || TREE_CODE (type) == QUAL_UNION_TYPE)
                && TYPE_NAME (type) == decl
-               && !(use_gnu_debug_info_extensions && have_used_extensions)
+               && !use_gnu_debug_info_extensions
                && !TREE_ASM_WRITTEN (TYPE_NAME (type))
                /* Distinguish the implicit typedefs of C++
                   from explicit ones that might be found in C.  */
@@ -2529,11 +2523,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
 
            dbxout_begin_complex_stabs ();
 
-           /* Output leading class/struct qualifiers.
-              ??? why not set have_used_extensions here ... because
-              then the test of it below would always be true, I
-              guess.  But it's not clear to me why we shouldn't do
-              that always in extended mode.  */
+           /* Output leading class/struct qualifiers.  */
            if (use_gnu_debug_info_extensions)
              dbxout_class_name_qualifiers (decl);
 
@@ -2550,7 +2540,7 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
                   from explicit ones that might be found in C.  */
                && DECL_ARTIFICIAL (decl))
              {
-               if (use_gnu_debug_info_extensions && have_used_extensions)
+               if (use_gnu_debug_info_extensions)
                  {
                    stabstr_C ('T');
                    TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
@@ -2739,6 +2729,37 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
 
          letter = decl_function_context (decl) ? 'V' : 'S';
 
+         /* Some ports can transform a symbol ref into a label ref,
+            because the symbol ref is too far away and has to be
+            dumped into a constant pool.  Alternatively, the symbol
+            in the constant pool might be referenced by a different
+            symbol.  */
+         if (GET_CODE (addr) == SYMBOL_REF
+             && CONSTANT_POOL_ADDRESS_P (addr))
+           {
+             bool marked;
+             rtx tmp = get_pool_constant_mark (addr, &marked);
+
+             if (GET_CODE (tmp) == SYMBOL_REF)
+               {
+                 addr = tmp;
+                 if (CONSTANT_POOL_ADDRESS_P (addr))
+                   get_pool_constant_mark (addr, &marked);
+                 else
+                   marked = true;
+               }
+             else if (GET_CODE (tmp) == LABEL_REF)
+               {
+                 addr = tmp;
+                 marked = true;
+               }
+
+             /* If all references to the constant pool were optimized
+                out, we just ignore the symbol.  */
+             if (!marked)
+               return 0;
+           }
+
          /* This should be the same condition as in assemble_variable, but
             we don't have access to dont_output_data here.  So, instead,
             we rely on the fact that error_mark_node initializers always
@@ -2753,37 +2774,6 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
            code = DBX_STATIC_CONST_VAR_CODE;
          else
            {
-             /* Some ports can transform a symbol ref into a label ref,
-                because the symbol ref is too far away and has to be
-                dumped into a constant pool.  Alternatively, the symbol
-                in the constant pool might be referenced by a different
-                symbol.  */
-             if (GET_CODE (addr) == SYMBOL_REF
-                 && CONSTANT_POOL_ADDRESS_P (addr))
-               {
-                 bool marked;
-                 rtx tmp = get_pool_constant_mark (addr, &marked);
-
-                 if (GET_CODE (tmp) == SYMBOL_REF)
-                   {
-                     addr = tmp;
-                     if (CONSTANT_POOL_ADDRESS_P (addr))
-                       get_pool_constant_mark (addr, &marked);
-                     else
-                       marked = true;
-                   }
-                 else if (GET_CODE (tmp) == LABEL_REF)
-                   {
-                     addr = tmp;
-                     marked = true;
-                   }
-
-                  /* If all references to the constant pool were optimized
-                     out, we just ignore the symbol.  */
-                 if (!marked)
-                   return 0;
-               }
-
              /* Ultrix `as' seems to need this.  */
 #ifdef DBX_STATIC_STAB_DATA_SECTION
              data_section ();
@@ -2902,12 +2892,14 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
     return 0;
 
   /* Ok, start a symtab entry and output the variable name.  */
+  emit_pending_bincls_if_required ();
+  FORCE_TEXT;
 
 #ifdef DBX_STATIC_BLOCK_START
   DBX_STATIC_BLOCK_START (asm_out_file, code);
 #endif
 
-  dbxout_begin_complex_stabs ();
+  dbxout_begin_complex_stabs_noforcetext ();
   dbxout_symbol_name (decl, suffix, letter);
   dbxout_type (type, 0);
   dbxout_finish_complex_stabs (decl, code, addr, 0, number);
@@ -3078,7 +3070,7 @@ dbxout_parms (tree parms)
               That is, its address was passed in a register.
               Output it as if it lived in that register.
               The debugger will know from the type
-              that it was actually passed by invisible reference. */
+              that it was actually passed by invisible reference.  */
 
            code = DBX_REGPARM_STABS_CODE;
  
@@ -3359,7 +3351,12 @@ dbxout_block (tree block, int depth, tree args)
 static void
 dbxout_begin_function (tree decl)
 {
-  int saved_tree_used1 = TREE_USED (decl);
+  int saved_tree_used1;
+
+  if (DECL_IGNORED_P (decl))
+    return;
+
+  saved_tree_used1 = TREE_USED (decl);
   TREE_USED (decl) = 1;
   if (DECL_NAME (DECL_RESULT (decl)) != 0)
     {