* Makefile.in (autoconf-install): New target.
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index 8c03a6f7de764dc1f55f946964a02710f3376641..e779c934e3c2106fdd5ccd7dea9f83211aeee187 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for decoding "stabs" debugging information format.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
+   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
              Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -344,7 +344,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
     {
       real_filenum = this_object_header_files[filenum];
 
-      if (real_filenum >= n_header_files)
+      if (real_filenum >= N_HEADER_FILES (current_objfile))
        {
          struct type *temp_type;
          struct type **temp_type_p;
@@ -358,7 +358,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
          return temp_type_p;
        }
 
-      f = &header_files[real_filenum];
+      f = HEADER_FILES (current_objfile) + real_filenum;
 
       f_orig_length = f->length;
       if (index >= f_orig_length)
@@ -1777,21 +1777,25 @@ define_symbol (valu, string, desc, type, objfile)
   /* When passing structures to a function, some systems sometimes pass
      the address in a register, not the structure itself. */
 
-  if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
-                             SYMBOL_TYPE (sym))
-      && ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET)))
+  if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
+      && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
     {
-      /* If REG_STRUCT_HAS_ADDR yields non-zero we have to
-       convert LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
-      if (SYMBOL_CLASS (sym) == LOC_REGPARM)
-       SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
-      /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th and
-        subsequent arguments on the sparc, for example).  */
-      else if (SYMBOL_CLASS (sym) == LOC_ARG)
-       SYMBOL_CLASS (sym) = LOC_REF_ARG;
+      struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
+
+      if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
+       {
+         /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
+            LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
+         if (SYMBOL_CLASS (sym) == LOC_REGPARM)
+           SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+         /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
+            and subsequent arguments on the sparc, for example).  */
+         else if (SYMBOL_CLASS (sym) == LOC_ARG)
+           SYMBOL_CLASS (sym) = LOC_REF_ARG;
+       }
     }
 
   return sym;
@@ -1953,15 +1957,21 @@ read_type (pp, objfile)
          p = strchr(*pp, ':');
          if (p == NULL)
            return error_type (pp, objfile);
-         while (q1 && p > q1 && p[1] == ':')
+         if (q1 && p > q1 && p[1] == ':')
            {
-              q2 = strchr(q1, '>');
-              if (!q2 || q2 < p)
-                break;
-              p += 2;
-              p = strchr(p, ':');
-              if (p == NULL)
-                return error_type (pp, objfile);
+             int nesting_level = 0;
+             for (q2 = q1; *q2; q2++)
+               {
+                 if (*q2 == '<')
+                   nesting_level++;
+                 else if (*q2 == '>')
+                   nesting_level--;
+                 else if (*q2 == ':' && nesting_level == 0)
+                   break;
+               }
+             p = q2;
+             if (*p != ':')
+               return error_type (pp, objfile);
            }
          to = type_name = 
                (char *)obstack_alloc (&objfile->type_obstack, p - *pp + 1);
@@ -4487,87 +4497,105 @@ scan_file_globals (objfile)
   int hash;
   struct minimal_symbol *msymbol;
   struct symbol *sym, *prev;
+  struct objfile *resolve_objfile;
 
-  /* Avoid expensive loop through all minimal symbols if there are
-     no unresolved symbols.  */
-  for (hash = 0; hash < HASHSIZE; hash++)
-    {
-      if (global_sym_chain[hash])
-       break;
-    }
-  if (hash >= HASHSIZE)
-    return;
+  /* SVR4 based linkers copy referenced global symbols from shared
+     libraries to the main executable.
+     If we are scanning the symbols for a shared library, try to resolve
+     them from the minimal symbols of the main executable first.  */
 
-  for (msymbol = objfile -> msymbols;
-       msymbol && SYMBOL_NAME (msymbol) != NULL;
-       msymbol++)
-    {
-      QUIT;
+  if (symfile_objfile && objfile != symfile_objfile)
+    resolve_objfile = symfile_objfile;
+  else
+    resolve_objfile = objfile;
 
-      /* Skip static symbols.  */
-      switch (MSYMBOL_TYPE (msymbol))
+  while (1)
+    {
+      /* Avoid expensive loop through all minimal symbols if there are
+        no unresolved symbols.  */
+      for (hash = 0; hash < HASHSIZE; hash++)
        {
-       case mst_file_text:
-       case mst_file_data:
-       case mst_file_bss:
-         continue;
-       default:
-         break;
+         if (global_sym_chain[hash])
+           break;
        }
+      if (hash >= HASHSIZE)
+       return;
+
+      for (msymbol = resolve_objfile -> msymbols;
+          msymbol && SYMBOL_NAME (msymbol) != NULL;
+          msymbol++)
+       {
+         QUIT;
 
-      prev = NULL;
+         /* Skip static symbols.  */
+         switch (MSYMBOL_TYPE (msymbol))
+           {
+           case mst_file_text:
+           case mst_file_data:
+           case mst_file_bss:
+             continue;
+           default:
+             break;
+           }
 
-      /* Get the hash index and check all the symbols
-        under that hash index. */
+         prev = NULL;
 
-      hash = hashname (SYMBOL_NAME (msymbol));
+         /* Get the hash index and check all the symbols
+            under that hash index. */
 
-      for (sym = global_sym_chain[hash]; sym;)
-       {
-         if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
-             STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
+         hash = hashname (SYMBOL_NAME (msymbol));
+
+         for (sym = global_sym_chain[hash]; sym;)
            {
-             /* Splice this symbol out of the hash chain and
-                assign the value we have to it. */
-             if (prev)
+             if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
+                 STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
                {
-                 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
-               }
-             else
-               {
-                 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
-               }
-             
-             /* Check to see whether we need to fix up a common block.  */
-             /* Note: this code might be executed several times for
-                the same symbol if there are multiple references.  */
+                 /* Splice this symbol out of the hash chain and
+                    assign the value we have to it. */
+                 if (prev)
+                   {
+                     SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
+                   }
+                 else
+                   {
+                     global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
+                   }
+                 
+                 /* Check to see whether we need to fix up a common block.  */
+                 /* Note: this code might be executed several times for
+                    the same symbol if there are multiple references.  */
 
-             if (SYMBOL_CLASS (sym) == LOC_BLOCK)
-               {
-                 fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
-               }
-             else
-               {
-                 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
-               }
+                 if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+                   {
+                     fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
+                   }
+                 else
+                   {
+                     SYMBOL_VALUE_ADDRESS (sym)
+                       = SYMBOL_VALUE_ADDRESS (msymbol);
+                   }
 
-             SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
-             
-             if (prev)
-               {
-                 sym = SYMBOL_VALUE_CHAIN (prev);
+                 SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
+                 
+                 if (prev)
+                   {
+                     sym = SYMBOL_VALUE_CHAIN (prev);
+                   }
+                 else
+                   {
+                     sym = global_sym_chain[hash];
+                   }
                }
              else
                {
-                 sym = global_sym_chain[hash];
+                 prev = sym;
+                 sym = SYMBOL_VALUE_CHAIN (sym);
                }
            }
-         else
-           {
-             prev = sym;
-             sym = SYMBOL_VALUE_CHAIN (sym);
-           }
        }
+      if (resolve_objfile == objfile)
+       break;
+      resolve_objfile = objfile;
     }
 
   /* Change the storage class of any remaining unresolved globals to
@@ -4589,7 +4617,7 @@ scan_file_globals (objfile)
            SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
          else
            complain (&unresolved_sym_chain_complaint,
-                     objfile->name, SYMBOL_NAME (prev));
+                     objfile -> name, SYMBOL_NAME (prev));
        }
     }
   memset (global_sym_chain, 0, sizeof (global_sym_chain));
This page took 0.026028 seconds and 4 git commands to generate.