Handle bit offset and bit size in base types
[deliverable/binutils-gdb.git] / gdb / gdbtypes.c
index 7ade2ccb533b95880fcbe3bb256f31a8fdb5b985..43c05d344d0b5b8265c5a065d277ab6c0951f047 100644 (file)
@@ -630,7 +630,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
   ntype = type;
   do
     {
-      if (TYPE_INSTANCE_FLAGS (ntype) == new_flags)
+      if (ntype->instance_flags () == new_flags)
        return ntype;
       ntype = TYPE_CHAIN (ntype);
     }
@@ -753,7 +753,7 @@ struct type *
 make_restrict_type (struct type *type)
 {
   return make_qualified_type (type,
-                             (TYPE_INSTANCE_FLAGS (type)
+                             (type->instance_flags ()
                               | TYPE_INSTANCE_FLAG_RESTRICT),
                              NULL);
 }
@@ -764,7 +764,7 @@ struct type *
 make_unqualified_type (struct type *type)
 {
   return make_qualified_type (type,
-                             (TYPE_INSTANCE_FLAGS (type)
+                             (type->instance_flags ()
                               & ~(TYPE_INSTANCE_FLAG_CONST
                                   | TYPE_INSTANCE_FLAG_VOLATILE
                                   | TYPE_INSTANCE_FLAG_RESTRICT)),
@@ -777,7 +777,7 @@ struct type *
 make_atomic_type (struct type *type)
 {
   return make_qualified_type (type,
-                             (TYPE_INSTANCE_FLAGS (type)
+                             (type->instance_flags ()
                               | TYPE_INSTANCE_FLAG_ATOMIC),
                              NULL);
 }
@@ -825,7 +825,7 @@ replace_type (struct type *ntype, struct type *type)
 
   /* Assert that the two types have equivalent instance qualifiers.
      This should be true for at least all of our debug readers.  */
-  gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type));
+  gdb_assert (ntype->instance_flags () == type->instance_flags ());
 }
 
 /* Implement direct support for MEMBER_TYPE in GNU C++.
@@ -2834,9 +2834,7 @@ check_typedef (struct type *type)
             move over any other types NEWTYPE refers to, which could
             be an unbounded amount of stuff.  */
          if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type))
-           type = make_qualified_type (newtype,
-                                       TYPE_INSTANCE_FLAGS (type),
-                                       type);
+           type = make_qualified_type (newtype, type->instance_flags (), type);
          else
            type = newtype;
        }
@@ -2862,9 +2860,8 @@ check_typedef (struct type *type)
              with the complete type only if they are in the same
              objfile.  */
          if (TYPE_OBJFILE (SYMBOL_TYPE (sym)) == TYPE_OBJFILE (type))
-            type = make_qualified_type (SYMBOL_TYPE (sym),
-                                       TYPE_INSTANCE_FLAGS (type),
-                                       type);
+           type = make_qualified_type (SYMBOL_TYPE (sym),
+                                       type->instance_flags (), type);
          else
            type = SYMBOL_TYPE (sym);
         }
@@ -3197,6 +3194,10 @@ init_integer_type (struct objfile *objfile,
   if (unsigned_p)
     t->set_is_unsigned (true);
 
+  TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
+  TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
+  TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+
   return t;
 }
 
@@ -3231,6 +3232,10 @@ init_boolean_type (struct objfile *objfile,
   if (unsigned_p)
     t->set_is_unsigned (true);
 
+  TYPE_SPECIFIC_FIELD (t) = TYPE_SPECIFIC_INT;
+  TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_size = bit;
+  TYPE_MAIN_TYPE (t)->type_specific.int_stuff.bit_offset = 0;
+
   return t;
 }
 
@@ -4001,7 +4006,7 @@ check_types_equal (struct type *type1, struct type *type2,
       || type1->has_varargs () != type2->has_varargs ()
       || type1->is_vector () != type2->is_vector ()
       || TYPE_NOTTEXT (type1) != TYPE_NOTTEXT (type2)
-      || TYPE_INSTANCE_FLAGS (type1) != TYPE_INSTANCE_FLAGS (type2)
+      || type1->instance_flags () != type2->instance_flags ()
       || type1->num_fields () != type2->num_fields ())
     return false;
 
@@ -5191,6 +5196,16 @@ recursive_dump_type (struct type *type, int spaces)
        gdb_print_host_address (TYPE_SELF_TYPE (type), gdb_stdout);
        puts_filtered ("\n");
        break;
+
+    case TYPE_SPECIFIC_INT:
+      if (type->bit_size_differs_p ())
+       {
+         unsigned bit_size = type->bit_size ();
+         unsigned bit_off = type->bit_offset ();
+         printfi_filtered (spaces, " bit size = %u, bit offset = %u\n",
+                           bit_size, bit_off);
+       }
+      break;
     }
 
   if (spaces == 0)
@@ -5230,13 +5245,13 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
    types without duplicates.  We use OBJFILE's obstack, because
    OBJFILE is about to be deleted.  */
 
-htab_t
+htab_up
 create_copied_types_hash (struct objfile *objfile)
 {
-  return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
-                              NULL, &objfile->objfile_obstack,
-                              hashtab_obstack_allocate,
-                              dummy_obstack_deallocate);
+  return htab_up (htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
+                                       NULL, &objfile->objfile_obstack,
+                                       hashtab_obstack_allocate,
+                                       dummy_obstack_deallocate));
 }
 
 /* Recursively copy (deep copy) a dynamic attribute list of a type.  */
@@ -5414,6 +5429,12 @@ copy_type_recursive (struct objfile *objfile,
                          copy_type_recursive (objfile, TYPE_SELF_TYPE (type),
                                               copied_types));
       break;
+    case TYPE_SPECIFIC_INT:
+      TYPE_SPECIFIC_FIELD (new_type) = TYPE_SPECIFIC_INT;
+      TYPE_MAIN_TYPE (new_type)->type_specific.int_stuff
+       = TYPE_MAIN_TYPE (type)->type_specific.int_stuff;
+      break;
+
     default:
       gdb_assert_not_reached ("bad type_specific_kind");
     }
This page took 0.026613 seconds and 4 git commands to generate.