]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/dwarf2read.c
Switch the license of all .c files to GPLv3.
[thirdparty/binutils-gdb.git] / gdb / dwarf2read.c
index a2a066a1bbf909430fd8f0a1648e2aa2c39d5f92..458d04a258679f2a53e32c87add0627f92ec5993 100644 (file)
@@ -1,32 +1,29 @@
 /* DWARF 2 debugging format support for GDB.
 
    Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006
-   Free Software Foundation, Inc.
+                 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
    Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
    Inc.  with support from Florida State University (under contract
    with the Ada Joint Program Office), and Silicon Graphics, Inc.
    Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
    based on Fred Fish's (Cygnus Support) implementation of DWARF 1
-   support in dwarfread.c
+   support.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or (at
-   your option) any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "bfd.h"
    can be used for any other data associated to the objfile (symbol
    names, type names, location expressions to name a few).  */
 
-#ifndef DWARF2_REG_TO_REGNUM
-#define DWARF2_REG_TO_REGNUM(REG) (REG)
-#endif
-
 #if 0
 /* .debug_info header for a compilation unit
    Because of alignment constraints, this structure has padding and cannot
@@ -180,6 +173,10 @@ struct dwarf2_per_objfile
   /* A chain of compilation units that are currently read in, so that
      they can be freed later.  */
   struct dwarf2_per_cu_data *read_in_chain;
+
+  /* A flag indicating wether this objfile has a section loaded at a
+     VMA of 0.  */
+  int has_section_at_zero;
 };
 
 static struct dwarf2_per_objfile *dwarf2_per_objfile;
@@ -338,6 +335,9 @@ struct dwarf2_cu
      partial symbol tables do not have dependencies.  */
   htab_t dependencies;
 
+  /* Header data from the line table, during full symbol processing.  */
+  struct line_header *line_header;
+
   /* Mark used when releasing cached dies.  */
   unsigned int mark : 1;
 
@@ -360,16 +360,22 @@ struct dwarf2_cu
 
 struct dwarf2_per_cu_data
 {
-  /* The start offset and length of this compilation unit.  2**31-1
+  /* The start offset and length of this compilation unit.  2**30-1
      bytes should suffice to store the length of any compilation unit
      - if it doesn't, GDB will fall over anyway.  */
   unsigned long offset;
-  unsigned long length : 31;
+  unsigned long length : 30;
 
   /* Flag indicating this compilation unit will be read in before
      any of the current compilation units are processed.  */
   unsigned long queued : 1;
 
+  /* This flag will be set if we need to load absolutely all DIEs
+     for this compilation unit, instead of just the ones we think
+     are interesting.  It gets set if we look for a DIE in the
+     hash table and don't find it.  */
+  unsigned int load_all_dies : 1;
+
   /* Set iff currently read in.  */
   struct dwarf2_cu *cu;
 
@@ -379,7 +385,9 @@ struct dwarf2_per_cu_data
      it.  */
   htab_t type_hash;
 
-  /* The partial symbol table associated with this compilation unit.  */
+  /* The partial symbol table associated with this compilation unit,
+     or NULL for partial units (which do not have an associated
+     symtab).  */
   struct partial_symtab *psymtab;
 };
 
@@ -421,6 +429,7 @@ struct line_header
     unsigned int mod_time;
     unsigned int length;
     int included_p; /* Non-zero if referenced by the Line Number Program.  */
+    struct symtab *symtab; /* The associated symbol table, if any.  */
   } *file_names;
 
   /* The start and end of the statement program following this
@@ -455,6 +464,9 @@ struct partial_die_info
        computed.  */
     unsigned int scope_set : 1;
 
+    /* Flag set if the DIE has a byte_size attribute.  */
+    unsigned int has_byte_size : 1;
+
     /* The name of this DIE.  Normally the value of DW_AT_name, but
        sometimes DW_TAG_MIPS_linkage_name or a string computed in some
        other fashion.  */
@@ -669,6 +681,13 @@ dwarf2_statement_list_fits_in_line_number_section_complaint (void)
             _("statement list doesn't fit in .debug_line section"));
 }
 
+static void
+dwarf2_debug_line_missing_file_complaint (void)
+{
+  complaint (&symfile_complaints,
+            _(".debug_line section has line data without a file"));
+}
+
 static void
 dwarf2_complex_location_expr_complaint (void)
 {
@@ -840,7 +859,7 @@ static struct line_header *(dwarf_decode_line_header
 static void dwarf_decode_lines (struct line_header *, char *, bfd *,
                                struct dwarf2_cu *, struct partial_symtab *);
 
-static void dwarf2_start_subfile (char *, char *);
+static void dwarf2_start_subfile (char *, char *, char *);
 
 static struct symbol *new_symbol (struct die_info *, struct type *,
                                  struct dwarf2_cu *);
@@ -1021,19 +1040,15 @@ static void dwarf_decode_macros (struct line_header *, unsigned int,
 
 static int attr_form_is_block (struct attribute *);
 
-static void
-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
-                            struct dwarf2_cu *cu);
+static void dwarf2_symbol_mark_computed (struct attribute *attr,
+                                        struct symbol *sym,
+                                        struct dwarf2_cu *cu);
 
 static gdb_byte *skip_one_die (gdb_byte *info_ptr, struct abbrev_info *abbrev,
                                struct dwarf2_cu *cu);
 
 static void free_stack_comp_unit (void *);
 
-static void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
-
-static void dummy_obstack_deallocate (void *object, void *data);
-
 static hashval_t partial_die_hash (const void *item);
 
 static int partial_die_eq (const void *item_lhs, const void *item_rhs);
@@ -1060,7 +1075,8 @@ static void reset_die_and_siblings_types (struct die_info *,
 
 static void create_all_comp_units (struct objfile *);
 
-static struct dwarf2_cu *load_full_comp_unit (struct dwarf2_per_cu_data *);
+static struct dwarf2_cu *load_full_comp_unit (struct dwarf2_per_cu_data *,
+                                             struct objfile *);
 
 static void process_full_comp_unit (struct dwarf2_per_cu_data *);
 
@@ -1071,6 +1087,9 @@ static void dwarf2_mark (struct dwarf2_cu *);
 
 static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
 
+static void read_set_type (struct die_info *, struct dwarf2_cu *);
+
+
 /* Try to locate the sections we need for DWARF 2 debugging
    information and return true if we have enough to do something.  */
 
@@ -1104,7 +1123,7 @@ dwarf2_has_info (struct objfile *objfile)
    in.  */
 
 static void
-dwarf2_locate_sections (bfd *ignore_abfd, asection *sectp, void *ignore_ptr)
+dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
 {
   if (strcmp (sectp->name, INFO_SECTION) == 0)
     {
@@ -1165,6 +1184,10 @@ dwarf2_locate_sections (bfd *ignore_abfd, asection *sectp, void *ignore_ptr)
       dwarf2_per_objfile->ranges_size = bfd_get_section_size (sectp);
       dwarf_ranges_section = sectp;
     }
+  
+  if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
+      && bfd_section_vma (abfd, sectp) == 0)
+    dwarf2_per_objfile->has_section_at_zero = 1;
 }
 
 /* Build a partial symbol table.  */
@@ -1299,7 +1322,7 @@ partial_read_comp_unit_head (struct comp_unit_head *header, gdb_byte *info_ptr,
 
   info_ptr = read_comp_unit_head (header, info_ptr, abfd);
 
-  if (header->version != 2)
+  if (header->version != 2 && header->version != 3)
     error (_("Dwarf Error: wrong version in compilation unit header "
           "(is %d, should be %d) [in module %s]"), header->version,
           2, bfd_get_filename (abfd));
@@ -1457,6 +1480,14 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
       info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
                                   abfd, info_ptr, &cu);
 
+      if (comp_unit_die.tag == DW_TAG_partial_unit)
+       {
+         info_ptr = (beg_of_comp_unit + cu.header.length
+                     + cu.header.initial_length_size);
+         do_cleanups (back_to_inner);
+         continue;
+       }
+
       /* Set the language we're debugging */
       set_cu_language (comp_unit_die.language, &cu);
 
@@ -1853,7 +1884,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
   CORE_ADDR addr = 0;
-  char *actual_name;
+  char *actual_name = NULL;
   const char *my_prefix;
   const struct partial_symbol *psym = NULL;
   CORE_ADDR baseaddr;
@@ -1861,8 +1892,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  actual_name = NULL;
-
   if (pdi_needs_namespace (pdi->tag))
     {
       actual_name = partial_die_full_name (pdi, cu);
@@ -1926,7 +1955,11 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
        {
          /* Static Variable. Skip symbols without location descriptors.  */
          if (pdi->locdesc == NULL)
-           return;
+           {
+             if (built_actual_name)
+               xfree (actual_name);
+             return;
+           }
          addr = decode_locdesc (pdi->locdesc, cu);
          /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
             mst_file_data, objfile); */
@@ -1955,12 +1988,20 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
     case DW_TAG_enumeration_type:
-      /* Skip aggregate types without children, these are external
-         references.  */
+      /* Skip external references.  The DWARF standard says in the section
+         about "Structure, Union, and Class Type Entries": "An incomplete
+         structure, union or class type is represented by a structure,
+         union or class entry that does not have a byte size attribute
+         and that has a DW_AT_declaration attribute."  */
+      if (!pdi->has_byte_size && pdi->is_declaration)
+       {
+         if (built_actual_name)
+           xfree (actual_name);
+         return;
+       }
+
       /* NOTE: carlton/2003-10-07: See comment in new_symbol about
         static vs. global.  */
-      if (pdi->has_children == 0)
-       return;
       add_psymbol_to_list (actual_name, strlen (actual_name),
                           STRUCT_DOMAIN, LOC_TYPEDEF,
                           (cu->language == language_cplus
@@ -1970,7 +2011,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
                           0, (CORE_ADDR) 0, cu->language, objfile);
 
       if (cu->language == language_cplus
-          || cu->language == language_java)
+          || cu->language == language_java
+          || cu->language == language_ada)
        {
          /* For C++ and Java, these implicitly act as typedefs as well. */
          add_psymbol_to_list (actual_name, strlen (actual_name),
@@ -2373,14 +2415,14 @@ process_queue (struct objfile *objfile)
     {
       /* Read in this compilation unit.  This may add new items to
         the end of the queue.  */
-      load_full_comp_unit (item->per_cu);
+      load_full_comp_unit (item->per_cu, objfile);
 
       item->per_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
       dwarf2_per_objfile->read_in_chain = item->per_cu;
 
       /* If this compilation unit has already had full symbols created,
         reset the TYPE fields in each DIE.  */
-      if (item->per_cu->psymtab->readin)
+      if (item->per_cu->type_hash)
        reset_die_and_siblings_types (item->per_cu->cu->dies,
                                      item->per_cu->cu);
     }
@@ -2389,7 +2431,7 @@ process_queue (struct objfile *objfile)
      them, one at a time, removing from the queue as we finish.  */
   for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item)
     {
-      if (!item->per_cu->psymtab->readin)
+      if (item->per_cu->psymtab && !item->per_cu->psymtab->readin)
        process_full_comp_unit (item->per_cu);
 
       item->per_cu->queued = 0;
@@ -2482,10 +2524,9 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
 /* Load the DIEs associated with PST and PER_CU into memory.  */
 
 static struct dwarf2_cu *
-load_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
+load_full_comp_unit (struct dwarf2_per_cu_data *per_cu, struct objfile *objfile)
 {
-  struct partial_symtab *pst = per_cu->psymtab;
-  bfd *abfd = pst->objfile->obfd;
+  bfd *abfd = objfile->obfd;
   struct dwarf2_cu *cu;
   unsigned long offset;
   gdb_byte *info_ptr;
@@ -2504,7 +2545,7 @@ load_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
   /* If an error occurs while loading, release our storage.  */
   free_cu_cleanup = make_cleanup (free_one_comp_unit, cu);
 
-  cu->objfile = pst->objfile;
+  cu->objfile = objfile;
 
   /* read in the comp_unit header  */
   info_ptr = read_comp_unit_head (&cu->header, info_ptr, abfd);
@@ -2660,6 +2701,9 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_subroutine_type:
       read_subroutine_type (die, cu);
       break;
+    case DW_TAG_set_type:
+      read_set_type (die, cu);
+      break;
     case DW_TAG_array_type:
       read_array_type (die, cu);
       break;
@@ -2721,6 +2765,15 @@ initialize_cu_func_list (struct dwarf2_cu *cu)
   cu->first_fn = cu->last_fn = cu->cached_fn = NULL;
 }
 
+static void
+free_cu_line_header (void *arg)
+{
+  struct dwarf2_cu *cu = arg;
+
+  free_line_header (cu->line_header);
+  cu->line_header = NULL;
+}
+
 static void
 read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -2730,7 +2783,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   CORE_ADDR lowpc = ((CORE_ADDR) -1);
   CORE_ADDR highpc = ((CORE_ADDR) 0);
   struct attribute *attr;
-  char *name = "<unknown>";
+  char *name = NULL;
   char *comp_dir = NULL;
   struct die_info *child_die;
   bfd *abfd = objfile->obfd;
@@ -2753,21 +2806,29 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
     {
       name = DW_STRING (attr);
     }
+
   attr = dwarf2_attr (die, DW_AT_comp_dir, cu);
   if (attr)
+    comp_dir = DW_STRING (attr);
+  else if (name != NULL && IS_ABSOLUTE_PATH (name))
     {
-      comp_dir = DW_STRING (attr);
-      if (comp_dir)
-       {
-         /* Irix 6.2 native cc prepends <machine>.: to the compilation
-            directory, get rid of it.  */
-         char *cp = strchr (comp_dir, ':');
+      comp_dir = ldirname (name);
+      if (comp_dir != NULL)
+       make_cleanup (xfree, comp_dir);
+    }
+  if (comp_dir != NULL)
+    {
+      /* Irix 6.2 native cc prepends <machine>.: to the compilation
+        directory, get rid of it.  */
+      char *cp = strchr (comp_dir, ':');
 
-         if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
-           comp_dir = cp + 1;
-       }
+      if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
+       comp_dir = cp + 1;
     }
 
+  if (name == NULL)
+    name = "<unknown>";
+
   attr = dwarf2_attr (die, DW_AT_language, cu);
   if (attr)
     {
@@ -2777,16 +2838,9 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   attr = dwarf2_attr (die, DW_AT_producer, cu);
   if (attr) 
     cu->producer = DW_STRING (attr);
-  
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
-#if 0
-  /* FIXME:Do something here.  */
-  if (dip->at_producer != NULL)
-    {
-      handle_producer (dip->at_producer);
-    }
-#endif
 
   /* The compilation unit may be in a different language or objfile,
      zero out all remembered fundamental types.  */
@@ -2794,21 +2848,13 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   start_symtab (name, comp_dir, lowpc);
   record_debugformat ("DWARF 2");
+  record_producer (cu->producer);
 
   initialize_cu_func_list (cu);
 
-  /* Process all dies in compilation unit.  */
-  if (die->child != NULL)
-    {
-      child_die = die->child;
-      while (child_die && child_die->tag)
-       {
-         process_die (child_die, cu);
-         child_die = sibling_die (child_die);
-       }
-    }
-
-  /* Decode line number information if present.  */
+  /* Decode line number information if present.  We do this before
+     processing child DIEs, so that the line header table is available
+     for DW_AT_decl_file.  */
   attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
   if (attr)
     {
@@ -2816,12 +2862,23 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
       line_header = dwarf_decode_line_header (line_offset, abfd, cu);
       if (line_header)
         {
-          make_cleanup ((make_cleanup_ftype *) free_line_header,
-                        (void *) line_header);
+          cu->line_header = line_header;
+          make_cleanup (free_cu_line_header, cu);
           dwarf_decode_lines (line_header, comp_dir, abfd, cu, NULL);
         }
     }
 
+  /* Process all dies in compilation unit.  */
+  if (die->child != NULL)
+    {
+      child_die = die->child;
+      while (child_die && child_die->tag)
+       {
+         process_die (child_die, cu);
+         child_die = sibling_die (child_die);
+       }
+    }
+
   /* Decode macro information, if present.  Dwarf 2 macro information
      refers to information in the line number info statement program
      header, so we can only read it if we've read the header
@@ -3169,7 +3226,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
      labels are not in the output, so the relocs get a value of 0.
      If this is a discarded function, mark the pc bounds as invalid,
      so that GDB will ignore it.  */
-  if (low == 0 && (bfd_get_file_flags (obfd) & HAS_RELOC) == 0)
+  if (low == 0 && !dwarf2_per_objfile->has_section_at_zero)
     return 0;
 
   *lowpc = low;
@@ -3673,7 +3730,6 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
   TYPE_NFN_FIELDS_TOTAL (type) = total_length;
 }
 
-
 /* Returns non-zero if NAME is the name of a vtable member in CU's
    language, zero otherwise.  */
 static int
@@ -3692,6 +3748,72 @@ is_vtable_name (const char *name, struct dwarf2_cu *cu)
   return 0;
 }
 
+/* GCC outputs unnamed structures that are really pointers to member
+   functions, with the ABI-specified layout.  If DIE (from CU) describes
+   such a structure, set its type, and return nonzero.  Otherwise return
+   zero.
+
+   GCC shouldn't do this; it should just output pointer to member DIEs.
+   This is GCC PR debug/28767.  */
+
+static int
+quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct objfile *objfile = cu->objfile;
+  struct type *type;
+  struct die_info *pfn_die, *delta_die;
+  struct attribute *pfn_name, *delta_name;
+  struct type *pfn_type, *domain_type;
+
+  /* Check for a structure with no name and two children.  */
+  if (die->tag != DW_TAG_structure_type
+      || dwarf2_attr (die, DW_AT_name, cu) != NULL
+      || die->child == NULL
+      || die->child->sibling == NULL
+      || (die->child->sibling->sibling != NULL
+         && die->child->sibling->sibling->tag != DW_TAG_padding))
+    return 0;
+
+  /* Check for __pfn and __delta members.  */
+  pfn_die = die->child;
+  pfn_name = dwarf2_attr (pfn_die, DW_AT_name, cu);
+  if (pfn_die->tag != DW_TAG_member
+      || pfn_name == NULL
+      || DW_STRING (pfn_name) == NULL
+      || strcmp ("__pfn", DW_STRING (pfn_name)) != 0)
+    return 0;
+
+  delta_die = pfn_die->sibling;
+  delta_name = dwarf2_attr (delta_die, DW_AT_name, cu);
+  if (delta_die->tag != DW_TAG_member
+      || delta_name == NULL
+      || DW_STRING (delta_name) == NULL
+      || strcmp ("__delta", DW_STRING (delta_name)) != 0)
+    return 0;
+
+  /* Find the type of the method.  */
+  pfn_type = die_type (pfn_die, cu);
+  if (pfn_type == NULL
+      || TYPE_CODE (pfn_type) != TYPE_CODE_PTR
+      || TYPE_CODE (TYPE_TARGET_TYPE (pfn_type)) != TYPE_CODE_FUNC)
+    return 0;
+
+  /* Look for the "this" argument.  */
+  pfn_type = TYPE_TARGET_TYPE (pfn_type);
+  if (TYPE_NFIELDS (pfn_type) == 0
+      || TYPE_CODE (TYPE_FIELD_TYPE (pfn_type, 0)) != TYPE_CODE_PTR)
+    return 0;
+
+  domain_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
+  type = alloc_type (objfile);
+  smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type),
+                       TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
+                       TYPE_VARARGS (pfn_type));
+  type = lookup_methodptr_type (type);
+  set_die_type (die, type, cu);
+
+  return 1;
+}
 
 /* Called when we find the DIE that starts a structure or union scope
    (definition) to process all dies that define the members of the
@@ -3721,8 +3843,10 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
   if (die->type)
     return;
 
-  type = alloc_type (objfile);
+  if (quirk_gcc_member_function_pointer (die, cu))
+    return;
 
+  type = alloc_type (objfile);
   INIT_CPLUS_SPECIFIC (type);
   attr = dwarf2_attr (die, DW_AT_name, cu);
   if (attr && DW_STRING (attr))
@@ -3770,6 +3894,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
       TYPE_LENGTH (type) = 0;
     }
 
+  TYPE_FLAGS (type) |= TYPE_FLAG_STUB_SUPPORTED;
   if (die_is_declaration (die, cu))
     TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
 
@@ -3923,7 +4048,11 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
       child_die = sibling_die (child_die);
     }
 
-  if (die->child != NULL && ! die_is_declaration (die, cu))
+  /* Do not consider external references.  According to the DWARF standard,
+     these DIEs are identified by the fact that they have no byte_size
+     attribute, and a declaration attribute.  */
+  if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL
+      || !die_is_declaration (die, cu))
     new_symbol (die, die->type, cu);
 
   processing_current_prefix = previous_prefix;
@@ -4198,6 +4327,10 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
   if (attr)
     TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;
 
+  attr = dwarf2_attr (die, DW_AT_name, cu);
+  if (attr && DW_STRING (attr))
+    TYPE_NAME (type) = DW_STRING (attr);
+  
   do_cleanups (back_to);
 
   /* Install the type in the die. */
@@ -4238,6 +4371,15 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
     };
 }
 
+/* Extract all information from a DW_TAG_set_type DIE and put it in
+   the DIE's type field. */
+
+static void
+read_set_type (struct die_info *die, struct dwarf2_cu *cu)
+{
+  if (die->type == NULL)
+    die->type = create_set_type ((struct type *) NULL, die_type (die, cu));
+}
 
 /* First cut: install each common block member as a global variable.  */
 
@@ -4417,11 +4559,12 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
      length accordingly.  */
   if (TYPE_LENGTH (type) != byte_size || addr_class != DW_ADDR_none)
     {
-      if (ADDRESS_CLASS_TYPE_FLAGS_P ())
+      if (gdbarch_address_class_type_flags_p (current_gdbarch))
        {
          int type_flags;
 
-         type_flags = ADDRESS_CLASS_TYPE_FLAGS (byte_size, addr_class);
+         type_flags = gdbarch_address_class_type_flags
+                        (current_gdbarch, byte_size, addr_class);
          gdb_assert ((type_flags & ~TYPE_FLAG_ADDRESS_CLASS_ALL) == 0);
          type = make_type_with_address_space (type, type_flags);
        }
@@ -4454,10 +4597,13 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
       return;
     }
 
-  type = alloc_type (objfile);
   to_type = die_type (die, cu);
   domain = die_containing_type (die, cu);
-  smash_to_member_type (type, domain, to_type);
+
+  if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_METHOD)
+    type = lookup_methodptr_type (to_type);
+  else
+    type = lookup_memberptr_type (to_type, domain);
 
   set_die_type (die, type, cu);
 }
@@ -4627,7 +4773,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
       /* Allocate storage for parameters and fill them in.  */
       TYPE_NFIELDS (ftype) = nparams;
       TYPE_FIELDS (ftype) = (struct field *)
-       TYPE_ALLOC (ftype, nparams * sizeof (struct field));
+       TYPE_ZALLOC (ftype, nparams * sizeof (struct field));
 
       child_die = die->child;
       while (child_die && child_die->tag)
@@ -4726,10 +4872,17 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
          code = TYPE_CODE_FLT;
          break;
        case DW_ATE_signed:
-       case DW_ATE_signed_char:
          break;
        case DW_ATE_unsigned:
-       case DW_ATE_unsigned_char:
+         type_flags |= TYPE_FLAG_UNSIGNED;
+         break;
+       case DW_ATE_signed_char:
+         if (cu->language == language_m2)
+           code = TYPE_CODE_CHAR;
+         break;
+       case DW_ATE_unsigned_char:
+         if (cu->language == language_m2)
+           code = TYPE_CODE_CHAR;
          type_flags |= TYPE_FLAG_UNSIGNED;
          break;
        default:
@@ -4777,16 +4930,15 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
     return;
 
   base_type = die_type (die, cu);
-  if (base_type == NULL)
+  if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
     {
       complaint (&symfile_complaints,
                 _("DW_AT_type missing from DW_TAG_subrange_type"));
-      return;
+      base_type
+       = dwarf_base_type (DW_ATE_signed,
+                          gdbarch_addr_bit (current_gdbarch) / 8, cu);
     }
 
-  if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
-    base_type = alloc_type (NULL);
-
   if (cu->language == language_fortran)
     { 
       /* FORTRAN implies a lower bound of 1, if not given.  */
@@ -4835,6 +4987,23 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   set_die_type (die, range_type, cu);
 }
   
+static void
+read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct type *type;
+  struct attribute *attr;
+
+  if (die->type)
+    return;
+
+  /* For now, we only support the C meaning of an unspecified type: void.  */
+
+  attr = dwarf2_attr (die, DW_AT_name, cu);
+  type = init_type (TYPE_CODE_VOID, 0, 0, attr ? DW_STRING (attr) : "",
+                   cu->objfile);
+
+  set_die_type (die, type, cu);
+}
 
 /* Read a whole compilation unit into a linked list of dies.  */
 
@@ -5148,12 +5317,16 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
   struct partial_die_info *parent_die, *last_die, *first_die = NULL;
   struct abbrev_info *abbrev;
   unsigned int bytes_read;
+  unsigned int load_all = 0;
 
   int nesting_level = 1;
 
   parent_die = NULL;
   last_die = NULL;
 
+  if (cu->per_cu && cu->per_cu->load_all_dies)
+    load_all = 1;
+
   cu->partial_dies
     = htab_create_alloc_ex (cu->header.length / 12,
                            partial_die_hash,
@@ -5189,12 +5362,17 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
          continue;
        }
 
-      /* Check whether this DIE is interesting enough to save.  */
-      if (!is_type_tag_for_partial (abbrev->tag)
+      /* Check whether this DIE is interesting enough to save.  Normally
+        we would not be interested in members here, but there may be
+        later variables referencing them via DW_AT_specification (for
+        static members).  */
+      if (!load_all
+         && !is_type_tag_for_partial (abbrev->tag)
          && abbrev->tag != DW_TAG_enumerator
          && abbrev->tag != DW_TAG_subprogram
          && abbrev->tag != DW_TAG_variable
-         && abbrev->tag != DW_TAG_namespace)
+         && abbrev->tag != DW_TAG_namespace
+         && abbrev->tag != DW_TAG_member)
        {
          /* Otherwise we skip to the next sibling, if any.  */
          info_ptr = skip_one_die (info_ptr + bytes_read, abbrev, cu);
@@ -5294,9 +5472,11 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
 
         Adding more things than necessary to the hash table is harmless
         except for the performance cost.  Adding too few will result in
-        internal errors in find_partial_die.  */
+        wasted time in find_partial_die, when we reread the compilation
+        unit with load_all_dies set.  */
 
-      if (abbrev->tag == DW_TAG_subprogram
+      if (load_all
+         || abbrev->tag == DW_TAG_subprogram
          || abbrev->tag == DW_TAG_variable
          || abbrev->tag == DW_TAG_namespace
          || part_die->is_declaration)
@@ -5316,7 +5496,8 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
         languages we have to, both so that we can get at method physnames
         to infer fully qualified class names, and for DW_AT_specification.  */
       if (last_die->has_children
-         && (last_die->tag == DW_TAG_namespace
+         && (load_all
+             || last_die->tag == DW_TAG_namespace
              || last_die->tag == DW_TAG_enumeration_type
              || (cu->language != language_c
                  && (last_die->tag == DW_TAG_class_type
@@ -5436,6 +5617,9 @@ read_partial_die (struct partial_die_info *part_die,
           part_die->has_stmt_list = 1;
           part_die->line_offset = DW_UNSND (&attr);
           break;
+        case DW_AT_byte_size:
+          part_die->has_byte_size = 1;
+          break;
        default:
          break;
        }
@@ -5452,7 +5636,7 @@ read_partial_die (struct partial_die_info *part_die,
   if (has_low_pc_attr && has_high_pc_attr
       && part_die->lowpc < part_die->highpc
       && (part_die->lowpc != 0
-         || (bfd_get_file_flags (abfd) & HAS_RELOC)))
+         || dwarf2_per_objfile->has_section_at_zero))
     part_die->has_pc_info = 1;
   return info_ptr;
 }
@@ -5468,10 +5652,6 @@ find_partial_die_in_comp_unit (unsigned long offset, struct dwarf2_cu *cu)
   part_die.offset = offset;
   lookup_die = htab_find_with_hash (cu->partial_dies, &part_die, offset);
 
-  if (lookup_die == NULL)
-    internal_error (__FILE__, __LINE__,
-                   _("could not find partial DIE in cache\n"));
-
   return lookup_die;
 }
 
@@ -5480,11 +5660,16 @@ find_partial_die_in_comp_unit (unsigned long offset, struct dwarf2_cu *cu)
 static struct partial_die_info *
 find_partial_die (unsigned long offset, struct dwarf2_cu *cu)
 {
-  struct dwarf2_per_cu_data *per_cu;
+  struct dwarf2_per_cu_data *per_cu = NULL;
+  struct partial_die_info *pd = NULL;
 
   if (offset >= cu->header.offset
       && offset < cu->header.offset + cu->header.length)
-    return find_partial_die_in_comp_unit (offset, cu);
+    {
+      pd = find_partial_die_in_comp_unit (offset, cu);
+      if (pd != NULL)
+       return pd;
+    }
 
   per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile);
 
@@ -5496,7 +5681,42 @@ find_partial_die (unsigned long offset, struct dwarf2_cu *cu)
     }
 
   per_cu->cu->last_used = 0;
-  return find_partial_die_in_comp_unit (offset, per_cu->cu);
+  pd = find_partial_die_in_comp_unit (offset, per_cu->cu);
+
+  if (pd == NULL && per_cu->load_all_dies == 0)
+    {
+      struct cleanup *back_to;
+      struct partial_die_info comp_unit_die;
+      struct abbrev_info *abbrev;
+      unsigned int bytes_read;
+      char *info_ptr;
+
+      per_cu->load_all_dies = 1;
+
+      /* Re-read the DIEs.  */
+      back_to = make_cleanup (null_cleanup, 0);
+      if (per_cu->cu->dwarf2_abbrevs == NULL)
+       {
+         dwarf2_read_abbrevs (per_cu->cu->objfile->obfd, per_cu->cu);
+         back_to = make_cleanup (dwarf2_free_abbrev_table, per_cu->cu);
+       }
+      info_ptr = per_cu->cu->header.first_die_ptr;
+      abbrev = peek_die_abbrev (info_ptr, &bytes_read, per_cu->cu);
+      info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
+                                  per_cu->cu->objfile->obfd, info_ptr,
+                                  per_cu->cu);
+      if (comp_unit_die.has_children)
+       load_partial_dies (per_cu->cu->objfile->obfd, info_ptr, 0, per_cu->cu);
+      do_cleanups (back_to);
+
+      pd = find_partial_die_in_comp_unit (offset, per_cu->cu);
+    }
+
+  if (pd == NULL)
+    internal_error (__FILE__, __LINE__,
+                   _("could not find partial DIE 0x%lx in cache [from module %s]\n"),
+                   offset, bfd_get_filename (cu->objfile->obfd));
+  return pd;
 }
 
 /* Adjust PART_DIE before generating a symbol for it.  This function
@@ -6118,10 +6338,14 @@ set_cu_language (unsigned int lang, struct dwarf2_cu *cu)
     case DW_LANG_Ada95:
       cu->language = language_ada;
       break;
+    case DW_LANG_Modula2:
+      cu->language = language_m2;
+      break;
+    case DW_LANG_Pascal83:
+      cu->language = language_pascal;
+      break;
     case DW_LANG_Cobol74:
     case DW_LANG_Cobol85:
-    case DW_LANG_Pascal83:
-    case DW_LANG_Modula2:
     default:
       cu->language = language_minimal;
       break;
@@ -6267,6 +6491,7 @@ add_file_name (struct line_header *lh,
   fe->mod_time = mod_time;
   fe->length = length;
   fe->included_p = 0;
+  fe->symtab = NULL;
 }
  
 
@@ -6447,13 +6672,14 @@ static void
 dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                    struct dwarf2_cu *cu, struct partial_symtab *pst)
 {
-  gdb_byte *line_ptr;
+  gdb_byte *line_ptr, *extended_end;
   gdb_byte *line_end;
-  unsigned int bytes_read;
+  unsigned int bytes_read, extended_len;
   unsigned char op_code, extended_op, adj_opcode;
   CORE_ADDR baseaddr;
   struct objfile *objfile = cu->objfile;
   const int decode_for_pst_p = (pst != NULL);
+  struct subfile *last_subfile = NULL, *first_subfile = current_subfile;
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
@@ -6479,13 +6705,12 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
             directory and file name numbers in the statement program
             are 1-based.  */
           struct file_entry *fe = &lh->file_names[file - 1];
-          char *dir;
+          char *dir = NULL;
 
           if (fe->dir_index)
             dir = lh->include_dirs[fe->dir_index - 1];
-          else
-            dir = comp_dir;
-         dwarf2_start_subfile (fe->name, dir);
+
+         dwarf2_start_subfile (fe->name, dir, comp_dir);
        }
 
       /* Decode the table.  */
@@ -6501,29 +6726,47 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
              address += (adj_opcode / lh->line_range)
                * lh->minimum_instruction_length;
              line += lh->line_base + (adj_opcode % lh->line_range);
-              lh->file_names[file - 1].included_p = 1;
-              if (!decode_for_pst_p)
-                {
-                 /* Append row to matrix using current values.  */
-                 record_line (current_subfile, line, 
-                              check_cu_functions (address, cu));
-                }
+             if (lh->num_file_names < file)
+               dwarf2_debug_line_missing_file_complaint ();
+             else
+               {
+                 lh->file_names[file - 1].included_p = 1;
+                 if (!decode_for_pst_p)
+                    {
+                      if (last_subfile != current_subfile)
+                        {
+                          if (last_subfile)
+                            record_line (last_subfile, 0, address);
+                          last_subfile = current_subfile;
+                        }
+                     /* Append row to matrix using current values.  */
+                     record_line (current_subfile, line, 
+                                  check_cu_functions (address, cu));
+                   }
+               }
              basic_block = 1;
            }
          else switch (op_code)
            {
            case DW_LNS_extended_op:
-             read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+             extended_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
              line_ptr += bytes_read;
+             extended_end = line_ptr + extended_len;
              extended_op = read_1_byte (abfd, line_ptr);
              line_ptr += 1;
              switch (extended_op)
                {
                case DW_LNE_end_sequence:
                  end_sequence = 1;
-                  lh->file_names[file - 1].included_p = 1;
-                  if (!decode_for_pst_p)
-                   record_line (current_subfile, 0, address);
+
+                 if (lh->num_file_names < file)
+                   dwarf2_debug_line_missing_file_complaint ();
+                 else
+                   {
+                     lh->file_names[file - 1].included_p = 1;
+                     if (!decode_for_pst_p)
+                       record_line (current_subfile, 0, address);
+                   }
                  break;
                case DW_LNE_set_address:
                  address = read_address (abfd, line_ptr, cu, &bytes_read);
@@ -6554,12 +6797,34 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                             _("mangled .debug_line section"));
                  return;
                }
+             /* Make sure that we parsed the extended op correctly.  If e.g.
+                we expected a different address size than the producer used,
+                we may have read the wrong number of bytes.  */
+             if (line_ptr != extended_end)
+               {
+                 complaint (&symfile_complaints,
+                            _("mangled .debug_line section"));
+                 return;
+               }
              break;
            case DW_LNS_copy:
-              lh->file_names[file - 1].included_p = 1;
-              if (!decode_for_pst_p)
-               record_line (current_subfile, line, 
-                            check_cu_functions (address, cu));
+             if (lh->num_file_names < file)
+               dwarf2_debug_line_missing_file_complaint ();
+             else
+               {
+                 lh->file_names[file - 1].included_p = 1;
+                 if (!decode_for_pst_p)
+                    {
+                      if (last_subfile != current_subfile)
+                        {
+                          if (last_subfile)
+                            record_line (last_subfile, 0, address);
+                          last_subfile = current_subfile;
+                        }
+                      record_line (current_subfile, line, 
+                                   check_cu_functions (address, cu));
+                    }
+               }
              basic_block = 0;
              break;
            case DW_LNS_advance_pc:
@@ -6577,17 +6842,23 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                    0-based, but the directory and file name numbers in
                    the statement program are 1-based.  */
                 struct file_entry *fe;
-                char *dir;
+                char *dir = NULL;
 
                 file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                 line_ptr += bytes_read;
-                fe = &lh->file_names[file - 1];
-                if (fe->dir_index)
-                  dir = lh->include_dirs[fe->dir_index - 1];
+                if (lh->num_file_names < file)
+                  dwarf2_debug_line_missing_file_complaint ();
                 else
-                  dir = comp_dir;
-                if (!decode_for_pst_p)
-                  dwarf2_start_subfile (fe->name, dir);
+                  {
+                    fe = &lh->file_names[file - 1];
+                    if (fe->dir_index)
+                      dir = lh->include_dirs[fe->dir_index - 1];
+                    if (!decode_for_pst_p)
+                      {
+                        last_subfile = current_subfile;
+                        dwarf2_start_subfile (fe->name, dir, comp_dir);
+                      }
+                  }
               }
              break;
            case DW_LNS_set_column:
@@ -6663,11 +6934,41 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
               dwarf2_create_include_psymtab (include_name, pst, objfile);
           }
     }
+  else
+    {
+      /* Make sure a symtab is created for every file, even files
+        which contain only variables (i.e. no code with associated
+        line numbers).  */
+
+      int i;
+      struct file_entry *fe;
+
+      for (i = 0; i < lh->num_file_names; i++)
+       {
+         char *dir = NULL;
+         fe = &lh->file_names[i];
+         if (fe->dir_index)
+           dir = lh->include_dirs[fe->dir_index - 1];
+         dwarf2_start_subfile (fe->name, dir, comp_dir);
+
+         /* Skip the main file; we don't need it, and it must be
+            allocated last, so that it will show up before the
+            non-primary symtabs in the objfile's symtab list.  */
+         if (current_subfile == first_subfile)
+           continue;
+
+         if (current_subfile->symtab == NULL)
+           current_subfile->symtab = allocate_symtab (current_subfile->name,
+                                                      cu->objfile);
+         fe->symtab = current_subfile->symtab;
+       }
+    }
 }
 
 /* Start a subfile for DWARF.  FILENAME is the name of the file and
    DIRNAME the name of the source directory which contains FILENAME
-   or NULL if not known.
+   or NULL if not known.  COMP_DIR is the compilation directory for the
+   linetable's compilation unit or NULL if not known.
    This routine tries to keep line numbers from identical absolute and
    relative file names in a common subfile.
 
@@ -6683,31 +6984,35 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
    files.files[1].dir:  /srcdir
 
    The line number information for list0.c has to end up in a single
-   subfile, so that `break /srcdir/list0.c:1' works as expected.  */
+   subfile, so that `break /srcdir/list0.c:1' works as expected.
+   start_subfile will ensure that this happens provided that we pass the
+   concatenation of files.files[1].dir and files.files[1].name as the
+   subfile's name.  */
 
 static void
-dwarf2_start_subfile (char *filename, char *dirname)
+dwarf2_start_subfile (char *filename, char *dirname, char *comp_dir)
 {
-  /* If the filename isn't absolute, try to match an existing subfile
-     with the full pathname.  */
+  char *fullname;
+
+  /* While reading the DIEs, we call start_symtab(DW_AT_name, DW_AT_comp_dir).
+     `start_symtab' will always pass the contents of DW_AT_comp_dir as
+     second argument to start_subfile.  To be consistent, we do the
+     same here.  In order not to lose the line information directory,
+     we concatenate it to the filename when it makes sense.
+     Note that the Dwarf3 standard says (speaking of filenames in line
+     information): ``The directory index is ignored for file names
+     that represent full path names''.  Thus ignoring dirname in the
+     `else' branch below isn't an issue.  */
 
   if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
-    {
-      struct subfile *subfile;
-      char *fullname = concat (dirname, "/", filename, (char *)NULL);
+    fullname = concat (dirname, SLASH_STRING, filename, (char *)NULL);
+  else
+    fullname = filename;
 
-      for (subfile = subfiles; subfile; subfile = subfile->next)
-       {
-         if (FILENAME_CMP (subfile->name, fullname) == 0)
-           {
-             current_subfile = subfile;
-             xfree (fullname);
-             return;
-           }
-       }
-      xfree (fullname);
-    }
-  start_subfile (filename, dirname);
+  start_subfile (fullname, comp_dir);
+
+  if (fullname != filename)
+    xfree (fullname);
 }
 
 static void
@@ -6803,7 +7108,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      SYMBOL_CLASS (sym) = LOC_STATIC;
+      SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
       if (type != NULL)
        SYMBOL_TYPE (sym) = type;
       else
@@ -6813,6 +7118,23 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
        {
          SYMBOL_LINE (sym) = DW_UNSND (attr);
        }
+
+      attr = dwarf2_attr (die, DW_AT_decl_file, cu);
+      if (attr)
+       {
+         int file_index = DW_UNSND (attr);
+         if (cu->line_header == NULL
+             || file_index > cu->line_header->num_file_names)
+           complaint (&symfile_complaints,
+                      _("file index out of range"));
+         else if (file_index > 0)
+           {
+             struct file_entry *fe;
+             fe = &cu->line_header->file_names[file_index - 1];
+             SYMBOL_SYMTAB (sym) = fe->symtab;
+           }
+       }
+
       switch (die->tag)
        {
        case DW_TAG_label:
@@ -6842,10 +7164,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
             with missing type entries. Change the misleading `void' type
             to something sensible.  */
          if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
-           SYMBOL_TYPE (sym) = init_type (TYPE_CODE_INT,
-                                          TARGET_INT_BIT / HOST_CHAR_BIT, 0,
-                                          "<variable, no debug info>",
-                                          objfile);
+           SYMBOL_TYPE (sym)
+             = builtin_type (current_gdbarch)->nodebug_data_symbol;
+
          attr = dwarf2_attr (die, DW_AT_const_value, cu);
          if (attr)
            {
@@ -6908,6 +7229,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
        case DW_TAG_class_type:
        case DW_TAG_structure_type:
        case DW_TAG_union_type:
+       case DW_TAG_set_type:
        case DW_TAG_enumeration_type:
          SYMBOL_CLASS (sym) = LOC_TYPEDEF;
          SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
@@ -6957,7 +7279,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
               defines a typedef for the class.  Synthesize a typedef symbol
               so that "ptype foo" works as expected.  */
            if (cu->language == language_cplus
-               || cu->language == language_java)
+               || cu->language == language_java
+               || cu->language == language_ada)
              {
                struct symbol *typedef_sym = (struct symbol *)
                  obstack_alloc (&objfile->objfile_obstack,
@@ -7053,7 +7376,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
                                                      cu_header->addr_size,
                                                      TYPE_LENGTH (SYMBOL_TYPE
                                                                   (sym)));
-      SYMBOL_VALUE_BYTES (sym) = (char *)
+      SYMBOL_VALUE_BYTES (sym) = 
        obstack_alloc (&objfile->objfile_obstack, cu_header->addr_size);
       /* NOTE: cagney/2003-05-09: In-lined store_address call with
          it's body - store_unsigned_integer.  */
@@ -7071,7 +7394,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
                                                      blk->size,
                                                      TYPE_LENGTH (SYMBOL_TYPE
                                                                   (sym)));
-      SYMBOL_VALUE_BYTES (sym) = (char *)
+      SYMBOL_VALUE_BYTES (sym) =
        obstack_alloc (&objfile->objfile_obstack, blk->size);
       memcpy (SYMBOL_VALUE_BYTES (sym), blk->data, blk->size);
       SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
@@ -7237,6 +7560,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_array_type:
       read_array_type (die, cu);
       break;
+    case DW_TAG_set_type:
+      read_set_type (die, cu);
+      break;
     case DW_TAG_pointer_type:
       read_tag_pointer_type (die, cu);
       break;
@@ -7264,8 +7590,11 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_base_type:
       read_base_type (die, cu);
       break;
+    case DW_TAG_unspecified_type:
+      read_unspecified_type (die, cu);
+      break;
     default:
-      complaint (&symfile_complaints, _("unexepected tag in read_type_die: '%s'"),
+      complaint (&symfile_complaints, _("unexpected tag in read_type_die: '%s'"),
                 dwarf_tag_name (die->tag));
       break;
     }
@@ -7672,14 +8001,34 @@ dwarf_tag_name (unsigned tag)
       return "DW_TAG_partial_unit";
     case DW_TAG_imported_unit:
       return "DW_TAG_imported_unit";
+    case DW_TAG_condition:
+      return "DW_TAG_condition";
+    case DW_TAG_shared_type:
+      return "DW_TAG_shared_type";
     case DW_TAG_MIPS_loop:
       return "DW_TAG_MIPS_loop";
+    case DW_TAG_HP_array_descriptor:
+      return "DW_TAG_HP_array_descriptor";
     case DW_TAG_format_label:
       return "DW_TAG_format_label";
     case DW_TAG_function_template:
       return "DW_TAG_function_template";
     case DW_TAG_class_template:
       return "DW_TAG_class_template";
+    case DW_TAG_GNU_BINCL:
+      return "DW_TAG_GNU_BINCL";
+    case DW_TAG_GNU_EINCL:
+      return "DW_TAG_GNU_EINCL";
+    case DW_TAG_upc_shared_type:
+      return "DW_TAG_upc_shared_type";
+    case DW_TAG_upc_strict_type:
+      return "DW_TAG_upc_strict_type";
+    case DW_TAG_upc_relaxed_type:
+      return "DW_TAG_upc_relaxed_type";
+    case DW_TAG_PGI_kanji_type:
+      return "DW_TAG_PGI_kanji_type";
+    case DW_TAG_PGI_interface_block:
+      return "DW_TAG_PGI_interface_block";
     default:
       return "DW_TAG_<unknown>";
     }
@@ -7816,6 +8165,7 @@ dwarf_attr_name (unsigned attr)
       return "DW_AT_virtuality";
     case DW_AT_vtable_elem_location:
       return "DW_AT_vtable_elem_location";
+    /* DWARF 3 values.  */
     case DW_AT_allocated:
       return "DW_AT_allocated";
     case DW_AT_associated:
@@ -7840,7 +8190,38 @@ dwarf_attr_name (unsigned attr)
       return "DW_AT_call_file";
     case DW_AT_call_line:
       return "DW_AT_call_line";
+    case DW_AT_description:
+      return "DW_AT_description";
+    case DW_AT_binary_scale:
+      return "DW_AT_binary_scale";
+    case DW_AT_decimal_scale:
+      return "DW_AT_decimal_scale";
+    case DW_AT_small:
+      return "DW_AT_small";
+    case DW_AT_decimal_sign:
+      return "DW_AT_decimal_sign";
+    case DW_AT_digit_count:
+      return "DW_AT_digit_count";
+    case DW_AT_picture_string:
+      return "DW_AT_picture_string";
+    case DW_AT_mutable:
+      return "DW_AT_mutable";
+    case DW_AT_threads_scaled:
+      return "DW_AT_threads_scaled";
+    case DW_AT_explicit:
+      return "DW_AT_explicit";
+    case DW_AT_object_pointer:
+      return "DW_AT_object_pointer";
+    case DW_AT_endianity:
+      return "DW_AT_endianity";
+    case DW_AT_elemental:
+      return "DW_AT_elemental";
+    case DW_AT_pure:
+      return "DW_AT_pure";
+    case DW_AT_recursive:
+      return "DW_AT_recursive";
 #ifdef MIPS
+    /* SGI/MIPS extensions.  */
     case DW_AT_MIPS_fde:
       return "DW_AT_MIPS_fde";
     case DW_AT_MIPS_loop_begin:
@@ -7853,10 +8234,47 @@ dwarf_attr_name (unsigned attr)
       return "DW_AT_MIPS_loop_unroll_factor";
     case DW_AT_MIPS_software_pipeline_depth:
       return "DW_AT_MIPS_software_pipeline_depth";
-#endif
     case DW_AT_MIPS_linkage_name:
       return "DW_AT_MIPS_linkage_name";
-
+    case DW_AT_MIPS_stride:
+      return "DW_AT_MIPS_stride";
+    case DW_AT_MIPS_abstract_name:
+      return "DW_AT_MIPS_abstract_name";
+    case DW_AT_MIPS_clone_origin:
+      return "DW_AT_MIPS_clone_origin";
+    case DW_AT_MIPS_has_inlines:
+      return "DW_AT_MIPS_has_inlines";
+#endif
+    /* HP extensions.  */
+    case DW_AT_HP_block_index:
+      return "DW_AT_HP_block_index";
+    case DW_AT_HP_unmodifiable:
+      return "DW_AT_HP_unmodifiable";
+    case DW_AT_HP_actuals_stmt_list:
+      return "DW_AT_HP_actuals_stmt_list";
+    case DW_AT_HP_proc_per_section:
+      return "DW_AT_HP_proc_per_section";
+    case DW_AT_HP_raw_data_ptr:
+      return "DW_AT_HP_raw_data_ptr";
+    case DW_AT_HP_pass_by_reference:
+      return "DW_AT_HP_pass_by_reference";
+    case DW_AT_HP_opt_level:
+      return "DW_AT_HP_opt_level";
+    case DW_AT_HP_prof_version_id:
+      return "DW_AT_HP_prof_version_id";
+    case DW_AT_HP_opt_flags:
+      return "DW_AT_HP_opt_flags";
+    case DW_AT_HP_cold_region_low_pc:
+      return "DW_AT_HP_cold_region_low_pc";
+    case DW_AT_HP_cold_region_high_pc:
+      return "DW_AT_HP_cold_region_high_pc";
+    case DW_AT_HP_all_variables_modifiable:
+      return "DW_AT_HP_all_variables_modifiable";
+    case DW_AT_HP_linkage_name:
+      return "DW_AT_HP_linkage_name";
+    case DW_AT_HP_prof_flags:
+      return "DW_AT_HP_prof_flags";
+    /* GNU extensions.  */
     case DW_AT_sf_names:
       return "DW_AT_sf_names";
     case DW_AT_src_info:
@@ -7871,6 +8289,19 @@ dwarf_attr_name (unsigned attr)
       return "DW_AT_body_end";
     case DW_AT_GNU_vector:
       return "DW_AT_GNU_vector";
+    /* VMS extensions.  */
+    case DW_AT_VMS_rtnbeg_pd_address:
+      return "DW_AT_VMS_rtnbeg_pd_address";
+    /* UPC extension.  */
+    case DW_AT_upc_threads_scaled:
+      return "DW_AT_upc_threads_scaled";
+    /* PGI (STMicroelectronics) extensions.  */
+    case DW_AT_PGI_lbase:
+      return "DW_AT_PGI_lbase";
+    case DW_AT_PGI_soffset:
+      return "DW_AT_PGI_soffset";
+    case DW_AT_PGI_lstride:
+      return "DW_AT_PGI_lstride";
     default:
       return "DW_AT_<unknown>";
     }
@@ -8227,7 +8658,7 @@ dwarf_stack_op_name (unsigned op)
       return "DW_OP_xderef_size";
     case DW_OP_nop:
       return "DW_OP_nop";
-      /* DWARF 3 extensions.  */
+    /* DWARF 3 extensions.  */
     case DW_OP_push_object_address:
       return "DW_OP_push_object_address";
     case DW_OP_call2:
@@ -8236,9 +8667,30 @@ dwarf_stack_op_name (unsigned op)
       return "DW_OP_call4";
     case DW_OP_call_ref:
       return "DW_OP_call_ref";
-      /* GNU extensions.  */
+    /* GNU extensions.  */
+    case DW_OP_form_tls_address:
+      return "DW_OP_form_tls_address";
+    case DW_OP_call_frame_cfa:
+      return "DW_OP_call_frame_cfa";
+    case DW_OP_bit_piece:
+      return "DW_OP_bit_piece";
     case DW_OP_GNU_push_tls_address:
       return "DW_OP_GNU_push_tls_address";
+    case DW_OP_GNU_uninit:
+      return "DW_OP_GNU_uninit";
+    /* HP extensions. */ 
+    case DW_OP_HP_is_value:
+      return "DW_OP_HP_is_value";
+    case DW_OP_HP_fltconst4:
+      return "DW_OP_HP_fltconst4";
+    case DW_OP_HP_fltconst8:
+      return "DW_OP_HP_fltconst8";
+    case DW_OP_HP_mod_range:
+      return "DW_OP_HP_mod_range";
+    case DW_OP_HP_unmod_range:
+      return "DW_OP_HP_unmod_range";
+    case DW_OP_HP_tls:
+      return "DW_OP_HP_tls";
     default:
       return "OP_<unknown>";
     }
@@ -8260,6 +8712,8 @@ dwarf_type_encoding_name (unsigned enc)
 {
   switch (enc)
     {
+    case DW_ATE_void:
+      return "DW_ATE_void";
     case DW_ATE_address:
       return "DW_ATE_address";
     case DW_ATE_boolean:
@@ -8276,8 +8730,36 @@ dwarf_type_encoding_name (unsigned enc)
       return "DW_ATE_unsigned";
     case DW_ATE_unsigned_char:
       return "DW_ATE_unsigned_char";
+    /* DWARF 3.  */
     case DW_ATE_imaginary_float:
       return "DW_ATE_imaginary_float";
+    case DW_ATE_packed_decimal:
+      return "DW_ATE_packed_decimal";
+    case DW_ATE_numeric_string:
+      return "DW_ATE_numeric_string";
+    case DW_ATE_edited:
+      return "DW_ATE_edited";
+    case DW_ATE_signed_fixed:
+      return "DW_ATE_signed_fixed";
+    case DW_ATE_unsigned_fixed:
+      return "DW_ATE_unsigned_fixed";
+    case DW_ATE_decimal_float:
+      return "DW_ATE_decimal_float";
+    /* HP extensions.  */
+    case DW_ATE_HP_float80:
+      return "DW_ATE_HP_float80";
+    case DW_ATE_HP_complex_float80:
+      return "DW_ATE_HP_complex_float80";
+    case DW_ATE_HP_float128:
+      return "DW_ATE_HP_float128";
+    case DW_ATE_HP_complex_float128:
+      return "DW_ATE_HP_complex_float128";
+    case DW_ATE_HP_floathpintel:
+      return "DW_ATE_HP_floathpintel";
+    case DW_ATE_HP_imaginary_float80:
+      return "DW_ATE_HP_imaginary_float80";
+    case DW_ATE_HP_imaginary_float128:
+      return "DW_ATE_HP_imaginary_float128";
     default:
       return "DW_ATE_<unknown>";
     }
@@ -8327,8 +8809,7 @@ dwarf_cfi_name (unsigned cfi_opc)
       return "DW_CFA_def_cfa_register";
     case DW_CFA_def_cfa_offset:
       return "DW_CFA_def_cfa_offset";
-
-    /* DWARF 3 */
+    /* DWARF 3.  */
     case DW_CFA_def_cfa_expression:
       return "DW_CFA_def_cfa_expression";
     case DW_CFA_expression:
@@ -8339,19 +8820,22 @@ dwarf_cfi_name (unsigned cfi_opc)
       return "DW_CFA_def_cfa_sf";
     case DW_CFA_def_cfa_offset_sf:
       return "DW_CFA_def_cfa_offset_sf";
-
-      /* SGI/MIPS specific */
+    case DW_CFA_val_offset:
+      return "DW_CFA_val_offset";
+    case DW_CFA_val_offset_sf:
+      return "DW_CFA_val_offset_sf";
+    case DW_CFA_val_expression:
+      return "DW_CFA_val_expression";
+    /* SGI/MIPS specific.  */
     case DW_CFA_MIPS_advance_loc8:
       return "DW_CFA_MIPS_advance_loc8";
-
-    /* GNU extensions */
+    /* GNU extensions.  */
     case DW_CFA_GNU_window_save:
       return "DW_CFA_GNU_window_save";
     case DW_CFA_GNU_args_size:
       return "DW_CFA_GNU_args_size";
     case DW_CFA_GNU_negative_offset_extended:
       return "DW_CFA_GNU_negative_offset_extended";
-
     default:
       return "DW_CFA_<unknown>";
     }
@@ -8769,6 +9253,9 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
            dwarf2_complex_location_expr_complaint ();
           break;
 
+       case DW_OP_GNU_uninit:
+         break;
+
        default:
          complaint (&symfile_complaints, _("unsupported stack op: '%s'"),
                     dwarf_stack_op_name (op));
@@ -9223,13 +9710,24 @@ static void
 dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
                             struct dwarf2_cu *cu)
 {
-  if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
+  struct objfile *objfile = cu->objfile;
+
+  /* Save the master objfile, so that we can report and look up the
+     correct file containing this variable.  */
+  if (objfile->separate_debug_objfile_backlink)
+    objfile = objfile->separate_debug_objfile_backlink;
+
+  if ((attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
+      /* ".debug_loc" may not exist at all, or the offset may be outside
+        the section.  If so, fall through to the complaint in the
+        other branch.  */
+      && DW_UNSND (attr) < dwarf2_per_objfile->loc_size)
     {
       struct dwarf2_loclist_baton *baton;
 
       baton = obstack_alloc (&cu->objfile->objfile_obstack,
                             sizeof (struct dwarf2_loclist_baton));
-      baton->objfile = cu->objfile;
+      baton->objfile = objfile;
 
       /* We don't know how long the location list is, but make sure we
         don't run off the edge of the section.  */
@@ -9249,7 +9747,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
 
       baton = obstack_alloc (&cu->objfile->objfile_obstack,
                             sizeof (struct dwarf2_locexpr_baton));
-      baton->objfile = cu->objfile;
+      baton->objfile = objfile;
 
       if (attr_form_is_block (attr))
        {
@@ -9622,28 +10120,6 @@ dwarf2_clear_marks (struct dwarf2_per_cu_data *per_cu)
     }
 }
 
-/* Allocation function for the libiberty hash table which uses an
-   obstack.  */
-
-static void *
-hashtab_obstack_allocate (void *data, size_t size, size_t count)
-{
-  unsigned int total = size * count;
-  void *ptr = obstack_alloc ((struct obstack *) data, total);
-  memset (ptr, 0, total);
-  return ptr;
-}
-
-/* Trivial deallocation function for the libiberty splay tree and hash
-   table - don't deallocate anything.  Rely on later deletion of the
-   obstack.  */
-
-static void
-dummy_obstack_deallocate (void *object, void *data)
-{
-  return;
-}
-
 /* Trivial hash function for partial_die_info: the hash value of a DIE
    is its offset in .debug_info for this objfile.  */