From patchwork Wed Jun 13 12:55:52 2018 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: 138477 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp723120lji; Wed, 13 Jun 2018 06:26:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4rcJ3Z9regQuSEck3pxgTuk+Kte7b9zz0i9nyN8bvehPCs+28x5vD83GTZngq9peyLJMS X-Received: by 2002:a37:4c47:: with SMTP id z68-v6mr4140099qka.233.1528896399340; Wed, 13 Jun 2018 06:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528896399; cv=none; d=google.com; s=arc-20160816; b=PxT0OhdshOrwwn4lVjmkKq5COOsygLndvJx38AnEF7vcrTA8d6NalnEgrweB3qjLrt AE4XPvDQOmRynyta8kwJuU/h5CUpLDcmqsq8QwSypYbyzd394UIt/erfEvqA1LAMhBXZ s1cdWEdNHht5EMPumeFEnuqPKJkpxZRlak8kz1+oxxa52eOBmPyVO7BIhOSDPpMxvUoH 657dcNxQS3ybG5sNvmvPOOIs9JCn/YaouZVUFjw9zRh5jPMSfjM47Fl7WWHevOWSqQip YTfhmoyxim0pfF0ylHswrlHtv+wc6bD8HPdI9htZAaIItD8v4XmXHrt/VOV4BF8cSdKA WD7A== 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=jjUldyaKeKYrcB+Cm5ncCoScFYt4ewD1ApH+rdYho6Q=; b=uaVRbEAKR8XqB+K+pA5LneGBeGibwNQ6PClXgsdXVRK08R4XG07MntGIXmxFCquJJL MX5ZwwPdiZjRSrQJR4kd9/XJfo+qvs0jL6Nv50dIzcLGYmDiE+DyzIZavD7RNRztdKqy WOCERAKZ94X6NDoe5RTFS9HPmqkU4IHPCzjo4tqaAkv6FoTDDhggHx7QBX6Yx7k3rrAb A1whqVoQaCSW9DwWWm9SkhhZ+uCbCb9yow1bU3Juw8mmyD8ibm0iDdFeAkLFaCh1uB/z Auyh2Wc1ckl2QghlMCSKSgiCINABgMw+CY41e19cYOALXD7wF89+/9hvoVLpAqOAkpKh II4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UnL5ND9L; 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 i14-v6si2718062qtc.286.2018.06.13.06.26.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Jun 2018 06:26:39 -0700 (PDT) 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=UnL5ND9L; 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]:34314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5nK-0001nc-Ra for patch@linaro.org; Wed, 13 Jun 2018 09:26:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5SN-0001d4-0G for qemu-devel@nongnu.org; Wed, 13 Jun 2018 09:05:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fT5SH-0005a0-JP for qemu-devel@nongnu.org; Wed, 13 Jun 2018 09:04:58 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:38598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fT5SH-0005Wj-8K for qemu-devel@nongnu.org; Wed, 13 Jun 2018 09:04:53 -0400 Received: by mail-wm0-x22e.google.com with SMTP id 69-v6so5264145wmf.3 for ; Wed, 13 Jun 2018 06:04:53 -0700 (PDT) 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=jjUldyaKeKYrcB+Cm5ncCoScFYt4ewD1ApH+rdYho6Q=; b=UnL5ND9LpxSZPfN4HtOqCm/yrEG1j7w/Sjb81Ir+u4rFHDBZOL8lOBUoHoXVJEvT9G Qf4CjTlsnbZoJ+QUhI7Prx9Adum7CeM53qKnx9L8YkafG0oIJXuybKY6obmDXDkVq9Ax IbqzSTWS2wwJdtjqWw7PGn1nVe4H2yvnh6sJU= 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=jjUldyaKeKYrcB+Cm5ncCoScFYt4ewD1ApH+rdYho6Q=; b=dE3YxRay0OA7X7GwXFLmlXIy11MUM86cH4wLWfNs0on6C7IIrzMGBPpsBI1GhyrGlU LWLlvH16LH5GeRF6DgOy3XBWb2vff0DZ5Bblhc4ac73UpcbtZfKw9bLlA4on+5lSd3Ut qbRHkSo9QIzs2ivY2O4UMvn9OXNHcU6+UjY3ft2LrDbqIusWhVogFkuFOp8gOI768+3I KJ0FtKDiklXNMGsSZpjxK0kAFi5L+h9VqRh36GlNVctp75kdS1+hBpoLKt7dpu83XyIv SYAl/a0uY3R1aAMBRcOM90VEZ7l+cN+iyNDpntssv3/2VltIPAne/GMfhm9148ddvOPa 4doQ== X-Gm-Message-State: APt69E3wsmPUFMc5tI+D4250zSFXCE0mvpYS1fo4inRRtGq0IZws9st3 8OFJLVqPCHGpLqrRIxyIBfu9wg== X-Received: by 2002:a1c:ee06:: with SMTP id m6-v6mr2267922wmh.70.1528895092106; Wed, 13 Jun 2018 06:04:52 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s17-v6sm1911858wmc.34.2018.06.13.06.04.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 06:04:49 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id CFD303E129C; Wed, 13 Jun 2018 13:56:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 13 Jun 2018 13:55:52 +0100 Message-Id: <20180613125601.14371-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613125601.14371-1-alex.bennee@linaro.org> References: <20180613125601.14371-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:c09::22e Subject: [Qemu-devel] [RISU PATCH v3 13/22] 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org, 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 --- v2 - better concatenation of default and extra opts --- risu.c | 29 +++++++++++++++++++++++++---- 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, 49 insertions(+), 6 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/risu.c b/risu.c index c684c90..18de351 100644 --- a/risu.c +++ b/risu.c @@ -46,8 +46,7 @@ gzFile gz_trace_file; sigjmp_buf jmpbuf; -/* Should we test for FP exception status bits? */ -int test_fp_exc; +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* Master functions */ @@ -283,6 +282,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) @@ -293,12 +295,31 @@ 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) { + const size_t osize = sizeof(struct option); + const int default_count = ARRAY_SIZE(default_longopts); + struct option *dptr; + int extra_count = 0; + + /* count additional opts */ + dptr = arch_long_opts; + do {} while (dptr[extra_count++].name); + + lopts = calloc(default_count + extra_count, osize); + + /* Copy default opts + extra opts */ + memcpy(lopts, default_longopts, default_count * osize); + dptr = &lopts[default_count - 1]; + memcpy(dptr, arch_long_opts, extra_count * osize); + } + + 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 3bb4339..ab12270 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -18,6 +18,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 5f33648..395111c 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) {