From patchwork Thu Apr 27 21:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 68412 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 BE68A38768A7 for ; Thu, 27 Apr 2023 21:02:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 732EC385700A for ; Thu, 27 Apr 2023 21:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 732EC385700A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id B9DC51A84BA9; Thu, 27 Apr 2023 17:01:37 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Cc: Aleksandar Paunovic Subject: [PATCH v5 15/19] gdbserver: Refactor the legacy region within the xsave struct Date: Thu, 27 Apr 2023 14:01:09 -0700 Message-Id: <20230427210113.45380-16-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427210113.45380-1-jhb@FreeBSD.org> References: <20230427210113.45380-1-jhb@FreeBSD.org> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Thu, 27 Apr 2023 17:01:38 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Aleksandar Paunovic Legacy fields of the XSAVE area are already defined within fx_save struct. Use class inheritance to remove code duplication. The two changed functions are called within all tests which run gdbserver. Signed-off-by: Aleksandar Paunovic Co-authored-by: John Baldwin --- gdbserver/i387-fp.cc | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc index 1900106a502..e63eef60330 100644 --- a/gdbserver/i387-fp.cc +++ b/gdbserver/i387-fp.cc @@ -81,29 +81,7 @@ struct i387_fxsave { unsigned char xmm_space[256]; }; -struct i387_xsave { - /* All these are only sixteen bits, plus padding, except for fop (which - is only eleven bits), and fooff / fioff (which are 32 bits each). */ - unsigned short fctrl; - unsigned short fstat; - unsigned short ftag; - unsigned short fop; - unsigned int fioff; - unsigned short fiseg; - unsigned short pad1; - unsigned int fooff; - unsigned short foseg; - unsigned short pad12; - - unsigned int mxcsr; - unsigned int mxcsr_mask; - - /* Space for eight 80-bit FP values in 128-bit spaces. */ - unsigned char st_space[128]; - - /* Space for eight 128-bit XMM values, or 16 on x86-64. */ - unsigned char xmm_space[256]; - +struct i387_xsave : public i387_fxsave { unsigned char reserved1[48]; /* The extended control register 0 (the XFEATURE_ENABLED_MASK @@ -725,7 +703,6 @@ void i387_xsave_to_cache (struct regcache *regcache, const void *buf) { struct i387_xsave *fp = (struct i387_xsave *) buf; - struct i387_fxsave *fxp = (struct i387_fxsave *) buf; bool amd64 = register_size (regcache->tdesc, 0) == 8; int i, top; unsigned long val; @@ -962,7 +939,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf) { int tag; if (fp->ftag & (1 << i)) - tag = i387_ftag (fxp, (i + 8 - top) % 8); + tag = i387_ftag (fp, (i + 8 - top) % 8); else tag = 3; val |= tag << (2 * i);