*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 05fbd0936ca260fd2095a225dec4d69a365c06a7..127d10fc741fd7afee8f90e103777307125cf618 100644 (file)
@@ -645,6 +645,16 @@ struct field_info
 
     /* Number of entries in the fnfieldlists array.  */
     int nfnfields;
+
+    /* typedefs defined inside this class.  TYPEDEF_FIELD_LIST contains head of
+       a NULL terminated list of TYPEDEF_FIELD_LIST_COUNT elements.  */
+    struct typedef_field_list
+      {
+       struct typedef_field field;
+       struct typedef_field_list *next;
+      }
+    *typedef_field_list;
+    unsigned typedef_field_list_count;
   };
 
 /* One item on the queue of compilation units to read in full symbols
@@ -906,7 +916,7 @@ static struct type *read_type_die (struct die_info *, struct dwarf2_cu *);
 
 static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
 
-static char *typename_concat (struct obstack *obs, const char *prefix, 
+static char *typename_concat (struct obstack *obs, const char *prefix,
                              const char *suffix, int physname,
                              struct dwarf2_cu *cu);
 
@@ -965,7 +975,7 @@ static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *);
 
 static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
 
-static enum dwarf_array_dim_ordering read_array_order (struct die_info *, 
+static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
                                                       struct dwarf2_cu *);
 
 static struct die_info *read_comp_unit (gdb_byte *, struct dwarf2_cu *);
@@ -1523,7 +1533,7 @@ read_type_comp_unit_head (struct comp_unit_head *cu_header,
 {
   gdb_byte *initial_types_ptr = types_ptr;
 
-  dwarf2_read_section (dwarf2_per_objfile->objfile, 
+  dwarf2_read_section (dwarf2_per_objfile->objfile,
                       &dwarf2_per_objfile->types);
   cu_header->offset = types_ptr - dwarf2_per_objfile->types.buffer;
 
@@ -1995,6 +2005,16 @@ build_type_psymtabs (struct objfile *objfile)
                          process_type_comp_unit, objfile);
 }
 
+/* A cleanup function that clears objfile's psymtabs_addrmap field.  */
+
+static void
+psymtabs_addrmap_cleanup (void *o)
+{
+  struct objfile *objfile = o;
+
+  objfile->psymtabs_addrmap = NULL;
+}
+
 /* Build the partial symbol table by doing a quick pass through the
    .debug_info and .debug_abbrev sections.  */
 
@@ -2002,7 +2022,8 @@ static void
 dwarf2_build_psymtabs_hard (struct objfile *objfile)
 {
   gdb_byte *info_ptr;
-  struct cleanup *back_to;
+  struct cleanup *back_to, *addrmap_cleanup;
+  struct obstack temp_obstack;
 
   dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
   info_ptr = dwarf2_per_objfile->info.buffer;
@@ -2015,8 +2036,12 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
 
   create_all_comp_units (objfile);
 
-  objfile->psymtabs_addrmap =
-    addrmap_create_mutable (&objfile->objfile_obstack);
+  /* Create a temporary address map on a temporary obstack.  We later
+     copy this to the final obstack.  */
+  obstack_init (&temp_obstack);
+  make_cleanup_obstack_free (&temp_obstack);
+  objfile->psymtabs_addrmap = addrmap_create_mutable (&temp_obstack);
+  addrmap_cleanup = make_cleanup (psymtabs_addrmap_cleanup, objfile);
 
   /* Since the objects we're extracting from .debug_info vary in
      length, only the individual functions to extract them (like
@@ -2048,6 +2073,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
                                                    &objfile->objfile_obstack);
+  discard_cleanups (addrmap_cleanup);
 
   do_cleanups (back_to);
 }
@@ -2136,7 +2162,7 @@ create_all_comp_units (struct objfile *objfile)
   n_allocated = 10;
   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)
     {
       unsigned int length, initial_length_size;
@@ -2309,7 +2335,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
      DW_TAG_namespace DIEs with a name of "::" for the global namespace.
      Work around this problem here.  */
   if (cu->language == language_cplus
-      && parent->tag == DW_TAG_namespace 
+      && parent->tag == DW_TAG_namespace
       && strcmp (parent->name, "::") == 0
       && grandparent_scope == NULL)
     {
@@ -2558,7 +2584,7 @@ add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc,
    symbol for that subprogram.  When the CU language allows it, this
    routine also defines a partial symbol for each nested subprogram
    that this subprogram contains.
-   
+
    DIE my also be a lexical block, in which case we simply search
    recursively for suprograms defined inside that lexical block.
    Again, this is only performed when the CU language allows this
@@ -2597,7 +2623,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
              add_partial_symbol (pdi, cu);
         }
     }
-  
+
   if (! pdi->has_children)
     return;
 
@@ -3345,7 +3371,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
 
          /* For Java and C++ methods, append formal parameter type
             information, if PHYSNAME.  */
-         
+
          if (physname && die->tag == DW_TAG_subprogram
              && (cu->language == language_cplus
                  || cu->language == language_java))
@@ -3546,7 +3572,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   bfd *abfd = objfile->obfd;
   struct line_header *line_header = 0;
   CORE_ADDR baseaddr;
-  
+
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   get_scope_pc_bounds (die, &lowpc, &highpc, cu);
@@ -3595,7 +3621,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
     }
 
   attr = dwarf2_attr (die, DW_AT_producer, cu);
-  if (attr) 
+  if (attr)
     cu->producer = DW_STRING (attr);
 
   /* We assume that we're processing GCC output. */
@@ -3697,7 +3723,7 @@ read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu)
   /* This isn't technically needed today.  It is done for symmetry
      with read_file_scope.  */
   attr = dwarf2_attr (die, DW_AT_producer, cu);
-  if (attr) 
+  if (attr)
     cu->producer = DW_STRING (attr);
 
   /* We assume that we're processing GCC output. */
@@ -3997,7 +4023,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   /* If we have address ranges, record them.  */
   dwarf2_record_block_ranges (die, block, baseaddr, cu);
-  
+
   /* In C++, we can have functions nested inside functions (e.g., when
      a function declares a class that has methods).  This means that
      when we finish processing a function scope, we may need to go
@@ -4029,7 +4055,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   /* Ignore blocks with missing or invalid low and high pc attributes.  */
   /* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
      as multiple lexical blocks?  Handling children in a sane way would
-     be nasty.  Might be easier to properly extend generic blocks to 
+     be nasty.  Might be easier to properly extend generic blocks to
      describe ranges.  */
   if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
     return;
@@ -4282,7 +4308,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die,
      subprograms or lexical blocks), we're done.  */
   if (cu->language != language_ada)
     return;
-     
+
   /* Check all the children of the given DIE.  If it contains nested
      subprograms, then check their pc bounds.  Likewise, we need to
      check lexical blocks as well, as they may also contain subprogram
@@ -4444,8 +4470,8 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
                   return;
                 }
 
-              record_block_range (block, 
-                                  baseaddr + base + start, 
+              record_block_range (block,
+                                  baseaddr + base + start,
                                   baseaddr + base + end - 1);
             }
         }
@@ -4457,7 +4483,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 static void
 dwarf2_add_field (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 nextfield *new_field;
@@ -4502,10 +4528,15 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
 
   fp = &new_field->field;
 
+  /* NOTE: According to the dwarf standard, static data members are
+     indicated by having DW_AT_external.
+     The check here for ! die_is_declaration is historical.
+     This test is replicated in new_symbol.  */
+
   if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
     {
       /* Data member other than a C++ static data member.  */
-      
+
       /* Get type of field.  */
       fp->type = die_type (die, cu);
 
@@ -4609,7 +4640,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
         is a declaration, but all versions of G++ as of this writing
         (so through at least 3.2.1) incorrectly generate
         DW_TAG_variable tags.  */
-      
+
       char *physname;
 
       /* Get name of field.  */
@@ -4617,6 +4648,14 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
       if (fieldname == NULL)
        return;
 
+      attr = dwarf2_attr (die, DW_AT_const_value, cu);
+      if (attr)
+       {
+         /* A static const member, not much different than an enum as far as
+            we're concerned, except that we can support more types.  */
+         new_symbol (die, NULL, cu);
+       }
+
       /* Get physical name.  */
       physname = (char *) dwarf2_physname (fieldname, die, cu);
 
@@ -4652,6 +4691,39 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
     }
 }
 
+/* Add a typedef defined in the scope of the FIP's class.  */
+
+static void
+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;
+  char *fieldname = "";
+
+  /* Allocate a new field list entry and link it in.  */
+  new_field = xzalloc (sizeof (*new_field));
+  make_cleanup (xfree, new_field);
+
+  gdb_assert (die->tag == DW_TAG_typedef);
+
+  fp = &new_field->field;
+
+  /* Get name of field.  */
+  fp->name = dwarf2_name (die, cu);
+  if (fp->name == NULL)
+    return;
+
+  fp->type = read_type_die (die, cu);
+
+  new_field->next = fip->typedef_field_list;
+  fip->typedef_field_list = new_field;
+  fip->typedef_field_list_count++;
+}
+
 /* Create the vector of fields, and attach it to the type.  */
 
 static void
@@ -4879,19 +4951,46 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
     fnp->is_artificial = 1;
 
   /* Get index in virtual function table if it is a virtual member
-     function.  For GCC, this is an offset in the appropriate
-     virtual table, as specified by DW_AT_containing_type.  For
-     everyone else, it is an expression to be evaluated relative
+     function.  For older versions of GCC, this is an offset in the
+     appropriate virtual table, as specified by DW_AT_containing_type.
+     For everyone else, it is an expression to be evaluated relative
      to the object address.  */
 
   attr = dwarf2_attr (die, DW_AT_vtable_elem_location, cu);
-  if (attr && fnp->fcontext)
+  if (attr)
     {
-      /* Support the .debug_loc offsets */
-      if (attr_form_is_block (attr))
+      if (attr_form_is_block (attr) && DW_BLOCK (attr)->size > 0)
         {
-          fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu) + 2;
-        }
+         if (DW_BLOCK (attr)->data[0] == DW_OP_constu)
+           {
+             /* Old-style GCC.  */
+             fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu) + 2;
+           }
+         else if (DW_BLOCK (attr)->data[0] == DW_OP_deref
+                  || (DW_BLOCK (attr)->size > 1
+                      && DW_BLOCK (attr)->data[0] == DW_OP_deref_size
+                      && DW_BLOCK (attr)->data[1] == cu->header.addr_size))
+           {
+             struct dwarf_block blk;
+             int offset;
+
+             offset = (DW_BLOCK (attr)->data[0] == DW_OP_deref
+                       ? 1 : 2);
+             blk.size = DW_BLOCK (attr)->size - offset;
+             blk.data = DW_BLOCK (attr)->data + offset;
+             fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu);
+             if ((fnp->voffset % cu->header.addr_size) != 0)
+               dwarf2_complex_location_expr_complaint ();
+             else
+               fnp->voffset /= cu->header.addr_size;
+             fnp->voffset += 2;
+           }
+         else
+           dwarf2_complex_location_expr_complaint ();
+
+         if (!fnp->fcontext)
+           fnp->fcontext = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
+       }
       else if (attr_form_is_section_offset (attr))
         {
          dwarf2_complex_location_expr_complaint ();
@@ -4902,28 +5001,6 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
                                                 fieldname);
         }
     }
-  else if (attr)
-    {
-      /* We only support trivial expressions here.  This hack will work
-        for v3 classes, which always start with the vtable pointer.  */
-      if (attr_form_is_block (attr) && DW_BLOCK (attr)->size > 0
-         && DW_BLOCK (attr)->data[0] == DW_OP_deref)
-       {
-         struct dwarf_block blk;
-
-         blk.size = DW_BLOCK (attr)->size - 1;
-         blk.data = DW_BLOCK (attr)->data + 1;
-         fnp->voffset = decode_locdesc (&blk, cu);
-         if ((fnp->voffset % cu->header.addr_size) != 0)
-           dwarf2_complex_location_expr_complaint ();
-         else
-           fnp->voffset /= cu->header.addr_size;
-         fnp->voffset += 2;
-         fnp->fcontext = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
-       }
-      else
-       dwarf2_complex_location_expr_complaint ();
-    }
   else
     {
       attr = dwarf2_attr (die, DW_AT_virtuality, cu);
@@ -4933,6 +5010,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
          complaint (&symfile_complaints,
                     _("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;
        }
     }
@@ -5061,7 +5139,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
   struct type *type;
   struct attribute *attr;
   char *name;
-  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+  struct cleanup *back_to;
 
   /* If the definition of this type lives in .debug_types, read that type.
      Don't follow DW_AT_specification though, that will take us back up
@@ -5080,6 +5158,8 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
       return set_die_type (die, type, cu);
     }
 
+  back_to = make_cleanup (null_cleanup, 0);
+
   type = alloc_type (objfile);
   INIT_CPLUS_SPECIFIC (type);
 
@@ -5178,6 +5258,8 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
              /* C++ base class field.  */
              dwarf2_add_field (&fi, child_die, cu);
            }
+         else if (child_die->tag == DW_TAG_typedef)
+           dwarf2_add_typedef (&fi, child_die, cu);
          child_die = sibling_die (child_die);
        }
 
@@ -5251,6 +5333,29 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
                }
            }
        }
+
+      /* Copy fi.typedef_field_list linked list elements content into the
+        allocated array TYPE_TYPEDEF_FIELD_ARRAY (type).  */
+      if (fi.typedef_field_list)
+       {
+         int i = fi.typedef_field_list_count;
+
+         ALLOCATE_CPLUS_STRUCT_TYPE (type);
+         TYPE_TYPEDEF_FIELD_ARRAY (type)
+           = TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i);
+         TYPE_TYPEDEF_FIELD_COUNT (type) = i;
+
+         /* Reverse the list order to keep the debug info elements order.  */
+         while (--i >= 0)
+           {
+             struct typedef_field *dest, *src;
+
+             dest = &TYPE_TYPEDEF_FIELD (type, i);
+             src = &fi.typedef_field_list->field;
+             fi.typedef_field_list = fi.typedef_field_list->next;
+             *dest = *src;
+           }
+       }
     }
 
   quirk_gcc_member_function_pointer (type, cu->objfile);
@@ -5517,7 +5622,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
   name = dwarf2_name (die, cu);
   if (name)
     TYPE_NAME (type) = name;
-  
+
   /* Install the type in the die. */
   set_die_type (die, type, cu);
 
@@ -5530,7 +5635,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
 }
 
 static enum dwarf_array_dim_ordering
-read_array_order (struct die_info *die, struct dwarf2_cu *cu) 
+read_array_order (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct attribute *attr;
 
@@ -5540,10 +5645,10 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
 
   /*
     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 
+    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 
+    FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
     version checking.
   */
 
@@ -5553,7 +5658,7 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
       return DW_ORD_row_major;
     }
 
-  switch (cu->language_defn->la_array_ordering) 
+  switch (cu->language_defn->la_array_ordering)
     {
     case array_column_major:
       return DW_ORD_col_major;
@@ -5716,7 +5821,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
   if (die->child != NULL)
     {
       struct die_info *child_die = die->child;
-      
+
       while (child_die && child_die->tag)
        {
          process_die (child_die, cu);
@@ -5846,7 +5951,7 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
        {
          complaint (&symfile_complaints, _("invalid pointer size %d"), byte_size);
        }
-      else 
+      else
        {
          /* Should we also complain about unhandled address classes?  */
        }
@@ -6036,7 +6141,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
      we don't infinitely recurse when dealing with parameters
      declared as the same subroutine type. */
   set_die_type (die, ftype, cu);
-  
+
   if (die->child != NULL)
     {
       struct type *void_type = objfile_type (cu->objfile)->builtin_void;
@@ -6181,7 +6286,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
        type_flags |= TYPE_FLAG_UNSIGNED;
        break;
       case DW_ATE_signed_char:
-       if (cu->language == language_ada || cu->language == language_m2 
+       if (cu->language == language_ada || cu->language == language_m2
            || cu->language == language_pascal)
          code = TYPE_CODE_CHAR;
        break;
@@ -6191,6 +6296,11 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
          code = TYPE_CODE_CHAR;
        type_flags |= TYPE_FLAG_UNSIGNED;
        break;
+      case DW_ATE_UTF:
+       /* We just treat this as an integer and then recognize the
+          type by name elsewhere.  */
+       break;
+
       default:
        complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
                   dwarf_type_encoding_name (encoding));
@@ -6229,7 +6339,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
     return range_type;
 
   if (cu->language == language_fortran)
-    { 
+    {
       /* FORTRAN implies a lower bound of 1, if not given.  */
       low = 1;
     }
@@ -6243,7 +6353,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
 
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
   if (attr)
-    {       
+    {
       if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
         {
           /* GCC encodes arrays with unspecified or dynamic length
@@ -6311,7 +6421,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
        }
     }
 
-  negative_mask = 
+  negative_mask =
     (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
   if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
     low |= negative_mask;
@@ -6329,7 +6439,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   name = dwarf2_name (die, cu);
   if (name)
     TYPE_NAME (range_type) = name;
-  
+
   attr = dwarf2_attr (die, DW_AT_byte_size, cu);
   if (attr)
     TYPE_LENGTH (range_type) = DW_UNSND (attr);
@@ -6341,7 +6451,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
 
   return range_type;
 }
-  
+
 static struct type *
 read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -6582,7 +6692,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 */
   while (abbrev_number)
     {
@@ -7531,7 +7641,7 @@ read_address (bfd *abfd, gdb_byte *buf, struct dwarf2_cu *cu,
      from:
 
        http://reality.sgiweb.org/davea/dwarf3-draft8-011125.pdf
-     
+
      This document is only a draft and is subject to change.  (So beware.)
 
      Details regarding the older, non-standard 64-bit format were
@@ -7938,7 +8048,7 @@ add_include_dir (struct line_header *lh, char *include_dir)
 
   lh->include_dirs[lh->num_include_dirs++] = include_dir;
 }
+
 
 /* Add an entry to LH's file name table.  */
 static void
@@ -7973,7 +8083,7 @@ add_file_name (struct line_header *lh,
   fe->included_p = 0;
   fe->symtab = NULL;
 }
+
 
 /* Read the statement program header starting at OFFSET in
    .debug_line, according to the endianness of ABFD.  Return a pointer
@@ -8016,7 +8126,7 @@ dwarf_decode_line_header (unsigned int offset, bfd *abfd,
   line_ptr = dwarf2_per_objfile->line.buffer + offset;
 
   /* Read in the header.  */
-  lh->total_length = 
+  lh->total_length =
     read_checked_initial_length_and_offset (abfd, line_ptr, &cu->header,
                                            &bytes_read, &offset_size);
   line_ptr += bytes_read;
@@ -8090,7 +8200,7 @@ dwarf_decode_line_header (unsigned int offset, bfd *abfd,
       add_file_name (lh, cur_file, dir_index, mod_time, length);
     }
   line_ptr += bytes_read;
-  lh->statement_program_start = line_ptr; 
+  lh->statement_program_start = line_ptr;
 
   if (line_ptr > (dwarf2_per_objfile->line.buffer
                  + dwarf2_per_objfile->line.size))
@@ -8155,7 +8265,7 @@ check_cu_functions (CORE_ADDR address, struct dwarf2_cu *cu)
       to create all necessary symbol tables, and their linetables.
       The compilation directory of the file is passed in COMP_DIR,
       and must not be NULL.
-   
+
    2. If PST is not NULL, this procedure reads the program to determine
       the list of files included by the unit represented by PST, and
       builds all the associated partial symbol tables.  In this case,
@@ -8225,7 +8335,7 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
             }
 
          if (op_code >= lh->opcode_base)
-           {           
+           {
              /* Special operand.  */
              adj_opcode = op_code - lh->opcode_base;
              address += (((op_index + (adj_opcode / lh->line_range))
@@ -8281,7 +8391,7 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                   {
                     char *cur_file;
                     unsigned int dir_index, mod_time, length;
-                    
+
                     cur_file = read_string (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     dir_index =
@@ -8727,6 +8837,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
             BLOCK_FUNCTION from the blockvector.  */
          break;
        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.  */
@@ -8735,6 +8846,17 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
              = objfile_type (objfile)->nodebug_data_symbol;
 
          attr = dwarf2_attr (die, DW_AT_const_value, cu);
+         /* In the case of DW_TAG_member, we should only be called for
+            static const members.  */
+         if (die->tag == DW_TAG_member)
+           {
+             /* NOTE: This test seems wrong according to the dwarf standard.
+                static data members are represented by DW_AT_external.
+                However, dwarf2_add_field is currently calling
+                die_is_declaration to check, so we do the same.  */
+             gdb_assert (die_is_declaration (die, cu));
+             gdb_assert (attr);
+           }
          if (attr)
            {
              dwarf2_const_value (attr, sym, cu);
@@ -8866,7 +8988,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
                           && (cu->language == language_cplus
                               || cu->language == language_java)
                           ? &global_symbols : cu->list_in_scope);
-         
+
            add_symbol_to_list (sym, list_to_add);
 
            /* The semantics of C++ state that "struct foo { ... }" also
@@ -8913,7 +9035,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
                           && (cu->language == language_cplus
                               || cu->language == language_java)
                           ? &global_symbols : cu->list_in_scope);
-         
+
            add_symbol_to_list (sym, list_to_add);
          }
          break;
@@ -8960,7 +9082,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
                                                      cu_header->addr_size,
                                                      TYPE_LENGTH (SYMBOL_TYPE
                                                                   (sym)));
-      SYMBOL_VALUE_BYTES (sym) = 
+      SYMBOL_VALUE_BYTES (sym) =
        obstack_alloc (&objfile->objfile_obstack, cu_header->addr_size);
       /* NOTE: cagney/2003-05-09: In-lined store_address call with
          it's body - store_unsigned_integer.  */
@@ -9152,9 +9274,18 @@ tag_type_to_type (struct die_info *die, struct dwarf2_cu *cu)
   this_type = read_type_die (die, cu);
   if (!this_type)
     {
-      dump_die_for_error (die);
-      error (_("Dwarf Error: Cannot find type of die [in module %s]"), 
-            cu->objfile->name);
+      char *message, *saved;
+
+      /* read_type_die already issued a complaint.  */
+      message = xstrprintf (_("<unknown type in %s, CU 0x%x, DIE 0x%x>"),
+                           cu->objfile->name,
+                           cu->header.offset,
+                           die->offset);
+      saved = obstack_copy0 (&cu->objfile->objfile_obstack,
+                            message, strlen (message));
+      xfree (message);
+
+      this_type = init_type (TYPE_CODE_ERROR, 0, 0, saved, cu->objfile);
     }
   return this_type;
 }
@@ -10372,6 +10503,9 @@ dwarf_type_encoding_name (unsigned enc)
       return "DW_ATE_unsigned_fixed";
     case DW_ATE_decimal_float:
       return "DW_ATE_decimal_float";
+    /* DWARF 4.  */
+    case DW_ATE_UTF:
+      return "DW_ATE_UTF";
     /* HP extensions.  */
     case DW_ATE_HP_float80:
       return "DW_ATE_HP_float80";
@@ -11267,7 +11401,7 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
   if (1 <= file && file <= lh->num_file_names)
     {
       struct file_entry *fe = &lh->file_names[file - 1];
-  
+
       if (IS_ABSOLUTE_PATH (fe->name))
         return xstrdup (fe->name);
       else
@@ -11303,7 +11437,7 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
 
       sprintf (fake_name, "<bad macro file number %d>", file);
 
-      complaint (&symfile_complaints, 
+      complaint (&symfile_complaints,
                  _("bad file number in macro information (%d)"),
                  file);
 
@@ -11335,7 +11469,7 @@ macro_start_file (int file, int line,
     current_file = macro_include (current_file, line, full_name);
 
   xfree (full_name);
-              
+
   return current_file;
 }
 
@@ -11392,7 +11526,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
 
      The Dwarf 2 spec says that an object-like macro's name is always
      followed by a space, but versions of GCC around March 2002 omit
-     the space when the macro's definition is the empty string. 
+     the space when the macro's definition is the empty string.
 
      The Dwarf 2 spec says that there should be no spaces between the
      formal arguments in a function-like macro's formal argument list,
@@ -11421,7 +11555,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
          dwarf2_macro_malformed_definition_complaint (body);
           replacement = body + name_len;
         }
-      
+
       macro_define_object (file, line, name, replacement);
 
       xfree (name);
@@ -11479,14 +11613,14 @@ parse_macro_definition (struct macro_source_file *file, int line,
           if (*p == ' ')
             /* Perfectly formed definition, no complaints.  */
             macro_define_function (file, line, name,
-                                   argc, (const char **) argv, 
+                                   argc, (const char **) argv,
                                    p + 1);
           else if (*p == '\0')
             {
               /* Complain, but do define it.  */
              dwarf2_macro_malformed_definition_complaint (body);
               macro_define_function (file, line, name,
-                                     argc, (const char **) argv, 
+                                     argc, (const char **) argv,
                                      p);
             }
           else
@@ -11667,8 +11801,8 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
                complaint (&symfile_complaints,
                           _("debug info with no main source gives macro %s "
                             "on line %d: %s"),
-                          macinfo_type == DW_MACINFO_define ? 
-                            _("definition") : 
+                          macinfo_type == DW_MACINFO_define ?
+                            _("definition") :
                               macinfo_type == DW_MACINFO_undef ?
                                 _("undefinition") :
                                 _("something-or-other"), line, body);
@@ -11679,7 +11813,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
                         _("debug info gives %s macro %s with %s line %d: %s"),
                         at_commandline ? _("command-line") : _("in-file"),
                         macinfo_type == DW_MACINFO_define ?
-                          _("definition") : 
+                          _("definition") :
                             macinfo_type == DW_MACINFO_undef ?
                               _("undefinition") :
                               _("something-or-other"),
@@ -11891,7 +12025,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
          baton->size = 0;
          baton->data = NULL;
        }
-      
+
       SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
       SYMBOL_LOCATION_BATON (sym) = baton;
     }
@@ -12387,7 +12521,7 @@ set_dwarf2_cmd (char *args, int from_tty)
 
 static void
 show_dwarf2_cmd (char *args, int from_tty)
-{ 
+{
   cmd_show_list (show_dwarf2_cmdlist, from_tty, "");
 }
 
This page took 0.038696 seconds and 4 git commands to generate.