aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2020-12-05 03:03:48 -0500
committerJoel Brobecker <brobecker@adacore.com>2020-12-05 03:03:48 -0500
commit3c7ba803ac3fbf2b3d7960c14867844238029d55 (patch)
treef8385120746722df4ada0e3a27ba362ce13e8873 /gdb
parent7e45e7a9ab38ee904ca62ed9934e933fdb1d6e9c (diff)
downloadgdb-3c7ba803ac3fbf2b3d7960c14867844238029d55.zip
gdb-3c7ba803ac3fbf2b3d7960c14867844238029d55.tar.gz
gdb-3c7ba803ac3fbf2b3d7960c14867844238029d55.tar.bz2
Fix TARGET_CHAR_BIT/HOST_CHAR_BIT confusion in gmp-utils.c
In a couple of gdb_mpz methods, we are computing the number of bits in a gdb::array_view of gdb_byte. Since gdb_byte is defined using a host-side type (see common-types.h), the number of bits in a gdb_byte should be HOST_CHAR_BIT, not TARGET_CHAR_BIT. gdb/ChangeLog: * gmp-utils.c (gdb_mpz::read): Use HOST_CHAR_BIT instead of TARGET_CHAR_BIT. (gdb_mpz::write): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/gmp-utils.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8252c71..fd95992 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-05 Joel Brobecker <brobecker@adacore.com>
+
+ * gmp-utils.c (gdb_mpz::read): Use HOST_CHAR_BIT instead of
+ TARGET_CHAR_BIT.
+ (gdb_mpz::write): Likewise.
+
2020-12-04 Simon Marchi <simon.marchi@efficios.com>
* amd64-linux-tdep.c (amd64_linux_init_abi): Pass 2 as the
diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c
index 7994108..e3a3333 100644
--- a/gdb/gmp-utils.c
+++ b/gdb/gmp-utils.c
@@ -56,7 +56,7 @@ gdb_mpz::read (gdb::array_view<const gdb_byte> buf, enum bfd_endian byte_order,
was in fact negative, we need to adjust VAL accordingly. */
gdb_mpz max;
- mpz_ui_pow_ui (max.val, 2, buf.size () * TARGET_CHAR_BIT - 1);
+ mpz_ui_pow_ui (max.val, 2, buf.size () * HOST_CHAR_BIT - 1);
if (mpz_cmp (val, max.val) >= 0)
mpz_submul_ui (val, max.val, 2);
}
@@ -77,7 +77,7 @@ gdb_mpz::write (gdb::array_view<gdb_byte> buf, enum bfd_endian byte_order,
would be the same as our negative value. */
gdb_mpz neg_offset;
- mpz_ui_pow_ui (neg_offset.val, 2, buf.size () * TARGET_CHAR_BIT);
+ mpz_ui_pow_ui (neg_offset.val, 2, buf.size () * HOST_CHAR_BIT);
mpz_add (exported_val.val, exported_val.val, neg_offset.val);
}