From patchwork Tue Feb 28 11:28:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 65754 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C4B13850206 for ; Tue, 28 Feb 2023 11:31:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C4B13850206 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583917; bh=9j0ytXxdgRHfcq2l0ziDip25WTnR7i70+6eowTl4faE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vdb8D7in8l4y+9nXW+clsYbpjJPV89hyELR5ByM7p7kWgr8NBnIY9JEXCI/DR9TGD UlKkkCDYczTDCqGBeaeWDG1WMM2fOYYrPvDnvQVSp+1+VwfUYRl1gdA4e1KrNHIoa8 Fzg1kMRvqT+Nl1rys8Wu/EX5+srMLWuvMaERoXEE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 9591B3850206 for ; Tue, 28 Feb 2023 11:30:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9591B3850206 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="313785148" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="313785148" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:30:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="623992205" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="623992205" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:30:45 -0800 To: gdb-patches@sourceware.org Subject: [PATCH 19/26] gdbserver: fix the declared type of register_status in regcache Date: Tue, 28 Feb 2023 12:28:17 +0100 Message-Id: <0c082e1edb5933f2ac5a7aac06197f8957099628.1677582745.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tankut Baris Aktemur via Gdb-patches From: Tankut Baris Aktemur Reply-To: Tankut Baris Aktemur Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The register_status field of regcache is declared as `unsigned char *`. This is incorrect, because `enum register_status` from gdbsupport/common-regcache.h is based on signed char and REG_UNAVAILABLE is defined as -1. Fix the declared type. The get/set methods already use the correct type, but we update cast operations in two places. --- gdbserver/regcache.cc | 4 ++-- gdbserver/regcache.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 0e21c1aa7d1..09ea58bdbd6 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -147,7 +147,7 @@ regcache::initialize (const target_desc *tdesc, = (unsigned char *) xcalloc (1, tdesc->registers_size); this->registers_owned = true; this->register_status - = (unsigned char *) xmalloc (tdesc->reg_defs.size ()); + = (enum register_status *) xmalloc (tdesc->reg_defs.size ()); memset ((void *) this->register_status, REG_UNAVAILABLE, tdesc->reg_defs.size ()); #else @@ -490,7 +490,7 @@ regcache::get_register_status (int regnum) const #ifndef IN_PROCESS_AGENT gdb_assert (regnum >= 0 && regnum < tdesc->reg_defs.size ()); if (register_status != nullptr) - return (enum register_status) (register_status[regnum]); + return register_status[regnum]; else return REG_VALID; #else diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 3fcd4643a42..ad71a9acaec 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -46,8 +46,8 @@ struct regcache : public reg_buffer_common bool registers_owned = false; unsigned char *registers = nullptr; #ifndef IN_PROCESS_AGENT - /* One of REG_UNAVAILABLE or REG_VALID. */ - unsigned char *register_status = nullptr; + /* See gdbsupport/common-regcache.h. */ + enum register_status *register_status = nullptr; /* Constructors. */ regcache () = default;