From patchwork Fri Jun 22 14:11:56 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: 139680 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp971959lji; Fri, 22 Jun 2018 07:57:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf93oz7LPkPkbGCGc8qjZnFtDyCTeaoZr1oF3OZBFXNws1L3CLR5OlnHkEiReTBKLUH3qJE X-Received: by 2002:ae9:c10d:: with SMTP id z13-v6mr1569240qki.359.1529679471832; Fri, 22 Jun 2018 07:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529679471; cv=none; d=google.com; s=arc-20160816; b=vptGRpgsVOZdEcN5tEaNaJH7KhvBNHSQfLqpUKJZtCExw5SZazDJ9dkvNl7o3UBz/B WytxLlF2Of+Xw+buem1/nTUEch5pNpzUOal1ZLE89lOvExUlO2n3JKANuGLJ/2sc6y3b 3hXNr/PUsJIM8lru/6a6ubOfHivvDdMvSsFvobtFtziKRmflIZkpE2cyXDnCLPbUrLqm WUj5+iOqdZUe4t/ZZBF/9pD2pA0QY5Cv6DeJ4P2P3rk+QR2Kwkv2kXwOj6N/Se6x+xbV OQZ8DB3lWCuIbDEsGAv0mOUZgakCqnw3C5lH5Sc70B0UDD0a1lctEHICuteFxIWOqot4 SwQQ== 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=BN9TlWSjJtBY5uzotv2E0/KhskH7jcna9d7GkYd5aiA=; b=CQ6EY2wOHmZsZxUsSCrt988Bstv1cjHAl608ogKOlEmYeuJvy/5mFqeCe8Uc26RsTv ohId78D4ckkUt9wok6crQTI7Gcqe1oOFhCUn/zOZNQg1RdkJafywqjvjnbJQP2XiOc5y P+aERQWXQDfnTCGsC4vEdwlR6PGORJpTC9gYFnueJfsZsHmcvcqxF7Y3vCywydYbFi2x 27c1hcRGFFTHVA5HJ4lvkk1puHpSyqHfCMtLj2dZ7TejqX36PHBaoPvw1ZViRo9cGCSZ sF5GBR+PSnK3eCW+JLW1RWfml/BChrmqRMLpFa7LSsvXLbjAsbqQfna8HQ/KI/bSNrwj B89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cONDAWzf; 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 m82-v6si3232080qki.213.2018.06.22.07.57.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 07:57:51 -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=cONDAWzf; 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]:34591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWNVX-00019v-98 for patch@linaro.org; Fri, 22 Jun 2018 10:57:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWMx0-0005yO-0t for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWMwy-0003Zx-O6 for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:09 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:35869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWMwy-0003ZG-DJ for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:08 -0400 Received: by mail-wm0-x235.google.com with SMTP id v131-v6so2837145wma.1 for ; Fri, 22 Jun 2018 07:22:08 -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=BN9TlWSjJtBY5uzotv2E0/KhskH7jcna9d7GkYd5aiA=; b=cONDAWzfmgxXivtwzSEUVMsYGwP/afnN9Z92kmAHCX9mw7UsJ1Z29UEz38BHIUQF5G 76LwD821rGHANB7FT/FVoXh34nJ3hfWEolN0Jo04tY0UJpzlvmLE2nW/8cJ9KJ70a5lQ /q8wtX1M8wmU6l2OHjmKCAnt9QkAeRmIaspCI= 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=BN9TlWSjJtBY5uzotv2E0/KhskH7jcna9d7GkYd5aiA=; b=k9a/vpsyTZ5abV1Mzi6W1QnMQHjsZzHf5EBPY+jh9fGA4HGavTAHWUqyMSqHabBAAE hq2wKt2yAORgZkOzwvWhrXur37RnjMkuHNcwYN7J8j4AK93c4VTrDweUs0v8ukOl/pS4 JJ3lWSwJuzINFe9kzvZlrbcy8zUHszUt022oKMARkjwPln5QRKN0V6UAVs9XJ0AI8GCy jcmZ/HFbSshp3xrgTd8sYRLFg5ZndrBtYkXVvJOr8LAv5mO3KhcnoaA29UhC2t1Ll1E6 yirvBHyIhHA1bbTVRqB6gMLlnZ8gIknVVXEiDzR56DK3rLOJYxRSq/iw2Zom52s+4bS5 z8Pw== X-Gm-Message-State: APt69E26n5+MRUDedCuJa/Y29j5AiPvN/BAbBy73J904tf+cq3Dh/DKf 9JXyItMyC4KXwuF6aAJqJ3gaEw== X-Received: by 2002:a1c:b6c3:: with SMTP id g186-v6mr1857305wmf.40.1529677327304; Fri, 22 Jun 2018 07:22:07 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h11-v6sm7378200wrs.85.2018.06.22.07.22.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 07:22:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id EFD243E0BB0; Fri, 22 Jun 2018 15:12:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 22 Jun 2018 15:11:56 +0100 Message-Id: <20180622141205.16306-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622141205.16306-1-alex.bennee@linaro.org> References: <20180622141205.16306-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::235 Subject: [Qemu-devel] [RISU PATCH v4 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 Reviewed-by: Richard Henderson --- 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 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) {