OSDN Git Service

*** empty log message ***
[pf3gnuchains/sourceware.git] / gdb / dwarf2read.c
index 82a2f0b..5d498d5 100644 (file)
@@ -253,7 +253,7 @@ static struct dwarf2_per_objfile *dwarf2_per_objfile;
 
 /* local data types */
 
-/* We hold several abbreviation tables in memory at the same time. */
+/* We hold several abbreviation tables in memory at the same time.  */
 #ifndef ABBREV_HASH_SIZE
 #define ABBREV_HASH_SIZE 121
 #endif
@@ -464,11 +464,11 @@ struct signatured_type
   struct dwarf2_per_cu_data per_cu;
 };
 
-/* Struct used to pass misc. parameters to read_die_and_children, et. al.
-   which are used for both .debug_info and .debug_types dies.
-   All parameters here are unchanging for the life of the call.
-   This struct exists to abstract away the constant parameters of
-   die reading.  */
+/* Struct used to pass misc. parameters to read_die_and_children, et
+   al.  which are used for both .debug_info and .debug_types dies.
+   All parameters here are unchanging for the life of the call.  This
+   struct exists to abstract away the constant parameters of die
+   reading.  */
 
 struct die_reader_specs
 {
@@ -531,7 +531,7 @@ struct line_header
 };
 
 /* When we construct a partial symbol table entry we only
-   need this much information. */
+   need this much information.  */
 struct partial_die_info
   {
     /* Offset of this DIE.  */
@@ -596,7 +596,7 @@ struct partial_die_info
     struct partial_die_info *die_parent, *die_child, *die_sibling;
   };
 
-/* This data structure holds the information of an abbrev. */
+/* This data structure holds the information of an abbrev.  */
 struct abbrev_info
   {
     unsigned int number;       /* number identifying abbrev */
@@ -613,7 +613,7 @@ struct attr_abbrev
     ENUM_BITFIELD(dwarf_form) form : 16;
   };
 
-/* Attributes have a name and a value */
+/* Attributes have a name and a value */
 struct attribute
   {
     ENUM_BITFIELD(dwarf_attribute) name : 16;
@@ -636,7 +636,7 @@ struct attribute
     u;
   };
 
-/* This data structure holds a complete die structure. */
+/* This data structure holds a complete die structure.  */
 struct die_info
   {
     /* DWARF-2 tag for this DIE.  */
@@ -677,7 +677,7 @@ struct function_range
   struct function_range *next;
 };
 
-/* Get at parts of an attribute structure */
+/* Get at parts of an attribute structure */
 
 #define DW_STRING(attr)    ((attr)->u.str)
 #define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical)
@@ -687,7 +687,7 @@ struct function_range
 #define DW_ADDR(attr)     ((attr)->u.addr)
 #define DW_SIGNATURED_TYPE(attr) ((attr)->u.signatured_type)
 
-/* Blocks are a bunch of untyped bytes. */
+/* Blocks are a bunch of untyped bytes.  */
 struct dwarf_block
   {
     unsigned int size;
@@ -713,7 +713,7 @@ static int bits_per_byte = 8;
    in an instance of a field_info structure, as defined below.  */
 struct field_info
   {
-    /* List of data member and baseclasses fields. */
+    /* List of data member and baseclasses fields.  */
     struct nextfield
       {
        struct nextfield *next;
@@ -787,13 +787,13 @@ static void
 show_dwarf2_max_cache_age (struct ui_file *file, int from_tty,
                           struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-The upper bound on the age of cached dwarf2 compilation units is %s.\n"),
+  fprintf_filtered (file, _("The upper bound on the age of cached "
+                           "dwarf2 compilation units is %s.\n"),
                    value);
 }
 
 
-/* Various complaints about symbol reading that don't abort the process */
+/* Various complaints about symbol reading that don't abort the process */
 
 static void
 dwarf2_statement_list_fits_in_line_number_section_complaint (void)
@@ -813,7 +813,8 @@ static void
 dwarf2_debug_line_missing_end_sequence_complaint (void)
 {
   complaint (&symfile_complaints,
-            _(".debug_line section has line program sequence without an end"));
+            _(".debug_line section has line "
+              "program sequence without an end"));
 }
 
 static void
@@ -827,8 +828,8 @@ dwarf2_const_value_length_mismatch_complaint (const char *arg1, int arg2,
                                              int arg3)
 {
   complaint (&symfile_complaints,
-            _("const value length mismatch for '%s', got %d, expected %d"), arg1,
-            arg2, arg3);
+            _("const value length mismatch for '%s', got %d, expected %d"),
+            arg1, arg2, arg3);
 }
 
 static void
@@ -842,7 +843,8 @@ static void
 dwarf2_macro_malformed_definition_complaint (const char *arg1)
 {
   complaint (&symfile_complaints,
-            _("macro debug info contains a malformed macro definition:\n`%s'"),
+            _("macro debug info contains a "
+              "malformed macro definition:\n`%s'"),
             arg1);
 }
 
@@ -850,7 +852,8 @@ static void
 dwarf2_invalid_attrib_class_complaint (const char *arg1, const char *arg2)
 {
   complaint (&symfile_complaints,
-            _("invalid attribute class or form for '%s' in '%s'"), arg1, arg2);
+            _("invalid attribute class or form for '%s' in '%s'"),
+            arg1, arg2);
 }
 
 /* local function prototypes */
@@ -1014,7 +1017,8 @@ static struct type *die_type (struct die_info *, struct dwarf2_cu *);
 
 static int need_gnat_info (struct dwarf2_cu *);
 
-static struct type *die_descriptive_type (struct die_info *, struct dwarf2_cu *);
+static struct type *die_descriptive_type (struct die_info *,
+                                         struct dwarf2_cu *);
 
 static void set_descriptive_type (struct type *, struct die_info *,
                                  struct dwarf2_cu *);
@@ -1068,7 +1072,8 @@ static void dwarf2_add_member_fn (struct field_info *,
                                  struct dwarf2_cu *);
 
 static void dwarf2_attach_fn_fields_to_type (struct field_info *,
-                                            struct type *, struct dwarf2_cu *);
+                                            struct type *,
+                                            struct dwarf2_cu *);
 
 static void process_structure_scope (struct die_info *, struct dwarf2_cu *);
 
@@ -1448,7 +1453,8 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
   int header_size = 12;
 
   if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
-      || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size)
+      || bfd_bread (compressed_buffer,
+                   compressed_size, abfd) != compressed_size)
     error (_("Dwarf Error: Can't read DWARF data from '%s'"),
            bfd_get_filename (abfd));
 
@@ -1503,6 +1509,14 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
 #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.  */
@@ -1521,7 +1535,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
   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.  */
@@ -1586,8 +1600,24 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
           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. */
+   SECTION_NAME.  */
 
 void
 dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
@@ -1614,9 +1644,7 @@ dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
   else
     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;
@@ -2002,8 +2030,7 @@ dwarf2_read_index (struct objfile *objfile)
   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
@@ -2018,13 +2045,14 @@ 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
-     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 4
+     contained incomplete addrmap.  So, it seems better to just ignore such
+     indices.  */
+  if (version < 4)
     return 0;
   /* Indexes with higher version than the one supported by GDB may be no
      longer backward compatible.  */
-  if (version > 3)
+  if (version > 4)
     return 0;
 
   map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
@@ -2144,8 +2172,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);
-  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;
@@ -2739,7 +2767,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
   if (dwarf2_read_index (objfile))
     return 1;
 
-  dwarf2_build_psymtabs (objfile);
   return 0;
 }
 
@@ -2816,7 +2843,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));
 
-  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,
@@ -2992,7 +3021,8 @@ create_debug_types_hash_table (struct objfile *objfile)
   if (dwarf2_die_debug)
     fprintf_unfiltered (gdb_stdlog, "Signatured types:\n");
 
-  while (info_ptr < dwarf2_per_objfile->types.buffer + dwarf2_per_objfile->types.size)
+  while (info_ptr < dwarf2_per_objfile->types.buffer
+        + dwarf2_per_objfile->types.size)
     {
       unsigned int offset;
       unsigned int offset_size;
@@ -3015,7 +3045,8 @@ create_debug_types_hash_table (struct objfile *objfile)
          > dwarf2_per_objfile->types.buffer + dwarf2_per_objfile->types.size)
        {
          complaint (&symfile_complaints,
-                    _("debug type entry runs off end of `.debug_types' section, ignored"));
+                    _("debug type entry runs off end "
+                      "of `.debug_types' section, ignored"));
          break;
        }
 
@@ -3159,6 +3190,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;
+  const char *filename;
 
   init_one_comp_unit (&cu, objfile);
   back_to_inner = make_cleanup (free_stack_comp_unit, &cu);
@@ -3218,8 +3250,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);
+  if (attr == NULL || !DW_STRING (attr))
+    filename = "";
+  else
+    filename = DW_STRING (attr);
   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,
@@ -3233,7 +3269,7 @@ process_psymtab_comp_unit (struct objfile *objfile,
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  /* Store the function that reads in the rest of the symbol table */
+  /* Store the function that reads in the rest of the symbol table */
   pst->read_symtab = dwarf2_psymtab_to_symtab;
 
   this_cu->v.psymtab = pst;
@@ -3253,7 +3289,7 @@ process_psymtab_comp_unit (struct objfile *objfile,
 
   /* Check if comp unit has_children.
      If so, read the rest of the partial symbols from this comp unit.
-     If not, there's no more debug_info for this comp unit. */
+     If not, there's no more debug_info for this comp unit.  */
   if (has_children)
     {
       struct partial_die_info *first_die;
@@ -3402,7 +3438,8 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
     {
       struct dwarf2_per_cu_data *this_cu;
 
-      this_cu = dwarf2_find_comp_unit (info_ptr - dwarf2_per_objfile->info.buffer,
+      this_cu = dwarf2_find_comp_unit (info_ptr
+                                      - dwarf2_per_objfile->info.buffer,
                                       objfile);
 
       info_ptr = process_psymtab_comp_unit (objfile, this_cu,
@@ -3486,7 +3523,7 @@ load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu,
 
   /* Check if comp unit has_children.
      If so, read the rest of the partial symbols from this comp unit.
-     If not, there's no more debug_info for this comp unit. */
+     If not, there's no more debug_info for this comp unit.  */
   if (has_children)
     load_partial_dies (abfd, dwarf2_per_objfile->info.buffer, info_ptr, 0, cu);
 
@@ -3521,7 +3558,8 @@ create_all_comp_units (struct objfile *objfile)
   all_comp_units = xmalloc (n_allocated
                            * sizeof (struct dwarf2_per_cu_data *));
 
-  while (info_ptr < dwarf2_per_objfile->info.buffer + dwarf2_per_objfile->info.size)
+  while (info_ptr < dwarf2_per_objfile->info.buffer
+        + dwarf2_per_objfile->info.size)
     {
       unsigned int length, initial_length_size;
       struct dwarf2_per_cu_data *this_cu;
@@ -3715,7 +3753,8 @@ partial_die_parent_scope (struct partial_die_info *pdi,
       if (grandparent_scope == NULL)
        parent->scope = parent->name;
       else
-       parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
+       parent->scope = typename_concat (&cu->comp_unit_obstack,
+                                        grandparent_scope,
                                         parent->name, 0, cu);
     }
   else if (parent->tag == DW_TAG_enumerator)
@@ -3802,25 +3841,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.  */
-         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             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
        {
-         /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
             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:
@@ -3831,10 +3870,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
          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:
@@ -3866,30 +3904,30 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
             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
        {
-         /* Static Variable. Skip symbols without location descriptors.  */
+         /* Static Variable.  Skip symbols without location descriptors.  */
          if (pdi->locdesc == NULL)
            {
              if (built_actual_name)
                xfree (actual_name);
              return;
            }
-         /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
+         /* prim_record_minimal_symbol (actual_name, addr + baseaddr,
             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:
@@ -4090,8 +4128,8 @@ peek_die_abbrev (gdb_byte *info_ptr, unsigned int *bytes_read,
   abbrev = dwarf2_lookup_abbrev (abbrev_number, cu);
   if (!abbrev)
     {
-      error (_("Dwarf Error: Could not find abbrev number %d [in module %s]"), abbrev_number,
-                     bfd_get_filename (abfd));
+      error (_("Dwarf Error: Could not find abbrev number %d [in module %s]"),
+            abbrev_number, bfd_get_filename (abfd));
     }
 
   return abbrev;
@@ -4140,7 +4178,8 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
          read_attribute (&attr, &abbrev->attrs[i],
                          abfd, info_ptr, cu);
          if (attr.form == DW_FORM_ref_addr)
-           complaint (&symfile_complaints, _("ignoring absolute DW_AT_sibling"));
+           complaint (&symfile_complaints,
+                      _("ignoring absolute DW_AT_sibling"));
          else
            return buffer + dwarf2_get_ref_die_offset (&attr);
        }
@@ -4216,7 +4255,8 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
          goto skip_attribute;
 
        default:
-         error (_("Dwarf Error: Cannot handle %s in DWARF reader [in module %s]"),
+         error (_("Dwarf Error: Cannot handle %s "
+                  "in DWARF reader [in module %s]"),
                 dwarf_form_name (form),
                 bfd_get_filename (abfd));
        }
@@ -4261,13 +4301,15 @@ dwarf2_psymtab_to_symtab (struct partial_symtab *pst)
     {
       if (pst->readin)
        {
-         warning (_("bug: psymtab for %s is already read in."), pst->filename);
+         warning (_("bug: psymtab for %s is already read in."),
+                  pst->filename);
        }
       else
        {
          if (info_verbose)
            {
-             printf_filtered (_("Reading in symbols for %s..."), pst->filename);
+             printf_filtered (_("Reading in symbols for %s..."),
+                              pst->filename);
              gdb_flush (gdb_stdout);
            }
 
@@ -4394,7 +4436,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
             fputs_filtered ("and ", gdb_stdout);
             wrap_here ("");
             printf_filtered ("%s...", pst->dependencies[i]->filename);
-            wrap_here ("");     /* Flush output */
+            wrap_here ("");     /* Flush output */
             gdb_flush (gdb_stdout);
           }
         psymtab_to_symtab_1 (pst->dependencies[i]);
@@ -4416,7 +4458,8 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
 /* Load the DIEs associated with PER_CU into memory.  */
 
 static void
-load_full_comp_unit (struct dwarf2_per_cu_data *per_cu, struct objfile *objfile)
+load_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
+                    struct objfile *objfile)
 {
   bfd *abfd = objfile->obfd;
   struct dwarf2_cu *cu;
@@ -4810,7 +4853,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
              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
@@ -4881,7 +4924,8 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
                  if (attr == NULL)
                    {
                      complaint (&symfile_complaints,
-                                _("template parameter missing DW_AT_const_value"));
+                                _("template parameter missing "
+                                  "DW_AT_const_value"));
                      fputs_unfiltered ("UNKNOWN_VALUE", buf);
                      continue;
                    }
@@ -4912,7 +4956,8 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
                      else
                        v = value_from_longest (type, value);
 
-                     /* Specify decimal so that we do not depend on the radix.  */
+                     /* Specify decimal so that we do not depend on
+                        the radix.  */
                      get_formatted_print_options (&opts, 'd');
                      opts.raw = 1;
                      value_print (v, buf, &opts);
@@ -4950,7 +4995,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
              if (cu->language == language_java)
                {
                  /* For java, we must append the return type to method
-                    names. */
+                    names.  */
                  if (die->tag == DW_TAG_subprogram)
                    java_print_type (TYPE_TARGET_TYPE (type), "", buf,
                                     0, 0);
@@ -4965,7 +5010,8 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
                  if (TYPE_NFIELDS (type) > 0
                      && TYPE_FIELD_ARTIFICIAL (type, 0)
                      && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_PTR
-                     && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0))))
+                     && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type,
+                                                                       0))))
                    fputs_unfiltered (" const", buf);
                }
            }
@@ -4995,7 +5041,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
    not have a name.  NAME may either be from a previous call to
    dwarf2_name or NULL.
 
-   The output string will be canonicalized (if C++/Java). */
+   The output string will be canonicalized (if C++/Java).  */
 
 static const char *
 dwarf2_full_name (char *name, struct die_info *die, struct dwarf2_cu *cu)
@@ -5219,7 +5265,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
     cu->language = language_opencl;
 
-  /* We assume that we're processing GCC output. */
+  /* We assume that we're processing GCC output.  */
   processing_gcc_compilation = 2;
 
   processing_has_namespace_info = 0;
@@ -5322,7 +5368,7 @@ read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu)
   if (attr)
     cu->producer = DW_STRING (attr);
 
-  /* We assume that we're processing GCC output. */
+  /* We assume that we're processing GCC output.  */
   processing_gcc_compilation = 2;
 
   processing_has_namespace_info = 0;
@@ -5385,8 +5431,9 @@ unsigned_int_compar (const void *ap, const void *bp)
 }
 
 /* DW_AT_abstract_origin inherits whole DIEs (not just their attributes).
-   Inherit only the children of the DW_AT_abstract_origin DIE not being already
-   referenced by DW_AT_abstract_origin from the children of the current DIE.  */
+   Inherit only the children of the DW_AT_abstract_origin DIE not being
+   already referenced by DW_AT_abstract_origin from the children of the
+   current DIE.  */
 
 static void
 inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
@@ -5484,8 +5531,9 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
         unsigned_int_compar);
   for (offsetp = offsets + 1; offsetp < offsets_end; offsetp++)
     if (offsetp[-1] == *offsetp)
-      complaint (&symfile_complaints, _("Multiple children of DIE 0x%x refer "
-                                       "to DIE 0x%x as their abstract origin"),
+      complaint (&symfile_complaints,
+                _("Multiple children of DIE 0x%x refer "
+                  "to DIE 0x%x as their abstract origin"),
                 die->offset, *offsetp);
 
   offsetp = offsets;
@@ -5556,7 +5604,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
       attr = dwarf2_attr (die, DW_AT_external, cu);
       if (!attr || !DW_UNSND (attr))
        complaint (&symfile_complaints,
-                  _("cannot get low and high bounds for subprogram DIE at %d"),
+                  _("cannot get low and high bounds "
+                    "for subprogram DIE at %d"),
                   die->offset);
       return;
     }
@@ -5840,12 +5889,25 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
          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;
 
-      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,
+                          range_beginning + baseaddr,
+                          range_end - 1 + baseaddr,
                           ranges_pst);
 
       /* FIXME: This is recording everything as a low-high
@@ -5920,7 +5982,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
@@ -6023,7 +6086,7 @@ get_scope_pc_bounds (struct die_info *die,
              }
            break;
          default:
-           /* Ignore. */
+           /* Ignore.  */
            break;
          }
 
@@ -6120,10 +6183,24 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
               if (!base_known)
                 {
                   complaint (&symfile_complaints,
-                             _("Invalid .debug_ranges data (no base address)"));
+                            _("Invalid .debug_ranges data "
+                              "(no base address)"));
                   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);
@@ -6352,7 +6429,6 @@ dwarf2_add_typedef (struct field_info *fip, struct die_info *die,
                    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;
@@ -6424,9 +6500,9 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
       TYPE_N_BASECLASSES (type) = fip->nbaseclasses;
     }
 
-  /* Copy the saved-up fields into the field vector.  Start from the head
-     of the list, adding to the tail of the field array, so that they end
-     up in the same order in the array in which they were added to the list.  */
+  /* Copy the saved-up fields into the field vector.  Start from the head of
+     the list, adding to the tail of the field array, so that they end up in
+     the same order in the array in which they were added to the list.  */
   while (nfields-- > 0)
     {
       struct nextfield *fieldp;
@@ -6473,7 +6549,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
            case DW_VIRTUALITY_virtual:
            case DW_VIRTUALITY_pure_virtual:
              if (cu->language == language_ada)
-               error ("unexpected virtuality in component of Ada type");
+               error (_("unexpected virtuality in component of Ada type"));
              SET_TYPE_FIELD_VIRTUAL (type, nfields);
              break;
            }
@@ -6497,7 +6573,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
   struct type *this_type;
 
   if (cu->language == language_ada)
-    error ("unexpected member function in Ada type");
+    error (_("unexpected member function in Ada type"));
 
   /* Get name of member function.  */
   fieldname = dwarf2_name (die, cu);
@@ -6533,7 +6609,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
     }
 
   /* Create a new member function field and chain it to the field list
-     entry. */
+     entry.  */
   new_fnfield = (struct nextfnfield *) xmalloc (sizeof (struct nextfnfield));
   make_cleanup (xfree, new_fnfield);
   memset (new_fnfield, 0, sizeof (struct nextfnfield));
@@ -6572,10 +6648,10 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
 
       /* Handle static member functions.
          Dwarf2 has no clean way to discern C++ static and non-static
-         member functions. G++ helps GDB by marking the first
-         parameter for non-static member functions (which is the
-         this pointer) as artificial. We obtain this information
-         from read_subroutine_type via TYPE_FIELD_ARTIFICIAL.  */
+         member functions.  G++ helps GDB by marking the first
+         parameter for non-static member functions (which is the this
+         pointer) as artificial.  We obtain this information from
+         read_subroutine_type via TYPE_FIELD_ARTIFICIAL.  */
       if (nparams == 0 || TYPE_FIELD_ARTIFICIAL (this_type, 0) == 0)
        fnp->voffset = VOFFSET_STATIC;
     }
@@ -6587,8 +6663,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
   if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL)
     fnp->fcontext = die_containing_type (die, cu);
 
-  /* dwarf2 doesn't have stubbed physical names, so the setting of is_const
-     and is_volatile is irrelevant, as it is needed by gdb_mangle_name only.  */
+  /* dwarf2 doesn't have stubbed physical names, so the setting of is_const and
+     is_volatile is irrelevant, as it is needed by gdb_mangle_name only.  */
 
   /* Get accessibility.  */
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);
@@ -6668,7 +6744,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
        {
          /* GCC does this, as of 2008-08-25; PR debug/37237.  */
          complaint (&symfile_complaints,
-                    _("Member function \"%s\" (offset %d) is virtual but the vtable offset is not specified"),
+                    _("Member function \"%s\" (offset %d) is virtual "
+                      "but the vtable offset is not specified"),
                     fieldname, die->offset);
          ALLOCATE_CPLUS_STRUCT_TYPE (type);
          TYPE_CPLUS_DYNAMIC (type) = 1;
@@ -6687,7 +6764,7 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
   int i;
 
   if (cu->language == language_ada)
-    error ("unexpected member functions in Ada type");
+    error (_("unexpected member functions in Ada type"));
 
   ALLOCATE_CPLUS_STRUCT_TYPE (type);
   TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
@@ -6889,7 +6966,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
 
   /* We need to add the type field to the die immediately so we don't
      infinitely recurse when dealing with pointers to the structure
-     type within the structure itself. */
+     type within the structure itself.  */
   set_die_type (die, type, cu);
 
   /* set_die_type should be already done.  */
@@ -6937,7 +7014,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
            }
          else if (child_die->tag == DW_TAG_subprogram)
            {
-             /* C++ member function. */
+             /* C++ member function.  */
              dwarf2_add_member_fn (&fi, child_die, type, cu);
            }
          else if (child_die->tag == DW_TAG_inheritance)
@@ -7014,7 +7091,8 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
                  /* Complain if virtual function table field not found.  */
                  if (i < TYPE_N_BASECLASSES (t))
                    complaint (&symfile_complaints,
-                              _("virtual function table pointer not found when defining class '%s'"),
+                              _("virtual function table pointer "
+                                "not found when defining class '%s'"),
                               TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) :
                               "");
                }
@@ -7281,8 +7359,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
 
           if (child_type != NULL)
             {
-             /* The range type was succesfully read. Save it for
-                 the array type creation.  */
+             /* The range type was succesfully read.  Save it for the
+                 array type creation.  */
               if ((ndim % DW_FIELD_ALLOC_CHUNK) == 0)
                 {
                   range_types = (struct type **)
@@ -7334,15 +7412,16 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
       if (DW_UNSND (attr) >= TYPE_LENGTH (type))
        TYPE_LENGTH (type) = DW_UNSND (attr);
       else
-       complaint (&symfile_complaints, _("\
-DW_AT_byte_size for array type smaller than the total size of elements"));
+       complaint (&symfile_complaints,
+                  _("DW_AT_byte_size for array type smaller "
+                    "than the total size of elements"));
     }
 
   name = dwarf2_name (die, cu);
   if (name)
     TYPE_NAME (type) = name;
 
-  /* Install the type in the die. */
+  /* Install the type in the die.  */
   set_die_type (die, type, cu);
 
   /* set_die_type should be already done.  */
@@ -7362,14 +7441,12 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
 
   if (attr) return DW_SND (attr);
 
-  /*
-    GNU F77 is a special case, as at 08/2004 array type info is the
-    opposite order to the dwarf2 specification, but data is still
-    laid out as per normal fortran.
+  /* GNU F77 is a special case, as at 08/2004 array type info is the
+     opposite order to the dwarf2 specification, but data is still
+     laid out as per normal fortran.
 
-    FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
-    version checking.
-  */
+     FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
+     version checking.  */
 
   if (cu->language == language_fortran
       && cu->producer && strstr (cu->producer, "GNU F77"))
@@ -7388,7 +7465,7 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
 }
 
 /* Extract all information from a DW_TAG_set_type DIE and put it in
-   the DIE's type field. */
+   the DIE's type field.  */
 
 static struct type *
 read_set_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -7425,7 +7502,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
   attr = dwarf2_attr (die, DW_AT_location, cu);
   if (attr)
     {
-      /* Support the .debug_loc offsets */
+      /* Support the .debug_loc offsets */
       if (attr_form_is_block (attr))
         {
           base = decode_locdesc (DW_BLOCK (attr), cu);
@@ -7516,7 +7593,6 @@ static void
 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
@@ -7530,7 +7606,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *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);
@@ -7565,7 +7641,8 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
 
   module_name = dwarf2_name (die, cu);
   if (!module_name)
-    complaint (&symfile_complaints, _("DW_TAG_module has no name, offset 0x%x"),
+    complaint (&symfile_complaints,
+              _("DW_TAG_module has no name, offset 0x%x"),
                die->offset);
   type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile);
 
@@ -7671,7 +7748,8 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
        }
       else if (TYPE_LENGTH (type) != byte_size)
        {
-         complaint (&symfile_complaints, _("invalid pointer size %d"), byte_size);
+         complaint (&symfile_complaints,
+                    _("invalid pointer size %d"), byte_size);
        }
       else
        {
@@ -7815,7 +7893,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
     }
   else
     {
-      /* check for the DW_AT_byte_size attribute */
+      /* Check for the DW_AT_byte_size attribute.  */
       attr = dwarf2_attr (die, DW_AT_byte_size, cu);
       if (attr)
         {
@@ -7843,14 +7921,13 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
    int b;
    };
 
-   ('funcp' generates a DW_TAG_subroutine_type DIE)
- */
+   ('funcp' generates a DW_TAG_subroutine_type DIE).  */
 
 static struct type *
 read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct type *type;           /* Type that this function returns */
-  struct type *ftype;          /* Function that returns above type */
+  struct type *type;           /* Type that this function returns */
+  struct type *ftype;          /* Function that returns above type */
   struct attribute *attr;
 
   type = die_type (die, cu);
@@ -7880,11 +7957,16 @@ 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);
-  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
-     declared as the same subroutine type. */
+     declared as the same subroutine type.  */
   set_die_type (die, ftype, cu);
 
   if (die->child != NULL)
@@ -8106,7 +8188,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)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
   struct type *base_type;
   struct type *range_type;
   struct attribute *attr;
@@ -8166,6 +8247,11 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
          int count = dwarf2_get_attr_constant_value (attr, 1);
          high = low + count - 1;
        }
+      else
+       {
+         /* Unspecified array length.  */
+         high = low - 1;
+       }
     }
 
   /* Dwarf-2 specifications explicitly allows to create subrange types
@@ -8179,8 +8265,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
      For the following C code: `extern char gdb_int [];'
      GCC produces an empty range DIE.
      FIXME: muller/2010-05-28: Possible references to object for low bound,
-     high bound or count are not yet handled by this code.
-  */
+     high bound or count are not yet handled by this code.  */
   if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
     {
       struct objfile *objfile = cu->objfile;
@@ -8222,6 +8307,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   if (attr && attr->form == DW_FORM_block1)
     TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
 
+  /* Ada expects an empty array on no boundary attributes.  */
+  if (attr == NULL && cu->language != language_ada)
+    TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+
   name = dwarf2_name (die, cu);
   if (name)
     TYPE_NAME (range_type) = name;
@@ -8477,7 +8566,7 @@ dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
   struct attr_abbrev *cur_attrs;
   unsigned int allocated_attrs;
 
-  /* Initialize dwarf2 abbrevs */
+  /* Initialize dwarf2 abbrevs */
   obstack_init (&cu->abbrev_obstack);
   cu->dwarf2_abbrevs = obstack_alloc (&cu->abbrev_obstack,
                                      (ABBREV_HASH_SIZE
@@ -8494,7 +8583,7 @@ dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu)
   allocated_attrs = ATTR_ALLOC_CHUNK;
   cur_attrs = xmalloc (allocated_attrs * sizeof (struct attr_abbrev));
 
-  /* loop until we reach an abbrev number of 0 */
+  /* Loop until we reach an abbrev number of 0.  */
   while (abbrev_number)
     {
       cur_abbrev = dwarf_alloc_abbrev (cu);
@@ -8785,7 +8874,8 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
          && parent_die->has_specification == 0)
        {
          if (part_die->name == NULL)
-           complaint (&symfile_complaints, _("malformed enumerator DIE ignored"));
+           complaint (&symfile_complaints,
+                      _("malformed enumerator DIE ignored"));
          else if (building_psymtab)
            add_psymbol_to_list (part_die->name, strlen (part_die->name), 0,
                                 VAR_DOMAIN, LOC_CONST,
@@ -8966,7 +9056,7 @@ read_partial_die (struct partial_die_info *part_die,
          part_die->highpc = DW_ADDR (&attr);
          break;
        case DW_AT_location:
-          /* Support the .debug_loc offsets */
+          /* Support the .debug_loc offsets */
           if (attr_form_is_block (&attr))
             {
               part_die->locdesc = DW_BLOCK (&attr);
@@ -9000,7 +9090,8 @@ read_partial_die (struct partial_die_info *part_die,
          /* Ignore absolute siblings, they might point outside of
             the current compile unit.  */
          if (attr.form == DW_FORM_ref_addr)
-           complaint (&symfile_complaints, _("ignoring absolute DW_AT_sibling"));
+           complaint (&symfile_complaints,
+                      _("ignoring absolute DW_AT_sibling"));
          else
            part_die->sibling = buffer + dwarf2_get_ref_die_offset (&attr);
          break;
@@ -9037,19 +9128,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;
 }
@@ -9140,7 +9253,8 @@ find_partial_die (unsigned int offset, struct dwarf2_cu *cu)
 
   if (pd == NULL)
     internal_error (__FILE__, __LINE__,
-                   _("could not find partial DIE 0x%x in cache [from module %s]\n"),
+                   _("could not find partial DIE 0x%x "
+                     "in cache [from module %s]\n"),
                    offset, bfd_get_filename (cu->objfile->obfd));
   return pd;
 }
@@ -9270,7 +9384,8 @@ read_attribute_value (struct attribute *attr, unsigned form,
       if (cu->header.version == 2)
        DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
       else
-       DW_ADDR (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+       DW_ADDR (attr) = read_offset (abfd, info_ptr,
+                                     &cu->header, &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_addr:
@@ -9426,7 +9541,7 @@ read_attribute (struct attribute *attr, struct attr_abbrev *abbrev,
   return read_attribute_value (attr, abbrev->form, abfd, info_ptr, cu);
 }
 
-/* read dwarf information from a buffer */
+/* Read dwarf information from a buffer.  */
 
 static unsigned int
 read_1_byte (bfd *abfd, gdb_byte *buf)
@@ -9511,7 +9626,8 @@ read_address (bfd *abfd, gdb_byte *buf, struct dwarf2_cu *cu,
          break;
        default:
          internal_error (__FILE__, __LINE__,
-                         _("read_address: bad switch, unsigned [in module %s]"),
+                         _("read_address: bad switch, "
+                           "unsigned [in module %s]"),
                          bfd_get_filename (abfd));
        }
     }
@@ -9689,8 +9805,9 @@ read_indirect_string (bfd *abfd, gdb_byte *buf,
     }
   if (str_offset >= dwarf2_per_objfile->str.size)
     {
-      error (_("DW_FORM_strp pointing outside of .debug_str section [in module %s]"),
-                     bfd_get_filename (abfd));
+      error (_("DW_FORM_strp pointing outside of "
+              ".debug_str section [in module %s]"),
+            bfd_get_filename (abfd));
       return NULL;
     }
   gdb_assert (HOST_CHAR_BIT == 8);
@@ -10064,7 +10181,8 @@ dwarf_decode_line_header (unsigned int offset, bfd *abfd,
     {
       lh->maximum_ops_per_instruction = 1;
       complaint (&symfile_complaints,
-                _("invalid maximum_ops_per_instruction in `.debug_line' section"));
+                _("invalid maximum_ops_per_instruction "
+                  "in `.debug_line' section"));
     }
 
   lh->default_is_stmt = read_1_byte (abfd, line_ptr);
@@ -10114,7 +10232,8 @@ dwarf_decode_line_header (unsigned int offset, bfd *abfd,
   if (line_ptr > (dwarf2_per_objfile->line.buffer
                  + dwarf2_per_objfile->line.size))
     complaint (&symfile_complaints,
-              _("line number info header doesn't fit in `.debug_line' section"));
+              _("line number info header doesn't "
+                "fit in `.debug_line' section"));
 
   discard_cleanups (back_to);
   return lh;
@@ -10363,7 +10482,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
          else switch (op_code)
            {
            case DW_LNS_extended_op:
-             extended_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+             extended_len = read_unsigned_leb128 (abfd, line_ptr,
+                                                  &bytes_read);
              line_ptr += bytes_read;
              extended_end = line_ptr + extended_len;
              extended_op = read_1_byte (abfd, line_ptr);
@@ -10384,7 +10504,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
                     char *cur_file;
                     unsigned int dir_index, mod_time, length;
 
-                    cur_file = read_direct_string (abfd, line_ptr, &bytes_read);
+                    cur_file = read_direct_string (abfd, line_ptr,
+                                                  &bytes_read);
                     line_ptr += bytes_read;
                     dir_index =
                       read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
@@ -10496,7 +10617,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
-              scaled the the increment.  */
+              scaled the increment.  */
            case DW_LNS_const_add_pc:
              {
                CORE_ADDR adjust = (255 - lh->opcode_base) / lh->line_range;
@@ -10611,7 +10732,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
    subfile's name.  */
 
 static void
-dwarf2_start_subfile (char *filename, const char *dirname, const char *comp_dir)
+dwarf2_start_subfile (char *filename, const char *dirname,
+                     const char *comp_dir)
 {
   char *fullname;
 
@@ -10825,9 +10947,9 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
        case DW_TAG_constant:
        case DW_TAG_variable:
        case DW_TAG_member:
-         /* Compilation with minimal debug info may result in variables
-            with missing type entries. Change the misleading `void' type
-            to something sensible.  */
+         /* Compilation with minimal debug info may result in
+            variables with missing type entries.  Change the
+            misleading `void' type to something sensible.  */
          if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
            SYMBOL_TYPE (sym)
              = objfile_type (objfile)->nodebug_data_symbol;
@@ -11036,7 +11158,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
          /* Not a tag we recognize.  Hopefully we aren't processing
             trash data, but since we must specifically ignore things
             we don't recognize, there is nothing else we should do at
-            this point. */
+            this point.  */
          complaint (&symfile_complaints, _("unsupported tag: '%s'"),
                     dwarf_tag_name (die->tag));
          break;
@@ -11179,16 +11301,20 @@ dwarf2_const_value_attr (struct attribute *attr, struct type *type,
         converted to host endianness, so we just need to sign- or
         zero-extend it as appropriate.  */
     case DW_FORM_data1:
-      *bytes = dwarf2_const_value_data (attr, type, name, obstack, cu, value, 8);
+      *bytes = dwarf2_const_value_data (attr, type, name,
+                                       obstack, cu, value, 8);
       break;
     case DW_FORM_data2:
-      *bytes = dwarf2_const_value_data (attr, type, name, obstack, cu, value, 16);
+      *bytes = dwarf2_const_value_data (attr, type, name,
+                                       obstack, cu, value, 16);
       break;
     case DW_FORM_data4:
-      *bytes = dwarf2_const_value_data (attr, type, name, obstack, cu, value, 32);
+      *bytes = dwarf2_const_value_data (attr, type, name,
+                                       obstack, cu, value, 32);
       break;
     case DW_FORM_data8:
-      *bytes = dwarf2_const_value_data (attr, type, name, obstack, cu, value, 64);
+      *bytes = dwarf2_const_value_data (attr, type, name,
+                                       obstack, cu, value, 64);
       break;
 
     case DW_FORM_sdata:
@@ -11489,7 +11615,8 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu)
       this_type = read_module_type (die, cu);
       break;
     default:
-      complaint (&symfile_complaints, _("unexpected tag in read_type_die: '%s'"),
+      complaint (&symfile_complaints,
+                _("unexpected tag in read_type_die: '%s'"),
                 dwarf_tag_name (die->tag));
       break;
     }
@@ -11552,7 +11679,8 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
 
                      /* Test for '::' as a sanity check.  */
                      if (actual_name_len > die_name_len + 2
-                         && actual_name[actual_name_len - die_name_len - 1] == ':')
+                         && actual_name[actual_name_len
+                                        - die_name_len - 1] == ':')
                        name =
                          obsavestring (actual_name,
                                        actual_name_len - die_name_len - 2,
@@ -11713,11 +11841,11 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
       }
 }
 
-/* Return a newly-allocated string formed by concatenating PREFIX and
-   SUFFIX with appropriate separator.  If PREFIX or SUFFIX is NULL or empty, then
-   simply copy the SUFFIX or PREFIX, respectively.  If OBS is non-null,
-   perform an obconcat, otherwise allocate storage for the result.  The CU argument
-   is used to determine the language and hence, the appropriate separator.  */
+/* Return a newly-allocated string formed by concatenating PREFIX and SUFFIX
+   with appropriate separator.  If PREFIX or SUFFIX is NULL or empty, then
+   simply copy the SUFFIX or PREFIX, respectively.  If OBS is non-null, perform
+   an obconcat, otherwise allocate storage for the result.  The CU argument is
+   used to determine the language and hence, the appropriate separator.  */
 
 #define MAX_SEP_LEN 7  /* strlen ("__") + strlen ("_MOD_")  */
 
@@ -11728,7 +11856,8 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
   const char *lead = "";
   const char *sep;
 
-  if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0')
+  if (suffix == NULL || suffix[0] == '\0'
+      || prefix == NULL || prefix[0] == '\0')
     sep = "";
   else if (cu->language == language_java)
     sep = ".";
@@ -11750,7 +11879,8 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
 
   if (obs == NULL)
     {
-      char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
+      char *retval
+       = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
 
       strcpy (retval, lead);
       strcat (retval, prefix);
@@ -12390,7 +12520,7 @@ dwarf_form_name (unsigned form)
 /* 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)
     {
@@ -12712,7 +12842,7 @@ dwarf_stack_op_name (unsigned op, int def)
     case DW_OP_GNU_implicit_pointer:
       return "DW_OP_GNU_implicit_pointer";
     default:
-      return def ? "OP_<unknown>" : NULL;
+      return NULL;
     }
 }
 
@@ -12788,7 +12918,7 @@ dwarf_type_encoding_name (unsigned enc)
     }
 }
 
-/* Convert a DWARF call frame info operation to its string name. */
+/* Convert a DWARF call frame info operation to its string name.  */
 
 #if 0
 static char *
@@ -12906,7 +13036,8 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
        case DW_FORM_block4:
        case DW_FORM_block:
        case DW_FORM_block1:
-         fprintf_unfiltered (f, "block: size %d", DW_BLOCK (&die->attrs[i])->size);
+         fprintf_unfiltered (f, "block: size %d",
+                             DW_BLOCK (&die->attrs[i])->size);
          break;
        case DW_FORM_exprloc:
          fprintf_unfiltered (f, "expression: size %u",
@@ -12955,9 +13086,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
          fprintf_unfiltered (f, "flag: TRUE");
          break;
        case DW_FORM_indirect:
-         /* the reader will have reduced the indirect form to
-            the "base form" so this form should not occur */
-         fprintf_unfiltered (f, "unexpected attribute form: DW_FORM_indirect");
+         /* The reader will have reduced the indirect form to
+            the "base form" so this form should not occur.  */
+         fprintf_unfiltered (f, 
+                             "unexpected attribute form: DW_FORM_indirect");
          break;
        default:
          fprintf_unfiltered (f, "unsupported attribute form: %d.",
@@ -12997,7 +13129,8 @@ dump_die_1 (struct ui_file *f, int level, int max_level, struct die_info *die)
        }
       else
        {
-         fprintf_unfiltered (f, " [not printed, max nesting level reached]\n");
+         fprintf_unfiltered (f,
+                             " [not printed, max nesting level reached]\n");
        }
     }
 
@@ -13071,7 +13204,8 @@ dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
     return DW_UNSND (attr);
   else
     {
-      complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"),
+      complaint (&symfile_complaints,
+                _("Attribute value is not a constant (%s)"),
                  dwarf_form_name (attr->form));
       return default_value;
     }
@@ -13302,8 +13436,8 @@ follow_die_sig (struct die_info *src_die, struct attribute *attr,
       return die;
     }
 
-  error (_("Dwarf Error: Cannot find signatured DIE at 0x%x referenced from DIE "
-        "at 0x%x [in module %s]"),
+  error (_("Dwarf Error: Cannot find signatured DIE at 0x%x referenced "
+        "from DIE at 0x%x [in module %s]"),
         sig_type->type_offset, src_die->offset, objfile->name);
 }
 
@@ -13598,7 +13732,8 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
          break;
 
        case DW_OP_plus_uconst:
-         stack[stacki] += read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+         stack[stacki] += read_unsigned_leb128 (NULL, (data + i),
+                                                &bytes_read);
          i += bytes_read;
          break;
 
@@ -13631,8 +13766,17 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
          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]);
        }
 
@@ -13799,7 +13943,8 @@ consume_improper_spaces (const char *p, const char *body)
   if (*p == ' ')
     {
       complaint (&symfile_complaints,
-                _("macro definition contains spaces in formal argument list:\n`%s'"),
+                _("macro definition contains spaces "
+                  "in formal argument list:\n`%s'"),
                 body);
 
       while (*p == ' ')
@@ -13990,7 +14135,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
       if (mac_ptr >= mac_end)
         {
          /* Complaint is printed during the second pass as GDB will probably
-            stop the first pass earlier upon finding DW_MACINFO_start_file.  */
+            stop the first pass earlier upon finding
+            DW_MACINFO_start_file.  */
          break;
         }
 
@@ -14027,8 +14173,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
            file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
            mac_ptr += bytes_read;
 
-           current_file = macro_start_file (file, line, current_file, comp_dir,
-                                            lh, cu->objfile);
+           current_file = macro_start_file (file, line, current_file,
+                                            comp_dir, lh, cu->objfile);
          }
          break;
 
@@ -14114,7 +14260,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
                                 _("something-or-other"), line, body);
                break;
              }
-           if ((line == 0 && !at_commandline) || (line != 0 && at_commandline))
+           if ((line == 0 && !at_commandline)
+               || (line != 0 && at_commandline))
              complaint (&symfile_complaints,
                         _("debug info gives %s macro %s with %s line %d: %s"),
                         at_commandline ? _("command-line") : _("in-file"),
@@ -14142,7 +14289,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
             file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
 
-           if ((line == 0 && !at_commandline) || (line != 0 && at_commandline))
+           if ((line == 0 && !at_commandline)
+               || (line != 0 && at_commandline))
              complaint (&symfile_complaints,
                         _("debug info gives source %d included "
                           "from %s at %s line %d"),
@@ -14164,7 +14312,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
         case DW_MACINFO_end_file:
           if (! current_file)
            complaint (&symfile_complaints,
-                      _("macro debug info has an unmatched `close_file' directive"));
+                      _("macro debug info has an unmatched "
+                        "`close_file' directive"));
           else
             {
               current_file = current_file->included_by;
@@ -14189,7 +14338,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
                   next_type = read_1_byte (abfd, mac_ptr);
                   if (next_type != 0)
                    complaint (&symfile_complaints,
-                              _("no terminating 0-type entry for macros in `.debug_macinfo' section"));
+                              _("no terminating 0-type entry for "
+                                "macros in `.debug_macinfo' section"));
 
                   return;
                 }
@@ -14200,11 +14350,10 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
           {
             unsigned int bytes_read;
             int constant;
-            char *string;
 
             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.  */
@@ -14215,7 +14364,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
 }
 
 /* Check if the attribute's form is a DW_FORM_block*
-   if so return true else false. */
+   if so return true else false.  */
 static int
 attr_form_is_block (struct attribute *attr)
 {
@@ -14300,7 +14449,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.  */
-      && 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;
 
@@ -14311,7 +14461,8 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
 
       if (cu->base_known == 0)
        complaint (&symfile_complaints,
-                  _("Location list used without specifying the CU base address."));
+                  _("Location list used without "
+                    "specifying the CU base address."));
 
       SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
       SYMBOL_LOCATION_BATON (sym) = baton;
@@ -15285,7 +15436,7 @@ struct addrmap_index_data
   int previous_valid;
   /* Index of the CU in the table of all CUs in the index file.  */
   unsigned int previous_cu_index;
-  /* Start address of the CU. */
+  /* Start address of the CU.  */
   CORE_ADDR previous_cu_start;
 };
 
@@ -15458,12 +15609,14 @@ write_one_signatured_type (void **slot, void *d)
 
   write_psymbols (info->symtab,
                  info->psyms_seen,
-                 info->objfile->global_psymbols.list + psymtab->globals_offset,
+                 info->objfile->global_psymbols.list
+                 + psymtab->globals_offset,
                  psymtab->n_global_syms, info->cu_index,
                  0);
   write_psymbols (info->symtab,
                  info->psyms_seen,
-                 info->objfile->static_psymbols.list + psymtab->statics_offset,
+                 info->objfile->static_psymbols.list
+                 + psymtab->statics_offset,
                  psymtab->n_static_syms, info->cu_index,
                  1);
 
@@ -15560,7 +15713,8 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
      all_comp_units, but only in their own hash table.  */
   for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
-      struct dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *per_cu
+       = dwarf2_per_objfile->all_comp_units[i];
       struct partial_symtab *psymtab = per_cu->v.psymtab;
       gdb_byte val[8];
       struct psymtab_cu_index_map *map;
@@ -15620,7 +15774,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   total_len = size_of_contents;
 
   /* The version number.  */
-  val = MAYBE_SWAP (3);
+  val = MAYBE_SWAP (4);
   obstack_grow (&contents, &val, sizeof (val));
 
   /* The offset of the CU list from the start of the file.  */
@@ -15678,7 +15832,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
    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
+   [0] The version number, currently 4.  Versions 1, 2 and 3 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.
@@ -15777,8 +15931,9 @@ static void
 show_dwarf2_always_disassemble (struct ui_file *file, int from_tty,
                                struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Whether to always disassemble DWARF expressions is %s.\n"),
+  fprintf_filtered (file,
+                   _("Whether to always disassemble "
+                     "DWARF expressions is %s.\n"),
                    value);
 }