daily update
[external/binutils.git] / gdb / dwarf2read.c
index 542fe34..15e168f 100644 (file)
@@ -1,7 +1,7 @@
 /* DWARF 2 debugging format support for GDB.
 
    Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+                 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
    Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
    Inc.  with support from Florida State University (under contract
@@ -1747,6 +1747,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
                }
              break;
            case DW_TAG_class_type:
+           case DW_TAG_interface_type:
            case DW_TAG_structure_type:
              if (!pdi->is_declaration)
                {
@@ -1829,6 +1830,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
   if (parent->tag == DW_TAG_namespace
       || parent->tag == DW_TAG_structure_type
       || parent->tag == DW_TAG_class_type
+      || parent->tag == DW_TAG_interface_type
       || parent->tag == DW_TAG_union_type)
     {
       if (grandparent_scope == NULL)
@@ -1976,6 +1978,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
                           0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     case DW_TAG_class_type:
+    case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
     case DW_TAG_enumeration_type:
@@ -2057,6 +2060,7 @@ pdi_needs_namespace (enum dwarf_tag tag)
     case DW_TAG_namespace:
     case DW_TAG_typedef:
     case DW_TAG_class_type:
+    case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
     case DW_TAG_enumeration_type:
@@ -2676,6 +2680,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
       read_lexical_block_scope (die, cu);
       break;
     case DW_TAG_class_type:
+    case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
       read_structure_type (die, cu);
@@ -3478,23 +3483,26 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
       attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
       if (attr)
        {
+          int byte_offset;
+
           if (attr_form_is_section_offset (attr))
             {
               dwarf2_complex_location_expr_complaint ();
-              FIELD_BITPOS (*fp) = 0;
+              byte_offset = 0;
             }
           else if (attr_form_is_constant (attr))
-            FIELD_BITPOS (*fp) = dwarf2_get_attr_constant_value (attr, 0);
+            byte_offset = dwarf2_get_attr_constant_value (attr, 0);
           else
-            FIELD_BITPOS (*fp) =
-              decode_locdesc (DW_BLOCK (attr), cu) * bits_per_byte;
+            byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
+
+          FIELD_BITPOS (*fp) = byte_offset * bits_per_byte;
        }
       else
        FIELD_BITPOS (*fp) = 0;
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr)
        {
-         if (BITS_BIG_ENDIAN)
+         if (gdbarch_bits_big_endian (current_gdbarch))
            {
              /* For big endian bits, the DW_AT_bit_offset gives the
                 additional bit offset from the MSB of the containing
@@ -4225,6 +4233,14 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
       TYPE_LENGTH (type) = 0;
     }
 
+  /* The enumeration DIE can be incomplete.  In Ada, any type can be
+     declared as private in the package spec, and then defined only
+     inside the package body.  Such types are known as Taft Amendment
+     Types.  When another package uses such a type, an incomplete DIE
+     may be generated by the compiler.  */
+  if (die_is_declaration (die, cu))
+    TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
+
   set_die_type (die, type, cu);
 }
 
@@ -4999,11 +5015,11 @@ 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_m2)
+       if (cu->language == language_ada || cu->language == language_m2)
          code = TYPE_CODE_CHAR;
        break;
       case DW_ATE_unsigned_char:
-       if (cu->language == language_m2)
+       if (cu->language == language_ada || cu->language == language_m2)
          code = TYPE_CODE_CHAR;
        type_flags |= TYPE_FLAG_UNSIGNED;
        break;
@@ -5400,6 +5416,7 @@ is_type_tag_for_partial (int tag)
 #endif
     case DW_TAG_base_type:
     case DW_TAG_class_type:
+    case DW_TAG_interface_type:
     case DW_TAG_enumeration_type:
     case DW_TAG_structure_type:
     case DW_TAG_subrange_type:
@@ -5605,6 +5622,7 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
              || last_die->tag == DW_TAG_enumeration_type
              || (cu->language != language_c
                  && (last_die->tag == DW_TAG_class_type
+                     || last_die->tag == DW_TAG_interface_type
                      || last_die->tag == DW_TAG_structure_type
                      || last_die->tag == DW_TAG_union_type))))
        {
@@ -7355,6 +7373,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
             (FIXME?) */
          break;
        case DW_TAG_class_type:
+       case DW_TAG_interface_type:
        case DW_TAG_structure_type:
        case DW_TAG_union_type:
        case DW_TAG_set_type:
@@ -7674,6 +7693,7 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
   switch (die->tag)
     {
     case DW_TAG_class_type:
+    case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
       read_structure_type (die, cu);
@@ -7778,6 +7798,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
        }
        break;
       case DW_TAG_class_type:
+      case DW_TAG_interface_type:
       case DW_TAG_structure_type:
        {
          if (parent->type != NULL && TYPE_TAG_NAME (parent->type) != NULL)
@@ -8913,7 +8934,7 @@ dump_die (struct die_info *die)
        case DW_FORM_ref_addr:
        case DW_FORM_addr:
          fprintf_unfiltered (gdb_stderr, "address: ");
-         deprecated_print_address_numeric (DW_ADDR (&die->attrs[i]), 1, gdb_stderr);
+         fputs_filtered (paddress (DW_ADDR (&die->attrs[i])), gdb_stderr);
          break;
        case DW_FORM_block2:
        case DW_FORM_block4:
@@ -9734,9 +9755,14 @@ attr_form_is_block (struct attribute *attr)
       || attr->form == DW_FORM_block);
 }
 
-/* Return non-zero if ATTR's value is a section offset (classes
-   lineptr, loclistptr, macptr or rangelistptr).  In this case,
-   you may use DW_UNSND (attr) to retrieve the offset.  */
+/* Return non-zero if ATTR's value is a section offset --- classes
+   lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
+   You may use DW_UNSND (attr) to retrieve such offsets.
+
+   Section 7.5.4, "Attribute Encodings", explains that no attribute
+   may have a value that belongs to more than one of these classes; it
+   would be ambiguous if we did, because we use the same forms for all
+   of them.  */
 static int
 attr_form_is_section_offset (struct attribute *attr)
 {