From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id B394E385040C for ; Sun, 29 Nov 2020 15:46:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B394E385040C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=brobecke@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 61C8D5616D; Sun, 29 Nov 2020 10:46:01 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 175ZQnGePv4u; Sun, 29 Nov 2020 10:46:01 -0500 (EST) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 5098256171; Sun, 29 Nov 2020 10:46:01 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4233) id 4DD9FAD; Sun, 29 Nov 2020 10:46:01 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Simon Marchi , Joel Brobecker Subject: [RFA 1/2] Fix TARGET_CHAR_BIT/HOST_CHAR_BIT confusion in gmp-utils.c Date: Sun, 29 Nov 2020 10:45:56 -0500 Message-Id: <1606664757-144138-2-git-send-email-brobecker@adacore.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1606664757-144138-1-git-send-email-brobecker@adacore.com> References: <20201123042711.GA967337@adacore.com> <1606664757-144138-1-git-send-email-brobecker@adacore.com> X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2020 15:46:02 -0000 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. --- gdb/gmp-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 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 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); } -- 2.1.4