From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EC3JCCrm/WNbeAAAWB0awg (envelope-from ) for ; Tue, 28 Feb 2023 06:31:54 -0500 Received: by simark.ca (Postfix, from userid 112) id 1FD681E222; Tue, 28 Feb 2023 06:31:54 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=R2yCVKTs; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C9C441E128 for ; Tue, 28 Feb 2023 06:31:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EC18385B539 for ; Tue, 28 Feb 2023 11:31:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EC18385B539 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583913; 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=R2yCVKTskpEjx+fEngr4OCqqtHu5Lo7Tm+7i6ZALwhaAQZ8jsEKtnrq8SOVS5pFVg 1/S8EwO0WgjgZ9ZPWZI2+aVJsPf2RHKUS/0IRBFjnt2XREQxcLSONYL/RNH1l5HxTW Ectmbbx3PJMhvw6hkb5qOXoji5VcsArHE0k+Ay80= 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: , From: Tankut Baris Aktemur via Gdb-patches Reply-To: Tankut Baris Aktemur Errors-To: gdb-patches-bounces+public-inbox=simark.ca@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; -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928