]> Git Repo - binutils.git/blobdiff - gdb/dwarfread.c
Sat Nov 30 18:58:40 1991 Steve Chamberlain (sac at cygnus.com)
[binutils.git] / gdb / dwarfread.c
index 6bb6c16fc2780bd3245cda26ceb602ce33629a84..4fb1ddb31c53ce4a6d44dbd17acdb7c3b130def5 100644 (file)
@@ -63,13 +63,15 @@ FIXME: See other FIXME's and "ifdef 0" scattered throughout the code for
 other things to work on, if you get bored. :-)
 
 */
-
 #include <stdio.h>
+#ifdef __STDC__
 #include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
 #include <fcntl.h>
 
 #include "defs.h"
-#include "param.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "symfile.h"
@@ -93,7 +95,17 @@ typedef unsigned int DIEREF; /* Reference to a DIE */
 
 #define STREQ(a,b)             (strcmp(a,b)==0)
 
-extern CORE_ADDR entry_point;          /* Process entry point */
+/* The Amiga SVR4 header file <dwarf.h> defines AT_element_list as a
+   FORM_BLOCK2, and this is the value emitted by the AT&T compiler.
+   However, the Issue 2 DWARF specification from AT&T defines it as
+   a FORM_BLOCK4, as does the latest specification from UI/PLSIG.
+   For backwards compatibility with the AT&T compiler produced executables
+   we define AT_short_element_list for this variant. */
+
+#define        AT_short_element_list    (0x00f0|FORM_BLOCK2)
+
+/* External variables referenced. */
+
 extern CORE_ADDR startup_file_start;   /* From blockframe.c */
 extern CORE_ADDR startup_file_end;     /* From blockframe.c */
 extern CORE_ADDR entry_scope_lowpc;    /* From blockframe.c */
@@ -125,7 +137,7 @@ extern int info_verbose;            /* From main.c; nonzero => verbose */
    Some fields have a flag <name>_p that is set when the value of the
    field is valid (I.E. we found a matching attribute in the DIE).  Since
    we may want to test for the presence of some attributes in the DIE,
-   such as AT_is_external, without restricting the values of the field,
+   such as AT_low_pc, without restricting the values of the field,
    we need someway to note that we found such an attribute.
    
  */
@@ -150,7 +162,6 @@ struct dieinfo {
   long         at_byte_size;
   short                at_bit_offset;
   long         at_bit_size;
-  BLOCK *      at_deriv_list;
   BLOCK *      at_element_list;
   long         at_stmt_list;
   long         at_low_pc;
@@ -164,17 +175,14 @@ struct dieinfo {
   BLOCK *      at_string_length;
   char *       at_comp_dir;
   char *       at_producer;
-  long         at_loclist;
   long         at_frame_base;
-  short                at_incomplete;
   long         at_start_scope;
   long         at_stride_size;
   long         at_src_info;
   short                at_prototyped;
-  BLOCK *      at_const_data;
-  short                at_is_external;
-  unsigned int at_is_external_p:1;
-  unsigned int at_stmt_list_p:1;
+  unsigned int has_at_low_pc:1;
+  unsigned int has_at_stmt_list:1;
+  unsigned int short_element_list:1;
 };
 
 static int diecount;   /* Approximate count of dies for compilation unit */
@@ -310,10 +318,11 @@ EXFUN (scan_partial_symbols, (char *thisdie AND char *enddie));
 static void
 EXFUN (scan_compilation_units,
        (char *filename AND CORE_ADDR addr AND char *thisdie AND char *enddie
-       AND unsigned int dbfoff AND unsigned int lnoffset));
+       AND unsigned int dbfoff AND unsigned int lnoffset
+        AND struct objfile *objfile));
 
 static struct partial_symtab *
-EXFUN(start_psymtab, (char *symfile_name AND CORE_ADDR addr
+EXFUN(start_psymtab, (struct objfile *objfile AND CORE_ADDR addr
                      AND char *filename AND CORE_ADDR textlow
                      AND CORE_ADDR texthigh AND int dbfoff
                      AND int curoff AND int culength AND int lnfoff
@@ -341,17 +350,14 @@ static void
 EXFUN(dwarf_psymtab_to_symtab, (struct partial_symtab *pst));
 
 static void
-EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst AND int desc ));
+EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst));
 
 static struct symtab *
-EXFUN(read_ofile_symtab, (struct partial_symtab *pst AND int desc));
+EXFUN(read_ofile_symtab, (struct partial_symtab *pst));
 
 static void
-EXFUN(process_dies, (char *thisdie AND char *enddie));
-
-static void
-EXFUN(read_lexical_block_scope,
-      (struct dieinfo *dip AND char *thisdie AND char *enddie));
+EXFUN(process_dies,
+     (char *thisdie AND char *enddie AND struct objfile *objfile));
 
 static void
 EXFUN(read_structure_scope,
@@ -381,19 +387,12 @@ EXFUN(struct_type,
 static struct type *
 EXFUN(enum_type, (struct dieinfo *dip));
 
-static void
-EXFUN(read_func_scope,
-      (struct dieinfo *dip AND char *thisdie AND char *enddie));
-
-static void
-EXFUN(read_file_scope,
-      (struct dieinfo *dip AND char *thisdie AND char *enddie));
-
 static void
 EXFUN(start_symtab, (void));
 
 static void
-EXFUN(end_symtab, (char *filename AND long language));
+EXFUN(end_symtab,
+      (char *filename AND long language AND struct objfile *objfile));
 
 static int
 EXFUN(scopecount, (struct scopenode *node));
@@ -459,7 +458,8 @@ static int
 EXFUN(locval, (char *loc));
 
 static void
-EXFUN(record_misc_function, (char *name AND CORE_ADDR address));
+EXFUN(record_misc_function, (char *name AND CORE_ADDR address AND
+                            enum misc_function_type));
 
 static int
 EXFUN(compare_psymbols,
@@ -476,7 +476,8 @@ SYNOPSIS
 
        void dwarf_build_psymtabs (int desc, char *filename, CORE_ADDR addr,
             int mainline, unsigned int dbfoff, unsigned int dbsize,
-            unsigned int lnoffset, unsigned int lnsize)
+            unsigned int lnoffset, unsigned int lnsize,
+            struct objfile *objfile)
 
 DESCRIPTION
 
@@ -499,7 +500,8 @@ RETURNS
 
 void
 DEFUN(dwarf_build_psymtabs,
-      (desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize),
+      (desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize,
+       objfile),
       int desc AND
       char *filename AND
       CORE_ADDR addr AND
@@ -507,7 +509,8 @@ DEFUN(dwarf_build_psymtabs,
       unsigned int dbfoff AND
       unsigned int dbsize AND
       unsigned int lnoffset AND
-      unsigned int lnsize)
+      unsigned int lnsize AND
+      struct objfile *objfile)
 {
   struct cleanup *back_to;
   
@@ -530,20 +533,13 @@ DEFUN(dwarf_build_psymtabs,
       init_psymbol_list (1024);
     }
   
-  init_misc_bunches ();
-  make_cleanup (discard_misc_bunches, 0);
-  
   /* Follow the compilation unit sibling chain, building a partial symbol
      table entry for each one.  Save enough information about each compilation
      unit to locate the full DWARF information later. */
   
   scan_compilation_units (filename, addr, dbbase, dbbase + dbsize,
-                         dbfoff, lnoffset);
-  
-  /* Go over the miscellaneous functions and install them in the miscellaneous
-     function vector. */
+                         dbfoff, lnoffset, objfile);
   
-  condense_misc_bunches (!mainline);
   do_cleanups (back_to);
 }
 
@@ -556,7 +552,8 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static void record_misc_function (char *name, CORE_ADDR address)
+       static void record_misc_function (char *name, CORE_ADDR address,
+                                         enum misc_function_type mf_type)
 
 DESCRIPTION
 
@@ -565,17 +562,14 @@ DESCRIPTION
        symbol, records this information for later use in building the
        miscellaneous function vector.
 
-NOTES
-
-       FIXME:  For now we just use mf_text as the type.  This should be
-       fixed.
  */
 
 static void
-DEFUN(record_misc_function, (name, address), char *name AND CORE_ADDR address)
+DEFUN(record_misc_function, (name, address, mf_type),
+      char *name AND CORE_ADDR address AND enum misc_function_type mf_type)
 {
   prim_record_misc_function (obsavestring (name, strlen (name)), address,
-                            mf_text);
+                            mf_type);
 }
 
 /*
@@ -606,6 +600,7 @@ NOTES
        information for the DIE where the problem was noticed.
 */
 
+#ifdef __STDC__
 static void
 DEFUN(dwarfwarn, (fmt), char *fmt DOTS)
 {
@@ -623,7 +618,29 @@ DEFUN(dwarfwarn, (fmt), char *fmt DOTS)
   fflush (stderr);
   va_end (ap);
 }
+#else
 
+static void
+dwarfwarn (va_alist)
+     va_dcl
+{
+  va_list ap;
+  char *fmt;
+  
+  va_start (ap);
+  fmt = va_arg (ap, char *);
+  warning_setup ();
+  fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref);
+  if (curdie -> at_name)
+    {
+      fprintf (stderr, "'%s': ", curdie -> at_name);
+    }
+  vfprintf (stderr, fmt, ap);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+  va_end (ap);
+}
+#endif
 /*
 
 LOCAL FUNCTION
@@ -690,13 +707,14 @@ DESCRIPTION
  */
 
 static void
-DEFUN(read_lexical_block_scope, (dip, thisdie, enddie),
+DEFUN(read_lexical_block_scope, (dip, thisdie, enddie, objfile),
      struct dieinfo *dip AND
      char *thisdie AND
-     char *enddie)
+     char *enddie AND
+     struct objfile *objfile)
 {
   openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
-  process_dies (thisdie + dip -> dielength, enddie);
+  process_dies (thisdie + dip -> dielength, enddie, objfile);
   closescope ();
 }
 
@@ -883,23 +901,34 @@ DEFUN(struct_type, (dip, thisdie, enddie),
     {
       type = alloc_utype (dip -> dieref, NULL);
     }
-  switch (dip -> dietag)
+  if (dip -> dietag == TAG_structure_type || dip -> dietag == TAG_union_type)
+    {
+      TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
+       obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type));
+      (void) memset (TYPE_CPLUS_SPECIFIC (type), 0,
+                    sizeof (struct cplus_struct_type));
+      if (dip -> dietag == TAG_structure_type)
+       {
+         TYPE_CODE (type) = TYPE_CODE_STRUCT;
+         tpart1 = "struct ";
+       }
+      else
+       {
+         TYPE_CODE (type) = TYPE_CODE_UNION;
+         tpart1 = "union ";
+       }
+    }
+  else
     {
-    case TAG_structure_type:
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
-      tpart1 = "struct ";
-      break;
-    case TAG_union_type:
-      TYPE_CODE (type) = TYPE_CODE_UNION;
-      tpart1 = "union ";
-      break;
-    default:
       tpart1 = "";
       SQUAWK (("missing structure or union tag"));
       TYPE_CODE (type) = TYPE_CODE_UNDEF;
-      break;
     }
-  if (dip -> at_name == NULL)
+  /* Some compilers try to be helpful by inventing "fake" names for anonymous
+     enums, structures, and unions, like "~0fake".  Thanks, but no thanks. */
+  if (dip -> at_name == NULL
+      || *dip -> at_name == '~'
+      || *dip -> at_name == '.')
     {
       tpart2 = "{...}";
     }
@@ -914,7 +943,7 @@ DEFUN(struct_type, (dip, thisdie, enddie),
       TYPE_LENGTH (type) = dip -> at_byte_size;
       tpart3 = "";
     }
-  TYPE_NAME (type) = concat (tpart1, tpart2, tpart3);
+  TYPE_NAME (type) = concat (tpart1, tpart2, tpart3, NULL);
   thisdie += dip -> dielength;
   while (thisdie < enddie)
     {
@@ -1307,7 +1336,8 @@ DEFUN(enum_type, (dip), struct dieinfo *dip)
   char *tpart3;
   char *scan;
   char *listend;
-  long temp;
+  long ltemp;
+  short stemp;
   
   if ((type = lookup_utype (dip -> dieref)) == NULL)
     {
@@ -1315,7 +1345,11 @@ DEFUN(enum_type, (dip), struct dieinfo *dip)
     }
   TYPE_CODE (type) = TYPE_CODE_ENUM;
   tpart1 = "enum ";
-  if (dip -> at_name == NULL)
+  /* Some compilers try to be helpful by inventing "fake" names for anonymous
+     enums, structures, and unions, like "~0fake".  Thanks, but no thanks. */
+  if (dip -> at_name == NULL
+      || *dip -> at_name == '~'
+      || *dip -> at_name == '.')
     {
       tpart2 = "{...}";
     } else {
@@ -1330,12 +1364,21 @@ DEFUN(enum_type, (dip), struct dieinfo *dip)
       TYPE_LENGTH (type) = dip -> at_byte_size;
       tpart3 = "";
     }
-  TYPE_NAME (type) = concat (tpart1, tpart2, tpart3);
+  TYPE_NAME (type) = concat (tpart1, tpart2, tpart3, NULL);
   if ((scan = dip -> at_element_list) != NULL)
     {
-      (void) memcpy (&temp, scan, sizeof (temp));
-      listend = scan + temp + sizeof (temp);
-      scan += sizeof (temp);
+      if (dip -> short_element_list)
+       {
+         (void) memcpy (&stemp, scan, sizeof (stemp));
+         listend = scan + stemp + sizeof (stemp);
+         scan += sizeof (stemp);
+       }
+      else
+       {
+         (void) memcpy (&ltemp, scan, sizeof (ltemp));
+         listend = scan + ltemp + sizeof (ltemp);
+         scan += sizeof (ltemp);
+       }
       while (scan < listend)
        {
          new = (struct nextfield *) alloca (sizeof (struct nextfield));
@@ -1368,11 +1411,6 @@ LOCAL FUNCTION
 
        read_func_scope -- process all dies within a function scope
 
-SYNOPSIS
-
-       static void read_func_scope (struct dieinfo dip, char *thisdie,
-           char *enddie)
-
 DESCRIPTION
 
        Process all dies within a given function scope.  We are passed
@@ -1389,10 +1427,11 @@ DESCRIPTION
  */
 
 static void
-DEFUN(read_func_scope, (dip, thisdie, enddie),
+DEFUN(read_func_scope, (dip, thisdie, enddie, objfile),
      struct dieinfo *dip AND
      char *thisdie AND
-     char *enddie)
+     char *enddie AND
+     struct objfile *objfile)
 {
   struct symbol *sym;
   
@@ -1408,7 +1447,7 @@ DEFUN(read_func_scope, (dip, thisdie, enddie),
     }
   sym = new_symbol (dip);
   openscope (sym, dip -> at_low_pc, dip -> at_high_pc);
-  process_dies (thisdie + dip -> dielength, enddie);
+  process_dies (thisdie + dip -> dielength, enddie, objfile);
   closescope ();
 }
 
@@ -1418,11 +1457,6 @@ LOCAL FUNCTION
 
        read_file_scope -- process all dies within a file scope
 
-SYNOPSIS
-
-       static void read_file_scope (struct dieinfo *dip, char *thisdie
-               char *enddie)
-
 DESCRIPTION
 
        Process all dies within a given file scope.  We are passed a
@@ -1440,10 +1474,11 @@ DESCRIPTION
  */
 
 static void
-DEFUN(read_file_scope, (dip, thisdie, enddie),
+DEFUN(read_file_scope, (dip, thisdie, enddie, objfile),
      struct dieinfo *dip AND
      char *thisdie AND
-     char *enddie)
+     char *enddie AND
+     struct objfile *objfile)
 {
   struct cleanup *back_to;
   
@@ -1459,9 +1494,9 @@ DEFUN(read_file_scope, (dip, thisdie, enddie),
   start_symtab ();
   openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
   decode_line_numbers (lnbase);
-  process_dies (thisdie + dip -> dielength, enddie);
+  process_dies (thisdie + dip -> dielength, enddie, objfile);
   closescope ();
-  end_symtab (dip -> at_name, dip -> at_language);
+  end_symtab (dip -> at_name, dip -> at_language, objfile);
   do_cleanups (back_to);
   utypes = NULL;
   numutypes = 0;
@@ -1515,7 +1550,8 @@ DESCRIPTION
  */
 
 static void
-DEFUN(process_dies, (thisdie, enddie), char *thisdie AND char *enddie)
+DEFUN(process_dies, (thisdie, enddie, objfile),
+      char *thisdie AND char *enddie AND struct objfile *objfile)
 {
   char *nextdie;
   struct dieinfo di;
@@ -1545,17 +1581,17 @@ DEFUN(process_dies, (thisdie, enddie), char *thisdie AND char *enddie)
          switch (di.dietag)
            {
            case TAG_compile_unit:
-             read_file_scope (&di, thisdie, nextdie);
+             read_file_scope (&di, thisdie, nextdie, objfile);
              break;
            case TAG_global_subroutine:
            case TAG_subroutine:
-             if (!di.at_is_external_p)
+             if (di.has_at_low_pc)
                {
-                 read_func_scope (&di, thisdie, nextdie);
+                 read_func_scope (&di, thisdie, nextdie, objfile);
                }
              break;
            case TAG_lexical_block:
-             read_lexical_block_scope (&di, thisdie, nextdie);
+             read_lexical_block_scope (&di, thisdie, nextdie, objfile);
              break;
            case TAG_structure_type:
            case TAG_union_type:
@@ -1598,7 +1634,8 @@ DESCRIPTION
  */
 
 static void
-DEFUN(end_symtab, (filename, language), char *filename AND long language)
+DEFUN(end_symtab, (filename, language, objfile),
+     char *filename AND long language AND struct objfile *objfile)
 {
   struct symtab *symtab;
   struct blockvector *blockvector;
@@ -1620,15 +1657,14 @@ DEFUN(end_symtab, (filename, language), char *filename AND long language)
   
   /* Now create the symtab object for this source file.  */
   
-  symtab = (struct symtab *) xmalloc (sizeof (struct symtab));
-  (void) memset (symtab, 0, sizeof (struct symtab));
+  symtab = allocate_symtab (savestring (filename, strlen (filename)),
+                           objfile);
   
   symtab -> free_ptr = 0;
   
   /* Fill in its components.  */
   symtab -> blockvector = blockvector;
   symtab -> free_code = free_linetable;
-  symtab -> filename = savestring (filename, strlen (filename));
   
   /* Save the line number information. */
   
@@ -1639,15 +1675,21 @@ DEFUN(end_symtab, (filename, language), char *filename AND long language)
       nbytes += (line_vector_index - 1) * sizeof (struct linetable_entry);
     }
   symtab -> linetable = (struct linetable *) xrealloc (line_vector, nbytes);
-  symtab -> nlines = 0;
-  symtab -> line_charpos = 0;
   
   /* FIXME:  The following may need to be expanded for other languages */
-  if (language == LANG_C89 || language == LANG_C) 
+  switch (language)
     {
-      symtab -> language = language_c;
+      case LANG_C89:
+      case LANG_C:
+       symtab -> language = language_c;
+       break;
+      case LANG_C_PLUS_PLUS:
+       symtab -> language = language_cplus;
+       break;
+      default:
+       ;
     }
-  
+
   /* Link the new symtab into the list of such.  */
   symtab -> next = symtab_list;
   symtab_list = symtab;
@@ -2260,29 +2302,21 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static struct symtab *read_ofile_symtab (struct partial_symtab *pst,
-               int desc)
+       static struct symtab *read_ofile_symtab (struct partial_symtab *pst)
 
 DESCRIPTION
 
-       DESC is the file descriptor for the file, positioned at the
-       beginning of the symtab
-       SYM_SIZE is the size of the symbol section to read
-       TEXT_OFFSET is the beginning of the text segment we are reading
-       symbols for
-       TEXT_SIZE is the size of the text segment read in.
-       OFFSET is a relocation offset which gets added to each symbol
-
+       OFFSET is a relocation offset which gets added to each symbol (FIXME).
  */
 
 static struct symtab *
-DEFUN(read_ofile_symtab, (pst, desc),
-      struct partial_symtab *pst AND
-      int desc)
+DEFUN(read_ofile_symtab, (pst),
+      struct partial_symtab *pst)
 {
   struct cleanup *back_to;
   long lnsize;
   int foffset;
+  bfd *abfd = pst->objfile->obfd;
   
   /* Allocate a buffer for the entire chunk of DIE's for this compilation
      unit, seek to the location in the file, and read in all the DIE's. */
@@ -2291,8 +2325,8 @@ DEFUN(read_ofile_symtab, (pst, desc),
   dbbase = xmalloc (DBLENGTH(pst));
   dbroff = DBROFF(pst);
   foffset = DBFOFF(pst) + dbroff;
-  if ((lseek (desc, foffset, 0) != foffset) ||
-      (read (desc, dbbase, DBLENGTH(pst)) != DBLENGTH(pst)))
+  if (bfd_seek (abfd, foffset, 0) ||
+      (bfd_read (dbbase, DBLENGTH(pst), 1, abfd) != DBLENGTH(pst)))
     {
       free (dbbase);
       error ("can't read DWARF data");
@@ -2308,14 +2342,14 @@ DEFUN(read_ofile_symtab, (pst, desc),
   lnbase = NULL;
   if (LNFOFF (pst))
     {
-      if ((lseek (desc, LNFOFF (pst), 0) != LNFOFF (pst)) ||
-         (read (desc, &lnsize, sizeof(long)) != sizeof(long)))
+      if (bfd_seek (abfd, LNFOFF (pst), 0) ||
+         (bfd_read (&lnsize, sizeof(long), 1, abfd) != sizeof(long)))
        {
          error ("can't read DWARF line number table size");
        }
       lnbase = xmalloc (lnsize);
-      if ((lseek (desc, LNFOFF (pst), 0) != LNFOFF (pst)) ||
-         (read (desc, lnbase, lnsize) != lnsize))
+      if (bfd_seek (abfd, LNFOFF (pst), 0) ||
+         (bfd_read (lnbase, lnsize, 1, abfd) != lnsize))
        {
          free (lnbase);
          error ("can't read DWARF line numbers");
@@ -2323,7 +2357,7 @@ DEFUN(read_ofile_symtab, (pst, desc),
       make_cleanup (free, lnbase);
     }
 
-  process_dies (dbbase, dbbase + DBLENGTH(pst));
+  process_dies (dbbase, dbbase + DBLENGTH(pst), pst->objfile);
   do_cleanups (back_to);
   return (symtab_list);
 }
@@ -2336,7 +2370,7 @@ LOCAL FUNCTION
 
 SYNOPSIS
 
-       static void psymtab_to_symtab_1 (struct partial_symtab *pst, int desc)
+       static void psymtab_to_symtab_1 (struct partial_symtab *pst)
 
 DESCRIPTION
 
@@ -2347,9 +2381,8 @@ DESCRIPTION
 
 static void
 DEFUN(psymtab_to_symtab_1,
-      (pst, desc),
-      struct partial_symtab *pst AND
-      int desc)
+      (pst),
+      struct partial_symtab *pst)
 {
   int i;
   
@@ -2379,13 +2412,13 @@ DEFUN(psymtab_to_symtab_1,
            wrap_here ("");             /* Flush output */
            fflush (stdout);
          }
-       psymtab_to_symtab_1 (pst -> dependencies[i], desc);
+       psymtab_to_symtab_1 (pst -> dependencies[i]);
       }
   
   if (DBLENGTH(pst))           /* Otherwise it's a dummy */
     {
       /* Init stuff necessary for reading in symbols */
-      pst -> symtab = read_ofile_symtab (pst, desc);
+      pst -> symtab = read_ofile_symtab (pst);
       if (info_verbose)
        {
          printf_filtered ("%d DIE's, sorting...", diecount);
@@ -2417,10 +2450,7 @@ DESCRIPTION
 static void
 DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
 {
-  int desc;
-  struct cleanup *old_chain;
-  bfd *sym_bfd;
-  
+
   if (!pst)
     {
       return;
@@ -2442,30 +2472,7 @@ DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
          fflush (stdout);
        }
       
-      /* Open symbol file.  Symbol_file_command guarantees that the symbol
-        file name will be absolute, so there is no need for openp.  */
-      desc = open (pst -> symfile_name, O_RDONLY, 0);
-      
-      if (desc < 0)
-       {
-         perror_with_name (pst -> symfile_name);
-       }
-      
-      sym_bfd = bfd_fdopenr (pst -> symfile_name, NULL, desc);
-      if (!sym_bfd)
-       {
-         (void) close (desc);
-         error ("Could not open `%s' to read symbols: %s",
-                pst -> symfile_name, bfd_errmsg (bfd_error));
-       }
-      old_chain = make_cleanup (bfd_close, sym_bfd);
-      if (!bfd_check_format (sym_bfd, bfd_object))
-       {
-         error ("\"%s\": can't read symbols: %s.",
-                pst -> symfile_name, bfd_errmsg (bfd_error));
-       }
-      
-      psymtab_to_symtab_1 (pst, desc);
+      psymtab_to_symtab_1 (pst);
       
 #if 0 /* FIXME:  Check to see what dbxread is doing here and see if
         we need to do an equivalent or is this something peculiar to
@@ -2475,8 +2482,6 @@ DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
       scan_file_globals ();
 #endif
       
-      do_cleanups (old_chain);
-      
       /* Finish up the debug error message.  */
       if (info_verbose)
        {
@@ -2551,9 +2556,9 @@ DESCRIPTION
 
 static struct partial_symtab *
 DEFUN(start_psymtab,
-      (symfile_name, addr, filename, textlow, texthigh, dbfoff, curoff,
+      (objfile, addr, filename, textlow, texthigh, dbfoff, curoff,
        culength, lnfoff, global_syms, static_syms),
-      char *symfile_name AND
+      struct objfile *objfile AND
       CORE_ADDR addr AND
       char *filename AND
       CORE_ADDR textlow AND
@@ -2571,7 +2576,7 @@ DEFUN(start_psymtab,
       obstack_alloc (psymbol_obstack, sizeof (struct partial_symtab));
   (void) memset (result, 0, sizeof (struct partial_symtab));
   result -> addr = addr;
-  result -> symfile_name =  create_name (symfile_name, psymbol_obstack);
+  result -> objfile = objfile;
   result -> filename = create_name (filename, psymbol_obstack);
   result -> textlow = textlow;
   result -> texthigh = texthigh;
@@ -2655,11 +2660,13 @@ DEFUN(add_partial_symbol, (dip), struct dieinfo *dip)
   switch (dip -> dietag)
     {
     case TAG_global_subroutine:
-      record_misc_function (dip -> at_name, dip -> at_low_pc);
+      record_misc_function (dip -> at_name, dip -> at_low_pc, mf_text);
       add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE,
                           LOC_BLOCK, dip -> at_low_pc);
       break;
     case TAG_global_variable:
+      record_misc_function (dip -> at_name, locval (dip -> at_location),
+                           mf_data);
       add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE,
                           LOC_STATIC, 0);
       break;
@@ -2701,6 +2708,13 @@ DESCRIPTION
        so, then extracting all the attributes info and generating a
        partial symbol table entry.
 
+NOTES
+
+       Don't attempt to add anonymous structures, unions, or enumerations
+       since they have no name.  Also, for variables and subroutines,
+       check that this is the place where the actual definition occurs,
+       rather than just a reference to an external.
+
  */
 
 static void
@@ -2722,19 +2736,21 @@ DEFUN(scan_partial_symbols, (thisdie, enddie), char *thisdie AND char *enddie)
          switch (di.dietag)
            {
            case TAG_global_subroutine:
-           case TAG_global_variable:
            case TAG_subroutine:
+           case TAG_global_variable:
            case TAG_local_variable:
+             completedieinfo (&di);
+             if (di.at_name && (di.has_at_low_pc || di.at_location))
+               {
+                 add_partial_symbol (&di);
+               }
+             break;
            case TAG_typedef:
            case TAG_structure_type:
            case TAG_union_type:
            case TAG_enumeration_type:
              completedieinfo (&di);
-             /* Don't attempt to add anonymous structures, unions, or
-                enumerations since they have no name.  Also check that
-                this is the place where the actual definition occurs,
-                rather than just a reference to an external. */
-             if (di.at_name != NULL && !di.at_is_external_p)
+             if (di.at_name)
                {
                  add_partial_symbol (&di);
                }
@@ -2790,13 +2806,14 @@ RETURNS
 
 static void
 DEFUN(scan_compilation_units,
-      (filename, addr, thisdie, enddie, dbfoff, lnoffset),
+      (filename, addr, thisdie, enddie, dbfoff, lnoffset, objfile),
       char *filename AND
       CORE_ADDR addr AND
       char *thisdie AND
       char *enddie AND
       unsigned int dbfoff AND
-      unsigned int lnoffset)
+      unsigned int lnoffset AND
+      struct objfile *objfile)
 {
   char *nextdie;
   struct dieinfo di;
@@ -2829,8 +2846,8 @@ DEFUN(scan_compilation_units,
            }
          curoff = thisdie - dbbase;
          culength = nextdie - thisdie;
-         curlnoffset = di.at_stmt_list_p ? lnoffset + di.at_stmt_list : 0;
-         pst = start_psymtab (filename, addr, di.at_name,
+         curlnoffset = di.has_at_stmt_list ? lnoffset + di.at_stmt_list : 0;
+         pst = start_psymtab (objfile, addr, di.at_name,
                                     di.at_low_pc, di.at_high_pc,
                                     dbfoff, curoff, culength, curlnoffset,
                                     global_psymbols.next,
@@ -3017,7 +3034,7 @@ DEFUN(decode_mod_fund_type, (typedata), char *typedata)
   /* Deduct the size of the fundamental type bytes at the end of the block. */
   modcount -= sizeof (short);
   /* Skip over the two size bytes at the beginning of the block. */
-  modifiers = typedata + sizeof (short);
+  modifiers = (unsigned char *) typedata + sizeof (short);
   /* Now do the actual decoding */
   typep = decode_modified_type (modifiers, modcount, AT_mod_fund_type);
   return (typep);
@@ -3058,7 +3075,7 @@ DEFUN(decode_mod_u_d_type, (typedata), char *typedata)
   /* Deduct the size of the reference type bytes at the end of the block. */
   modcount -= sizeof (long);
   /* Skip over the two size bytes at the beginning of the block. */
-  modifiers = typedata + sizeof (short);
+  modifiers = (unsigned char *) typedata + sizeof (short);
   /* Now do the actual decoding */
   typep = decode_modified_type (modifiers, modcount, AT_mod_u_d_type);
   return (typep);
@@ -3438,10 +3455,11 @@ DEFUN(completedieinfo, (dip), struct dieinfo *dip)
          break;
        case AT_stmt_list:
          (void) memcpy (&dip -> at_stmt_list, diep, sizeof (long));
-         dip -> at_stmt_list_p = 1;
+         dip -> has_at_stmt_list = 1;
          break;
        case AT_low_pc:
          (void) memcpy (&dip -> at_low_pc, diep, sizeof (long));
+         dip -> has_at_low_pc = 1;
          break;
        case AT_high_pc:
          (void) memcpy (&dip -> at_high_pc, diep, sizeof (long));
@@ -3479,11 +3497,13 @@ DEFUN(completedieinfo, (dip), struct dieinfo *dip)
        case AT_mod_u_d_type:
          dip -> at_mod_u_d_type = diep;
          break;
-       case AT_deriv_list:
-         dip -> at_deriv_list = diep;
-         break;
        case AT_element_list:
          dip -> at_element_list = diep;
+         dip -> short_element_list = 0;
+         break;
+       case AT_short_element_list:
+         dip -> at_element_list = diep;
+         dip -> short_element_list = 1;
          break;
        case AT_discr_value:
          dip -> at_discr_value = diep;
@@ -3500,15 +3520,9 @@ DEFUN(completedieinfo, (dip), struct dieinfo *dip)
        case AT_producer:
          dip -> at_producer = diep;
          break;
-       case AT_loclist:
-         (void) memcpy (&dip -> at_loclist, diep, sizeof (long));
-         break;
        case AT_frame_base:
          (void) memcpy (&dip -> at_frame_base, diep, sizeof (long));
          break;
-       case AT_incomplete:
-         (void) memcpy (&dip -> at_incomplete, diep, sizeof (short));
-         break;
        case AT_start_scope:
          (void) memcpy (&dip -> at_start_scope, diep, sizeof (long));
          break;
@@ -3521,13 +3535,6 @@ DEFUN(completedieinfo, (dip), struct dieinfo *dip)
        case AT_prototyped:
          (void) memcpy (&dip -> at_prototyped, diep, sizeof (short));
          break;
-       case AT_const_data:
-         dip -> at_const_data = diep;
-         break;
-       case AT_is_external:
-         (void) memcpy (&dip -> at_is_external, diep, sizeof (short));
-         dip -> at_is_external_p = 1;
-         break;
        default:
          /* Found an attribute that we are unprepared to handle.  However
             it is specifically one of the design goals of DWARF that
This page took 0.050866 seconds and 4 git commands to generate.