From patchwork Tue Nov 7 15:05:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 118184 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp635606edm; Tue, 7 Nov 2017 07:09:31 -0800 (PST) X-Google-Smtp-Source: ABhQp+QJYPB6RAPjGywBpPSKjcT9EAdXhJX6aSBowe+S2PIaJcSr24lNxF63Rdfc25Ezf6t5Oa5Q X-Received: by 10.129.71.11 with SMTP id u11mr11532910ywa.86.1510067371137; Tue, 07 Nov 2017 07:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510067371; cv=none; d=google.com; s=arc-20160816; b=qonB60hrMf2yU5WyzQ7Filbp1s1BU268vtX8pTmtV/ANWgyryL4jQQHzTmIZzoiydm ne8N6a0Mv5miSECLmklvQ3lt2O8Skcj2c9DZfRNFBNKgJMAXBLqysB4S8KZG1Rd80LZq Yi5DaFX0G6MkAXySn59F3zrlvmiQt7nXFNfOkWNSpb3qFzLweKVy2+il3qYsM6yimSS0 3ZEmUsgwdv/JcoR91q1+k53mpp96JTRpg2dzRE13C4GKnoYl2voYoQJVDhEelcjtira7 FkP//TQsNBFfTeHCPMpQfgx8uIry4PLZPdOdPQ4PmCMMY6Bgbsd+IyPAUwfywNe776oA 218w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=JetAxh5yYChUz2jvr6sK3QTYSNc5deGIz46me3P2a5U=; b=C3r2fzONIwGX80muKop/hE7NfCUn070wa1fvH1EB0zTa0PI5TMpcE6Ox83bpnWgf8p m8C+Qeq8WfY2cD/2XFR2V9uoAXVyz62S3FBcIn4w8FOyzppiimSXleYXG9rQ0cKxtwTc uVi17rVFEgx+Ap4mljexLJlr4P55nO54bYg46pYZue8cbzq1ObMxeKZ2eeoI8qUIYfHQ K1OYm05+RHUK8XR/73DBXd086L8d/4Ug27i4S9z+UplLkbYc9AOLXktfkINlY1n+0/mu Vz0vFUcVr5XkdaphTNdCmoj8BWi7+ZXsvErOPCgVd/KPMxRyAWSmIW6bR6IwpPGpkaD9 wjBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H8BBLkaZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o17si321153ybe.768.2017.11.07.07.09.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Nov 2017 07:09:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H8BBLkaZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5VK-0007IJ-EG for patch@linaro.org; Tue, 07 Nov 2017 10:09:30 -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) 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-Received: by 10.223.152.149 with SMTP id w21mr15847255wrb.274.1510067174485; Tue, 07 Nov 2017 07:06:14 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Dave.Martin@arm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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(-) -- 2.14.2 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; sigjmp_buf jmpbuf; -/* Should we test for FP exception status bits? */ -int test_fp_exc; - /* Master functions */ int read_sock(void *ptr, size_t bytes) @@ -280,6 +277,9 @@ void usage(void) fprintf(stderr, " -p, --port=PORT Specify the port to connect to/listen on " "(default 9191)\n"); + if (arch_extra_help) { + fprintf(stderr, "%s", arch_extra_help); + } } 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 = &default_longopts[0]; *short_opts = "h:p:t:"; - return default_longopts; + + if (arch_long_opts) { + struct option *dptr, *sptr; + size_t osize = sizeof(default_longopts); + lopts = malloc(osize); + /* Copy default opts */ + memcpy(lopts, default_longopts, osize); + dptr = lopts; + while (dptr->name) { + dptr++; + } + /* Copy extra opts */ + sptr = arch_long_opts; + while (sptr->name) { + osize += sizeof(struct option); + lopts = realloc(lopts, osize); + *dptr++ = *sptr++; + } + memset(dptr, 0, sizeof(struct option)); + } + + return lopts; } 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 +/* 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; -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" +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 #include "risu.h" #include "risu_reginfo_arm.h" extern int insnsize(ucontext_t *uc); +/* Should we test for FP exception status bits? */ +static int test_fp_exc; +static struct option extra_opts[] = { + {"test-fp-exc", no_argument, &test_fp_exc, 1}, + {0, 0, 0, 0} +}; + +void *arch_long_opts = &extra_opts[0]; +char *arch_extra_help = " --test-fp-exc Check FP exception bits when 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" +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 +void *arch_long_opts; +char *arch_extra_help; + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) {