OSDN Git Service

2009-08-28 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
index edad611..bc7965e 100644 (file)
@@ -171,8 +171,7 @@ enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
    The file_number and type_number elements are used if DBX_USE_BINCL
    is defined.  */
 
-struct typeinfo GTY(())
-{
+struct GTY(()) typeinfo {
   enum typestatus status;
   int file_number;
   int type_number;
@@ -276,8 +275,6 @@ static const char *base_input_file;
 
 #include "gstab.h"
 
-#define STAB_CODE_TYPE enum __stab_debug_code
-
 /* 1 if PARM is passed to this function in memory.  */
 
 #define PARM_PASSED_IN_MEMORY(PARM) \
@@ -319,15 +316,15 @@ static void dbxout_args (tree);
 static void dbxout_type_fields (tree);
 static void dbxout_type_method_1 (tree);
 static void dbxout_type_methods (tree);
-static void dbxout_range_type (tree);
+static void dbxout_range_type (tree, tree, tree);
 static void dbxout_type (tree, int);
-static bool print_int_cst_bounds_in_octal_p (tree);
+static bool print_int_cst_bounds_in_octal_p (tree, tree, tree);
 static bool is_fortran (void);
 static void dbxout_type_name (tree);
 static void dbxout_class_name_qualifiers (tree);
 static int dbxout_symbol_location (tree, tree, const char *, rtx);
 static void dbxout_symbol_name (tree, const char *, int);
-static void dbxout_common_name (tree, const char *, STAB_CODE_TYPE);
+static void dbxout_common_name (tree, const char *, stab_code_type);
 static const char *dbxout_common_check (tree, int *);
 static void dbxout_global_decl (tree);
 static void dbxout_type_decl (tree, int);
@@ -336,7 +333,7 @@ static void dbxout_handle_pch (unsigned);
 /* The debug hooks structure.  */
 #if defined (DBX_DEBUGGING_INFO)
 
-static void dbxout_source_line (unsigned int, const char *);
+static void dbxout_source_line (unsigned int, const char *, int, bool);
 static void dbxout_begin_prologue (unsigned int, const char *);
 static void dbxout_source_file (const char *);
 static void dbxout_function_end (tree);
@@ -843,7 +840,7 @@ do {                                                                \
    to DBX_FINISH_STABS; see above for details.  */
    
 static void
-dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
+dbxout_finish_complex_stabs (tree sym, stab_code_type code,
                             rtx addr, const char *label, int number)
 {
   int line ATTRIBUTE_UNUSED;
@@ -1268,7 +1265,7 @@ dbxout_begin_prologue (unsigned int lineno, const char *filename)
   /* pre-increment the scope counter */
   scope_labelno++;
 
-  dbxout_source_line (lineno, filename);
+  dbxout_source_line (lineno, filename, 0, true);
   /* Output function begin block at function scope, referenced 
      by dbxout_block, dbxout_source_line and dbxout_function_end.  */
   emit_pending_bincls_if_required ();
@@ -1279,7 +1276,9 @@ dbxout_begin_prologue (unsigned int lineno, const char *filename)
    number LINENO.  */
 
 static void
-dbxout_source_line (unsigned int lineno, const char *filename)
+dbxout_source_line (unsigned int lineno, const char *filename,
+                    int discriminator ATTRIBUTE_UNUSED,
+                    bool is_stmt ATTRIBUTE_UNUSED)
 {
   dbxout_source_file (filename);
 
@@ -1594,10 +1593,10 @@ dbxout_type_methods (tree type)
 
 /* Emit a "range" type specification, which has the form:
    "r<index type>;<lower bound>;<upper bound>;".
-   TYPE is an INTEGER_TYPE.  */
+   TYPE is an INTEGER_TYPE, LOW and HIGH are the bounds.  */
 
 static void
-dbxout_range_type (tree type)
+dbxout_range_type (tree type, tree low, tree high)
 {
   stabstr_C ('r');
   if (TREE_TYPE (type))
@@ -1625,25 +1624,23 @@ dbxout_range_type (tree type)
     }
 
   stabstr_C (';');
-  if (TYPE_MIN_VALUE (type) != 0
-      && host_integerp (TYPE_MIN_VALUE (type), 0))
+  if (low && host_integerp (low, 0))
     {
-      if (print_int_cst_bounds_in_octal_p (type))
-        stabstr_O (TYPE_MIN_VALUE (type));
+      if (print_int_cst_bounds_in_octal_p (type, low, high))
+        stabstr_O (low);
       else
-        stabstr_D (tree_low_cst (TYPE_MIN_VALUE (type), 0));
+        stabstr_D (tree_low_cst (low, 0));
     }
   else
     stabstr_C ('0');
 
   stabstr_C (';');
-  if (TYPE_MAX_VALUE (type) != 0
-      && host_integerp (TYPE_MAX_VALUE (type), 0))
+  if (high && host_integerp (high, 0))
     {
-      if (print_int_cst_bounds_in_octal_p (type))
-        stabstr_O (TYPE_MAX_VALUE (type));
+      if (print_int_cst_bounds_in_octal_p (type, low, high))
+        stabstr_O (high);
       else
-        stabstr_D (tree_low_cst (TYPE_MAX_VALUE (type), 0));
+        stabstr_D (tree_low_cst (high, 0));
       stabstr_C (';');
     }
   else
@@ -1664,10 +1661,9 @@ dbxout_range_type (tree type)
 static void
 dbxout_type (tree type, int full)
 {
-  tree tem;
-  tree main_variant;
   static int anonymous_type_number = 0;
   bool vector_type = false;
+  tree tem, main_variant, low, high;
 
   if (TREE_CODE (type) == VECTOR_TYPE)
     {
@@ -1677,6 +1673,27 @@ dbxout_type (tree type, int full)
       vector_type = true;
     }
 
+  if (TREE_CODE (type) == INTEGER_TYPE)
+    {
+      if (TREE_TYPE (type) == 0)
+       {
+         low = TYPE_MIN_VALUE (type);
+         high = TYPE_MAX_VALUE (type);
+       }
+
+      else if (subrange_type_for_debug_p (type, &low, &high))
+       ;
+
+      /* If this is a subtype that should not be emitted as a subrange type,
+        use the base type.  */
+      else
+       {
+         type = TREE_TYPE (type);
+         low = TYPE_MIN_VALUE (type);
+         high = TYPE_MAX_VALUE (type);
+       }
+    }
+
   /* If there was an input error and we don't really have a type,
      avoid crashing and write something that is at least valid
      by assuming `int'.  */
@@ -1878,7 +1895,7 @@ dbxout_type (tree type, int full)
              stabstr_C (';');
            }
 
-         dbxout_range_type (type);
+         dbxout_range_type (type, low, high);
        }
 
       else
@@ -1894,7 +1911,7 @@ dbxout_type (tree type, int full)
              stabstr_C (';');
            }
 
-         if (print_int_cst_bounds_in_octal_p (type))
+         if (print_int_cst_bounds_in_octal_p (type, low, high))
            {
              stabstr_C ('r');
 
@@ -1909,15 +1926,15 @@ dbxout_type (tree type, int full)
                 dbxout_type_index (type);
 
              stabstr_C (';');
-             stabstr_O (TYPE_MIN_VALUE (type));
+             stabstr_O (low);
              stabstr_C (';');
-             stabstr_O (TYPE_MAX_VALUE (type));
+             stabstr_O (high);
              stabstr_C (';');
            }
 
          else
            /* Output other integer types as subranges of `int'.  */
-           dbxout_range_type (type);
+           dbxout_range_type (type, low, high);
        }
 
       break;
@@ -2011,7 +2028,7 @@ dbxout_type (tree type, int full)
       else
        {
          stabstr_C ('a');
-         dbxout_range_type (tem);
+         dbxout_range_type (tem, TYPE_MIN_VALUE (tem), TYPE_MAX_VALUE (tem));
        }
 
       dbxout_type (TREE_TYPE (type), 0);
@@ -2259,7 +2276,7 @@ dbxout_type (tree type, int full)
    should be printed in octal format.  */
 
 static bool
-print_int_cst_bounds_in_octal_p (tree type)
+print_int_cst_bounds_in_octal_p (tree type, tree low, tree high)
 {
   /* If we can use GDB extensions and the size is wider than a long
      (the size used by GDB to read them) or we may have trouble writing
@@ -2273,10 +2290,8 @@ print_int_cst_bounds_in_octal_p (tree type)
      can't span same size unsigned types.  */
 
   if (use_gnu_debug_info_extensions
-      && TYPE_MIN_VALUE (type) != 0
-      && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
-      && TYPE_MAX_VALUE (type) != 0
-      && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
+      && low && TREE_CODE (low) == INTEGER_CST
+      && high && TREE_CODE (high) == INTEGER_CST
       && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
          || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
              && TYPE_UNSIGNED (type))
@@ -2763,9 +2778,15 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
       }
 
     case PARM_DECL:
-      /* Parm decls go in their own separate chains
-        and are output by dbxout_reg_parms and dbxout_parms.  */
-      gcc_unreachable ();
+      if (DECL_HAS_VALUE_EXPR_P (decl))
+       decl = DECL_VALUE_EXPR (decl);
+
+      /* PARM_DECLs go in their own separate chain and are output by
+        dbxout_reg_parms and dbxout_parms, except for those that are
+        disguised VAR_DECLs like Out parameters in Ada.  */
+      gcc_assert (TREE_CODE (decl) == VAR_DECL);
+
+      /* ... fall through ...  */
 
     case RESULT_DECL:
     case VAR_DECL:
@@ -2837,7 +2858,7 @@ static int
 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
 {
   int letter = 0;
-  STAB_CODE_TYPE code;
+  stab_code_type code;
   rtx addr = 0;
   int number = 0;
   int regno = -1;
@@ -3017,7 +3038,7 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
     }
   else if (MEM_P (home)
           && GET_CODE (XEXP (home, 0)) == PLUS
-          && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
+          && CONST_INT_P (XEXP (XEXP (home, 0), 1)))
     {
       code = N_LSYM;
       /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
@@ -3142,7 +3163,7 @@ dbxout_symbol_name (tree decl, const char *suffix, int letter)
    emits the N_BCOMM and N_ECOMM stabs.  */
 
 static void
-dbxout_common_name (tree decl, const char *name, STAB_CODE_TYPE op)
+dbxout_common_name (tree decl, const char *name, stab_code_type op)
 {
   dbxout_begin_complex_stabs ();
   stabstr_S (name);
@@ -3203,7 +3224,7 @@ dbxout_common_check (tree decl, int *value)
       switch (GET_CODE (sym_addr))
         {
         case PLUS:
-          if (GET_CODE (XEXP (sym_addr, 0)) == CONST_INT)
+          if (CONST_INT_P (XEXP (sym_addr, 0)))
             {
               name =
                 targetm.strip_name_encoding(XSTR (XEXP (sym_addr, 1), 0));
@@ -3310,7 +3331,7 @@ dbxout_parms (tree parms)
       {
        tree eff_type;
        char letter;
-       STAB_CODE_TYPE code;
+       stab_code_type code;
        int number;
 
        /* Perform any necessary register eliminations on the parameter's rtl,
@@ -3336,7 +3357,7 @@ dbxout_parms (tree parms)
               If that is not true, we produce meaningless results,
               but do not crash.  */
            if (GET_CODE (inrtl) == PLUS
-               && GET_CODE (XEXP (inrtl, 1)) == CONST_INT)
+               && CONST_INT_P (XEXP (inrtl, 1)))
              number = INTVAL (XEXP (inrtl, 1));
            else
              number = 0;