]> Git Repo - binutils.git/blobdiff - gdb/stabsread.c
Thu Apr 22 14:50:05 1993 Jim Kingdon ([email protected])
[binutils.git] / gdb / stabsread.c
index 170dbe8e346d067051757f030e6ed7fc2b524a4c..9b475bd0f31ecc2c9a267de719e9b32b5bb2cbd1 100644 (file)
@@ -833,6 +833,7 @@ define_symbol (valu, string, desc, type, objfile)
 
 #endif /* no BELIEVE_PCC_PROMOTION_TYPE.  */
 
+    case 'R':
     case 'P':
       /* acc seems to use P to delare the prototypes of functions that
          are referenced by this file.  gdb is not prepared to deal
@@ -852,7 +853,6 @@ define_symbol (valu, string, desc, type, objfile)
       add_symbol_to_list (sym, &local_symbols);
       break;
 
-    case 'R':
     case 'r':
       /* Register variable (either global or local).  */
       SYMBOL_CLASS (sym) = LOC_REGISTER;
@@ -864,7 +864,31 @@ define_symbol (valu, string, desc, type, objfile)
        }
       SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
       if (within_function)
-        add_symbol_to_list (sym, &local_symbols);
+       {
+         /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
+            name to represent an argument passed in a register.
+            GCC uses 'P' for the same case.  So if we find such a symbol pair
+            we combine it into one 'P' symbol.
+            Note that this code illegally combines
+              main(argc) int argc; { register int argc = 1; }
+            but this case is considered pathological and causes a warning
+            from a decent compiler.  */
+         if (local_symbols
+             && local_symbols->nsyms > 0)
+           {
+             struct symbol *prev_sym;
+             prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
+             if (SYMBOL_CLASS (prev_sym) == LOC_ARG
+                 && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME(sym)))
+               {
+                 SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
+                 SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
+                 sym = prev_sym;
+                 break;
+               }
+           }
+          add_symbol_to_list (sym, &local_symbols);
+       }
       else
         add_symbol_to_list (sym, &file_symbols);
       break;
@@ -965,6 +989,23 @@ define_symbol (valu, string, desc, type, objfile)
     default:
       error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
     }
+
+  /* When passing structures to a function, some systems sometimes pass
+     the address in a register, not the structure itself. 
+
+     If REG_STRUCT_HAS_ADDR yields non-zero we have to convert LOC_REGPARM
+     to LOC_REGPARM_ADDR for structures and unions.  */
+
+#if !defined (REG_STRUCT_HAS_ADDR)
+#define REG_STRUCT_HAS_ADDR(gcc_p) 0
+#endif
+
+  if (SYMBOL_CLASS (sym) == LOC_REGPARM
+      && REG_STRUCT_HAS_ADDR (processing_gcc_compilation)
+      && (   (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
+         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)))
+    SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+
   return sym;
 }
 
@@ -1566,6 +1607,8 @@ read_member_functions (fip, pp, type, objfile)
 
          if (TYPE_FLAGS (new_sublist -> fn_field.type) & TYPE_FLAG_STUB)
            {
+             if (!TYPE_DOMAIN_TYPE (new_sublist -> fn_field.type))
+               TYPE_DOMAIN_TYPE (new_sublist -> fn_field.type) = type;
              new_sublist -> fn_field.is_stub = 1;
            }
          new_sublist -> fn_field.physname = savestring (*pp, p - *pp);
@@ -2370,32 +2413,12 @@ read_struct_type (pp, type, objfile)
      member functions, attach them to the type, and then read any tilde
      field (baseclass specifier for the class holding the main vtable). */
 
-  if (!read_baseclasses (&fi, pp, type, objfile))
-    {
-      do_cleanups (back_to);
-      return (error_type (pp));
-    }
-  if (!read_struct_fields (&fi, pp, type, objfile))
-    {
-      do_cleanups (back_to);
-      return (error_type (pp));
-    }
-  if (!attach_fields_to_type (&fi, type, objfile))
-    {
-      do_cleanups (back_to);
-      return (error_type (pp));
-    }
-  if (!read_member_functions (&fi, pp, type, objfile))
-    {
-      do_cleanups (back_to);
-      return (error_type (pp));
-    }
-  if (!attach_fn_fields_to_type (&fi, type))
-    {
-      do_cleanups (back_to);
-      return (error_type (pp));
-    }
-  if (!read_tilde_fields (&fi, pp, type, objfile))
+  if (!read_baseclasses (&fi, pp, type, objfile)
+      || !read_struct_fields (&fi, pp, type, objfile)
+      || !attach_fields_to_type (&fi, type, objfile)
+      || !read_member_functions (&fi, pp, type, objfile)
+      || !attach_fn_fields_to_type (&fi, type)
+      || !read_tilde_fields (&fi, pp, type, objfile))
     {
       do_cleanups (back_to);
       return (error_type (pp));
This page took 0.026636 seconds and 4 git commands to generate.