]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make init_type/arch_type take a size in bits
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 27 Sep 2017 17:02:00 +0000 (19:02 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 27 Sep 2017 17:02:00 +0000 (19:02 +0200)
This changes the interfaces to init_type and arch_type to take the
type length in bits as input (instead of as bytes).  The routines
assert 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 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).

gdb/ChangeLog
2017-09-27  Ulrich Weigand  <uweigand@de.ibm.com>

* gdbtypes.c (init_type): Change incoming argument from
length-in-bytes to length-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_gdb_vtable_type): Likewise.
(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.

25 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/avr-tdep.c
gdb/d-lang.c
gdb/dwarf2read.c
gdb/f-lang.c
gdb/fbsd-tdep.c
gdb/ft32-tdep.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/gnu-v3-abi.c
gdb/go-lang.c
gdb/jit.c
gdb/linux-tdep.c
gdb/m32c-tdep.c
gdb/m68k-tdep.c
gdb/mdebugread.c
gdb/opencl-lang.c
gdb/rl78-tdep.c
gdb/rx-tdep.c
gdb/sparc-tdep.c
gdb/sparc64-tdep.c
gdb/stabsread.c
gdb/target-descriptions.c
gdb/windows-tdep.c

index 48fb9b54f38a5c0c698fd0bcc0ee43b42d796c11..7de454209985ed65a127c9414957706ae67bdb90 100644 (file)
@@ -1,3 +1,65 @@
+2017-09-27  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * gdbtypes.c (init_type): Change incoming argument from
+       length-in-bytes to length-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_gdb_vtable_type): Likewise.
+       (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.
+
 2017-09-27  Tom Tromey  <tom@tromey.com>
 
        * findcmd.c (find_command): Constify.
index ea051c3e2c8d1b9f33b22aceac5adeb28ca2a517..b5a3b655b9ee174cc50be2ebc51bd0ec4c41a007 100644 (file)
@@ -13859,7 +13859,8 @@ ada_language_arch_info (struct gdbarch *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 6818f334e7528a2720965fee83b741b5a9f47d29..9aca8c32e5e7606bb704b32a59838d31d3970605 100644 (file)
@@ -1460,7 +1460,8 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* 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 277df012b3561b19d54680d45a491fed7271a116..e3220d41f6e51b192d6347694a281b0af9b155ff 100644 (file)
@@ -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 8c056da59fad6dd4972c98346b0ae24735d4130e..7a59c1b4358276b0173eb965dc8b8051403d1c4f 100644 (file)
@@ -15212,7 +15212,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
   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;
 }
@@ -15250,7 +15250,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
     {
       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:
@@ -15316,8 +15316,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
       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 54f665d00708bbed06b9f07e9af37c351d8c566b..073d5291f7498b55301ba47718b3dc6d05dcdd67 100644 (file)
@@ -304,7 +304,7 @@ build_fortran_types (struct gdbarch *gdbarch)
     = 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 19082696326ab2f2ef2209e5d8340a353008b140..727e28a6456bb3c20a957c9b48fd297849172ee8 100644 (file)
@@ -432,13 +432,14 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch)
 
   /* __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 a988421ec3964cf78105d56f27e9a6080e0a94b5..0e61a4bdfe6d19771c2db11de86a5b39dfaa9290 100644 (file)
@@ -598,7 +598,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* 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 37162d050d0578082632f67183f01d26805d758e..bec1fd5f2d08940c6d1b6c6178c57deff1cc10cf 100644 (file)
@@ -2757,14 +2757,15 @@ verify_floatformat (int bit, const struct floatformat **floatformats)
    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;
@@ -2790,7 +2791,7 @@ init_integer_type (struct objfile *objfile,
 {
   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;
 
@@ -2807,7 +2808,7 @@ init_character_type (struct objfile *objfile,
 {
   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;
 
@@ -2824,7 +2825,7 @@ init_boolean_type (struct objfile *objfile,
 {
   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;
 
@@ -2844,7 +2845,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;
@@ -2858,7 +2859,7 @@ init_decfloat_type (struct objfile *objfile, int bit, const char *name)
 {
   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;
 }
 
@@ -2872,7 +2873,7 @@ init_complex_type (struct objfile *objfile,
   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;
 }
@@ -2888,7 +2889,7 @@ init_pointer_type (struct objfile *objfile,
 {
   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;
@@ -4831,13 +4832,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);
@@ -4855,7 +4857,7 @@ arch_integer_type (struct gdbarch *gdbarch,
 {
   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;
 
@@ -4872,7 +4874,7 @@ arch_character_type (struct gdbarch *gdbarch,
 {
   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;
 
@@ -4889,7 +4891,7 @@ arch_boolean_type (struct gdbarch *gdbarch,
 {
   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;
 
@@ -4909,7 +4911,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;
@@ -4923,7 +4925,7 @@ arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name)
 {
   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;
 }
 
@@ -4937,7 +4939,7 @@ arch_complex_type (struct gdbarch *gdbarch,
   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;
 }
@@ -4953,27 +4955,26 @@ arch_pointer_type (struct gdbarch *gdbarch,
 {
   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;
 }
@@ -5118,7 +5119,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
 
   /* 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");
@@ -5169,9 +5170,9 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
     = 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.  */
@@ -5268,7 +5269,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");
@@ -5320,10 +5321,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 8d6fd9bb908a39974305c9bd281db30ba589f9f1..c96a3287d32c92f58b168e43319c92bd55273b38 100644 (file)
@@ -1683,7 +1683,7 @@ struct field *append_composite_type_field_raw (struct type *t, const char *name,
    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 aad812b47ac1ee897e7cdba2961a47c9aa491c79..2accc60efc6822d2247e5f27efc29e67583f1e08 100644 (file)
@@ -161,7 +161,7 @@ build_gdb_vtable_type (struct gdbarch *arch)
   /* We assumed in the allocation above that there were four fields.  */
   gdb_assert (field == (field_list + 4));
 
-  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_abi_vtable";
@@ -1024,7 +1024,7 @@ build_std_type_info_type (struct gdbarch *arch)
 
   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 7441bb30f6fbd56dd57670bb434e9298c06c6f5b..f66535ee61ea69938733383ca4568cba608cde69 100644 (file)
@@ -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 a8e63b349e63fe357d31546665c9785fd136dfd4..c19d3523a0fd510c457beea16008a2fbdc3d937d 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -697,7 +697,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       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 9ca1acab27714514fb1c3c99a9353ae39bf5973b..5dd87b7e847bcc5e17ed8c59db8a0cbaad4a01af 100644 (file)
@@ -279,19 +279,20 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
 
   /* __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 73591413c841b8582ae6f2211fea63232098a438..3a4dbda52bf02a3b4864b585698123a33e57e257 100644 (file)
@@ -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 afd86782198b3e01f060829967ed2ecd95a6e65d..ce126a8b814bd96df4dddb23100b70e805b1dd1c 100644 (file)
@@ -72,7 +72,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 d9942166c5c3c921f87f744a545ac9befdded117..13140e707d9e323fad86046b566da03e25da6d3c 100644 (file)
@@ -1469,14 +1469,13 @@ basic_type (int bt, struct objfile *objfile)
 
     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 a9c9a3460ee2f43ad733de565aca09850e03db1b..6a7232733adfeadadc42d08c75ea195bc1ad9300 100644 (file)
@@ -1171,7 +1171,7 @@ build_opencl_types (struct gdbarch *gdbarch)
   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 56abe28f5e1cae67c9aa1465ec9d97e6c11a6e17..c3d5352eacd3f2c58707b63f21a3a561caa69d8d 100644 (file)
@@ -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 info, struct gdbarch_list *arches)
   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 d1bc0b24276fac17820ded5bb222bfaca5bb29f0..ac2b68f33f366cddbb508be1920e6857eaf98868 100644 (file)
@@ -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 949c50104d83bbcf1a642d5cda22d2811a4064b4..8bb69f5e36e1feed2afce1eb47c58ae368cea332 100644 (file)
@@ -410,7 +410,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");
@@ -432,7 +432,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 a5ca434c289d82ba211f16928c1c4e262b7eda6d..8722f0acc80c73931e7bce34b3b09421a432cc46 100644 (file)
@@ -666,7 +666,7 @@ sparc64_pstate_type (struct gdbarch *gdbarch)
     {
       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");
@@ -693,7 +693,7 @@ sparc64_ccr_type (struct gdbarch *gdbarch)
     {
       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");
@@ -718,7 +718,7 @@ sparc64_fsr_type (struct gdbarch *gdbarch)
     {
       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");
@@ -751,7 +751,7 @@ sparc64_fprs_type (struct gdbarch *gdbarch)
     {
       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");
index d9a4d5e1d7e3430672bfcf8b634ceb966a302ba7..c51b3c7bf1f14183a8a7027f436aba5a7c412f69 100644 (file)
@@ -368,7 +368,7 @@ dbx_init_float_type (struct objfile *objfile, int bits)
   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 objfile *objfile)
       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, int typenums[2], struct objfile *objfile
 
   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 typenums[2], int type_size,
 
   /* 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 typenums[2], int type_size,
      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 6858ee1be1e67c147dc43822708cee0c44e5c9c9..06cfbb50e2c56ba3d0a9a416159607e32df4859b 100644 (file)
@@ -1067,7 +1067,7 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
        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++)
@@ -1090,7 +1090,8 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
        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 49402d372a31a95937dff4bd70a7af24c0453e5e..98b6d2b9324902d60177bde0ece4c9d2954ffade 100644 (file)
@@ -143,7 +143,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch)
   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 *gdbarch)
   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 *gdbarch)
   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 *gdbarch)
   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;