]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove long_long_align_bit gdbarch attribute
authorTom Tromey <tom@tromey.com>
Mon, 23 Apr 2018 19:41:27 +0000 (13:41 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 30 Apr 2018 17:25:32 +0000 (11:25 -0600)
This removes the long_long_align_bit gdbarch attribute in favor of
type_align.  This uncovered two possible issues.

First, arc-tdep.c claimed that long long alignment was 32 bits, but as
discussed on the list, ARC has a maximum alignment of 32 bits, so I've
added an arc_type_align function to account for this.

Second, jit.c, the sole user of long_long_align_bit, was confusing
"long long" with uint64_t.  The relevant structure is defined in the
JIT API part of the manual as:

     struct jit_code_entry
     {
       struct jit_code_entry *next_entry;
       struct jit_code_entry *prev_entry;
       const char *symfile_addr;
       uint64_t symfile_size;
     };

I've changed this code to use uint64_t.

2018-04-30  Tom Tromey  <tom@tromey.com>

* jit.c (jit_read_code_entry): Use type_align.
* i386-tdep.c (i386_gdbarch_init): Don't call
set_gdbarch_long_long_align_bit.
* gdbarch.sh: Remove long_long_align_bit.
* gdbarch.c, gdbarch.h: Rebuild.
* arc-tdep.c (arc_type_align): New function.
(arc_gdbarch_init): Use arc_type_align.  Don't call
set_gdbarch_long_long_align_bit.

gdb/ChangeLog
gdb/arc-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-tdep.c
gdb/jit.c

index 49481e04ff0a1d561319e58c05538fbfe8bfb8e9..9ca2e8e957437f0079588610f6923d0c269d3653 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-30  Tom Tromey  <tom@tromey.com>
+
+       * jit.c (jit_read_code_entry): Use type_align.
+       * i386-tdep.c (i386_gdbarch_init): Don't call
+       set_gdbarch_long_long_align_bit.
+       * gdbarch.sh: Remove long_long_align_bit.
+       * gdbarch.c, gdbarch.h: Rebuild.
+       * arc-tdep.c (arc_type_align): New function.
+       (arc_gdbarch_init): Use arc_type_align.  Don't call
+       set_gdbarch_long_long_align_bit.
+
 2018-04-30  Tom Tromey  <tom@tromey.com>
 
        * rust-lang.c (rust_type_alignment): Remove.
index b0d51addd3906ac2f38d3c6674954799dac97c36..286a289a06c7a600e51f17024a4c8743193a921d 100644 (file)
@@ -1957,6 +1957,15 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
   return TRUE;
 }
 
+/* Implement the type_align gdbarch function.  */
+
+static ULONGEST
+arc_type_align (struct gdbarch *gdbarch, struct type *type)
+{
+  type = check_typedef (type);
+  return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+}
+
 /* Implement the "init" gdbarch method.  */
 
 static struct gdbarch *
@@ -1982,7 +1991,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_int_bit (gdbarch, 32);
   set_gdbarch_long_bit (gdbarch, 32);
   set_gdbarch_long_long_bit (gdbarch, 64);
-  set_gdbarch_long_long_align_bit (gdbarch, 32);
+  set_gdbarch_type_align (gdbarch, arc_type_align);
   set_gdbarch_float_bit (gdbarch, 32);
   set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
   set_gdbarch_double_bit (gdbarch, 64);
index dd7c89d94802ce0218eee2b581553ce4d9cc5d86..82ac7519130d67bca780982fb8ccdd8ac0c4ec1b 100644 (file)
@@ -175,7 +175,6 @@ struct gdbarch
   int int_bit;
   int long_bit;
   int long_long_bit;
-  int long_long_align_bit;
   int half_bit;
   const struct floatformat ** half_format;
   int float_bit;
@@ -389,7 +388,6 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->int_bit = 4*TARGET_CHAR_BIT;
   gdbarch->long_bit = 4*TARGET_CHAR_BIT;
   gdbarch->long_long_bit = 2*gdbarch->long_bit;
-  gdbarch->long_long_align_bit = 2*gdbarch->long_bit;
   gdbarch->half_bit = 2*TARGET_CHAR_BIT;
   gdbarch->float_bit = 4*TARGET_CHAR_BIT;
   gdbarch->double_bit = 8*TARGET_CHAR_BIT;
@@ -530,7 +528,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of int_bit, invalid_p == 0 */
   /* Skip verify of long_bit, invalid_p == 0 */
   /* Skip verify of long_long_bit, invalid_p == 0 */
-  /* Skip verify of long_long_align_bit, invalid_p == 0 */
   /* Skip verify of half_bit, invalid_p == 0 */
   if (gdbarch->half_format == 0)
     gdbarch->half_format = floatformats_ieee_half;
@@ -1165,9 +1162,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: long_double_format = %s\n",
                       pformat (gdbarch->long_double_format));
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: long_long_align_bit = %s\n",
-                      plongest (gdbarch->long_long_align_bit));
   fprintf_unfiltered (file,
                       "gdbarch_dump: long_long_bit = %s\n",
                       plongest (gdbarch->long_long_bit));
@@ -1638,23 +1632,6 @@ set_gdbarch_long_long_bit (struct gdbarch *gdbarch,
   gdbarch->long_long_bit = long_long_bit;
 }
 
-int
-gdbarch_long_long_align_bit (struct gdbarch *gdbarch)
-{
-  gdb_assert (gdbarch != NULL);
-  /* Skip verify of long_long_align_bit, invalid_p == 0 */
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_long_long_align_bit called\n");
-  return gdbarch->long_long_align_bit;
-}
-
-void
-set_gdbarch_long_long_align_bit (struct gdbarch *gdbarch,
-                                 int long_long_align_bit)
-{
-  gdbarch->long_long_align_bit = long_long_align_bit;
-}
-
 int
 gdbarch_half_bit (struct gdbarch *gdbarch)
 {
index 3848ec50c7f8d4cc0b86395b45e9f1c282b6c50a..b3a15c9898c479f6a1c44659859c398f9088f366 100644 (file)
@@ -147,12 +147,6 @@ extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
 extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
 extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
 
-/* Alignment of a long long or unsigned long long for the target
-   machine. */
-
-extern int gdbarch_long_long_align_bit (struct gdbarch *gdbarch);
-extern void set_gdbarch_long_long_align_bit (struct gdbarch *gdbarch, int long_long_align_bit);
-
 /* The ABI default bit-size and format for "half", "float", "double", and
    "long double".  These bit/format pairs should eventually be combined
    into a single object.  For the moment, just initialize them as a pair.
index bb62e6d6205bbc7cf36b655550a19e321ca48431..bf12c6848739bafac9b8174fc84053b18cc9b9c4 100755 (executable)
@@ -360,9 +360,6 @@ v;int;long_bit;;;8 * sizeof (long);4*TARGET_CHAR_BIT;;0
 # Number of bits in a long long or unsigned long long for the target
 # machine.
 v;int;long_long_bit;;;8 * sizeof (LONGEST);2*gdbarch->long_bit;;0
-# Alignment of a long long or unsigned long long for the target
-# machine.
-v;int;long_long_align_bit;;;8 * sizeof (LONGEST);2*gdbarch->long_bit;;0
 
 # The ABI default bit-size and format for "half", "float", "double", and
 # "long double".  These bit/format pairs should eventually be combined
index fec74ee6c8c61e087da1179acf2b4a64194000a6..b359254c75f092931e297c9613c8a8f50dd76fff 100644 (file)
@@ -8429,7 +8429,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   tdep->record_regmap = i386_record_regmap;
 
-  set_gdbarch_long_long_align_bit (gdbarch, 32);
   set_gdbarch_type_align (gdbarch, i386_type_align);
 
   /* The format used for `long double' on almost all i386 targets is
index 2f23c058a034f96ea1970fd69b687ddad62f5f72..8cd645cb66e9930ac081bf7936edd28ed34916c1 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -413,8 +413,8 @@ jit_read_code_entry (struct gdbarch *gdbarch,
   ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
   ptr_size = TYPE_LENGTH (ptr_type);
 
-  /* Figure out where the longlong value will be.  */
-  align_bytes = gdbarch_long_long_align_bit (gdbarch) / 8;
+  /* Figure out where the uint64_t value will be.  */
+  align_bytes = type_align (builtin_type (gdbarch)->builtin_uint64);
   off = 3 * ptr_size;
   off = (off + (align_bytes - 1)) & ~(align_bytes - 1);