This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Make init_type/arch_type take a size in bits


Simon Marchi wrote:

> Since this is where we do the division by 
> TARGET_CHAR_BIT, and therefore assume (implicitly) that bit is a 
> multiple of TARGET_CHAR_BIT, I think this is where the assert should be 
> added.  To avoid adding them everywhere, we could make 
> arch_type/init_type take a size in bits, and do the division and assert 
> there.

As discussed, this changes the interfaces to init_type and arch_type
to take the type length in bits as input (instead of as bytes).  The
routine asserts that the length is a multiple of TARGET_CHAR_BIT.

For consistency, arch_flags_type is changed likewise, so that now
all type creation interfaces always use length in bits.

All callers are updated in the straightforward manner.

The assert actually found a bug in stabsread.c:read_range_type, where
the init_integer_type routine was called with a wrong argument (probably
a bug introduced with the conversion to use init_integer_type).

Bye,
Ulrich


ChangeLog:

	* gdbtypes.c (init_type): Change incoming argument from
	lenght-in-bytes to lenght-in-bits.  Assert length is a
	multiple of TARGET_CHAR_BITS.
	(arch_type, arch_flags_type): Likewise.
	(init_integer_type): Update call to init_type.
	(init_character_type): Likewise.
	(init_boolean_type): Likewise.
	(init_float_type): Likewise.
	(init_decfloat_type): Likewise.
	(init_complex_type): Likewise.
	(init_pointer_type): Likewise.
	(objfile_type): Likewise.
	(arch_integer_type): Update call to arch_type.
	(arch_character_type): Likewise.
	(arch_boolean_type): Likewise.
	(arch_float_type): Likewise.
	(arch_decfloat_type): Likewise.
	(arch_complex_type): Likewise.
	(arch_pointer_type): Likewise.
	(gdbtypes_post_init): Likewise.

	* dwarf2read.c (dwarf2_init_float_type): Update call to init_type.
	(read_base_type): Likewise.
	* mdebugread.c (basic_type): Likewise.
	* stabsread.c (dbx_init_float_type): Likewise.
	(rs6000_builtin_type): Likewise.
	(read_range_type): Likewise.  Also, fix call to init_integer_type
	with erroneous length argument.

	* ada-lang.c (ada_language_arch_info): Update call to arch_type.
	* d-lang.c (build_d_types): Likewise.
	* f-lang.c (build_fortran_types): Likewise.
	* go-lang.c (build_go_types): Likewise.
	* opencl-lang.c (build_opencl_types): Likewise.
	* jit.c (finalize_symtab): Likewise.
	* gnu-v3-abi.c (build_std_type_info_type): Likewise.
	* target-descriptions.c (tdesc_gdb_type): Likewise.  Also,
	update call to arch_flags_type.

	* linux-tdep.c (linux_get_siginfo_type_with_fields): Update call to
	arch_type.
	* fbsd-tdep.c (fbsd_get_siginfo_type): Likewise.
	* windows-tdep.c (windows_get_tlb_type): Likewise.

	* avr-tdep.c (avr_gdbarch_init): Update call to arch_type.
	* ft32-tdep.c (ft32_gdbarch_init): Likewise.
	* m32c-tdep.c (make_types): Likewise.
	* rl78-tdep.c (rl78_gdbarch_init): Likewise.
	(rl78_psw_type): Update call to arch_flags_type.
	* m68k-tdep.c (m68k_ps_type): Update call to arch_flags_type.
	* rx-tdep.c (rx_psw_type): Likewise.
	(rx_fpsw_type): Likewise.
	* sparc-tdep.c (sparc_psr_type): Likewise.
	(sparc_fsr_type): Likewise.
	* sparc64-tdep.c (sparc64_pstate_type): Likewise.
	(sparc64_ccr_type): Likewise.
	(sparc64_fsr_type): Likewise.
	(sparc64_fprs_type): Likewise.

Index: binutils-gdb/gdb/gdbtypes.h
===================================================================
--- binutils-gdb.orig/gdb/gdbtypes.h
+++ binutils-gdb/gdb/gdbtypes.h
@@ -1683,7 +1683,7 @@ struct field *append_composite_type_fiel
    type is created using arch_flag_type().  Flags are then added using
    append_flag_type_field() and append_flag_type_flag().  */
 extern struct type *arch_flags_type (struct gdbarch *gdbarch,
-				     const char *name, int length);
+				     const char *name, int bit);
 extern void append_flags_type_field (struct type *type,
 				     int start_bitpos, int nr_bits,
 				     struct type *field_type, const char *name);
Index: binutils-gdb/gdb/gdbtypes.c
===================================================================
--- binutils-gdb.orig/gdb/gdbtypes.c
+++ binutils-gdb/gdb/gdbtypes.c
@@ -2758,14 +2758,15 @@ verify_floatformat (int bit, const struc
    least as long as OBJFILE.  */
 
 struct type *
-init_type (struct objfile *objfile, enum type_code code, int length,
+init_type (struct objfile *objfile, enum type_code code, int bit,
 	   const char *name)
 {
   struct type *type;
 
   type = alloc_type (objfile);
   set_type_code (type, code);
-  TYPE_LENGTH (type) = length;
+  gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
+  TYPE_LENGTH (type) = bit / TARGET_CHAR_BIT;
   TYPE_NAME (type) = name;
 
   return type;
@@ -2791,7 +2792,7 @@ init_integer_type (struct objfile *objfi
 {
   struct type *t;
 
-  t = init_type (objfile, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_INT, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -2808,7 +2809,7 @@ init_character_type (struct objfile *obj
 {
   struct type *t;
 
-  t = init_type (objfile, TYPE_CODE_CHAR, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_CHAR, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -2825,7 +2826,7 @@ init_boolean_type (struct objfile *objfi
 {
   struct type *t;
 
-  t = init_type (objfile, TYPE_CODE_BOOL, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_BOOL, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -2845,7 +2846,7 @@ init_float_type (struct objfile *objfile
   struct type *t;
 
   bit = verify_floatformat (bit, floatformats);
-  t = init_type (objfile, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_FLT, bit, name);
   TYPE_FLOATFORMAT (t) = floatformats;
 
   return t;
@@ -2859,7 +2860,7 @@ init_decfloat_type (struct objfile *objf
 {
   struct type *t;
 
-  t = init_type (objfile, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_DECFLOAT, bit, name);
   return t;
 }
 
@@ -2873,7 +2874,7 @@ init_complex_type (struct objfile *objfi
   struct type *t;
 
   t = init_type (objfile, TYPE_CODE_COMPLEX,
-		 2 * TYPE_LENGTH (target_type), name);
+		 2 * TYPE_LENGTH (target_type) * TARGET_CHAR_BIT, name);
   TYPE_TARGET_TYPE (t) = target_type;
   return t;
 }
@@ -2889,7 +2890,7 @@ init_pointer_type (struct objfile *objfi
 {
   struct type *t;
 
-  t = init_type (objfile, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
+  t = init_type (objfile, TYPE_CODE_PTR, bit, name);
   TYPE_TARGET_TYPE (t) = target_type;
   TYPE_UNSIGNED (t) = 1;
   return t;
@@ -4832,13 +4833,14 @@ copy_type (const struct type *type)
 
 struct type *
 arch_type (struct gdbarch *gdbarch,
-	   enum type_code code, int length, const char *name)
+	   enum type_code code, int bit, const char *name)
 {
   struct type *type;
 
   type = alloc_type_arch (gdbarch);
   set_type_code (type, code);
-  TYPE_LENGTH (type) = length;
+  gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
+  TYPE_LENGTH (type) = bit / TARGET_CHAR_BIT;
 
   if (name)
     TYPE_NAME (type) = gdbarch_obstack_strdup (gdbarch, name);
@@ -4856,7 +4858,7 @@ arch_integer_type (struct gdbarch *gdbar
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_INT, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -4873,7 +4875,7 @@ arch_character_type (struct gdbarch *gdb
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_CHAR, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -4890,7 +4892,7 @@ arch_boolean_type (struct gdbarch *gdbar
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_BOOL, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
 
@@ -4910,7 +4912,7 @@ arch_float_type (struct gdbarch *gdbarch
   struct type *t;
 
   bit = verify_floatformat (bit, floatformats);
-  t = arch_type (gdbarch, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_FLT, bit, name);
   TYPE_FLOATFORMAT (t) = floatformats;
 
   return t;
@@ -4924,7 +4926,7 @@ arch_decfloat_type (struct gdbarch *gdba
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit, name);
   return t;
 }
 
@@ -4938,7 +4940,7 @@ arch_complex_type (struct gdbarch *gdbar
   struct type *t;
 
   t = arch_type (gdbarch, TYPE_CODE_COMPLEX,
-		 2 * TYPE_LENGTH (target_type), name);
+		 2 * TYPE_LENGTH (target_type) * TARGET_CHAR_BIT, name);
   TYPE_TARGET_TYPE (t) = target_type;
   return t;
 }
@@ -4954,27 +4956,26 @@ arch_pointer_type (struct gdbarch *gdbar
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
+  t = arch_type (gdbarch, TYPE_CODE_PTR, bit, name);
   TYPE_TARGET_TYPE (t) = target_type;
   TYPE_UNSIGNED (t) = 1;
   return t;
 }
 
 /* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
-   NAME is the type name.  LENGTH is the size of the flag word in bytes.  */
+   NAME is the type name.  BIT is the size of the flag word in bits.  */
 
 struct type *
-arch_flags_type (struct gdbarch *gdbarch, const char *name, int length)
+arch_flags_type (struct gdbarch *gdbarch, const char *name, int bit)
 {
-  int max_nfields = length * TARGET_CHAR_BIT;
   struct type *type;
 
-  type = arch_type (gdbarch, TYPE_CODE_FLAGS, length, name);
+  type = arch_type (gdbarch, TYPE_CODE_FLAGS, bit, name);
   TYPE_UNSIGNED (type) = 1;
   TYPE_NFIELDS (type) = 0;
   /* Pre-allocate enough space assuming every field is one bit.  */
   TYPE_FIELDS (type)
-    = (struct field *) TYPE_ZALLOC (type, max_nfields * sizeof (struct field));
+    = (struct field *) TYPE_ZALLOC (type, bit * sizeof (struct field));
 
   return type;
 }
@@ -5119,7 +5120,7 @@ gdbtypes_post_init (struct gdbarch *gdba
 
   /* Basic types.  */
   builtin_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   builtin_type->builtin_char
     = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
 			 !gdbarch_char_signed (gdbarch), "char");
@@ -5170,9 +5171,9 @@ gdbtypes_post_init (struct gdbarch *gdba
     = arch_complex_type (gdbarch, "double complex",
 			 builtin_type->builtin_double);
   builtin_type->builtin_string
-    = arch_type (gdbarch, TYPE_CODE_STRING, 1, "string");
+    = arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
   builtin_type->builtin_bool
-    = arch_type (gdbarch, TYPE_CODE_BOOL, 1, "bool");
+    = arch_type (gdbarch, TYPE_CODE_BOOL, TARGET_CHAR_BIT, "bool");
 
   /* The following three are about decimal floating point types, which
      are 32-bits, 64-bits and 128-bits respectively.  */
@@ -5269,7 +5270,7 @@ objfile_type (struct objfile *objfile)
 
   /* Basic types.  */
   objfile_type->builtin_void
-    = init_type (objfile, TYPE_CODE_VOID, 1, "void");
+    = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   objfile_type->builtin_char
     = init_integer_type (objfile, TARGET_CHAR_BIT,
 			 !gdbarch_char_signed (gdbarch), "char");
@@ -5321,10 +5322,10 @@ objfile_type (struct objfile *objfile)
   /* The following set of types is used for symbols with no
      debug information.  */
   objfile_type->nodebug_text_symbol
-    = init_type (objfile, TYPE_CODE_FUNC, 1,
+    = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT,
 		 "<text variable, no debug info>");
   objfile_type->nodebug_text_gnu_ifunc_symbol
-    = init_type (objfile, TYPE_CODE_FUNC, 1,
+    = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT,
 		 "<text gnu-indirect-function variable, no debug info>");
   /* Ifunc resolvers return a function address.  */
   TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol)
Index: binutils-gdb/gdb/dwarf2read.c
===================================================================
--- binutils-gdb.orig/gdb/dwarf2read.c
+++ binutils-gdb/gdb/dwarf2read.c
@@ -15211,7 +15211,7 @@ dwarf2_init_float_type (struct objfile *
   if (format)
     type = init_float_type (objfile, bits, name, format);
   else
-    type = init_type (objfile, TYPE_CODE_ERROR, bits / TARGET_CHAR_BIT, name);
+    type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
 
   return type;
 }
@@ -15249,7 +15249,7 @@ read_base_type (struct die_info *die, st
     {
       case DW_ATE_address:
 	/* Turn DW_ATE_address into a void * pointer.  */
-	type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
+	type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
 	type = init_pointer_type (objfile, bits, name, type);
 	break;
       case DW_ATE_boolean:
@@ -15315,8 +15315,7 @@ read_base_type (struct die_info *die, st
       default:
 	complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
 		   dwarf_type_encoding_name (encoding));
-	type = init_type (objfile, TYPE_CODE_ERROR,
-			  bits / TARGET_CHAR_BIT, name);
+	type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
 	break;
     }
 
Index: binutils-gdb/gdb/mdebugread.c
===================================================================
--- binutils-gdb.orig/gdb/mdebugread.c
+++ binutils-gdb/gdb/mdebugread.c
@@ -1469,14 +1469,13 @@ basic_type (int bt, struct objfile *objf
 
     case btFloatDec:
       tp = init_type (objfile, TYPE_CODE_ERROR,
-		      gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
-		      "floating decimal");
+		      gdbarch_double_bit (gdbarch), "floating decimal");
       break;
 
     case btString:
       /* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
 	 FIXME.  */
-      tp = init_type (objfile, TYPE_CODE_STRING, 1, "string");
+      tp = init_type (objfile, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
       break;
 
     case btVoid:
Index: binutils-gdb/gdb/stabsread.c
===================================================================
--- binutils-gdb.orig/gdb/stabsread.c
+++ binutils-gdb/gdb/stabsread.c
@@ -368,7 +368,7 @@ dbx_init_float_type (struct objfile *obj
   if (format)
     type = init_float_type (objfile, bits, NULL, format);
   else
-    type = init_type (objfile, TYPE_CODE_ERROR, bits / TARGET_CHAR_BIT, NULL);
+    type = init_type (objfile, TYPE_CODE_ERROR, bits, NULL);
 
   return type;
 }
@@ -2153,7 +2153,7 @@ rs6000_builtin_type (int typenum, struct
       rettype = init_integer_type (objfile, 32, 1, "unsigned long");
       break;
     case 11:
-      rettype = init_type (objfile, TYPE_CODE_VOID, 1, "void");
+      rettype = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
       break;
     case 12:
       /* IEEE single precision (32 bit).  */
@@ -3835,7 +3835,8 @@ read_sun_builtin_type (const char **pp,
 
   if (type_bits == 0)
     {
-      struct type *type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
+      struct type *type = init_type (objfile, TYPE_CODE_VOID,
+				     TARGET_CHAR_BIT, NULL);
       if (unsigned_type)
         TYPE_UNSIGNED (type) = 1;
       return type;
@@ -4147,7 +4148,7 @@ read_range_type (const char **pp, int ty
 
   /* A type defined as a subrange of itself, with bounds both 0, is void.  */
   if (self_subrange && n2 == 0 && n3 == 0)
-    return init_type (objfile, TYPE_CODE_VOID, 1, NULL);
+    return init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
 
   /* If n3 is zero and n2 is positive, we want a floating type, and n2
      is the width in bytes.
@@ -4193,7 +4194,8 @@ read_range_type (const char **pp, int ty
      itself with range 0-127.  */
   else if (self_subrange && n2 == 0 && n3 == 127)
     {
-      struct type *type = init_integer_type (objfile, 1, 0, NULL);
+      struct type *type = init_integer_type (objfile, TARGET_CHAR_BIT,
+					     0, NULL);
       TYPE_NOSIGN (type) = 1;
       return type;
     }
Index: binutils-gdb/gdb/ada-lang.c
===================================================================
--- binutils-gdb.orig/gdb/ada-lang.c
+++ binutils-gdb/gdb/ada-lang.c
@@ -13859,7 +13859,8 @@ ada_language_arch_info (struct gdbarch *
     = builtin->builtin_void;
 
   lai->primitive_type_vector [ada_primitive_type_system_address]
-    = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, 1, "void"));
+    = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
+				      "void"));
   TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
     = "system__address";
 
Index: binutils-gdb/gdb/d-lang.c
===================================================================
--- binutils-gdb.orig/gdb/d-lang.c
+++ binutils-gdb/gdb/d-lang.c
@@ -263,7 +263,7 @@ build_d_types (struct gdbarch *gdbarch)
 
   /* Basic types.  */
   builtin_d_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   builtin_d_type->builtin_bool
     = arch_boolean_type (gdbarch, 8, 1, "bool");
   builtin_d_type->builtin_byte
Index: binutils-gdb/gdb/f-lang.c
===================================================================
--- binutils-gdb.orig/gdb/f-lang.c
+++ binutils-gdb/gdb/f-lang.c
@@ -304,7 +304,7 @@ build_fortran_types (struct gdbarch *gdb
     = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_f_type);
 
   builtin_f_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "VOID");
+    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "VOID");
 
   builtin_f_type->builtin_character
     = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
Index: binutils-gdb/gdb/go-lang.c
===================================================================
--- binutils-gdb.orig/gdb/go-lang.c
+++ binutils-gdb/gdb/go-lang.c
@@ -621,7 +621,7 @@ build_go_types (struct gdbarch *gdbarch)
     = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_go_type);
 
   builtin_go_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   builtin_go_type->builtin_char
     = arch_character_type (gdbarch, 8, 1, "char");
   builtin_go_type->builtin_bool
Index: binutils-gdb/gdb/opencl-lang.c
===================================================================
--- binutils-gdb.orig/gdb/opencl-lang.c
+++ binutils-gdb/gdb/opencl-lang.c
@@ -1171,7 +1171,7 @@ build_opencl_types (struct gdbarch *gdba
   types[opencl_primitive_type_uintptr_t]
     = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
   types[opencl_primitive_type_void]
-    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
 
   return types;
 }
Index: binutils-gdb/gdb/jit.c
===================================================================
--- binutils-gdb.orig/gdb/jit.c
+++ binutils-gdb/gdb/jit.c
@@ -698,7 +698,7 @@ finalize_symtab (struct gdb_symtab *stab
       struct symbol *block_name = allocate_symbol (objfile);
       struct type *block_type = arch_type (get_objfile_arch (objfile),
 					   TYPE_CODE_VOID,
-					   1,
+					   TARGET_CHAR_BIT,
 					   "void");
 
       BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack,
Index: binutils-gdb/gdb/gnu-v3-abi.c
===================================================================
--- binutils-gdb.orig/gdb/gnu-v3-abi.c
+++ binutils-gdb/gdb/gnu-v3-abi.c
@@ -1024,7 +1024,7 @@ build_std_type_info_type (struct gdbarch
 
   gdb_assert (field == (field_list + 2));
 
-  t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);
+  t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
   TYPE_NFIELDS (t) = field - field_list;
   TYPE_FIELDS (t) = field_list;
   TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info";
Index: binutils-gdb/gdb/target-descriptions.c
===================================================================
--- binutils-gdb.orig/gdb/target-descriptions.c
+++ binutils-gdb/gdb/target-descriptions.c
@@ -1072,7 +1072,7 @@ tdesc_gdb_type (struct gdbarch *gdbarch,
 	int ix;
 
 	type = arch_flags_type (gdbarch, tdesc_type->name,
-				tdesc_type->u.u.size);
+				tdesc_type->u.u.size * TARGET_CHAR_BIT);
 	for (ix = 0;
 	     VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
 	     ix++)
@@ -1095,7 +1095,8 @@ tdesc_gdb_type (struct gdbarch *gdbarch,
 	int ix;
 
 	type = arch_type (gdbarch, TYPE_CODE_ENUM,
-			  tdesc_type->u.u.size, tdesc_type->name);
+			  tdesc_type->u.u.size * TARGET_CHAR_BIT,
+			  tdesc_type->name);
 	TYPE_UNSIGNED (type) = 1;
 	for (ix = 0;
 	     VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
Index: binutils-gdb/gdb/linux-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/linux-tdep.c
+++ binutils-gdb/gdb/linux-tdep.c
@@ -279,19 +279,20 @@ linux_get_siginfo_type_with_fields (stru
 
   /* __pid_t */
   pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			TYPE_LENGTH (int_type), "__pid_t");
+			TYPE_LENGTH (int_type) * TARGET_CHAR_BIT, "__pid_t");
   TYPE_TARGET_TYPE (pid_type) = int_type;
   TYPE_TARGET_STUB (pid_type) = 1;
 
   /* __uid_t */
   uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			TYPE_LENGTH (uint_type), "__uid_t");
+			TYPE_LENGTH (uint_type) * TARGET_CHAR_BIT, "__uid_t");
   TYPE_TARGET_TYPE (uid_type) = uint_type;
   TYPE_TARGET_STUB (uid_type) = 1;
 
   /* __clock_t */
   clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			  TYPE_LENGTH (long_type), "__clock_t");
+			  TYPE_LENGTH (long_type) * TARGET_CHAR_BIT,
+			  "__clock_t");
   TYPE_TARGET_TYPE (clock_type) = long_type;
   TYPE_TARGET_STUB (clock_type) = 1;
 
Index: binutils-gdb/gdb/fbsd-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/fbsd-tdep.c
+++ binutils-gdb/gdb/fbsd-tdep.c
@@ -432,13 +432,14 @@ fbsd_get_siginfo_type (struct gdbarch *g
 
   /* __pid_t */
   pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			TYPE_LENGTH (int32_type), "__pid_t");
+			TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t");
   TYPE_TARGET_TYPE (pid_type) = int32_type;
   TYPE_TARGET_STUB (pid_type) = 1;
 
   /* __uid_t */
   uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			TYPE_LENGTH (uint32_type), "__uid_t");
+			TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT,
+			"__uid_t");
   TYPE_TARGET_TYPE (uid_type) = uint32_type;
   TYPE_TARGET_STUB (uid_type) = 1;
 
Index: binutils-gdb/gdb/windows-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/windows-tdep.c
+++ binutils-gdb/gdb/windows-tdep.c
@@ -143,7 +143,8 @@ windows_get_tlb_type (struct gdbarch *gd
   TYPE_NAME (seh_type) = xstrdup ("seh");
 
   seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    TYPE_LENGTH (void_ptr_type), NULL);
+			    TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT,
+			    NULL);
   TYPE_TARGET_TYPE (seh_ptr_type) = seh_type;
 
   append_composite_type_field (seh_type, "next_seh", seh_ptr_type);
@@ -163,7 +164,8 @@ windows_get_tlb_type (struct gdbarch *gd
   append_composite_type_field (peb_ldr_type, "entry_in_progress",
 			       void_ptr_type);
   peb_ldr_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    TYPE_LENGTH (void_ptr_type), NULL);
+				TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT,
+				NULL);
   TYPE_TARGET_TYPE (peb_ldr_ptr_type) = peb_ldr_type;
 
 
@@ -181,7 +183,8 @@ windows_get_tlb_type (struct gdbarch *gd
   append_composite_type_field (peb_type, "process_heap", void_ptr_type);
   append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type);
   peb_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    TYPE_LENGTH (void_ptr_type), NULL);
+			    TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT,
+			    NULL);
   TYPE_TARGET_TYPE (peb_ptr_type) = peb_type;
 
 
@@ -224,7 +227,8 @@ windows_get_tlb_type (struct gdbarch *gd
   append_composite_type_field (tib_type, "last_error_number", dword_ptr_type);
 
   tib_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    TYPE_LENGTH (void_ptr_type), NULL);
+			    TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT,
+			    NULL);
   TYPE_TARGET_TYPE (tib_ptr_type) = tib_type;
 
   last_tlb_type = tib_ptr_type;
Index: binutils-gdb/gdb/avr-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/avr-tdep.c
+++ binutils-gdb/gdb/avr-tdep.c
@@ -1460,7 +1460,8 @@ avr_gdbarch_init (struct gdbarch_info in
 
   /* Create a type for PC.  We can't use builtin types here, as they may not
      be defined.  */
-  tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+  tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
+			       "void");
   tdep->func_void_type = make_function_type (tdep->void_type, NULL);
   tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
 				     tdep->func_void_type);
Index: binutils-gdb/gdb/ft32-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/ft32-tdep.c
+++ binutils-gdb/gdb/ft32-tdep.c
@@ -598,7 +598,7 @@ ft32_gdbarch_init (struct gdbarch_info i
 
   /* Create a type for PC.  We can't use builtin types here, as they may not
      be defined.  */
-  void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+  void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   func_void_type = make_function_type (void_type, NULL);
   tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
 				     func_void_type);
Index: binutils-gdb/gdb/m32c-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/m32c-tdep.c
+++ binutils-gdb/gdb/m32c-tdep.c
@@ -190,7 +190,7 @@ make_types (struct gdbarch *arch)
 
   /* The builtin_type_mumble variables are sometimes uninitialized when
      this is called, so we avoid using them.  */
-  tdep->voyd = arch_type (arch, TYPE_CODE_VOID, 1, "void");
+  tdep->voyd = arch_type (arch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->ptr_voyd
     = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd);
   tdep->func_voyd = lookup_function_type (tdep->voyd);
Index: binutils-gdb/gdb/rl78-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/rl78-tdep.c
+++ binutils-gdb/gdb/rl78-tdep.c
@@ -271,7 +271,7 @@ rl78_psw_type (struct gdbarch *gdbarch)
   if (tdep->rl78_psw_type == NULL)
     {
       tdep->rl78_psw_type = arch_flags_type (gdbarch,
-					     "builtin_type_rl78_psw", 1);
+					     "builtin_type_rl78_psw", 8);
       append_flags_type_flag (tdep->rl78_psw_type, 0, "CY");
       append_flags_type_flag (tdep->rl78_psw_type, 1, "ISP0");
       append_flags_type_flag (tdep->rl78_psw_type, 2, "ISP1");
@@ -1417,7 +1417,8 @@ rl78_gdbarch_init (struct gdbarch_info i
   tdep->elf_flags = elf_flags;
 
   /* Initialize types.  */
-  tdep->rl78_void = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+  tdep->rl78_void = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
+			       "void");
   tdep->rl78_uint8 = arch_integer_type (gdbarch, 8, 1, "uint8_t");
   tdep->rl78_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t");
   tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t");
Index: binutils-gdb/gdb/m68k-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/m68k-tdep.c
+++ binutils-gdb/gdb/m68k-tdep.c
@@ -73,7 +73,7 @@ m68k_ps_type (struct gdbarch *gdbarch)
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_m68k_ps", 4);
+      type = arch_flags_type (gdbarch, "builtin_type_m68k_ps", 32);
       append_flags_type_flag (type, 0, "C");
       append_flags_type_flag (type, 1, "V");
       append_flags_type_flag (type, 2, "Z");
Index: binutils-gdb/gdb/rx-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/rx-tdep.c
+++ binutils-gdb/gdb/rx-tdep.c
@@ -159,7 +159,7 @@ rx_psw_type (struct gdbarch *gdbarch)
 
   if (tdep->rx_psw_type == NULL)
     {
-      tdep->rx_psw_type = arch_flags_type (gdbarch, "rx_psw_type", 4);
+      tdep->rx_psw_type = arch_flags_type (gdbarch, "rx_psw_type", 32);
       append_flags_type_flag (tdep->rx_psw_type, 0, "C");
       append_flags_type_flag (tdep->rx_psw_type, 1, "Z");
       append_flags_type_flag (tdep->rx_psw_type, 2, "S");
@@ -184,7 +184,7 @@ rx_fpsw_type (struct gdbarch *gdbarch)
 
   if (tdep->rx_fpsw_type == NULL)
     {
-      tdep->rx_fpsw_type = arch_flags_type (gdbarch, "rx_fpsw_type", 4);
+      tdep->rx_fpsw_type = arch_flags_type (gdbarch, "rx_fpsw_type", 32);
       append_flags_type_flag (tdep->rx_fpsw_type, 0, "RM0");
       append_flags_type_flag (tdep->rx_fpsw_type, 1, "RM1");
       append_flags_type_flag (tdep->rx_fpsw_type, 2, "CV");
Index: binutils-gdb/gdb/sparc-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/sparc-tdep.c
+++ binutils-gdb/gdb/sparc-tdep.c
@@ -409,7 +409,7 @@ sparc_psr_type (struct gdbarch *gdbarch)
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc_psr", 4);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc_psr", 32);
       append_flags_type_flag (type, 5, "ET");
       append_flags_type_flag (type, 6, "PS");
       append_flags_type_flag (type, 7, "S");
@@ -431,7 +431,7 @@ sparc_fsr_type (struct gdbarch *gdbarch)
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc_fsr", 4);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc_fsr", 32);
       append_flags_type_flag (type, 0, "NXA");
       append_flags_type_flag (type, 1, "DZA");
       append_flags_type_flag (type, 2, "UFA");
Index: binutils-gdb/gdb/sparc64-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/sparc64-tdep.c
+++ binutils-gdb/gdb/sparc64-tdep.c
@@ -665,7 +665,7 @@ sparc64_pstate_type (struct gdbarch *gdb
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc64_pstate", 8);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc64_pstate", 64);
       append_flags_type_flag (type, 0, "AG");
       append_flags_type_flag (type, 1, "IE");
       append_flags_type_flag (type, 2, "PRIV");
@@ -692,7 +692,7 @@ sparc64_ccr_type (struct gdbarch *gdbarc
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc64_ccr", 8);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc64_ccr", 64);
       append_flags_type_flag (type, 0, "icc.c");
       append_flags_type_flag (type, 1, "icc.v");
       append_flags_type_flag (type, 2, "icc.z");
@@ -717,7 +717,7 @@ sparc64_fsr_type (struct gdbarch *gdbarc
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc64_fsr", 8);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc64_fsr", 64);
       append_flags_type_flag (type, 0, "NXC");
       append_flags_type_flag (type, 1, "DZC");
       append_flags_type_flag (type, 2, "UFC");
@@ -750,7 +750,7 @@ sparc64_fprs_type (struct gdbarch *gdbar
     {
       struct type *type;
 
-      type = arch_flags_type (gdbarch, "builtin_type_sparc64_fprs", 8);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc64_fprs", 64);
       append_flags_type_flag (type, 0, "DL");
       append_flags_type_flag (type, 1, "DU");
       append_flags_type_flag (type, 2, "FEF");

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]