From nobody Thu Oct 30 08:09:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510067329905873.4840523431793; Tue, 7 Nov 2017 07:08:49 -0800 (PST) Received: from localhost ([::1]:53855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5UZ-0007IJ-SQ for importer@patchew.org; Tue, 07 Nov 2017 10:08:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5SD-0005nG-PP for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC5SC-0008V4-7O for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:17 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:51462) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eC5SB-0008UB-Kd for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:16 -0500 Received: by mail-wr0-x241.google.com with SMTP id j15so12123142wre.8 for ; Tue, 07 Nov 2017 07:06:15 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o190sm1808400wmd.32.2017.11.07.07.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 07:06:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B25003E0449; Tue, 7 Nov 2017 15:06:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JetAxh5yYChUz2jvr6sK3QTYSNc5deGIz46me3P2a5U=; b=H8BBLkaZdGMv162LiNTqTZn/sqilVtUi2V0cM+A4mYiTAXDAcqv+pEMk75bfUBLJUc LSf1YKjdgJmOV9eUtX4aImJAcKN4yi7zCY9CzPEFkXJvw8nTk29bCtolH5nd8pwqI/cy XeLO9tsT5Wo9nZLsg1Xtm2H4u2yvNMRXj9RRo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JetAxh5yYChUz2jvr6sK3QTYSNc5deGIz46me3P2a5U=; b=uQ3r61w99Ehp/Tapwpe8AdsNh0JpRZYsUMKxL4nMSKFktx1uhZ5TDYzG4GpksOkvCw 7uuLryqyN5hNFei6SVrXRmdo8XcjU4d9dtwg5+K2wnOkzgc9Bd3vM7t8BC7ZwCGelLcT IHMDaQjyX4FeGXgqRoxwwFyx3BKMX9AaSMlINALbocP48Or+P+8N7le3xqFe3IbwUmF6 TqF5JW/HMrvv9JXepkPPWcIunyiQki54eT0FCJSG7wAX1h66zuIXU5qrn12nEZaiWCrR aNViZxiU7NPIJPN29p6i0GwCRRU4ecea4SgzSgzdIjARTWRiZ6rEi1Lja4l7uMoGC4E3 XkeA== X-Gm-Message-State: AMCzsaUmUkfhmxXGgFkir5oYniUyAnj4wGm4OoJNVw51JUz8pvMpn+P4 qhXLh0N/vnMzGEhDpOx3k0DnUA== X-Google-Smtp-Source: ABhQp+RqONY4sCGStUGIjSCUPcx7aR/EoM4mpqxVImVgtT9AwhwLYbTfIkQ2LNrjGqtrdqe7fQwK2g== X-Received: by 10.223.152.149 with SMTP id w21mr15847255wrb.274.1510067174485; Tue, 07 Nov 2017 07:06:14 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 7 Nov 2017 15:05:52 +0000 Message-Id: <20171107150558.22131-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107150558.22131-1-alex.bennee@linaro.org> References: <20171107150558.22131-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [RISU PATCH 04/10] risu: move optional args to each architecture X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Dave.Martin@arm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The key variables here are: *arch_long_opts and *arch_extra_help. If they are not NULL then we concatenate the extra options to appropriate structure to enable the support. Adding architecture short options is not supported. This also includes moving the ARM specific test_fp_exc/test-fp-exc into ARM specific code. Signed-off-by: Alex Benn=C3=A9e --- risu.c | 31 ++++++++++++++++++++++++++----- risu.h | 6 ++++-- risu_reginfo_aarch64.c | 3 +++ risu_reginfo_arm.c | 11 +++++++++++ risu_reginfo_m68k.c | 3 +++ risu_reginfo_ppc64.c | 3 +++ 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/risu.c b/risu.c index 616fc33..f063093 100644 --- a/risu.c +++ b/risu.c @@ -43,9 +43,6 @@ gzFile gz_trace_file; =20 sigjmp_buf jmpbuf; =20 -/* Should we test for FP exception status bits? */ -int test_fp_exc; - /* Master functions */ =20 int read_sock(void *ptr, size_t bytes) @@ -280,6 +277,9 @@ void usage(void) fprintf(stderr, " -p, --port=3DPORT Specify the port to connect to/listen o= n " "(default 9191)\n"); + if (arch_extra_help) { + fprintf(stderr, "%s", arch_extra_help); + } } =20 struct option * setup_options(char **short_opts) @@ -290,12 +290,33 @@ struct option * setup_options(char **short_opts) {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"trace", required_argument, 0, 't'}, - {"test-fp-exc", no_argument, &test_fp_exc, 1}, {0, 0, 0, 0} }; + struct option *lopts =3D &default_longopts[0]; =20 *short_opts =3D "h:p:t:"; - return default_longopts; + + if (arch_long_opts) { + struct option *dptr, *sptr; + size_t osize =3D sizeof(default_longopts); + lopts =3D malloc(osize); + /* Copy default opts */ + memcpy(lopts, default_longopts, osize); + dptr =3D lopts; + while (dptr->name) { + dptr++; + } + /* Copy extra opts */ + sptr =3D arch_long_opts; + while (sptr->name) { + osize +=3D sizeof(struct option); + lopts =3D realloc(lopts, osize); + *dptr++ =3D *sptr++; + } + memset(dptr, 0, sizeof(struct option)); + } + + return lopts; } =20 int main(int argc, char **argv) diff --git a/risu.h b/risu.h index 1c8ecee..89811f4 100644 --- a/risu.h +++ b/risu.h @@ -17,6 +17,10 @@ #include #include =20 +/* Extra option processing for architectures */ +extern void *arch_long_opts; +extern char *arch_extra_help; + /* GCC computed include to pull in the correct risu_reginfo_*.h for * the architecture. */ @@ -36,8 +40,6 @@ void send_response_byte(int sock, int resp); extern uintptr_t image_start_address; extern void *memblock; =20 -extern int test_fp_exc; - /* Ops code under test can request from risu: */ #define OP_COMPARE 0 #define OP_TESTEND 1 diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index e3fadde..38ad338 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -17,6 +17,9 @@ #include "risu.h" #include "risu_reginfo_aarch64.h" =20 +void *arch_long_opts; +char *arch_extra_help; + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 6b9ee7b..5acad02 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -13,12 +13,23 @@ #include #include #include +#include =20 #include "risu.h" #include "risu_reginfo_arm.h" =20 extern int insnsize(ucontext_t *uc); =20 +/* Should we test for FP exception status bits? */ +static int test_fp_exc; +static struct option extra_opts[] =3D { + {"test-fp-exc", no_argument, &test_fp_exc, 1}, + {0, 0, 0, 0} +}; + +void *arch_long_opts =3D &extra_opts[0]; +char *arch_extra_help =3D " --test-fp-exc Check FP exception bits whe= n comparing\n"; + static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) { /* Read VFP registers. These live in uc->uc_regspace, which is diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 4ff0aa8..d429502 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -14,6 +14,9 @@ #include "risu.h" #include "risu_reginfo_m68k.h" =20 +void *arch_long_opts; +char *arch_extra_help; + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index eb9c12b..aa5d8c6 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -22,6 +22,9 @@ #define XER 37 #define CCR 38 =20 +void *arch_long_opts; +char *arch_extra_help; + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { --=20 2.14.2