2011-06-15 Hui Zhu <teawater@gmail.com>
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 03bd331c6905acc55103250d77fc2caa2c82d4fe..399d5932211e4550557d6afb311c8fb6a7773e72 100644 (file)
@@ -57,6 +57,7 @@
 #include "vec.h"
 #include "c-lang.h"
 #include "valprint.h"
 #include "vec.h"
 #include "c-lang.h"
 #include "valprint.h"
+#include <ctype.h>
 
 #include <fcntl.h>
 #include "gdb_string.h"
 
 #include <fcntl.h>
 #include "gdb_string.h"
@@ -148,16 +149,24 @@ DEF_VEC_I (offset_type);
    a comment by the code that writes the index.  */
 struct mapped_index
 {
    a comment by the code that writes the index.  */
 struct mapped_index
 {
+  /* Index data format version.  */
+  int version;
+
   /* The total length of the buffer.  */
   off_t total_size;
   /* The total length of the buffer.  */
   off_t total_size;
+
   /* A pointer to the address table data.  */
   const gdb_byte *address_table;
   /* A pointer to the address table data.  */
   const gdb_byte *address_table;
+
   /* Size of the address table data in bytes.  */
   offset_type address_table_size;
   /* Size of the address table data in bytes.  */
   offset_type address_table_size;
+
   /* The symbol table, implemented as a hash table.  */
   const offset_type *symbol_table;
   /* The symbol table, implemented as a hash table.  */
   const offset_type *symbol_table;
+
   /* Size in slots, each slot is 2 offset_types.  */
   offset_type symbol_table_slots;
   /* Size in slots, each slot is 2 offset_types.  */
   offset_type symbol_table_slots;
+
   /* A pointer to the constant pool.  */
   const char *constant_pool;
 };
   /* A pointer to the constant pool.  */
   const char *constant_pool;
 };
@@ -234,22 +243,24 @@ struct dwarf2_per_objfile
 
 static struct dwarf2_per_objfile *dwarf2_per_objfile;
 
 
 static struct dwarf2_per_objfile *dwarf2_per_objfile;
 
-/* names of the debugging sections */
+/* Default names of the debugging sections.  */
 
 /* Note that if the debugging section has been compressed, it might
    have a name like .zdebug_info.  */
 
 
 /* Note that if the debugging section has been compressed, it might
    have a name like .zdebug_info.  */
 
-#define INFO_SECTION     "debug_info"
-#define ABBREV_SECTION   "debug_abbrev"
-#define LINE_SECTION     "debug_line"
-#define LOC_SECTION      "debug_loc"
-#define MACINFO_SECTION  "debug_macinfo"
-#define STR_SECTION      "debug_str"
-#define RANGES_SECTION   "debug_ranges"
-#define TYPES_SECTION    "debug_types"
-#define FRAME_SECTION    "debug_frame"
-#define EH_FRAME_SECTION "eh_frame"
-#define GDB_INDEX_SECTION "gdb_index"
+static const struct dwarf2_debug_sections dwarf2_elf_names = {
+  { ".debug_info", ".zdebug_info" },
+  { ".debug_abbrev", ".zdebug_abbrev" },
+  { ".debug_line", ".zdebug_line" },
+  { ".debug_loc", ".zdebug_loc" },
+  { ".debug_macinfo", ".zdebug_macinfo" },
+  { ".debug_str", ".zdebug_str" },
+  { ".debug_ranges", ".zdebug_ranges" },
+  { ".debug_types", ".zdebug_types" },
+  { ".debug_frame", ".zdebug_frame" },
+  { ".eh_frame", NULL },
+  { ".gdb_index", ".zgdb_index" }
+};
 
 /* local data types */
 
 
 /* local data types */
 
@@ -395,6 +406,13 @@ struct dwarf2_cu
      DIEs for namespaces, we don't need to try to infer them
      from mangled names.  */
   unsigned int has_namespace_info : 1;
      DIEs for namespaces, we don't need to try to infer them
      from mangled names.  */
   unsigned int has_namespace_info : 1;
+
+  /* This CU references .debug_loc.  See the symtab->locations_valid field.
+     This test is imperfect as there may exist optimized debug code not using
+     any location list and still facing inlining issues if handled as
+     unoptimized code.  For a future better test see GCC PR other/32998.  */
+
+  unsigned int has_loclist : 1;
 };
 
 /* Persistent data held for a compilation unit, even when not
 };
 
 /* Persistent data held for a compilation unit, even when not
@@ -454,9 +472,6 @@ struct signatured_type
 {
   ULONGEST signature;
 
 {
   ULONGEST signature;
 
-  /* Offset in .debug_types of the TU (type_unit) for this type.  */
-  unsigned int offset;
-
   /* Offset in .debug_types of the type defined by this TU.  */
   unsigned int type_offset;
 
   /* Offset in .debug_types of the type defined by this TU.  */
   unsigned int type_offset;
 
@@ -1322,10 +1337,13 @@ static const char *dwarf2_physname (char *name, struct die_info *die,
                                    struct dwarf2_cu *cu);
 
 /* Try to locate the sections we need for DWARF 2 debugging
                                    struct dwarf2_cu *cu);
 
 /* Try to locate the sections we need for DWARF 2 debugging
-   information and return true if we have enough to do something.  */
+   information and return true if we have enough to do something.
+   NAMES points to the dwarf2 section names, or is NULL if the standard
+   ELF names are used.  */
 
 int
 
 int
-dwarf2_has_info (struct objfile *objfile)
+dwarf2_has_info (struct objfile *objfile,
+                 const struct dwarf2_debug_sections *names)
 {
   dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
   if (!dwarf2_per_objfile)
 {
   dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
   if (!dwarf2_per_objfile)
@@ -1338,23 +1356,28 @@ dwarf2_has_info (struct objfile *objfile)
       set_objfile_data (objfile, dwarf2_objfile_data_key, data);
       dwarf2_per_objfile = data;
 
       set_objfile_data (objfile, dwarf2_objfile_data_key, data);
       dwarf2_per_objfile = data;
 
-      bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
+      bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections,
+                             (void *) names);
       dwarf2_per_objfile->objfile = objfile;
     }
   return (dwarf2_per_objfile->info.asection != NULL
          && dwarf2_per_objfile->abbrev.asection != NULL);
 }
 
       dwarf2_per_objfile->objfile = objfile;
     }
   return (dwarf2_per_objfile->info.asection != NULL
          && dwarf2_per_objfile->abbrev.asection != NULL);
 }
 
-/* When loading sections, we can either look for ".<name>", or for
* ".z<name>", which indicates a compressed section.  */
+/* When loading sections, we look either for uncompressed section or for
  compressed section names.  */
 
 static int
 
 static int
-section_is_p (const char *section_name, const char *name)
+section_is_p (const char *section_name,
+              const struct dwarf2_section_names *names)
 {
 {
-  return (section_name[0] == '.'
-         && (strcmp (section_name + 1, name) == 0
-             || (section_name[1] == 'z'
-                 && strcmp (section_name + 2, name) == 0)));
+  if (names->normal != NULL
+      && strcmp (section_name, names->normal) == 0)
+    return 1;
+  if (names->compressed != NULL
+      && strcmp (section_name, names->compressed) == 0)
+    return 1;
+  return 0;
 }
 
 /* This function is mapped across the sections and remembers the
 }
 
 /* This function is mapped across the sections and remembers the
@@ -1362,44 +1385,51 @@ section_is_p (const char *section_name, const char *name)
    in.  */
 
 static void
    in.  */
 
 static void
-dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
+dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
 {
 {
-  if (section_is_p (sectp->name, INFO_SECTION))
+  const struct dwarf2_debug_sections *names;
+
+  if (vnames == NULL)
+    names = &dwarf2_elf_names;
+  else
+    names = (const struct dwarf2_debug_sections *) vnames;
+
+  if (section_is_p (sectp->name, &names->info))
     {
       dwarf2_per_objfile->info.asection = sectp;
       dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->info.asection = sectp;
       dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, ABBREV_SECTION))
+  else if (section_is_p (sectp->name, &names->abbrev))
     {
       dwarf2_per_objfile->abbrev.asection = sectp;
       dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->abbrev.asection = sectp;
       dwarf2_per_objfile->abbrev.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, LINE_SECTION))
+  else if (section_is_p (sectp->name, &names->line))
     {
       dwarf2_per_objfile->line.asection = sectp;
       dwarf2_per_objfile->line.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->line.asection = sectp;
       dwarf2_per_objfile->line.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, LOC_SECTION))
+  else if (section_is_p (sectp->name, &names->loc))
     {
       dwarf2_per_objfile->loc.asection = sectp;
       dwarf2_per_objfile->loc.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->loc.asection = sectp;
       dwarf2_per_objfile->loc.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, MACINFO_SECTION))
+  else if (section_is_p (sectp->name, &names->macinfo))
     {
       dwarf2_per_objfile->macinfo.asection = sectp;
       dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->macinfo.asection = sectp;
       dwarf2_per_objfile->macinfo.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, STR_SECTION))
+  else if (section_is_p (sectp->name, &names->str))
     {
       dwarf2_per_objfile->str.asection = sectp;
       dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->str.asection = sectp;
       dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, FRAME_SECTION))
+  else if (section_is_p (sectp->name, &names->frame))
     {
       dwarf2_per_objfile->frame.asection = sectp;
       dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->frame.asection = sectp;
       dwarf2_per_objfile->frame.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, EH_FRAME_SECTION))
+  else if (section_is_p (sectp->name, &names->eh_frame))
     {
       flagword aflag = bfd_get_section_flags (ignore_abfd, sectp);
 
     {
       flagword aflag = bfd_get_section_flags (ignore_abfd, sectp);
 
@@ -1409,17 +1439,17 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
           dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
         }
     }
           dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
         }
     }
-  else if (section_is_p (sectp->name, RANGES_SECTION))
+  else if (section_is_p (sectp->name, &names->ranges))
     {
       dwarf2_per_objfile->ranges.asection = sectp;
       dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->ranges.asection = sectp;
       dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, TYPES_SECTION))
+  else if (section_is_p (sectp->name, &names->types))
     {
       dwarf2_per_objfile->types.asection = sectp;
       dwarf2_per_objfile->types.size = bfd_get_section_size (sectp);
     }
     {
       dwarf2_per_objfile->types.asection = sectp;
       dwarf2_per_objfile->types.size = bfd_get_section_size (sectp);
     }
-  else if (section_is_p (sectp->name, GDB_INDEX_SECTION))
+  else if (section_is_p (sectp->name, &names->gdb_index))
     {
       dwarf2_per_objfile->gdb_index.asection = sectp;
       dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
     {
       dwarf2_per_objfile->gdb_index.asection = sectp;
       dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
@@ -1509,6 +1539,14 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
 #endif
 }
 
 #endif
 }
 
+/* A helper function that decides whether a section is empty.  */
+
+static int
+dwarf2_section_empty_p (struct dwarf2_section_info *info)
+{
+  return info->asection == NULL || info->size == 0;
+}
+
 /* Read the contents of the section SECTP from object file specified by
    OBJFILE, store info about the section into INFO.
    If the section is compressed, uncompress it before returning.  */
 /* Read the contents of the section SECTP from object file specified by
    OBJFILE, store info about the section into INFO.
    If the section is compressed, uncompress it before returning.  */
@@ -1527,7 +1565,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
   info->was_mmapped = 0;
   info->readin = 1;
 
   info->was_mmapped = 0;
   info->readin = 1;
 
-  if (info->asection == NULL || info->size == 0)
+  if (dwarf2_section_empty_p (info))
     return;
 
   /* Check if the file has a 4-byte header indicating compression.  */
     return;
 
   /* Check if the file has a 4-byte header indicating compression.  */
@@ -1592,11 +1630,28 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
           bfd_get_filename (abfd));
 }
 
           bfd_get_filename (abfd));
 }
 
+/* A helper function that returns the size of a section in a safe way.
+   If you are positive that the section has been read before using the
+   size, then it is safe to refer to the dwarf2_section_info object's
+   "size" field directly.  In other cases, you must call this
+   function, because for compressed sections the size field is not set
+   correctly until the section has been read.  */
+
+static bfd_size_type
+dwarf2_section_size (struct objfile *objfile,
+                    struct dwarf2_section_info *info)
+{
+  if (!info->readin)
+    dwarf2_read_section (objfile, info);
+  return info->size;
+}
+
 /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
    SECTION_NAME.  */
 
 void
 /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
    SECTION_NAME.  */
 
 void
-dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
+dwarf2_get_section_info (struct objfile *objfile,
+                         enum dwarf2_section_enum sect,
                          asection **sectp, gdb_byte **bufp,
                          bfd_size_type *sizep)
 {
                          asection **sectp, gdb_byte **bufp,
                          bfd_size_type *sizep)
 {
@@ -1613,16 +1668,19 @@ dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
       *sizep = 0;
       return;
     }
       *sizep = 0;
       return;
     }
-  if (section_is_p (section_name, EH_FRAME_SECTION))
-    info = &data->eh_frame;
-  else if (section_is_p (section_name, FRAME_SECTION))
-    info = &data->frame;
-  else
-    gdb_assert_not_reached ("unexpected section");
+  switch (sect)
+    {
+    case DWARF2_DEBUG_FRAME:
+      info = &data->frame;
+      break;
+    case DWARF2_EH_FRAME:
+      info = &data->eh_frame;
+      break;
+    default:
+      gdb_assert_not_reached ("unexpected section");
+    }
 
 
-  if (info->asection != NULL && info->size != 0 && info->buffer == NULL)
-    /* We haven't read this section in yet.  Do it now.  */
-    dwarf2_read_section (objfile, info);
+  dwarf2_read_section (objfile, info);
 
   *sectp = info->asection;
   *bufp = info->buffer;
 
   *sectp = info->asection;
   *bufp = info->buffer;
@@ -1880,7 +1938,6 @@ create_signatured_type_table_from_index (struct objfile *objfile,
       type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
                                 struct signatured_type);
       type_sig->signature = signature;
       type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
                                 struct signatured_type);
       type_sig->signature = signature;
-      type_sig->offset = offset;
       type_sig->type_offset = type_offset;
       type_sig->per_cu.from_debug_types = 1;
       type_sig->per_cu.offset = offset;
       type_sig->type_offset = type_offset;
       type_sig->per_cu.from_debug_types = 1;
       type_sig->per_cu.offset = offset;
@@ -1940,21 +1997,27 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
   do_cleanups (cleanup);
 }
 
   do_cleanups (cleanup);
 }
 
-/* The hash function for strings in the mapped index.  This is the
-   same as the hashtab.c hash function, but we keep a separate copy to
-   maintain control over the implementation.  This is necessary
-   because the hash function is tied to the format of the mapped index
-   file.  */
+/* The hash function for strings in the mapped index.  This is the same as
+   SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
+   implementation.  This is necessary because the hash function is tied to the
+   format of the mapped index file.  The hash values do not have to match with
+   SYMBOL_HASH_NEXT.
+   
+   Use INT_MAX for INDEX_VERSION if you generate the current index format.  */
 
 static hashval_t
 
 static hashval_t
-mapped_index_string_hash (const void *p)
+mapped_index_string_hash (int index_version, const void *p)
 {
   const unsigned char *str = (const unsigned char *) p;
   hashval_t r = 0;
   unsigned char c;
 
   while ((c = *str++) != 0)
 {
   const unsigned char *str = (const unsigned char *) p;
   hashval_t r = 0;
   unsigned char c;
 
   while ((c = *str++) != 0)
-    r = r * 67 + c - 113;
+    {
+      if (index_version >= 5)
+       c = tolower (c);
+      r = r * 67 + c - 113;
+    }
 
   return r;
 }
 
   return r;
 }
@@ -1967,11 +2030,43 @@ static int
 find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
                          offset_type **vec_out)
 {
 find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
                          offset_type **vec_out)
 {
-  offset_type hash = mapped_index_string_hash (name);
+  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+  offset_type hash;
   offset_type slot, step;
   offset_type slot, step;
+  int (*cmp) (const char *, const char *);
+
+  if (current_language->la_language == language_cplus
+      || current_language->la_language == language_java
+      || current_language->la_language == language_fortran)
+    {
+      /* NAME is already canonical.  Drop any qualifiers as .gdb_index does
+        not contain any.  */
+      const char *paren = strchr (name, '(');
+
+      if (paren)
+       {
+         char *dup;
+
+         dup = xmalloc (paren - name + 1);
+         memcpy (dup, name, paren - name);
+         dup[paren - name] = 0;
+
+         make_cleanup (xfree, dup);
+         name = dup;
+       }
+    }
+
+  /* Index version 4 did not support case insensitive searches.  But the
+     indexes for case insensitive languages are built in lowercase, therefore
+     simulate our NAME being searched is also lowercased.  */
+  hash = mapped_index_string_hash ((index->version == 4
+                                    && case_sensitivity == case_sensitive_off
+                                   ? 5 : index->version),
+                                  name);
 
   slot = hash & (index->symbol_table_slots - 1);
   step = ((hash * 17) & (index->symbol_table_slots - 1)) | 1;
 
   slot = hash & (index->symbol_table_slots - 1);
   step = ((hash * 17) & (index->symbol_table_slots - 1)) | 1;
+  cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp);
 
   for (;;)
     {
 
   for (;;)
     {
@@ -1979,13 +2074,17 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
       offset_type i = 2 * slot;
       const char *str;
       if (index->symbol_table[i] == 0 && index->symbol_table[i + 1] == 0)
       offset_type i = 2 * slot;
       const char *str;
       if (index->symbol_table[i] == 0 && index->symbol_table[i + 1] == 0)
-       return 0;
+       {
+         do_cleanups (back_to);
+         return 0;
+       }
 
       str = index->constant_pool + MAYBE_SWAP (index->symbol_table[i]);
 
       str = index->constant_pool + MAYBE_SWAP (index->symbol_table[i]);
-      if (!strcmp (name, str))
+      if (!cmp (name, str))
        {
          *vec_out = (offset_type *) (index->constant_pool
                                      + MAYBE_SWAP (index->symbol_table[i + 1]));
        {
          *vec_out = (offset_type *) (index->constant_pool
                                      + MAYBE_SWAP (index->symbol_table[i + 1]));
+         do_cleanups (back_to);
          return 1;
        }
 
          return 1;
        }
 
@@ -2008,8 +2107,7 @@ dwarf2_read_index (struct objfile *objfile)
   offset_type types_list_elements = 0;
   int i;
 
   offset_type types_list_elements = 0;
   int i;
 
-  if (dwarf2_per_objfile->gdb_index.asection == NULL
-      || dwarf2_per_objfile->gdb_index.size == 0)
+  if (dwarf2_section_empty_p (&dwarf2_per_objfile->gdb_index))
     return 0;
 
   /* Older elfutils strip versions could keep the section in the main
     return 0;
 
   /* Older elfutils strip versions could keep the section in the main
@@ -2024,16 +2122,19 @@ dwarf2_read_index (struct objfile *objfile)
   /* Version check.  */
   version = MAYBE_SWAP (*(offset_type *) addr);
   /* Versions earlier than 3 emitted every copy of a psymbol.  This
   /* Version check.  */
   version = MAYBE_SWAP (*(offset_type *) addr);
   /* Versions earlier than 3 emitted every copy of a psymbol.  This
-     causes the index to behave very poorly for certain requests.  So,
-     it seems better to just ignore such indices.  */
-  if (version < 3)
+     causes the index to behave very poorly for certain requests.  Version 3
+     contained incomplete addrmap.  So, it seems better to just ignore such
+     indices.  Index version 4 uses a different hash function than index
+     version 5 and later.  */
+  if (version < 4)
     return 0;
   /* Indexes with higher version than the one supported by GDB may be no
      longer backward compatible.  */
     return 0;
   /* Indexes with higher version than the one supported by GDB may be no
      longer backward compatible.  */
-  if (version > 3)
+  if (version > 5)
     return 0;
 
   map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
     return 0;
 
   map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
+  map->version = version;
   map->total_size = dwarf2_per_objfile->gdb_index.size;
 
   metadata = (offset_type *) (addr + sizeof (offset_type));
   map->total_size = dwarf2_per_objfile->gdb_index.size;
 
   metadata = (offset_type *) (addr + sizeof (offset_type));
@@ -2150,8 +2251,8 @@ dw2_get_file_names (struct objfile *objfile,
   if (this_cu->from_debug_types)
     info_ptr += 8 /*signature*/ + cu.header.offset_size;
   init_cu_die_reader (&reader_specs, &cu);
   if (this_cu->from_debug_types)
     info_ptr += 8 /*signature*/ + cu.header.offset_size;
   init_cu_die_reader (&reader_specs, &cu);
-  info_ptr = read_full_die (&reader_specs, &comp_unit_die, info_ptr,
-                           &has_children);
+  read_full_die (&reader_specs, &comp_unit_die, info_ptr,
+                &has_children);
 
   lh = NULL;
   slot = NULL;
 
   lh = NULL;
   slot = NULL;
@@ -2377,7 +2478,7 @@ dw2_do_expand_symtabs_matching (struct objfile *objfile, const char *name)
 
 static void
 dw2_pre_expand_symtabs_matching (struct objfile *objfile,
 
 static void
 dw2_pre_expand_symtabs_matching (struct objfile *objfile,
-                                int kind, const char *name,
+                                enum block_enum block_kind, const char *name,
                                 domain_enum domain)
 {
   dw2_do_expand_symtabs_matching (objfile, name);
                                 domain_enum domain)
 {
   dw2_do_expand_symtabs_matching (objfile, name);
@@ -2523,7 +2624,7 @@ static void
 dw2_expand_symtabs_matching (struct objfile *objfile,
                             int (*file_matcher) (const char *, void *),
                             int (*name_matcher) (const char *, void *),
 dw2_expand_symtabs_matching (struct objfile *objfile,
                             int (*file_matcher) (const char *, void *),
                             int (*name_matcher) (const char *, void *),
-                            domain_enum kind,
+                            enum search_domain kind,
                             void *data)
 {
   int i;
                             void *data)
 {
   int i;
@@ -2537,30 +2638,31 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
     return;
   index = dwarf2_per_objfile->index_table;
 
     return;
   index = dwarf2_per_objfile->index_table;
 
-  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                  + dwarf2_per_objfile->n_type_comp_units); ++i)
-    {
-      int j;
-      struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
-      struct quick_file_names *file_data;
+  if (file_matcher != NULL)
+    for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+                    + dwarf2_per_objfile->n_type_comp_units); ++i)
+      {
+       int j;
+       struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+       struct quick_file_names *file_data;
 
 
-      per_cu->v.quick->mark = 0;
-      if (per_cu->v.quick->symtab)
-       continue;
+       per_cu->v.quick->mark = 0;
+       if (per_cu->v.quick->symtab)
+         continue;
 
 
-      file_data = dw2_get_file_names (objfile, per_cu);
-      if (file_data == NULL)
-       continue;
+       file_data = dw2_get_file_names (objfile, per_cu);
+       if (file_data == NULL)
+         continue;
 
 
-      for (j = 0; j < file_data->num_file_names; ++j)
-       {
-         if (file_matcher (file_data->file_names[j], data))
-           {
-             per_cu->v.quick->mark = 1;
-             break;
-           }
-       }
-    }
+       for (j = 0; j < file_data->num_file_names; ++j)
+         {
+           if (file_matcher (file_data->file_names[j], data))
+             {
+               per_cu->v.quick->mark = 1;
+               break;
+             }
+         }
+      }
 
   for (iter = 0; iter < index->symbol_table_slots; ++iter)
     {
 
   for (iter = 0; iter < index->symbol_table_slots; ++iter)
     {
@@ -2586,7 +2688,7 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
          struct dwarf2_per_cu_data *per_cu;
 
          per_cu = dw2_get_cu (MAYBE_SWAP (vec[vec_idx + 1]));
          struct dwarf2_per_cu_data *per_cu;
 
          per_cu = dw2_get_cu (MAYBE_SWAP (vec[vec_idx + 1]));
-         if (per_cu->v.quick->mark)
+         if (file_matcher == NULL || per_cu->v.quick->mark)
            dw2_instantiate_symtab (objfile, per_cu);
        }
     }
            dw2_instantiate_symtab (objfile, per_cu);
        }
     }
@@ -2618,38 +2720,7 @@ dw2_find_pc_sect_symtab (struct objfile *objfile,
 }
 
 static void
 }
 
 static void
-dw2_map_symbol_names (struct objfile *objfile,
-                     void (*fun) (const char *, void *),
-                     void *data)
-{
-  offset_type iter;
-  struct mapped_index *index;
-
-  dw2_setup (objfile);
-
-  /* index_table is NULL if OBJF_READNOW.  */
-  if (!dwarf2_per_objfile->index_table)
-    return;
-  index = dwarf2_per_objfile->index_table;
-
-  for (iter = 0; iter < index->symbol_table_slots; ++iter)
-    {
-      offset_type idx = 2 * iter;
-      const char *name;
-      offset_type *vec, vec_len, vec_idx;
-
-      if (index->symbol_table[idx] == 0 && index->symbol_table[idx + 1] == 0)
-       continue;
-
-      name = (index->constant_pool + MAYBE_SWAP (index->symbol_table[idx]));
-
-      (*fun) (name, data);
-    }
-}
-
-static void
-dw2_map_symbol_filenames (struct objfile *objfile,
-                         void (*fun) (const char *, const char *, void *),
+dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
                          void *data)
 {
   int i;
                          void *data)
 {
   int i;
@@ -2703,7 +2774,6 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
   dw2_map_matching_symbols,
   dw2_expand_symtabs_matching,
   dw2_find_pc_sect_symtab,
   dw2_map_matching_symbols,
   dw2_expand_symtabs_matching,
   dw2_find_pc_sect_symtab,
-  dw2_map_symbol_names,
   dw2_map_symbol_filenames
 };
 
   dw2_map_symbol_filenames
 };
 
@@ -2745,7 +2815,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
   if (dwarf2_read_index (objfile))
     return 1;
 
   if (dwarf2_read_index (objfile))
     return 1;
 
-  dwarf2_build_psymtabs (objfile);
   return 0;
 }
 
   return 0;
 }
 
@@ -2822,7 +2891,9 @@ partial_read_comp_unit_head (struct comp_unit_head *header, gdb_byte *info_ptr,
           "(is %d, should be 2, 3, or 4) [in module %s]"), header->version,
           bfd_get_filename (abfd));
 
           "(is %d, should be 2, 3, or 4) [in module %s]"), header->version,
           bfd_get_filename (abfd));
 
-  if (header->abbrev_offset >= dwarf2_per_objfile->abbrev.size)
+  if (header->abbrev_offset
+      >= dwarf2_section_size (dwarf2_per_objfile->objfile,
+                             &dwarf2_per_objfile->abbrev))
     error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header "
           "(offset 0x%lx + 6) [in module %s]"),
           (long) header->abbrev_offset,
     error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header "
           "(offset 0x%lx + 6) [in module %s]"),
           (long) header->abbrev_offset,
@@ -3040,13 +3111,24 @@ create_debug_types_hash_table (struct objfile *objfile)
       type_sig = obstack_alloc (&objfile->objfile_obstack, sizeof (*type_sig));
       memset (type_sig, 0, sizeof (*type_sig));
       type_sig->signature = signature;
       type_sig = obstack_alloc (&objfile->objfile_obstack, sizeof (*type_sig));
       memset (type_sig, 0, sizeof (*type_sig));
       type_sig->signature = signature;
-      type_sig->offset = offset;
       type_sig->type_offset = type_offset;
       type_sig->per_cu.objfile = objfile;
       type_sig->per_cu.from_debug_types = 1;
       type_sig->type_offset = type_offset;
       type_sig->per_cu.objfile = objfile;
       type_sig->per_cu.from_debug_types = 1;
+      type_sig->per_cu.offset = offset;
 
       slot = htab_find_slot (types_htab, type_sig, INSERT);
       gdb_assert (slot != NULL);
 
       slot = htab_find_slot (types_htab, type_sig, INSERT);
       gdb_assert (slot != NULL);
+      if (*slot != NULL)
+       {
+         const struct signatured_type *dup_sig = *slot;
+
+         complaint (&symfile_complaints,
+                    _("debug type entry at offset 0x%x is duplicate to the "
+                      "entry at offset 0x%x, signature 0x%s"),
+                    offset, dup_sig->per_cu.offset,
+                    phex (signature, sizeof (signature)));
+         gdb_assert (signature == dup_sig->signature);
+       }
       *slot = type_sig;
 
       if (dwarf2_die_debug)
       *slot = type_sig;
 
       if (dwarf2_die_debug)
@@ -3082,7 +3164,7 @@ lookup_signatured_type (struct objfile *objfile, ULONGEST sig)
   if (dwarf2_per_objfile->signatured_types == NULL)
     {
       complaint (&symfile_complaints,
   if (dwarf2_per_objfile->signatured_types == NULL)
     {
       complaint (&symfile_complaints,
-                _("missing `.debug_types' section for DW_FORM_sig8 die"));
+                _("missing `.debug_types' section for DW_FORM_ref_sig8 die"));
       return 0;
     }
 
       return 0;
     }
 
@@ -3167,6 +3249,7 @@ process_psymtab_comp_unit (struct objfile *objfile,
   struct attribute *attr;
   CORE_ADDR best_lowpc = 0, best_highpc = 0;
   struct die_reader_specs reader_specs;
   struct attribute *attr;
   CORE_ADDR best_lowpc = 0, best_highpc = 0;
   struct die_reader_specs reader_specs;
+  const char *filename;
 
   init_one_comp_unit (&cu, objfile);
   back_to_inner = make_cleanup (free_stack_comp_unit, &cu);
 
   init_one_comp_unit (&cu, objfile);
   back_to_inner = make_cleanup (free_stack_comp_unit, &cu);
@@ -3210,8 +3293,8 @@ process_psymtab_comp_unit (struct objfile *objfile,
 
   if (this_cu->from_debug_types)
     {
 
   if (this_cu->from_debug_types)
     {
-      /* offset,length haven't been set yet for type units.  */
-      this_cu->offset = cu.header.offset;
+      /* LENGTH has not been set yet for type units.  */
+      gdb_assert (this_cu->offset == cu.header.offset);
       this_cu->length = cu.header.length + cu.header.initial_length_size;
     }
   else if (comp_unit_die->tag == DW_TAG_partial_unit)
       this_cu->length = cu.header.length + cu.header.initial_length_size;
     }
   else if (comp_unit_die->tag == DW_TAG_partial_unit)
@@ -3226,8 +3309,12 @@ process_psymtab_comp_unit (struct objfile *objfile,
 
   /* Allocate a new partial symbol table structure.  */
   attr = dwarf2_attr (comp_unit_die, DW_AT_name, &cu);
 
   /* Allocate a new partial symbol table structure.  */
   attr = dwarf2_attr (comp_unit_die, DW_AT_name, &cu);
+  if (attr == NULL || !DW_STRING (attr))
+    filename = "";
+  else
+    filename = DW_STRING (attr);
   pst = start_psymtab_common (objfile, objfile->section_offsets,
   pst = start_psymtab_common (objfile, objfile->section_offsets,
-                             (attr != NULL) ? DW_STRING (attr) : "",
+                             filename,
                              /* TEXTLOW and TEXTHIGH are set below.  */
                              0,
                              objfile->global_psymbols.next,
                              /* TEXTLOW and TEXTHIGH are set below.  */
                              0,
                              objfile->global_psymbols.next,
@@ -3332,7 +3419,7 @@ process_type_comp_unit (void **slot, void *info)
   gdb_assert (dwarf2_per_objfile->types.readin);
   process_psymtab_comp_unit (objfile, this_cu,
                             dwarf2_per_objfile->types.buffer,
   gdb_assert (dwarf2_per_objfile->types.readin);
   process_psymtab_comp_unit (objfile, this_cu,
                             dwarf2_per_objfile->types.buffer,
-                            dwarf2_per_objfile->types.buffer + entry->offset,
+                            dwarf2_per_objfile->types.buffer + this_cu->offset,
                             dwarf2_per_objfile->types.size);
 
   return 1;
                             dwarf2_per_objfile->types.size);
 
   return 1;
@@ -3813,25 +3900,25 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
              of the global scope.  But in Ada, we want to be able to access
              nested procedures globally.  So all Ada subprograms are stored
              in the global scope.  */
              of the global scope.  But in Ada, we want to be able to access
              nested procedures globally.  So all Ada subprograms are stored
              in the global scope.  */
-         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             mst_text, objfile); */
             mst_text, objfile); */
-         psym = add_psymbol_to_list (actual_name, strlen (actual_name),
-                                     built_actual_name,
-                                     VAR_DOMAIN, LOC_BLOCK,
-                                     &objfile->global_psymbols,
-                                     0, pdi->lowpc + baseaddr,
-                                     cu->language, objfile);
+         add_psymbol_to_list (actual_name, strlen (actual_name),
+                              built_actual_name,
+                              VAR_DOMAIN, LOC_BLOCK,
+                              &objfile->global_psymbols,
+                              0, pdi->lowpc + baseaddr,
+                              cu->language, objfile);
        }
       else
        {
        }
       else
        {
-         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             mst_file_text, objfile); */
             mst_file_text, objfile); */
-         psym = add_psymbol_to_list (actual_name, strlen (actual_name),
-                                     built_actual_name,
-                                     VAR_DOMAIN, LOC_BLOCK,
-                                     &objfile->static_psymbols,
-                                     0, pdi->lowpc + baseaddr,
-                                     cu->language, objfile);
+         add_psymbol_to_list (actual_name, strlen (actual_name),
+                              built_actual_name,
+                              VAR_DOMAIN, LOC_BLOCK,
+                              &objfile->static_psymbols,
+                              0, pdi->lowpc + baseaddr,
+                              cu->language, objfile);
        }
       break;
     case DW_TAG_constant:
        }
       break;
     case DW_TAG_constant:
@@ -3842,10 +3929,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
          list = &objfile->global_psymbols;
        else
          list = &objfile->static_psymbols;
          list = &objfile->global_psymbols;
        else
          list = &objfile->static_psymbols;
-       psym = add_psymbol_to_list (actual_name, strlen (actual_name),
-                                   built_actual_name, VAR_DOMAIN, LOC_STATIC,
-                                   list, 0, 0, cu->language, objfile);
-
+       add_psymbol_to_list (actual_name, strlen (actual_name),
+                            built_actual_name, VAR_DOMAIN, LOC_STATIC,
+                            list, 0, 0, cu->language, objfile);
       }
       break;
     case DW_TAG_variable:
       }
       break;
     case DW_TAG_variable:
@@ -3877,12 +3963,12 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
             table building.  */
 
          if (pdi->locdesc || pdi->has_type)
             table building.  */
 
          if (pdi->locdesc || pdi->has_type)
-           psym = add_psymbol_to_list (actual_name, strlen (actual_name),
-                                       built_actual_name,
-                                       VAR_DOMAIN, LOC_STATIC,
-                                       &objfile->global_psymbols,
-                                       0, addr + baseaddr,
-                                       cu->language, objfile);
+           add_psymbol_to_list (actual_name, strlen (actual_name),
+                                built_actual_name,
+                                VAR_DOMAIN, LOC_STATIC,
+                                &objfile->global_psymbols,
+                                0, addr + baseaddr,
+                                cu->language, objfile);
        }
       else
        {
        }
       else
        {
@@ -3893,14 +3979,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
                xfree (actual_name);
              return;
            }
                xfree (actual_name);
              return;
            }
-         /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, addr + baseaddr,
             mst_file_data, objfile); */
             mst_file_data, objfile); */
-         psym = add_psymbol_to_list (actual_name, strlen (actual_name),
-                                     built_actual_name,
-                                     VAR_DOMAIN, LOC_STATIC,
-                                     &objfile->static_psymbols,
-                                     0, addr + baseaddr,
-                                     cu->language, objfile);
+         add_psymbol_to_list (actual_name, strlen (actual_name),
+                              built_actual_name,
+                              VAR_DOMAIN, LOC_STATIC,
+                              &objfile->static_psymbols,
+                              0, addr + baseaddr,
+                              cu->language, objfile);
        }
       break;
     case DW_TAG_typedef:
        }
       break;
     case DW_TAG_typedef:
@@ -4190,7 +4276,7 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
          break;
        case DW_FORM_data8:
        case DW_FORM_ref8:
          break;
        case DW_FORM_data8:
        case DW_FORM_ref8:
-       case DW_FORM_sig8:
+       case DW_FORM_ref_sig8:
          info_ptr += 8;
          break;
        case DW_FORM_string:
          info_ptr += 8;
          break;
        case DW_FORM_string:
@@ -4552,14 +4638,52 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
   struct delayed_method_info *mi;
   for (i = 0; VEC_iterate (delayed_method_info, cu->method_list, i, mi) ; ++i)
     {
   struct delayed_method_info *mi;
   for (i = 0; VEC_iterate (delayed_method_info, cu->method_list, i, mi) ; ++i)
     {
-      char *physname;
+      const char *physname;
       struct fn_fieldlist *fn_flp
        = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index);
       struct fn_fieldlist *fn_flp
        = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index);
-      physname = (char *) dwarf2_physname ((char *) mi->name, mi->die, cu);
+      physname = dwarf2_physname ((char *) mi->name, mi->die, cu);
       fn_flp->fn_fields[mi->index].physname = physname ? physname : "";
     }
 }
 
       fn_flp->fn_fields[mi->index].physname = physname ? physname : "";
     }
 }
 
+/* Check for GCC >= 4.0.  */
+
+static int
+producer_is_gcc_ge_4_0 (struct dwarf2_cu *cu)
+{
+  const char *cs;
+  int major, minor;
+
+  if (cu->producer == NULL)
+    {
+      /* For unknown compilers expect their behavior is not compliant.  For GCC
+        this case can also happen for -gdwarf-4 type units supported since
+        gcc-4.5.  */
+
+      return 0;
+    }
+
+  /* Skip any identifier after "GNU " - such as "C++" or "Java".  */
+
+  if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
+    {
+      /* For non-GCC compilers expect their behavior is not compliant.  */
+
+      return 0;
+    }
+  cs = &cu->producer[strlen ("GNU ")];
+  while (*cs && !isdigit (*cs))
+    cs++;
+  if (sscanf (cs, "%d.%d", &major, &minor) != 2)
+    {
+      /* Not recognized as GCC.  */
+
+      return 0;
+    }
+
+  return major >= 4;
+}
+
 /* Generate full symbol information for PST and CU, whose DIEs have
    already been loaded into memory.  */
 
 /* Generate full symbol information for PST and CU, whose DIEs have
    already been loaded into memory.  */
 
@@ -4599,13 +4723,26 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
 
   symtab = end_symtab (highpc + baseaddr, objfile, SECT_OFF_TEXT (objfile));
 
 
   symtab = end_symtab (highpc + baseaddr, objfile, SECT_OFF_TEXT (objfile));
 
-  /* Set symtab language to language from DW_AT_language.
-     If the compilation is from a C file generated by language preprocessors,
-     do not set the language if it was already deduced by start_subfile.  */
-  if (symtab != NULL
-      && !(cu->language == language_c && symtab->language != language_c))
+  if (symtab != NULL)
     {
     {
-      symtab->language = cu->language;
+      /* Set symtab language to language from DW_AT_language.  If the
+        compilation is from a C file generated by language preprocessors, do
+        not set the language if it was already deduced by start_subfile.  */
+      if (!(cu->language == language_c && symtab->language != language_c))
+       symtab->language = cu->language;
+
+      /* GCC-4.0 has started to support -fvar-tracking.  GCC-3.x still can
+        produce DW_AT_location with location lists but it can be possibly
+        invalid without -fvar-tracking.
+
+        For -gdwarf-4 type units LOCATIONS_VALID indication is fortunately not
+        needed, it would be wrong due to missing DW_AT_producer there.
+
+        Still one can confuse GDB by using non-standard GCC compilation
+        options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
+        */ 
+      if (cu->has_loclist && producer_is_gcc_ge_4_0 (cu))
+       symtab->locations_valid = 1;
     }
 
   if (dwarf2_per_objfile->using_index)
     }
 
   if (dwarf2_per_objfile->using_index)
@@ -4826,7 +4963,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
              xfree (prefixed_name);
            }
          else
              xfree (prefixed_name);
            }
          else
-           fputs_unfiltered (name ? name : "", buf);
+           fputs_unfiltered (name, buf);
 
          /* Template parameters may be specified in the DIE's DW_AT_name, or
             as children with DW_TAG_template_type_param or
 
          /* Template parameters may be specified in the DIE's DW_AT_name, or
             as children with DW_TAG_template_type_param or
@@ -4963,7 +5100,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
            {
              struct type *type = read_type_die (die, cu);
 
            {
              struct type *type = read_type_die (die, cu);
 
-             c_type_print_args (type, buf, 0, cu->language);
+             c_type_print_args (type, buf, 1, cu->language);
 
              if (cu->language == language_java)
                {
 
              if (cu->language == language_java)
                {
@@ -5862,10 +5999,22 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
          return 0;
        }
 
          return 0;
        }
 
+      if (range_beginning > range_end)
+       {
+         /* Inverted range entries are invalid.  */
+         complaint (&symfile_complaints,
+                    _("Invalid .debug_ranges data (inverted range)"));
+         return 0;
+       }
+
+      /* Empty range entries have no effect.  */
+      if (range_beginning == range_end)
+       continue;
+
       range_beginning += base;
       range_end += base;
 
       range_beginning += base;
       range_end += base;
 
-      if (ranges_pst != NULL && range_beginning < range_end)
+      if (ranges_pst != NULL)
        addrmap_set_empty (objfile->psymtabs_addrmap,
                           range_beginning + baseaddr,
                           range_end - 1 + baseaddr,
        addrmap_set_empty (objfile->psymtabs_addrmap,
                           range_beginning + baseaddr,
                           range_end - 1 + baseaddr,
@@ -5943,7 +6092,8 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
        }
     }
 
        }
     }
 
-  if (high < low)
+  /* read_partial_die has also the strict LOW < HIGH requirement.  */
+  if (high <= low)
     return 0;
 
   /* When using the GNU linker, .gnu.linkonce. sections are used to
     return 0;
 
   /* When using the GNU linker, .gnu.linkonce. sections are used to
@@ -6148,6 +6298,19 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
                   return;
                 }
 
                   return;
                 }
 
+             if (start > end)
+               {
+                 /* Inverted range entries are invalid.  */
+                 complaint (&symfile_complaints,
+                            _("Invalid .debug_ranges data "
+                              "(inverted range)"));
+                 return;
+               }
+
+             /* Empty range entries have no effect.  */
+             if (start == end)
+               continue;
+
               record_block_range (block,
                                   baseaddr + base + start,
                                   baseaddr + base + end - 1);
               record_block_range (block,
                                   baseaddr + base + start,
                                   baseaddr + base + end - 1);
@@ -6156,6 +6319,116 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
     }
 }
 
     }
 }
 
+/* Check for GCC PR debug/45124 fix which is not present in any G++ version up
+   to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed
+   during 4.6.0 experimental.  */
+
+static int
+producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
+{
+  const char *cs;
+  int major, minor, release;
+
+  if (cu->producer == NULL)
+    {
+      /* For unknown compilers expect their behavior is DWARF version
+        compliant.
+
+        GCC started to support .debug_types sections by -gdwarf-4 since
+        gcc-4.5.x.  As the .debug_types sections are missing DW_AT_producer
+        for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4
+        combination.  gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility
+        interpreted incorrectly by GDB now - GCC PR debug/48229.  */
+
+      return 0;
+    }
+
+  /* Skip any identifier after "GNU " - such as "C++" or "Java".  */
+
+  if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
+    {
+      /* For non-GCC compilers expect their behavior is DWARF version
+        compliant.  */
+
+      return 0;
+    }
+  cs = &cu->producer[strlen ("GNU ")];
+  while (*cs && !isdigit (*cs))
+    cs++;
+  if (sscanf (cs, "%d.%d.%d", &major, &minor, &release) != 3)
+    {
+      /* Not recognized as GCC.  */
+
+      return 0;
+    }
+
+  return major < 4 || (major == 4 && minor < 6);
+}
+
+/* Return the default accessibility type if it is not overriden by
+   DW_AT_accessibility.  */
+
+static enum dwarf_access_attribute
+dwarf2_default_access_attribute (struct die_info *die, struct dwarf2_cu *cu)
+{
+  if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu))
+    {
+      /* The default DWARF 2 accessibility for members is public, the default
+        accessibility for inheritance is private.  */
+
+      if (die->tag != DW_TAG_inheritance)
+       return DW_ACCESS_public;
+      else
+       return DW_ACCESS_private;
+    }
+  else
+    {
+      /* DWARF 3+ defines the default accessibility a different way.  The same
+        rules apply now for DW_TAG_inheritance as for the members and it only
+        depends on the container kind.  */
+
+      if (die->parent->tag == DW_TAG_class_type)
+       return DW_ACCESS_private;
+      else
+       return DW_ACCESS_public;
+    }
+}
+
+/* Look for DW_AT_data_member_location.  Set *OFFSET to the byte
+   offset.  If the attribute was not found return 0, otherwise return
+   1.  If it was found but could not properly be handled, set *OFFSET
+   to 0.  */
+
+static int
+handle_data_member_location (struct die_info *die, struct dwarf2_cu *cu,
+                            LONGEST *offset)
+{
+  struct attribute *attr;
+
+  attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
+  if (attr != NULL)
+    {
+      *offset = 0;
+
+      /* Note that we do not check for a section offset first here.
+        This is because DW_AT_data_member_location is new in DWARF 4,
+        so if we see it, we can assume that a constant form is really
+        a constant and not a section offset.  */
+      if (attr_form_is_constant (attr))
+       *offset = dwarf2_get_attr_constant_value (attr, 0);
+      else if (attr_form_is_section_offset (attr))
+       dwarf2_complex_location_expr_complaint ();
+      else if (attr_form_is_block (attr))
+       *offset = decode_locdesc (DW_BLOCK (attr), cu);
+      else
+       dwarf2_complex_location_expr_complaint ();
+
+      return 1;
+    }
+
+  return 0;
+}
+
 /* Add an aggregate field to the field list.  */
 
 static void
 /* Add an aggregate field to the field list.  */
 
 static void
@@ -6186,28 +6459,26 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
     }
   fip->nfields++;
 
     }
   fip->nfields++;
 
-  /* Handle accessibility and virtuality of field.
-     The default accessibility for members is public, the default
-     accessibility for inheritance is private.  */
-  if (die->tag != DW_TAG_inheritance)
-    new_field->accessibility = DW_ACCESS_public;
-  else
-    new_field->accessibility = DW_ACCESS_private;
-  new_field->virtuality = DW_VIRTUALITY_none;
-
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);
   if (attr)
     new_field->accessibility = DW_UNSND (attr);
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);
   if (attr)
     new_field->accessibility = DW_UNSND (attr);
+  else
+    new_field->accessibility = dwarf2_default_access_attribute (die, cu);
   if (new_field->accessibility != DW_ACCESS_public)
     fip->non_public_fields = 1;
   if (new_field->accessibility != DW_ACCESS_public)
     fip->non_public_fields = 1;
+
   attr = dwarf2_attr (die, DW_AT_virtuality, cu);
   if (attr)
     new_field->virtuality = DW_UNSND (attr);
   attr = dwarf2_attr (die, DW_AT_virtuality, cu);
   if (attr)
     new_field->virtuality = DW_UNSND (attr);
+  else
+    new_field->virtuality = DW_VIRTUALITY_none;
 
   fp = &new_field->field;
 
   if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
     {
 
   fp = &new_field->field;
 
   if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
     {
+      LONGEST offset;
+
       /* Data member other than a C++ static data member.  */
 
       /* Get type of field.  */
       /* Data member other than a C++ static data member.  */
 
       /* Get type of field.  */
@@ -6227,22 +6498,8 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
        }
 
       /* Get bit offset of field.  */
        }
 
       /* Get bit offset of field.  */
-      attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
-      if (attr)
-       {
-          int byte_offset = 0;
-
-          if (attr_form_is_section_offset (attr))
-           dwarf2_complex_location_expr_complaint ();
-          else if (attr_form_is_constant (attr))
-            byte_offset = dwarf2_get_attr_constant_value (attr, 0);
-          else if (attr_form_is_block (attr))
-            byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
-         else
-           dwarf2_complex_location_expr_complaint ();
-
-          SET_FIELD_BITPOS (*fp, byte_offset * bits_per_byte);
-       }
+      if (handle_data_member_location (die, cu, &offset))
+       SET_FIELD_BITPOS (*fp, offset * bits_per_byte);
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr)
        {
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr)
        {
@@ -6314,7 +6571,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
         (so through at least 3.2.1) incorrectly generate
         DW_TAG_variable tags.  */
 
         (so through at least 3.2.1) incorrectly generate
         DW_TAG_variable tags.  */
 
-      char *physname;
+      const char *physname;
 
       /* Get name of field.  */
       fieldname = dwarf2_name (die, cu);
 
       /* Get name of field.  */
       fieldname = dwarf2_name (die, cu);
@@ -6335,7 +6592,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
        }
 
       /* Get physical name.  */
        }
 
       /* Get physical name.  */
-      physname = (char *) dwarf2_physname (fieldname, die, cu);
+      physname = dwarf2_physname (fieldname, die, cu);
 
       /* The name is already allocated along with this objfile, so we don't
         need to duplicate it for the type.  */
 
       /* The name is already allocated along with this objfile, so we don't
         need to duplicate it for the type.  */
@@ -6345,23 +6602,11 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
     }
   else if (die->tag == DW_TAG_inheritance)
     {
     }
   else if (die->tag == DW_TAG_inheritance)
     {
-      /* C++ base class field.  */
-      attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
-      if (attr)
-       {
-          int byte_offset = 0;
-
-          if (attr_form_is_section_offset (attr))
-           dwarf2_complex_location_expr_complaint ();
-          else if (attr_form_is_constant (attr))
-            byte_offset = dwarf2_get_attr_constant_value (attr, 0);
-          else if (attr_form_is_block (attr))
-            byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
-         else
-           dwarf2_complex_location_expr_complaint ();
+      LONGEST offset;
 
 
-          SET_FIELD_BITPOS (*fp, byte_offset * bits_per_byte);
-       }
+      /* C++ base class field.  */
+      if (handle_data_member_location (die, cu, &offset))
+       SET_FIELD_BITPOS (*fp, offset * bits_per_byte);
       FIELD_BITSIZE (*fp) = 0;
       FIELD_TYPE (*fp) = die_type (die, cu);
       FIELD_NAME (*fp) = type_name_no_tag (fp->type);
       FIELD_BITSIZE (*fp) = 0;
       FIELD_TYPE (*fp) = die_type (die, cu);
       FIELD_NAME (*fp) = type_name_no_tag (fp->type);
@@ -6376,7 +6621,6 @@ dwarf2_add_typedef (struct field_info *fip, struct die_info *die,
                    struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
                    struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
-  struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct typedef_field_list *new_field;
   struct attribute *attr;
   struct typedef_field *fp;
   struct typedef_field_list *new_field;
   struct attribute *attr;
   struct typedef_field *fp;
@@ -6519,6 +6763,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
   char *fieldname;
   struct nextfnfield *new_fnfield;
   struct type *this_type;
   char *fieldname;
   struct nextfnfield *new_fnfield;
   struct type *this_type;
+  enum dwarf_access_attribute accessibility;
 
   if (cu->language == language_ada)
     error (_("unexpected member function in Ada type"));
 
   if (cu->language == language_ada)
     error (_("unexpected member function in Ada type"));
@@ -6576,7 +6821,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
     }
   else
     {
     }
   else
     {
-      char *physname = (char *) dwarf2_physname (fieldname, die, cu);
+      const char *physname = dwarf2_physname (fieldname, die, cu);
       fnp->physname = physname ? physname : "";
     }
 
       fnp->physname = physname ? physname : "";
     }
 
@@ -6617,16 +6862,17 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
   /* Get accessibility.  */
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);
   if (attr)
   /* Get accessibility.  */
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);
   if (attr)
+    accessibility = DW_UNSND (attr);
+  else
+    accessibility = dwarf2_default_access_attribute (die, cu);
+  switch (accessibility)
     {
     {
-      switch (DW_UNSND (attr))
-       {
-       case DW_ACCESS_private:
-         fnp->is_private = 1;
-         break;
-       case DW_ACCESS_protected:
-         fnp->is_protected = 1;
-         break;
-       }
+    case DW_ACCESS_private:
+      fnp->is_private = 1;
+      break;
+    case DW_ACCESS_protected:
+      fnp->is_protected = 1;
+      break;
     }
 
   /* Check for artificial methods.  */
     }
 
   /* Check for artificial methods.  */
@@ -7470,22 +7716,13 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
       child_die = die->child;
       while (child_die && child_die->tag)
        {
       child_die = die->child;
       while (child_die && child_die->tag)
        {
+         LONGEST offset;
+
          sym = new_symbol (child_die, NULL, cu);
          sym = new_symbol (child_die, NULL, cu);
-         attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
-         if (sym != NULL && attr != NULL)
+         if (sym != NULL
+             && handle_data_member_location (child_die, cu, &offset))
            {
            {
-             CORE_ADDR byte_offset = 0;
-
-             if (attr_form_is_section_offset (attr))
-               dwarf2_complex_location_expr_complaint ();
-             else if (attr_form_is_constant (attr))
-               byte_offset = dwarf2_get_attr_constant_value (attr, 0);
-             else if (attr_form_is_block (attr))
-               byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
-             else
-               dwarf2_complex_location_expr_complaint ();
-
-             SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
+             SYMBOL_VALUE_ADDRESS (sym) = base + offset;
              add_symbol_to_list (sym, &global_symbols);
            }
          child_die = sibling_die (child_die);
              add_symbol_to_list (sym, &global_symbols);
            }
          child_die = sibling_die (child_die);
@@ -7541,7 +7778,6 @@ static void
 read_namespace (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
 read_namespace (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
-  const char *name;
   int is_anonymous;
 
   /* Add a symbol associated to this if we haven't seen the namespace
   int is_anonymous;
 
   /* Add a symbol associated to this if we haven't seen the namespace
@@ -7555,7 +7791,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
       type = read_type_die (die, cu);
       new_symbol (die, type, cu);
 
       type = read_type_die (die, cu);
       new_symbol (die, type, cu);
 
-      name = namespace_name (die, &is_anonymous, cu);
+      namespace_name (die, &is_anonymous, cu);
       if (is_anonymous)
        {
          const char *previous_prefix = determine_prefix (die, cu);
       if (is_anonymous)
        {
          const char *previous_prefix = determine_prefix (die, cu);
@@ -7640,7 +7876,7 @@ namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *cu)
 
   *is_anonymous = (name == NULL);
   if (*is_anonymous)
 
   *is_anonymous = (name == NULL);
   if (*is_anonymous)
-    name = "(anonymous namespace)";
+    name = CP_ANONYMOUS_NAMESPACE_STR;
 
   return name;
 }
 
   return name;
 }
@@ -7906,7 +8142,12 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
      the subroutine die.  Otherwise set the calling convention to
      the default value DW_CC_normal.  */
   attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
      the subroutine die.  Otherwise set the calling convention to
      the default value DW_CC_normal.  */
   attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
-  TYPE_CALLING_CONVENTION (ftype) = attr ? DW_UNSND (attr) : DW_CC_normal;
+  if (attr)
+    TYPE_CALLING_CONVENTION (ftype) = DW_UNSND (attr);
+  else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL"))
+    TYPE_CALLING_CONVENTION (ftype) = DW_CC_GDB_IBM_OpenCL;
+  else
+    TYPE_CALLING_CONVENTION (ftype) = DW_CC_normal;
 
   /* We need to add the subroutine type to the die immediately so
      we don't infinitely recurse when dealing with parameters
 
   /* We need to add the subroutine type to the die immediately so
      we don't infinitely recurse when dealing with parameters
@@ -8132,7 +8373,6 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
 {
 static struct type *
 read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
   struct type *base_type;
   struct type *range_type;
   struct attribute *attr;
   struct type *base_type;
   struct type *range_type;
   struct attribute *attr;
@@ -8795,7 +9035,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
       if (parent_die == NULL
          && part_die->has_specification == 0
          && part_die->is_declaration == 0
       if (parent_die == NULL
          && part_die->has_specification == 0
          && part_die->is_declaration == 0
-         && (part_die->tag == DW_TAG_typedef
+         && ((part_die->tag == DW_TAG_typedef && !part_die->has_children)
              || part_die->tag == DW_TAG_base_type
              || part_die->tag == DW_TAG_subrange_type))
        {
              || part_die->tag == DW_TAG_base_type
              || part_die->tag == DW_TAG_subrange_type))
        {
@@ -8808,6 +9048,20 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
          continue;
        }
 
          continue;
        }
 
+      /* The exception for DW_TAG_typedef with has_children above is
+        a workaround of GCC PR debug/47510.  In the case of this complaint
+        type_name_no_tag_or_error will error on such types later.
+
+        GDB skipped children of DW_TAG_typedef by the shortcut above and then
+        it could not find the child DIEs referenced later, this is checked
+        above.  In correct DWARF DW_TAG_typedef should have no children.  */
+
+      if (part_die->tag == DW_TAG_typedef && part_die->has_children)
+       complaint (&symfile_complaints,
+                  _("DW_TAG_typedef has childen - GCC PR debug/47510 bug "
+                    "- DIE at 0x%x [in module %s]"),
+                  part_die->offset, cu->objfile->name);
+
       /* If we're at the second level, and we're an enumerator, and
         our parent has no specification (meaning possibly lives in a
         namespace elsewhere), then we can add the partial symbol now
       /* If we're at the second level, and we're an enumerator, and
         our parent has no specification (meaning possibly lives in a
         namespace elsewhere), then we can add the partial symbol now
@@ -9073,19 +9327,41 @@ read_partial_die (struct partial_die_info *part_die,
        }
     }
 
        }
     }
 
-  /* When using the GNU linker, .gnu.linkonce. sections are used to
-     eliminate duplicate copies of functions and vtables and such.
-     The linker will arbitrarily choose one and discard the others.
-     The AT_*_pc values for such functions refer to local labels in
-     these sections.  If the section from that file was discarded, the
-     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 (has_low_pc_attr && has_high_pc_attr
-      && part_die->lowpc < part_die->highpc
-      && (part_die->lowpc != 0
-         || dwarf2_per_objfile->has_section_at_zero))
-    part_die->has_pc_info = 1;
+  if (has_low_pc_attr && has_high_pc_attr)
+    {
+      /* When using the GNU linker, .gnu.linkonce. sections are used to
+        eliminate duplicate copies of functions and vtables and such.
+        The linker will arbitrarily choose one and discard the others.
+        The AT_*_pc values for such functions refer to local labels in
+        these sections.  If the section from that file was discarded, the
+        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 (part_die->lowpc == 0 && !dwarf2_per_objfile->has_section_at_zero)
+       {
+         struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
+
+         complaint (&symfile_complaints,
+                    _("DW_AT_low_pc %s is zero "
+                      "for DIE at 0x%x [in module %s]"),
+                    paddress (gdbarch, part_die->lowpc),
+                    part_die->offset, cu->objfile->name);
+       }
+      /* dwarf2_get_pc_bounds has also the strict low < high requirement.  */
+      else if (part_die->lowpc >= part_die->highpc)
+       {
+         struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
+
+         complaint (&symfile_complaints,
+                    _("DW_AT_low_pc %s is not < DW_AT_high_pc %s "
+                      "for DIE at 0x%x [in module %s]"),
+                    paddress (gdbarch, part_die->lowpc),
+                    paddress (gdbarch, part_die->highpc),
+                    part_die->offset, cu->objfile->name);
+       }
+      else
+       part_die->has_pc_info = 1;
+    }
 
   return info_ptr;
 }
 
   return info_ptr;
 }
@@ -9107,7 +9383,7 @@ find_partial_die_in_comp_unit (unsigned int offset, struct dwarf2_cu *cu)
 /* Find a partial DIE at OFFSET, which may or may not be in CU,
    except in the case of .debug_types DIEs which do not reference
    outside their CU (they do however referencing other types via
 /* Find a partial DIE at OFFSET, which may or may not be in CU,
    except in the case of .debug_types DIEs which do not reference
    outside their CU (they do however referencing other types via
-   DW_FORM_sig8).  */
+   DW_FORM_ref_sig8).  */
 
 static struct partial_die_info *
 find_partial_die (unsigned int offset, struct dwarf2_cu *cu)
 
 static struct partial_die_info *
 find_partial_die (unsigned int offset, struct dwarf2_cu *cu)
@@ -9270,7 +9546,7 @@ fixup_partial_die (struct partial_die_info *part_die,
   /* Set default names for some unnamed DIEs.  */
 
   if (part_die->name == NULL && part_die->tag == DW_TAG_namespace)
   /* Set default names for some unnamed DIEs.  */
 
   if (part_die->name == NULL && part_die->tag == DW_TAG_namespace)
-    part_die->name = "(anonymous namespace)";
+    part_die->name = CP_ANONYMOUS_NAMESPACE_STR;
 
   /* If there is no parent die to provide a namespace, and there are
      children, see if we can determine the namespace from their linkage
 
   /* If there is no parent die to provide a namespace, and there are
      children, see if we can determine the namespace from their linkage
@@ -9286,6 +9562,25 @@ fixup_partial_die (struct partial_die_info *part_die,
          || part_die->tag == DW_TAG_union_type))
     guess_partial_die_structure_name (part_die, cu);
 
          || part_die->tag == DW_TAG_union_type))
     guess_partial_die_structure_name (part_die, cu);
 
+  /* GCC might emit a nameless struct or union that has a linkage
+     name.  See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510.  */
+  if (part_die->name == NULL
+      && (part_die->tag == DW_TAG_structure_type
+         || part_die->tag == DW_TAG_union_type
+         || part_die->tag == DW_TAG_class_type)
+      && part_die->linkage_name != NULL)
+    {
+      char *demangled;
+
+      demangled = cplus_demangle (part_die->linkage_name, DMGL_TYPES);
+      if (demangled)
+       {
+         part_die->name = obsavestring (demangled, strlen (demangled),
+                                        &cu->objfile->objfile_obstack);
+         xfree (demangled);
+       }
+    }
+
   part_die->fixup_called = 1;
 }
 
   part_die->fixup_called = 1;
 }
 
@@ -9410,7 +9705,7 @@ read_attribute_value (struct attribute *attr, unsigned form,
       DW_ADDR (attr) = cu->header.offset + read_8_bytes (abfd, info_ptr);
       info_ptr += 8;
       break;
       DW_ADDR (attr) = cu->header.offset + read_8_bytes (abfd, info_ptr);
       info_ptr += 8;
       break;
-    case DW_FORM_sig8:
+    case DW_FORM_ref_sig8:
       /* Convert the signature to something we can record in DW_UNSND
         for later lookup.
          NOTE: This is NULL if the type wasn't found.  */
       /* Convert the signature to something we can record in DW_UNSND
         for later lookup.
          NOTE: This is NULL if the type wasn't found.  */
@@ -10287,6 +10582,14 @@ psymtab_include_file_name (const struct line_header *lh, int file_index,
   return include_name;
 }
 
   return include_name;
 }
 
+/* Ignore this record_line request.  */
+
+static void
+noop_record_line (struct subfile *subfile, int line, CORE_ADDR pc)
+{
+  return;
+}
+
 /* Decode the Line Number Program (LNP) for the given line_header
    structure and CU.  The actual information extracted and the type
    of structures created from the LNP depends on the value of PST.
 /* Decode the Line Number Program (LNP) for the given line_header
    structure and CU.  The actual information extracted and the type
    of structures created from the LNP depends on the value of PST.
@@ -10322,6 +10625,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   const int decode_for_pst_p = (pst != NULL);
   struct subfile *last_subfile = NULL, *first_subfile = current_subfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   const int decode_for_pst_p = (pst != NULL);
   struct subfile *last_subfile = NULL, *first_subfile = current_subfile;
+  void (*p_record_line) (struct subfile *subfile, int line, CORE_ADDR pc)
+    = record_line;
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
@@ -10391,13 +10696,13 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
                        {
                          addr = gdbarch_addr_bits_remove (gdbarch, address);
                          if (last_subfile)
                        {
                          addr = gdbarch_addr_bits_remove (gdbarch, address);
                          if (last_subfile)
-                           record_line (last_subfile, 0, addr);
+                           (*p_record_line) (last_subfile, 0, addr);
                          last_subfile = current_subfile;
                        }
                      /* Append row to matrix using current values.  */
                      addr = check_cu_functions (address, cu);
                      addr = gdbarch_addr_bits_remove (gdbarch, addr);
                          last_subfile = current_subfile;
                        }
                      /* Append row to matrix using current values.  */
                      addr = check_cu_functions (address, cu);
                      addr = gdbarch_addr_bits_remove (gdbarch, addr);
-                     record_line (current_subfile, line, addr);
+                     (*p_record_line) (current_subfile, line, addr);
                    }
                }
              basic_block = 0;
                    }
                }
              basic_block = 0;
@@ -10414,10 +10719,27 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
              switch (extended_op)
                {
                case DW_LNE_end_sequence:
              switch (extended_op)
                {
                case DW_LNE_end_sequence:
+                 p_record_line = record_line;
                  end_sequence = 1;
                  break;
                case DW_LNE_set_address:
                  address = read_address (abfd, line_ptr, cu, &bytes_read);
                  end_sequence = 1;
                  break;
                case DW_LNE_set_address:
                  address = read_address (abfd, line_ptr, cu, &bytes_read);
+
+                 if (address == 0 && !dwarf2_per_objfile->has_section_at_zero)
+                   {
+                     /* This line table is for a function which has been
+                        GCd by the linker.  Ignore it.  PR gdb/12528 */
+
+                     long line_offset
+                       = line_ptr - dwarf2_per_objfile->line.buffer;
+
+                     complaint (&symfile_complaints,
+                                _(".debug_line address at offset 0x%lx is 0 "
+                                  "[in module %s]"),
+                                line_offset, cu->objfile->name);
+                     p_record_line = noop_record_line;
+                   }
+
                  op_index = 0;
                  line_ptr += bytes_read;
                  address += baseaddr;
                  op_index = 0;
                  line_ptr += bytes_read;
                  address += baseaddr;
@@ -10474,12 +10796,12 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
                        {
                          addr = gdbarch_addr_bits_remove (gdbarch, address);
                          if (last_subfile)
                        {
                          addr = gdbarch_addr_bits_remove (gdbarch, address);
                          if (last_subfile)
-                           record_line (last_subfile, 0, addr);
+                           (*p_record_line) (last_subfile, 0, addr);
                          last_subfile = current_subfile;
                        }
                      addr = check_cu_functions (address, cu);
                      addr = gdbarch_addr_bits_remove (gdbarch, addr);
                          last_subfile = current_subfile;
                        }
                      addr = check_cu_functions (address, cu);
                      addr = gdbarch_addr_bits_remove (gdbarch, addr);
-                     record_line (current_subfile, line, addr);
+                     (*p_record_line) (current_subfile, line, addr);
                    }
                }
              basic_block = 0;
                    }
                }
              basic_block = 0;
@@ -10540,7 +10862,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
               address increment value corresponding to special opcode
               255.  I.e., this value is scaled by the minimum
               instruction length since special opcode 255 would have
               address increment value corresponding to special opcode
               255.  I.e., this value is scaled by the minimum
               instruction length since special opcode 255 would have
-              scaled the the increment.  */
+              scaled the increment.  */
            case DW_LNS_const_add_pc:
              {
                CORE_ADDR adjust = (255 - lh->opcode_base) / lh->line_range;
            case DW_LNS_const_add_pc:
              {
                CORE_ADDR adjust = (255 - lh->opcode_base) / lh->line_range;
@@ -10578,7 +10900,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
           if (!decode_for_pst_p)
            {
              addr = gdbarch_addr_bits_remove (gdbarch, address);
           if (!decode_for_pst_p)
            {
              addr = gdbarch_addr_bits_remove (gdbarch, address);
-             record_line (current_subfile, 0, addr);
+             (*p_record_line) (current_subfile, 0, addr);
            }
         }
     }
            }
         }
     }
@@ -10735,6 +11057,9 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
 
   dwarf2_symbol_mark_computed (attr, sym, cu);
   SYMBOL_CLASS (sym) = LOC_COMPUTED;
 
   dwarf2_symbol_mark_computed (attr, sym, cu);
   SYMBOL_CLASS (sym) = LOC_COMPUTED;
+
+  if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs)
+    cu->has_loclist = 1;
 }
 
 /* Given a pointer to a DWARF information entry, figure out if we need
 }
 
 /* Given a pointer to a DWARF information entry, figure out if we need
@@ -11393,7 +11718,7 @@ lookup_die_type (struct die_info *die, struct attribute *attr,
 
       this_type = get_die_type_at_offset (offset, cu->per_cu);
     }
 
       this_type = get_die_type_at_offset (offset, cu->per_cu);
     }
-  else if (attr->form == DW_FORM_sig8)
+  else if (attr->form == DW_FORM_ref_sig8)
     {
       struct signatured_type *sig_type = DW_SIGNATURED_TYPE (attr);
       struct dwarf2_cu *sig_cu;
     {
       struct signatured_type *sig_type = DW_SIGNATURED_TYPE (attr);
       struct dwarf2_cu *sig_cu;
@@ -11407,7 +11732,7 @@ lookup_die_type (struct die_info *die, struct attribute *attr,
               die->offset, cu->objfile->name);
 
       gdb_assert (sig_type->per_cu.from_debug_types);
               die->offset, cu->objfile->name);
 
       gdb_assert (sig_type->per_cu.from_debug_types);
-      offset = sig_type->offset + sig_type->type_offset;
+      offset = sig_type->per_cu.offset + sig_type->type_offset;
       this_type = get_die_type_at_offset (offset, &sig_type->per_cu);
     }
   else
       this_type = get_die_type_at_offset (offset, &sig_type->per_cu);
     }
   else
@@ -11856,7 +12181,11 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
   struct attribute *attr;
 
   attr = dwarf2_attr (die, DW_AT_name, cu);
   struct attribute *attr;
 
   attr = dwarf2_attr (die, DW_AT_name, cu);
-  if (!attr || !DW_STRING (attr))
+  if ((!attr || !DW_STRING (attr))
+      && die->tag != DW_TAG_class_type
+      && die->tag != DW_TAG_interface_type
+      && die->tag != DW_TAG_structure_type
+      && die->tag != DW_TAG_union_type)
     return NULL;
 
   switch (die->tag)
     return NULL;
 
   switch (die->tag)
@@ -11907,9 +12236,39 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
         structures or unions.  These were of the form "._%d" in GCC 4.1,
         or simply "<anonymous struct>" or "<anonymous union>" in GCC 4.3
         and GCC 4.4.  We work around this problem by ignoring these.  */
         structures or unions.  These were of the form "._%d" in GCC 4.1,
         or simply "<anonymous struct>" or "<anonymous union>" in GCC 4.3
         and GCC 4.4.  We work around this problem by ignoring these.  */
-      if (strncmp (DW_STRING (attr), "._", 2) == 0
-         || strncmp (DW_STRING (attr), "<anonymous", 10) == 0)
+      if (attr && DW_STRING (attr)
+         && (strncmp (DW_STRING (attr), "._", 2) == 0
+             || strncmp (DW_STRING (attr), "<anonymous", 10) == 0))
        return NULL;
        return NULL;
+
+      /* GCC might emit a nameless typedef that has a linkage name.  See
+        http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510.  */
+      if (!attr || DW_STRING (attr) == NULL)
+       {
+         char *demangled = NULL;
+
+         attr = dwarf2_attr (die, DW_AT_linkage_name, cu);
+         if (attr == NULL)
+           attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+
+         if (attr == NULL || DW_STRING (attr) == NULL)
+           return NULL;
+
+         /* Avoid demangling DW_STRING (attr) the second time on a second
+            call for the same DIE.  */
+         if (!DW_STRING_IS_CANONICAL (attr))
+           demangled = cplus_demangle (DW_STRING (attr), DMGL_TYPES);
+
+         if (demangled)
+           {
+             /* FIXME: we already did this for the partial symbol... */
+             DW_STRING (attr)
+               = obsavestring (demangled, strlen (demangled),
+                               &cu->objfile->objfile_obstack);
+             DW_STRING_IS_CANONICAL (attr) = 1;
+             xfree (demangled);
+           }
+       }
       break;
 
     default:
       break;
 
     default:
@@ -12433,8 +12792,8 @@ dwarf_form_name (unsigned form)
       return "DW_FORM_exprloc";
     case DW_FORM_flag_present:
       return "DW_FORM_flag_present";
       return "DW_FORM_exprloc";
     case DW_FORM_flag_present:
       return "DW_FORM_flag_present";
-    case DW_FORM_sig8:
-      return "DW_FORM_sig8";
+    case DW_FORM_ref_sig8:
+      return "DW_FORM_ref_sig8";
     default:
       return "DW_FORM_<unknown>";
     }
     default:
       return "DW_FORM_<unknown>";
     }
@@ -12443,7 +12802,7 @@ dwarf_form_name (unsigned form)
 /* Convert a DWARF stack opcode into its string name.  */
 
 const char *
 /* Convert a DWARF stack opcode into its string name.  */
 
 const char *
-dwarf_stack_op_name (unsigned op, int def)
+dwarf_stack_op_name (unsigned op)
 {
   switch (op)
     {
 {
   switch (op)
     {
@@ -12764,8 +13123,20 @@ dwarf_stack_op_name (unsigned op, int def)
       return "DW_OP_GNU_uninit";
     case DW_OP_GNU_implicit_pointer:
       return "DW_OP_GNU_implicit_pointer";
       return "DW_OP_GNU_uninit";
     case DW_OP_GNU_implicit_pointer:
       return "DW_OP_GNU_implicit_pointer";
+    case DW_OP_GNU_entry_value:
+      return "DW_OP_GNU_entry_value";
+    case DW_OP_GNU_const_type:
+      return "DW_OP_GNU_const_type";
+    case DW_OP_GNU_regval_type:
+      return "DW_OP_GNU_regval_type";
+    case DW_OP_GNU_deref_type:
+      return "DW_OP_GNU_deref_type";
+    case DW_OP_GNU_convert:
+      return "DW_OP_GNU_convert";
+    case DW_OP_GNU_reinterpret:
+      return "DW_OP_GNU_reinterpret";
     default:
     default:
-      return def ? "OP_<unknown>" : NULL;
+      return NULL;
     }
 }
 
     }
 }
 
@@ -12985,10 +13356,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
          fprintf_unfiltered (f, "section offset: %s",
                              pulongest (DW_UNSND (&die->attrs[i])));
          break;
          fprintf_unfiltered (f, "section offset: %s",
                              pulongest (DW_UNSND (&die->attrs[i])));
          break;
-       case DW_FORM_sig8:
+       case DW_FORM_ref_sig8:
          if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
            fprintf_unfiltered (f, "signatured type, offset: 0x%x",
          if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
            fprintf_unfiltered (f, "signatured type, offset: 0x%x",
-                               DW_SIGNATURED_TYPE (&die->attrs[i])->offset);
+                         DW_SIGNATURED_TYPE (&die->attrs[i])->per_cu.offset);
          else
            fprintf_unfiltered (f, "signatured type, offset: unknown");
          break;
          else
            fprintf_unfiltered (f, "signatured type, offset: unknown");
          break;
@@ -13187,7 +13558,7 @@ follow_die_ref_or_sig (struct die_info *src_die, struct attribute *attr,
 
   if (is_ref_attr (attr))
     die = follow_die_ref (src_die, attr, ref_cu);
 
   if (is_ref_attr (attr))
     die = follow_die_ref (src_die, attr, ref_cu);
-  else if (attr->form == DW_FORM_sig8)
+  else if (attr->form == DW_FORM_ref_sig8)
     die = follow_die_sig (src_die, attr, ref_cu);
   else
     {
     die = follow_die_sig (src_die, attr, ref_cu);
   else
     {
@@ -13218,7 +13589,7 @@ follow_die_offset (unsigned int offset, struct dwarf2_cu **ref_cu)
     {
       /* .debug_types CUs cannot reference anything outside their CU.
         If they need to, they have to reference a signatured type via
     {
       /* .debug_types CUs cannot reference anything outside their CU.
         If they need to, they have to reference a signatured type via
-        DW_FORM_sig8.  */
+        DW_FORM_ref_sig8.  */
       if (! offset_in_cu_p (&cu->header, offset))
        return NULL;
     }
       if (! offset_in_cu_p (&cu->header, offset))
        return NULL;
     }
@@ -13322,6 +13693,17 @@ dwarf2_fetch_die_location_block (unsigned int offset,
   return retval;
 }
 
   return retval;
 }
 
+/* Return the type of the DIE at DIE_OFFSET in the CU named by
+   PER_CU.  */
+
+struct type *
+dwarf2_get_die_type (unsigned int die_offset,
+                    struct dwarf2_per_cu_data *per_cu)
+{
+  dw2_setup (per_cu->objfile);
+  return get_die_type_at_offset (die_offset, per_cu);
+}
+
 /* Follow the signature attribute ATTR in SRC_DIE.
    On entry *REF_CU is the CU of SRC_DIE.
    On exit *REF_CU is the CU of the result.  */
 /* Follow the signature attribute ATTR in SRC_DIE.
    On entry *REF_CU is the CU of SRC_DIE.
    On exit *REF_CU is the CU of the result.  */
@@ -13385,7 +13767,7 @@ lookup_signatured_type_at_offset (struct objfile *objfile, unsigned int offset)
   /* This is only used to lookup previously recorded types.
      If we didn't find it, it's our bug.  */
   gdb_assert (type_sig != NULL);
   /* This is only used to lookup previously recorded types.
      If we didn't find it, it's our bug.  */
   gdb_assert (type_sig != NULL);
-  gdb_assert (offset == type_sig->offset);
+  gdb_assert (offset == type_sig->per_cu.offset);
 
   return type_sig;
 }
 
   return type_sig;
 }
@@ -13424,7 +13806,7 @@ read_signatured_type (struct objfile *objfile,
   struct cleanup *back_to, *free_cu_cleanup;
 
   dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
   struct cleanup *back_to, *free_cu_cleanup;
 
   dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
-  types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
+  types_ptr = dwarf2_per_objfile->types.buffer + type_sig->per_cu.offset;
 
   gdb_assert (type_sig->per_cu.cu == NULL);
 
 
   gdb_assert (type_sig->per_cu.cu == NULL);
 
@@ -13689,8 +14071,17 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
          break;
 
        default:
          break;
 
        default:
-         complaint (&symfile_complaints, _("unsupported stack op: '%s'"),
-                    dwarf_stack_op_name (op, 1));
+         {
+           const char *name = dwarf_stack_op_name (op);
+
+           if (name)
+             complaint (&symfile_complaints, _("unsupported stack op: '%s'"),
+                        name);
+           else
+             complaint (&symfile_complaints, _("unsupported stack op: '%02x'"),
+                        op);
+         }
+
          return (stack[stacki]);
        }
 
          return (stack[stacki]);
        }
 
@@ -14264,11 +14655,10 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
           {
             unsigned int bytes_read;
             int constant;
           {
             unsigned int bytes_read;
             int constant;
-            char *string;
 
             constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
 
             constant = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
-            string = read_direct_string (abfd, mac_ptr, &bytes_read);
+            read_direct_string (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
 
             /* We don't recognize any vendor extensions.  */
             mac_ptr += bytes_read;
 
             /* We don't recognize any vendor extensions.  */
@@ -14364,7 +14754,8 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
       /* ".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.  */
       /* ".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)
+      && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
+                                               &dwarf2_per_objfile->loc))
     {
       struct dwarf2_loclist_baton *baton;
 
     {
       struct dwarf2_loclist_baton *baton;
 
@@ -14566,7 +14957,10 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die)
   if (attr)
     set_cu_language (DW_UNSND (attr), cu);
   else
   if (attr)
     set_cu_language (DW_UNSND (attr), cu);
   else
-    set_cu_language (language_minimal, cu);
+    {
+      cu->language = language_minimal;
+      cu->language_defn = language_def (cu->language);
+    }
 }
 
 /* Release one cached compilation unit, CU.  We unlink it from the tree
 }
 
 /* Release one cached compilation unit, CU.  We unlink it from the tree
@@ -15011,13 +15405,16 @@ struct strtab_entry
   const char *str;
 };
 
   const char *str;
 };
 
-/* Hash function for a strtab_entry.  */
+/* Hash function for a strtab_entry.
+
+   Function is used only during write_hash_table so no index format backward
+   compatibility is needed.  */
 
 static hashval_t
 hash_strtab_entry (const void *e)
 {
   const struct strtab_entry *entry = e;
 
 static hashval_t
 hash_strtab_entry (const void *e)
 {
   const struct strtab_entry *entry = e;
-  return mapped_index_string_hash (entry->str);
+  return mapped_index_string_hash (INT_MAX, entry->str);
 }
 
 /* Equality function for a strtab_entry.  */
 }
 
 /* Equality function for a strtab_entry.  */
@@ -15155,12 +15552,15 @@ cleanup_mapped_symtab (void *p)
 }
 
 /* Find a slot in SYMTAB for the symbol NAME.  Returns a pointer to
 }
 
 /* Find a slot in SYMTAB for the symbol NAME.  Returns a pointer to
-   the slot.  */
+   the slot.
+   
+   Function is used only during write_hash_table so no index format backward
+   compatibility is needed.  */
 
 static struct symtab_index_entry **
 find_slot (struct mapped_symtab *symtab, const char *name)
 {
 
 static struct symtab_index_entry **
 find_slot (struct mapped_symtab *symtab, const char *name)
 {
-  offset_type index, step, hash = mapped_index_string_hash (name);
+  offset_type index, step, hash = mapped_index_string_hash (INT_MAX, name);
 
   index = hash & (symtab->size - 1);
   step = ((hash * 17) & (symtab->size - 1)) | 1;
 
   index = hash & (symtab->size - 1);
   step = ((hash * 17) & (symtab->size - 1)) | 1;
@@ -15221,7 +15621,7 @@ add_index_entry (struct mapped_symtab *symtab, const char *name,
   /* Don't push an index twice.  Due to how we add entries we only
      have to check the last one.  */ 
   if (VEC_empty (offset_type, (*slot)->cu_indices)
   /* Don't push an index twice.  Due to how we add entries we only
      have to check the last one.  */ 
   if (VEC_empty (offset_type, (*slot)->cu_indices)
-      || VEC_length (offset_type, (*slot)->cu_indices) != cu_index)
+      || VEC_last (offset_type, (*slot)->cu_indices) != cu_index)
     VEC_safe_push (offset_type, (*slot)->cu_indices, cu_index);
 }
 
     VEC_safe_push (offset_type, (*slot)->cu_indices, cu_index);
 }
 
@@ -15534,7 +15934,7 @@ write_one_signatured_type (void **slot, void *d)
                  psymtab->n_static_syms, info->cu_index,
                  1);
 
                  psymtab->n_static_syms, info->cu_index,
                  1);
 
-  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->offset);
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->per_cu.offset);
   obstack_grow (info->types_list, val, 8);
   store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
   obstack_grow (info->types_list, val, 8);
   obstack_grow (info->types_list, val, 8);
   store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
   obstack_grow (info->types_list, val, 8);
@@ -15573,8 +15973,9 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   htab_t cu_index_htab;
   struct psymtab_cu_index_map *psymtab_cu_index_map;
 
   htab_t cu_index_htab;
   struct psymtab_cu_index_map *psymtab_cu_index_map;
 
-  if (!objfile->psymtabs)
+  if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
     return;
     return;
+
   if (dwarf2_per_objfile->using_index)
     error (_("Cannot use an index to create the index"));
 
   if (dwarf2_per_objfile->using_index)
     error (_("Cannot use an index to create the index"));
 
@@ -15688,7 +16089,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   total_len = size_of_contents;
 
   /* The version number.  */
   total_len = size_of_contents;
 
   /* The version number.  */
-  val = MAYBE_SWAP (3);
+  val = MAYBE_SWAP (5);
   obstack_grow (&contents, &val, sizeof (val));
 
   /* The offset of the CU list from the start of the file.  */
   obstack_grow (&contents, &val, sizeof (val));
 
   /* The offset of the CU list from the start of the file.  */
@@ -15734,75 +16135,10 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   do_cleanups (cleanup);
 }
 
   do_cleanups (cleanup);
 }
 
-/* The mapped index file format is designed to be directly mmap()able
-   on any architecture.  In most cases, a datum is represented using a
-   little-endian 32-bit integer value, called an offset_type.  Big
-   endian machines must byte-swap the values before using them.
-   Exceptions to this rule are noted.  The data is laid out such that
-   alignment is always respected.
-
-   A mapped index consists of several sections.
-
-   1. The file header.  This is a sequence of values, of offset_type
-   unless otherwise noted:
-
-   [0] The version number, currently 3.  Versions 1 and 2 are
-   obsolete.
-   [1] The offset, from the start of the file, of the CU list.
-   [2] The offset, from the start of the file, of the types CU list.
-   Note that this section can be empty, in which case this offset will
-   be equal to the next offset.
-   [3] The offset, from the start of the file, of the address section.
-   [4] The offset, from the start of the file, of the symbol table.
-   [5] The offset, from the start of the file, of the constant pool.
-
-   2. The CU list.  This is a sequence of pairs of 64-bit
-   little-endian values, sorted by the CU offset.  The first element
-   in each pair is the offset of a CU in the .debug_info section.  The
-   second element in each pair is the length of that CU.  References
-   to a CU elsewhere in the map are done using a CU index, which is
-   just the 0-based index into this table.  Note that if there are
-   type CUs, then conceptually CUs and type CUs form a single list for
-   the purposes of CU indices.
-
-   3. The types CU list.  This is a sequence of triplets of 64-bit
-   little-endian values.  In a triplet, the first value is the CU
-   offset, the second value is the type offset in the CU, and the
-   third value is the type signature.  The types CU list is not
-   sorted.
-
-   4. The address section.  The address section consists of a sequence
-   of address entries.  Each address entry has three elements.
-   [0] The low address.  This is a 64-bit little-endian value.
-   [1] The high address.  This is a 64-bit little-endian value.
-       Like DW_AT_high_pc, the value is one byte beyond the end.
-   [2] The CU index.  This is an offset_type value.
-
-   5. The symbol table.  This is a hash table.  The size of the hash
-   table is always a power of 2.  The initial hash and the step are
-   currently defined by the `find_slot' function.
-
-   Each slot in the hash table consists of a pair of offset_type
-   values.  The first value is the offset of the symbol's name in the
-   constant pool.  The second value is the offset of the CU vector in
-   the constant pool.
-
-   If both values are 0, then this slot in the hash table is empty.
-   This is ok because while 0 is a valid constant pool index, it
-   cannot be a valid index for both a string and a CU vector.
-
-   A string in the constant pool is stored as a \0-terminated string,
-   as you'd expect.
-
-   A CU vector in the constant pool is a sequence of offset_type
-   values.  The first value is the number of CU indices in the vector.
-   Each subsequent value is the index of a CU in the CU list.  This
-   element in the hash table is used to indicate which CUs define the
-   symbol.
-
-   6. The constant pool.  This is simply a bunch of bytes.  It is
-   organized so that alignment is correct: CU vectors are stored
-   first, followed by strings.  */
+/* Implementation of the `save gdb-index' command.
+   
+   Note that the file format used by this command is documented in the
+   GDB manual.  Any changes here must be documented there.  */
 
 static void
 save_gdb_index_command (char *arg, int from_tty)
 
 static void
 save_gdb_index_command (char *arg, int from_tty)
This page took 0.055338 seconds and 4 git commands to generate.