From patchwork Wed Jun 21 15:42:35 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: 106103 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1995523qgd; Wed, 21 Jun 2017 08:45:11 -0700 (PDT) X-Received: by 10.200.36.144 with SMTP id s16mr43268362qts.224.1498059911185; Wed, 21 Jun 2017 08:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498059911; cv=none; d=google.com; s=arc-20160816; b=oztrIqaqElC8ymqEuHLabX60E3+8IuRWti3RcNMSxBuixakyp0VFYrSydbUx5oJvp+ 4IezjzUs75LvIl+GpbMh2S/D7SCTE1nwFKL+E/wub8Bv21apcM6y6IwH0D5hdjTIJ5th WApLPN6zP+JmWaaIBrqNLiz+6KG8WzP2A0XdwtKUtGZljuVwzF7vugXWSrtaFN1Fp8tO s2UU7yMhOgvy8aaiQE5pNX/Y1rj6SBFVJC+WroJm4RQTwCn4Lumyk8Cnfp9TjWJqcAhx ajZ7RGO2yoIridjVC4A9w/OleZf5mAAuswbBsN8SX/8JtEemY7sQMKa8rcnrjqi2rRin P5fQ== 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=KIzeihXmYJoDPmvc++cepWspnAnRTwkkvUe5QMRl8ao=; b=uV/VS3bk1o8+00eJ7h+cC/jpAHU0JKOpPscA1tJ2vQCrEQgCFZWpuLbLSIqiV8BtBU a8ykETFkR++6jpBzb+CyBePMAvBg+j9XX8Vy6ghEzeeM3qtMG1RBwmUguSf2TWBwR5Jb RG7lMPnEBPqhpYt2o9lbrWa4Z87jHcJFu5nCuimsBo4Y482SnGByraOlOFGsk5PxLEct PztY1HxKBqPfwZCGvF2kvumVmw981ajSeBOr8GC+8FZ7o2UBSR4w1E/ISafNPRdV14LV HVIC7NsjQrP+/pm708a6y+sIgNsRKw8evWGHgqytyTNaKaSVdVeQiDE00xHs3iOS9I2g S/+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=YF2GofxP; 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 t1si14825633qtd.85.2017.06.21.08.45.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:45:11 -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.b=YF2GofxP; 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]:54751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhoa-0008RP-My for patch@linaro.org; Wed, 21 Jun 2017 11:45:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlm-0006D5-Px for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhll-0002qV-B9 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:14 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:35633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhll-0002qH-4q for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:13 -0400 Received: by mail-wr0-x22f.google.com with SMTP id y25so100920227wrd.2 for ; Wed, 21 Jun 2017 08:42:13 -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=KIzeihXmYJoDPmvc++cepWspnAnRTwkkvUe5QMRl8ao=; b=YF2GofxPHZmeactEKkVa/dN+6Lh48hxQQFhMEEDB3t0NzjLmXp1F5wu9Frzk1YY46s CX71beP6xSqCTcJj99ogCtxzIvxuFC1U73kZTjFWZp/JswWy4uMMMvdsyMjUu/02H5TK 6/fP0Lh4+8JCSPHea59D4pwe4dC653ZXL95Jw= 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=KIzeihXmYJoDPmvc++cepWspnAnRTwkkvUe5QMRl8ao=; b=aF2LnhDXNQm0rxOuo3kkCx/erCoSGX4IE1s3NgD5YMvRkU1TwbraBa1Ked/4Cvelud ALyu2MTO1Ts2lBrQnYIu6095PA/h3XLXvfJAxQ++lnUXKlqGgwL8Niz3TyzbXpOQ6Nyj ZLP6b7sbkc2JFSLSAlSna4c9ijOxoQpOrdTw/sGycgeRUyhyju04Ebg19ofVasjuuk6f Y4eYpps3iQShFiZgzv9TuSdcOSWW5xKDvo9O0rau6PLZxxZR9KXT+bxvPlrlR8W3rWEu 1LwdRrHu9Irdhx42CSzOGRSR2+FC2bJ39lQq0Zb4LBH+eUSDsdGbzlYyE7zNur3YCQTo gARQ== X-Gm-Message-State: AKS2vOyPWdAwtGFs4p2C90FDjQ5y6nvklwn0d2rvtjHeKHfVeHV13CJe WUKxA83MTNSSTDnM X-Received: by 10.28.23.138 with SMTP id 132mr3106843wmx.114.1498059732133; Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id i7sm13970830wmc.29.2017.06.21.08.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:08 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3387C3E0550; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:35 +0100 Message-Id: <20170621154244.28309-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::22f Subject: [Qemu-devel] [RISU PATCH v6 01/10] README: document the coding style used for risu 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We also include the an Emacs .dir-locals (as per QEMU) that enforces this layout. Signed-off-by: Alex Bennée --- .dir-locals.el | 2 ++ README | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 .dir-locals.el -- 2.13.0 diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..3ac0cfc --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((c-mode . ((c-file-style . "stroustrup") + (indent-tabs-mode . nil)))) diff --git a/README b/README index 4b37b4e..858a349 100644 --- a/README +++ b/README @@ -42,6 +42,15 @@ architecture that we support and that you have a cross compiler installed for. This is useful for confirming that your changes to risu haven't broken anything. +Coding Style +------------ + +risu follows the same coding style as the QEMU project, namely 4 +spaces (no tabs) for indentation and the One True Brace Style variant +of K&R. The source tree includes a .dir-locals.el for Emacs users that +will set this automatically. Other editors are available. + + Usage ----- From patchwork Wed Jun 21 15:42:36 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: 106102 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1995162qgd; Wed, 21 Jun 2017 08:44:18 -0700 (PDT) X-Received: by 10.55.151.69 with SMTP id z66mr41846851qkd.90.1498059858331; Wed, 21 Jun 2017 08:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498059858; cv=none; d=google.com; s=arc-20160816; b=IFVeA3qLyDqNs+sMIfFbkvjEx0Q3No0XcMK+ZpcwulvXfc1MlQ7231j2a5Fg50DBcy SL6wILlsrzqZAHJzYVRvg/nPVIKm6ILCStQjBkWUUR6aClGsFkC7qOkDq+AjUfdaiHrM oCOMl3ISO8eXl4EcbtEZm1O9E48E+3S7X8wADFql9xs9ZNJOlmglizizubAMzJWB6P7i 2hlcHp7mqf3Bh9GVdl2YT06oWppRDmFrdeFGqhqETCjk8L2YlurKNFP7wmQIKZ3RtrcG yYZv5/Dl/9iuvAdNorxBodQHJy4mEmsUVqwdYzXcJ/EAvaETawyBXwYBp7LJIhYHnp4H yfYQ== 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=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=rdz6U+hyjz6ATtReRhx6t8o1z4Im90zlix9haILKfAZXaimzbcP+Fkw0H38dGe4H4f lpBGz74G+0THSmHFGLUisZY3qLSdwNbwxkrYGDoinRJnerTOdiZEF6Uu+spRcc12l9qF JVCZAJf+TzP7EMFWIsWsYCEXaNc0FrVAFFm+La2wbdcZrzaggRXcoIUxPs6qK6353MJA RseRZD2vzQGXol2kj3cn9XbeqUN0zxsOANFUYkPNbivugmiuV19zcPMuA6pJetyGlWbb UNK5mMzr0TVtV3zAYgEn9XVEmKoVrA0hM+7JHW83GW46dF77W90djeKUm4kBEtLv6/95 FLlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=AFptzrx5; 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 w7si14637351qkc.340.2017.06.21.08.44.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:44:18 -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.b=AFptzrx5; 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]:54748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhnj-0007VY-Hx for patch@linaro.org; Wed, 21 Jun 2017 11:44:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlm-0006D1-P8 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlj-0002pv-KI for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:14 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:33512) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlj-0002pi-Cy for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:11 -0400 Received: by mail-wr0-x22f.google.com with SMTP id r103so140131180wrb.0 for ; Wed, 21 Jun 2017 08:42:11 -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=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=AFptzrx5WALdkbxhhjYfcPKetwicKUBw1em+6BWuRZIv1W+XFvGAwxgMupWRbc5Xou Ni2mgRz7c5mZ7OlB+dK49fPChZNMlSXGUjWeqTfoLRRsDfvrbWqPdhw6sPyzA/rdmEAF HzchvbslbVkpXrBhlDFL0VgLid9cOAJ88azTg= 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=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=oj6Hax6oxepFFbFWhX2M9o/zsucJWn/fTzvQ0fVuktpaK5vi1RZaGk3tMEpi1iOFAl DT5HSoFuYBRgKZ9NNuqFAYKi+wwvc7lklQCBZSzqFK4qcGi/lIp/9cSYoNHydzbdYFtr MdrH/Ds6Dhcxhs/umwEFOkBMqSD58fPk9zZZeCUkKZPaI4BnfA0x015zbda87ecsKJkc nXyzwwdVTLZmMEBmEm8ozblFbBJJbw90fuks+SEs+8ZAxjRtvEqaJ6h4+xOcnQ9rPHq2 ejXpyQiAEtO90GDz1XPcwWll8Kt5jzoWa+sqP/Lcx8ghqVrldrVtC72aVYX6sAHfIKdD yzeg== X-Gm-Message-State: AKS2vOyaFwVglS9F4jsk5u1aOgfJL6vgXmqwuavCpzJ0R1hZtfu4Y4jb MtOdPnbEBkteU8oG X-Received: by 10.28.96.134 with SMTP id u128mr6868814wmb.85.1498059730170; Wed, 21 Jun 2017 08:42:10 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p34sm10819012wrc.66.2017.06.21.08.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:07 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3E3773E0F31; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:36 +0100 Message-Id: <20170621154244.28309-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::22f Subject: [Qemu-devel] [RISU PATCH v6 02/10] build-all-archs: support cross building via docker 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If we want to link to any other libraries we might find using simple cross toolchains doesn't work so well. One way around this is to use a dockerised cross-toolchain which then won't clash with your host system. If the user specifies --use-docker the obvious will be done. By default we use the QEMU projects qemu:debian-FOO-cross images as RISU hackers are likely to be QEMU developers too. However any docker tag can be passed on the command line. If none of the docker images have usable compilers we fall back to checking the host path. Signed-off-by: Alex Bennée --- v5 - swapped with --static patch so this can be dropped if desired --- build-all-archs | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) -- 2.13.0 diff --git a/build-all-archs b/build-all-archs index 581a1b4..63918e5 100755 --- a/build-all-archs +++ b/build-all-archs @@ -11,9 +11,6 @@ # Contributors: # Peter Maydell (Linaro) - initial implementation -# So we notice risugen failing even though it's in a pipeline -set -o pipefail - # Simple usage usage() { cat <<-EOF @@ -21,7 +18,10 @@ usage() { Options include: --static build a static binary + --use-docker[=tags] use docker cross compile + If specifying docker the default will be to use the any + qemu:debian-FOO-cross targets available on your system. EOF exit 1 } @@ -37,6 +37,14 @@ while [[ "$1" = -* ]]; do --static) CONF="--static" ;; + --use-docker) + if [ -z "$arg" ]; then + default_tags=$(docker images qemu --format "{{.Repository}}:{{.Tag}}" | grep "\(arm\|power\).*cross$") + docker_tags=$(echo $default_tags | sed 's/\n/\s/g' ) + else + docker_tags="$arg" + fi + ;; --help) usage ;; @@ -48,10 +56,24 @@ done # Debian stretch and Ubuntu Xenial have cross compiler packages for # all of these: -# gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-m68k-linux-gnu -# gcc-powerpc64le-linux-gnu gcc-powerpc64-linux-gnu +# gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-m68k-linux-gnu +# gcc-powerpc64le-linux-gnu gcc-powerpc64-linux-gnu +# If docker is enabled we just brute force the various images until we +# can set the one that has a workable cross compiler. + +DOCKER_RUN="docker run --rm -t -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)" program_exists() { + if [ ! -z "$docker_tags" ]; then + use_docker_tag="" + for tag in $docker_tags; do + if ${DOCKER_RUN} ${tag} /bin/bash -c "command -v $1 >/dev/null"; then + use_docker_tag=$tag + return + fi + done + fi + command -v "$1" >/dev/null 2>&1 } @@ -62,19 +84,29 @@ for triplet in aarch64-linux-gnu arm-linux-gnueabihf m68k-linux-gnu \ if ! program_exists "${triplet}-gcc"; then echo "Skipping ${triplet}: no compiler found" continue + else + echo "Building ${triplet} on ${use_docker_tag:-host}..." fi # Do a complete rebuild from scratch, because it's cheap enough. rm -rf build/${triplet} mkdir -p build/${triplet} - (cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure ${CONF}) - make -C build/${triplet} EXTRA_CFLAGS=-Werror + CONFIGURE="cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure ${CONF}" + MAKE="make -C build/${triplet} EXTRA_CFLAGS=-Werror" + if [ -z "$use_docker_tag" ]; then + /bin/bash -c "${CONFIGURE}" + ${MAKE} + else + ${DOCKER_RUN} $use_docker_tag /bin/bash -c "${CONFIGURE}" + ${DOCKER_RUN} $use_docker_tag /bin/bash -c "${MAKE}" + fi done # Now run risugen for all architectures mkdir -p build/risuout +set -o pipefail # detect failures in pipeline for f in *.risu; do echo "Running risugen on $f..." From patchwork Wed Jun 21 15:42:37 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: 106100 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1994972qgd; Wed, 21 Jun 2017 08:43:49 -0700 (PDT) X-Received: by 10.200.50.249 with SMTP id a54mr4324643qtb.91.1498059829922; Wed, 21 Jun 2017 08:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498059829; cv=none; d=google.com; s=arc-20160816; b=c0vscwY8/tJfrptvCcfdf1mNCpZjdfTFPMXGvx+j4rQf2HZASZUWIKM/k0wovYh9nm gSmFW8DNZxGA9inZ3RB2KEkmD/hv655OfFSBRhkYmn/0px5IegLIP4SBt0WJPe1Vn8js hUk/SzkpuFT9VI178JExWNUv6RVX79UVzjo1cB13NZJk+Vh3IvnTvA97nt10zdU7M8El NAhVHoflNZ+9zbbAbLsrwqNbpJdo5duxF+VMDzpTuTF4R5SNonGKKw55A0VAR2R+Op5N kKhADLZipKj00UGR9izB17iMavhRID6K6l17HMo/3unQyPGLHwzNC8NvTNlfJdKk7Rz+ sCBQ== 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=J/yN4C9X1+aePL3BdMqHjwT07KSj1vM+Via6aS7/6pM=; b=exgI2CBUr7ZnbG1lpqth9sIuM6wTVtSAz1VCH9QryMwuFjt/MImJDON2gXw+74WJot 68jL53Iz7DlfCfURPXutXsCMWxirWE03wKkdJYqMvH2sgwtSrStfdc4Gim0O9NEu49TA 9io2Xc0wjm5Bfadb1PQS6u1lun5HbTZ+42yz/ij6PQcFhOD5RemfcvIeSDlEChgbneT3 JrBaixorpz9Jm7atmOgSqCxhOMHygsa0Uzcra+DWFc9y4xwlXLfProYBD36a1ordA9xD dPYurhnFH/pbFHeimoSAE2jotL73oDKeBbxKDiE7xivSifao2Lcbk8OJCWgieOF60VJ5 vMgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=OtSVQL63; 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 b46si14944277qtb.40.2017.06.21.08.43.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:43:49 -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.b=OtSVQL63; 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]:54745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhnH-0007GW-D2 for patch@linaro.org; Wed, 21 Jun 2017 11:43:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlm-0006D4-Pd for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhli-0002pe-FP for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:14 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:33501) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhli-0002pQ-9D for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:10 -0400 Received: by mail-wr0-x233.google.com with SMTP id r103so140130537wrb.0 for ; Wed, 21 Jun 2017 08:42:10 -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=J/yN4C9X1+aePL3BdMqHjwT07KSj1vM+Via6aS7/6pM=; b=OtSVQL6353y2kS4NyLCN40WKUn6dq7FpTS48D60XkEJFl/cFTr0KH/ETAYCzWut3Sm TeD02qfbbKUwUHzgGLD62Bs3hyWrQzqxrhL1zOqZ0dHZ1kauuIkPWAa6A/4Ir3Fmo5/F NCROi0WffibNgEZbkIjRiEOlfxVu8S+7/DDA0= 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=J/yN4C9X1+aePL3BdMqHjwT07KSj1vM+Via6aS7/6pM=; b=ciEiOh6Dxi6Sy+O2Jud5o6UsVpVilmfEr2ylUtitdx4IW5LoEZqYtN9g24DMzLtsWf fx6E4wRqSn48rA9Aujjw8ZZs7/rR5gnydCsFAyIgF0FZTQ6SxgkzSMYDFQpDyUjBmhLQ VVfradUc7iv9C4HixjQ42PAzX7j7p+QA8ZxLkr+0MFY/Us7mXY5wPzXjUqULKDGcFcLF ijI2Te1QRb6TFfPKc5GgLx0TnBT9vVS5Hyn7sMlSt0r8BieiVpacC0Cb0n0tL8WcjWcJ sPj3Qgwk9IH56hBMGctlNvxfSU+qU3N196okcK8GRcYxhaEmpZn7YnrgqpX4a/LXWhEa wfEw== X-Gm-Message-State: AKS2vOxx2Ym5If+TqYxzRtcWPoVAnalR5WeMjlkz3mjaDrmdVLU6sRcp Kx9r5Yo00GuNUGcSiyIT5w== X-Received: by 10.223.170.79 with SMTP id q15mr21005811wrd.134.1498059729166; Wed, 21 Jun 2017 08:42:09 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 139sm19028573wmw.15.2017.06.21.08.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:07 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 48B0B3E0F68; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:37 +0100 Message-Id: <20170621154244.28309-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::233 Subject: [Qemu-devel] [RISU PATCH v6 03/10] risu: a bit more verbosity when starting 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When debugging faults it is useful to know where the generated instructions are living. Signed-off-by: Alex Bennée --- v6 - removed stray/stale declarations v5 - dropped all the status update due to signal handler contraints v3 - use portable fmt string for image_start_address - include arm dumping position --- risu.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.13.0 diff --git a/risu.c b/risu.c index 2cd6d22..a10422a 100644 --- a/risu.c +++ b/risu.c @@ -124,6 +124,8 @@ int master(int sock) } master_socket = sock; set_sigill_handler(&master_sigill); + fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", + image_start_address); fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); @@ -134,6 +136,8 @@ int apprentice(int sock) { apprentice_socket = sock; set_sigill_handler(&apprentice_sigill); + fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", + image_start_address); fprintf(stderr, "starting image\n"); image_start(); fprintf(stderr, "image returned unexpectedly\n"); From patchwork Wed Jun 21 15:42:38 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: 106101 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1995127qgd; Wed, 21 Jun 2017 08:44:12 -0700 (PDT) X-Received: by 10.55.188.71 with SMTP id m68mr40509755qkf.169.1498059852500; Wed, 21 Jun 2017 08:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498059852; cv=none; d=google.com; s=arc-20160816; b=GnzUaYZdaqYk9VButk+jzpr6Mb+xpKH6TdwAAIs4acv3zE4lCIiJcQ0Rx/ooU8Q1HX hp4bl+tmz+er+zQW49O4el7P9Z+0htqeMsi9QIWh8ntt1qZUUJCFFZo3tFNa8L+qQvzw mc8foUmTK7DQ0mwN88nWxfrSrRADeKzrBDaiAIMFSuqmTycHEetJOvlXbiyS3GbMZkcw Loz+2plo8Ff7BLDCsoWZmR5nWMNoY7/5pW/yPKtdsgbsSaLHhVvIAw4Db6i5+rsvL0Sz 9xWZT+KlQV3LPKaviDkG8061W/64zYleoBo+0IGVPMaV9ntN/ewupeZtrQtUULTepGGg Wjsw== 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=vwqteoGYppvNNxVT4gzgCtsJQIQqedXw7/a0zMX+Ps0=; b=IIfVnCr7d9VnN9L6sQ60zAv9z5raW4R/QycV/YcDNDj2jp/kGuZ4DpIiFITLi7hcAy xOraHwtNYjvpBsS73t0+3maQ1oB2a/JoRV14wkeTyRoO5oB++1E9m0J6KGx8dV0shceI hG4wI97Kb7+1eC76AsnQquvL42zFZNJAm+kA1Fw9QFf3OSiMVS4Yk3TF9WI5zwjb4rIF w3rX6b4UM3KoDZOAYLsHMgSfes+Rk3oqhiqxp8jp4P7GiQVAmnn9eYSNb8bCHGveEgIm QdR9APvxwqSKXs9RR4lv50XxEuuuLiNdLqDIL/L34ClECDwWfcc6lhFH2932Fsz/pedV eW7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=gTn8Vnvo; 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 d200si15431142qke.245.2017.06.21.08.44.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:44:12 -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.b=gTn8Vnvo; 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]:54747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhnd-0007QQ-Rf for patch@linaro.org; Wed, 21 Jun 2017 11:44:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlm-0006D3-PW for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlk-0002qD-HC for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:14 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:33521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlk-0002ps-7N for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:12 -0400 Received: by mail-wr0-x229.google.com with SMTP id r103so140131701wrb.0 for ; Wed, 21 Jun 2017 08:42:12 -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=vwqteoGYppvNNxVT4gzgCtsJQIQqedXw7/a0zMX+Ps0=; b=gTn8VnvoeebySomZANUYl5YtVzYCCbWgldMrLwXSnl2jRrEFY3xOQ5ajSQAttRLcbZ fYNv87FfDuaulNJz2Dlnqf/JDRwSVKqzLOQZrpSzDfFVqEC0tDKpniguPMSx2Cfd2qbw H1P1IhtT3ARfwwZs366or0hub8xdZVtGJqsFI= 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=vwqteoGYppvNNxVT4gzgCtsJQIQqedXw7/a0zMX+Ps0=; b=I9AAV9n6nb0y89cOkF0S1b1LtGr8AZo8Kn50DGcyu2e38gGjiRQgn5V7Yb2UMYIedh o6okx+nF7Tv/DvJz3uNfh1pJ+k/hxuyEUY0UQvTGtBt/B5C01oP8npg/O++/tu0z/DYi q9m76W8azeNMSB5m0ocAv/V6Bdl9sJx4pwK3phGAPu85Z9YCw7d4yUB2TPqoc0sP/Wty HjfGi3IuZluDSLYPo8xJe9HGqVnSmdDkO3CSPO7GemepbgL4mmj6vfLaodJd6a/Ngob1 u7NprGQy7kFrOHJHyIzwvzQZXwTex7IaHf0g06X+sZbcx3ut/T5/xTqthnGFGDHQDsve HogQ== X-Gm-Message-State: AKS2vOw2CBJ8b9AMdc47ocR0zX/dG02Vtv7Ev8rQOk7XzbbJK++BRGxb M3DwaHdyxQrw7DOu X-Received: by 10.28.214.148 with SMTP id n142mr7099586wmg.35.1498059731026; Wed, 21 Jun 2017 08:42:11 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z101sm13019864wrb.41.2017.06.21.08.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:08 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 536F73E0F74; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:38 +0100 Message-Id: <20170621154244.28309-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::229 Subject: [Qemu-devel] [RISU PATCH v6 04/10] risu: paramterise send/receive functions 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a precursor to record/playback support. Instead of passing the socket fd we now pass helper functions for reading/writing and responding. This will allow us to do the rest of the record/playback cleanly outside of the main worker function. Signed-off-by: Alex Bennée --- v6 - restore OP_TESTEND to return write_fn() - clean up wording on helper function prototypes v5 - re-base without tab/format cleanps v4 - split header code - fix formatting foo-bar's v3 - new for v3 - arm, aarch64, ppc64 --- reginfo.c | 38 ++++++++++++++++++-------------------- risu.c | 23 +++++++++++++++++++++-- risu.h | 14 ++++++++++++-- 3 files changed, 51 insertions(+), 24 deletions(-) -- 2.13.0 diff --git a/reginfo.c b/reginfo.c index 31bb99f..b69d11f 100644 --- a/reginfo.c +++ b/reginfo.c @@ -21,7 +21,7 @@ uint8_t apprentice_memblock[MEMBLOCKLEN]; static int mem_used; static int packet_mismatch; -int send_register_info(int sock, void *uc) +int send_register_info(write_fn write_fn, void *uc) { struct reginfo ri; int op; @@ -29,24 +29,24 @@ int send_register_info(int sock, void *uc) op = get_risuop(&ri); switch (op) { - case OP_COMPARE: case OP_TESTEND: - default: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - return send_data_pkt(sock, &ri, sizeof(ri)); + return write_fn(&ri, sizeof(ri)); case OP_SETMEMBLOCK: - memblock = (void *) (uintptr_t) get_reginfo_paramreg(&ri); + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); break; case OP_GETMEMBLOCK: set_ucontext_paramreg(uc, - get_reginfo_paramreg(&ri) + - (uintptr_t) memblock); + get_reginfo_paramreg(&ri) + (uintptr_t)memblock); break; case OP_COMPAREMEM: - return send_data_pkt(sock, memblock, MEMBLOCKLEN); + return write_fn(memblock, MEMBLOCKLEN); break; + case OP_COMPARE: + default: + /* Do a simple register compare on (a) explicit request + * (b) end of test (c) a non-risuop UNDEF + */ + return write_fn(&ri, sizeof(ri)); } return 0; } @@ -59,7 +59,7 @@ int send_register_info(int sock, void *uc) * that says whether it is register or memory data, so if the two * sides get out of sync then we will fail obscurely. */ -int recv_and_compare_register_info(int sock, void *uc) +int recv_and_compare_register_info(read_fn read_fn, respond_fn resp_fn, void *uc) { int resp = 0, op; @@ -73,36 +73,34 @@ int recv_and_compare_register_info(int sock, void *uc) /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) { + if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) { packet_mismatch = 1; resp = 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { /* register mismatch */ resp = 2; - } else if (op == OP_TESTEND) { resp = 1; } - send_response_byte(sock, resp); + resp_fn(resp); break; case OP_SETMEMBLOCK: - memblock = (void *) (uintptr_t) get_reginfo_paramreg(&master_ri); + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); break; case OP_GETMEMBLOCK: set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + - (uintptr_t) memblock); + (uintptr_t)memblock); break; case OP_COMPAREMEM: mem_used = 1; - if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) { + if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { packet_mismatch = 1; resp = 2; } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { /* memory mismatch */ resp = 2; } - send_response_byte(sock, resp); + resp_fn(resp); break; } diff --git a/risu.c b/risu.c index a10422a..88e586c 100644 --- a/risu.c +++ b/risu.c @@ -37,9 +37,28 @@ 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) +{ + return recv_data_pkt(master_socket, ptr, bytes); +} + +void respond_sock(int r) +{ + send_response_byte(master_socket, r); +} + +/* Apprentice function */ + +int write_sock(void *ptr, size_t bytes) +{ + return send_data_pkt(apprentice_socket, ptr, bytes); +} + void master_sigill(int sig, siginfo_t *si, void *uc) { - switch (recv_and_compare_register_info(master_socket, uc)) { + switch (recv_and_compare_register_info(read_sock, respond_sock, uc)) { case 0: /* match OK */ advance_pc(uc); @@ -52,7 +71,7 @@ void master_sigill(int sig, siginfo_t *si, void *uc) void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - switch (send_register_info(apprentice_socket, uc)) { + switch (send_register_info(write_sock, uc)) { case 0: /* match OK */ advance_pc(uc); diff --git a/risu.h b/risu.h index 3fbeda8..20bb824 100644 --- a/risu.h +++ b/risu.h @@ -52,17 +52,27 @@ struct reginfo; /* Functions operating on reginfo */ +/* Function prototypes for read/write helper functions. + * + * We pass the helper function to send_register_info and + * recv_and_compare_register_info which can either be backed by the + * traditional network socket or a trace file. + */ +typedef int (*write_fn) (void *ptr, size_t bytes); +typedef int (*read_fn) (void *ptr, size_t bytes); +typedef void (*respond_fn) (int response); + /* Send the register information from the struct ucontext down the socket. * Return the response code from the master. * NB: called from a signal handler. */ -int send_register_info(int sock, void *uc); +int send_register_info(write_fn write_fn, void *uc); /* Read register info from the socket and compare it with that from the * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch. * NB: called from a signal handler. */ -int recv_and_compare_register_info(int sock, void *uc); +int recv_and_compare_register_info(read_fn read_fn, respond_fn respond, void *uc); /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on From patchwork Wed Jun 21 15:42:39 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: 106105 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1996261qgd; Wed, 21 Jun 2017 08:46:51 -0700 (PDT) X-Received: by 10.159.38.20 with SMTP id 20mr9870118uag.25.1498060011422; Wed, 21 Jun 2017 08:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060011; cv=none; d=google.com; s=arc-20160816; b=ltaAhTsGs4rvtB77qKIrqul/VPKsPg+fLahpBTsDvnIvC+8O57z8GJgMthQzHCP/Ga vV6oeXlzPw/CsPU6RnB3hVx+TqNj1LQautwaNZ3Zi0ltlCI2gwWBsyoCWSrZdxk6XP0Y zepoDTMKkPV2GnaZe/nuQL/c1G6oL6RBAD6w4FmcT7+Dr/oG8o8zWcgEwU7o6IGN8qNF eFVWp1RCa0Z4ag7d+l3/g60Pao89dR6s/Fz0TnLs00QKV+YNqFcjJ0jAIDzpWxSbhCvv 0H15zk7hm9PMPeYNYKACFQWof1ti1OLRQRaQYA8P3sjrtO1ogzKgWRyvtGshc6TIS07c MuBw== 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=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=0IbjvviuBIRwf4ZgUUKoLdCq1v84xjgvscItELYYFx/JKM6MbGF+y4oGinwJk855Y6 nqesRL0N91+8m8jgk0/kUWqisF6CxZIhexdfNjBH3n8V8cvlkKKotdmDvutEFiPz6Uk/ d+YvisxnMKV/j2agSWPRvfyAJlyqa9obrYhYHyP3n7rOUMa+ZIScPn43TMxC/GO2hqTe uao/gxXMdZOqX4dd2X7Z2ygKYmIjoa4dkhGgNYqyOtGfq9ZTqGx9ImluWKxI4IfKVe9V 1CoRezB7iR+4w6A81oTbRLpVbGihYCCQCN5iB9/eb6f1UXgmHAh8s4zuniwhTR3vK3YQ dyyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=fOXQgRhe; 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 72si8046783vki.25.2017.06.21.08.46.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:46: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.b=fOXQgRhe; 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]:54762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhqC-0001RQ-PL for patch@linaro.org; Wed, 21 Jun 2017 11:46:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlp-0006FZ-Cf for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlo-0002rS-3Q for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:33559) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhln-0002r8-Pq for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:16 -0400 Received: by mail-wr0-x234.google.com with SMTP id r103so140133947wrb.0 for ; Wed, 21 Jun 2017 08:42:15 -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=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=fOXQgRhekMaoqudVplwluU4IgmSO1M2GgK6mmIbt3klQpphgaQGr/vMw2jw3LVOKM/ uEHPbhIepHmLjvP2RdcoY1cPOregwo8gD3WWS+eGLgRKwGG58u/wEMxMO1kfouZSsDqV 96ZmL5LskWvy+skf/RMPii1/zSLjgq1mr63/8= 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=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=r9HaIBrHofqbGu9th9z6hGu8QYsR3304XL5vJDpdG3yqeI0CsRBNMLYmNySVRlfM+8 vJt1dhyScYqGON8s7fsa5jveHQEB3LmLJ6en9D06d1gw7GobTIhDmrLJ3/d77No3FX/l wNwRJABkpee+TFkOcx5vEzjUHELak1+hVB1YpUosMUleQsV4vZoga3wVr0EWlnGs/0Yi k849UWY2/s18GdfIN/RG0qH6aGPTG2Rn+mdbUFUCXu3wlPTFHliPFHohwaUhGKPzcz49 v5D5GgKsvpc2bQkW9Gxc+Ybbxl0awWQMPaB6CPoJxTxbqfB5Yoe+sWYMyBbb9jaHKMn+ X7Uw== X-Gm-Message-State: AKS2vOy9+QBVlXSYoFlupUHv+8+4lcKh7IX6E8R5zqqYkzSN4gPDs8W9 1rpZqGcDNeIOkrIOJobOOQ== X-Received: by 10.223.136.116 with SMTP id e49mr15426469wre.14.1498059734502; Wed, 21 Jun 2017 08:42:14 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x94sm19462887wrb.47.2017.06.21.08.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5E2E33E0F7F; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:39 +0100 Message-Id: <20170621154244.28309-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::234 Subject: [Qemu-devel] [RISU PATCH v6 05/10] risu: add header to trace stream 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I've also added a header packet with pc/risu op in it so we can keep better track of how things are going. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell --- v5 - re-base without formatting fixes - dropped fprintfs in signal context v4 - split from previous patch --- reginfo.c | 94 +++++++++++++++++++++++++++++++++++++--------------------- risu.h | 9 ++++++ risu_aarch64.c | 5 ++++ risu_arm.c | 5 ++++ risu_m68k.c | 5 ++++ risu_ppc64.c | 5 ++++ 6 files changed, 89 insertions(+), 34 deletions(-) -- 2.13.0 diff --git a/reginfo.c b/reginfo.c index b69d11f..44d2786 100644 --- a/reginfo.c +++ b/reginfo.c @@ -24,10 +24,19 @@ static int packet_mismatch; int send_register_info(write_fn write_fn, void *uc) { struct reginfo ri; + trace_header_t header; int op; + reginfo_init(&ri, uc); op = get_risuop(&ri); + /* Write a header with PC/op to keep in sync */ + header.pc = get_pc(&ri); + header.risu_op = op; + if (write_fn(&header, sizeof(header)) != 0) { + return -1; + } + switch (op) { case OP_TESTEND: return write_fn(&ri, sizeof(ri)); @@ -62,46 +71,63 @@ int send_register_info(write_fn write_fn, void *uc) int recv_and_compare_register_info(read_fn read_fn, respond_fn resp_fn, void *uc) { int resp = 0, op; + trace_header_t header; reginfo_init(&master_ri, uc); op = get_risuop(&master_ri); - switch (op) { - case OP_COMPARE: - case OP_TESTEND: - default: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) { - packet_mismatch = 1; - resp = 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - /* register mismatch */ - resp = 2; - } else if (op == OP_TESTEND) { - resp = 1; - } - resp_fn(resp); - break; - case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); - break; - case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + - (uintptr_t)memblock); - break; - case OP_COMPAREMEM: - mem_used = 1; - if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { - packet_mismatch = 1; - resp = 2; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { - /* memory mismatch */ - resp = 2; + if (read_fn(&header, sizeof(header)) != 0) { + return -1; + } + + if (header.risu_op == op ) { + + /* send OK for the header */ + resp_fn(0); + + switch (op) { + case OP_COMPARE: + case OP_TESTEND: + default: + /* Do a simple register compare on (a) explicit request + * (b) end of test (c) a non-risuop UNDEF + */ + if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) { + packet_mismatch = 1; + resp = 2; + + } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + /* register mismatch */ + resp = 2; + + } else if (op == OP_TESTEND) { + resp = 1; + } + resp_fn(resp); + break; + case OP_SETMEMBLOCK: + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); + break; + case OP_GETMEMBLOCK: + set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + + (uintptr_t)memblock); + break; + case OP_COMPAREMEM: + mem_used = 1; + if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { + packet_mismatch = 1; + resp = 2; + } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { + /* memory mismatch */ + resp = 2; + } + resp_fn(resp); + break; } + } else { + /* We are out of sync */ + resp = 2; resp_fn(resp); - break; } return resp; diff --git a/risu.h b/risu.h index 20bb824..5248285 100644 --- a/risu.h +++ b/risu.h @@ -50,6 +50,12 @@ extern int test_fp_exc; struct reginfo; +typedef struct +{ + uintptr_t pc; + uint32_t risu_op; +} trace_header_t; + /* Functions operating on reginfo */ /* Function prototypes for read/write helper functions. @@ -102,6 +108,9 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri); */ int get_risuop(struct reginfo *ri); +/* Return the PC from a reginfo */ +uintptr_t get_pc(struct reginfo *ri); + /* initialize structure from a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc); diff --git a/risu_aarch64.c b/risu_aarch64.c index 9c6809d..492d141 100644 --- a/risu_aarch64.c +++ b/risu_aarch64.c @@ -40,3 +40,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x00005af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->pc; +} diff --git a/risu_arm.c b/risu_arm.c index a55c6c2..5fcb2a5 100644 --- a/risu_arm.c +++ b/risu_arm.c @@ -68,3 +68,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->gpreg[15]; +} diff --git a/risu_m68k.c b/risu_m68k.c index 0bf5c14..1056eef 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -33,3 +33,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x4afc7000; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->gregs[R_PC]; +} diff --git a/risu_ppc64.c b/risu_ppc64.c index eb60573..83f8d1f 100644 --- a/risu_ppc64.c +++ b/risu_ppc64.c @@ -38,3 +38,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x00005af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->nip; +} From patchwork Wed Jun 21 15:42:40 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: 106104 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1995541qgd; Wed, 21 Jun 2017 08:45:12 -0700 (PDT) X-Received: by 10.237.46.166 with SMTP id k35mr42109349qtd.115.1498059912831; Wed, 21 Jun 2017 08:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498059912; cv=none; d=google.com; s=arc-20160816; b=WsLtBcjVSCV1RgEftVJZgqOrMpDLLm1J2WVwy4DztSe3J6O+3rGZ/GQ/Qky99O7ylJ 3Ln6Z8id+QcN+uPQjAT08Cnu6cd5EcnS57qCv8y/8pMFuHU1l59s4sixTygexH7iUoej TRuDfhN7SK0Jo2MewvuCsbj+tnBQaz+kCIouNOLGrzfuIDV4C0DX2joPq1n2ayiHzlV9 bz/4xuYXDku2i8ZedsUpd3g7C7LGFd2cfuE7aEiH9JsYqZEedFYUwDWdk0fEmMWIdi09 fb2xP8a+g6N2o8THIDtEcl1hM9MghsSSGjMjVeYH1NRk+To15waBe73GdDTnNt5zc8D5 Jb/w== 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=LXdGdlUX1cBxxHXOsPXGf1VgqdcmxZFRDkJk/YNCJt8=; b=hjoac+SosSBlC73S1wBzoQNWEKr7BNcADrGLdr7clcOjdSHQXWjYHX8FqlroXrQwtG hwku2Uw7yEW0AC+FsMy1BU8sAoC4pzpTJyl1FBwRUSqObdftEgcRN1irECRl48aDL4MF ZPFG5o9RKUmM2mm+A1yu/rFdF0bhmfGX3KcXDDBXV3R8WHj0mcYiONFTFJERX5I3ALye 5sD2y5PKlMJEMJkKvN/QClY0Q2eZikwh0oSSLGlFNVThxl0lonmgBKB056rcS8Q1kcS6 tCG9D9nXjn1fDGVUFI2Mso+CKsud3oLgEIDT9HihM8cC2XUZ5Sef+fId0883YTTnT7h6 OVxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=V4JPoZVQ; 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 v5si14482356qtd.336.2017.06.21.08.45.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:45:12 -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.b=V4JPoZVQ; 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]:54752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhoc-0008Sn-5Y for patch@linaro.org; Wed, 21 Jun 2017 11:45:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlo-0006EY-D1 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhln-0002rC-5o for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:16 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:36651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlm-0002qd-SU for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:15 -0400 Received: by mail-wr0-x232.google.com with SMTP id c11so84695943wrc.3 for ; Wed, 21 Jun 2017 08:42:14 -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=LXdGdlUX1cBxxHXOsPXGf1VgqdcmxZFRDkJk/YNCJt8=; b=V4JPoZVQLNb8sUNqntgA/ke86ZRGnW9K1arFE2ZSfku8KOtVH6j/Y4I/9eG0Oyh0PE nIm/2Wb8YyxElnJpd2+EXB+A3UU4jcfQv7Qu6qX3EX5esU6aNe2aDAN7p5QQlSLBxFiC 0EUYYmdIaX6cZCyETp1nV/h47bR14wuQ9yfTo= 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=LXdGdlUX1cBxxHXOsPXGf1VgqdcmxZFRDkJk/YNCJt8=; b=N+hWNCx6uPRQp1Dflv+ZSjGRe0p3Ke1ZkIRz7kkT5oAJYlsG9dUMnd89UPWEvV9T15 14PWP/pupjPQcm+XRWsZLmxbB+HFqPcJOSRLg9TZ96IQfFjirr7rAVc0A9bpHFu3IKbM CMaPtvgrtKegmfChB4TIoXOTnNO0Puey3Fy68q2GQEK4VPnsnkv6Pq9Gp57CxjsJaRbp W60w2KGjpwQOZWlS9spIK9fgtkhYBKYNfokB2gaPc9BVJxIjI5KOeVw2L2batg9Ey9av KOrpbs/RDI10dI1HroNdpXGGkLbil42ImmxgXG6AVhMYC0+930QHltfIUQ0jtFsKKSzU DbYQ== X-Gm-Message-State: AKS2vOwdxMApzyb1N93N9dZpxBBqgDcvgOtGRi7GJMXWspWOgvoEOBxP e+OYt2qqClKFLuGI X-Received: by 10.28.131.142 with SMTP id f136mr3068246wmd.101.1498059733690; Wed, 21 Jun 2017 08:42:13 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u4sm14117767wmf.7.2017.06.21.08.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 68DE33E0F87; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:40 +0100 Message-Id: <20170621154244.28309-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::232 Subject: [Qemu-devel] [RISU PATCH v6 06/10] risu: add simple trace and replay support 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds a very dumb and easily breakable trace and replay support. In --master mode the various risu ops trigger a write of register/memory state into a binary file which can be played back to an apprentice. Currently there is no validation of the image source so feeding the wrong image will fail straight away. The trace files will get very big for any appreciable sized test file and this will be addressed in later patches. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell --- v5 - re-base without formatting fixes - unify socket/file descriptors - count number of signals/checkpoint - all output from sigjmp (not in signhandlers) v4 - fix formatting mess - abort() instead of reporting de-sync - don't fake return for compiler v3 - fix options parsing - re-factored so no need for copy & paste v2 - moved read/write functions into main risu.c - cleaned up formatting - report more in apprentice --trace mode --- risu.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 93 insertions(+), 19 deletions(-) -- 2.13.0 diff --git a/risu.c b/risu.c index 88e586c..93c274b 100644 --- a/risu.c +++ b/risu.c @@ -30,7 +30,9 @@ void *memblock; -int apprentice_socket, master_socket; +int apprentice_fd, master_fd; +int trace; +size_t signal_count; sigjmp_buf jmpbuf; @@ -41,24 +43,60 @@ int test_fp_exc; int read_sock(void *ptr, size_t bytes) { - return recv_data_pkt(master_socket, ptr, bytes); + return recv_data_pkt(master_fd, ptr, bytes); +} + +int write_trace(void *ptr, size_t bytes) +{ + size_t res = write(master_fd, ptr, bytes); + return (res == bytes) ? 0 : 1; } void respond_sock(int r) { - send_response_byte(master_socket, r); + send_response_byte(master_fd, r); } /* Apprentice function */ int write_sock(void *ptr, size_t bytes) { - return send_data_pkt(apprentice_socket, ptr, bytes); + return send_data_pkt(apprentice_fd, ptr, bytes); +} + +int read_trace(void *ptr, size_t bytes) +{ + size_t res = read(apprentice_fd, ptr, bytes); + return (res == bytes) ? 0 : 1; +} + +void respond_trace(int r) +{ + switch (r) { + case 0: /* test ok */ + case 1: /* end of test */ + break; + default: + /* mismatch - if tracing we need to report, otherwise barf */ + if (!trace) { + abort(); + } + break; + } } void master_sigill(int sig, siginfo_t *si, void *uc) { - switch (recv_and_compare_register_info(read_sock, respond_sock, uc)) { + int r; + signal_count++; + + if (trace) { + r = send_register_info(write_trace, uc); + } else { + r = recv_and_compare_register_info(read_sock, respond_sock, uc); + } + + switch (r) { case 0: /* match OK */ advance_pc(uc); @@ -71,7 +109,16 @@ void master_sigill(int sig, siginfo_t *si, void *uc) void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - switch (send_register_info(write_sock, uc)) { + int r; + signal_count++; + + if (trace) { + r = recv_and_compare_register_info(read_trace, respond_trace, uc); + } else { + r = send_register_info(write_sock, uc); + } + + switch (r) { case 0: /* match OK */ advance_pc(uc); @@ -81,6 +128,9 @@ void apprentice_sigill(int sig, siginfo_t *si, void *uc) exit(0); default: /* mismatch */ + if (trace) { + siglongjmp(jmpbuf, 1); + } exit(1); } } @@ -136,12 +186,17 @@ void load_image(const char *imgfile) image_start_address = (uintptr_t) addr; } -int master(int sock) +int master(void) { if (sigsetjmp(jmpbuf, 1)) { - return report_match_status(); + close(master_fd); + if (trace) { + fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); + return 0; + } else { + return report_match_status(); + } } - master_socket = sock; set_sigill_handler(&master_sigill); fprintf(stderr, "starting master image at 0x%"PRIxPTR"\n", image_start_address); @@ -151,9 +206,13 @@ int master(int sock) exit(1); } -int apprentice(int sock) +int apprentice(void) { - apprentice_socket = sock; + if (sigsetjmp(jmpbuf, 1)) { + close(apprentice_fd); + fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); + return report_match_status(); + } set_sigill_handler(&apprentice_sigill); fprintf(stderr, "starting apprentice image at 0x%"PRIxPTR"\n", image_start_address); @@ -175,6 +234,7 @@ void usage(void) fprintf(stderr, "between master and apprentice risu processes.\n\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, " --master Be the master (server)\n"); + fprintf(stderr, " -t, --trace=FILE Record/playback trace file\n"); fprintf(stderr, " -h, --host=HOST Specify master host machine (apprentice only)" "\n"); @@ -189,7 +249,7 @@ int main(int argc, char **argv) uint16_t port = 9191; char *hostname = "localhost"; char *imgfile; - int sock; + char *trace_fn = NULL; /* TODO clean this up later */ @@ -203,7 +263,7 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; int optidx = 0; - int c = getopt_long(argc, argv, "h:p:", longopts, &optidx); + int c = getopt_long(argc, argv, "h:p:t:", longopts, &optidx); if (c == -1) { break; } @@ -214,6 +274,12 @@ int main(int argc, char **argv) /* flag set by getopt_long, do nothing */ break; } + case 't': + { + trace_fn = optarg; + trace = 1; + break; + } case 'h': { hostname = optarg; @@ -245,12 +311,20 @@ int main(int argc, char **argv) load_image(imgfile); if (ismaster) { - fprintf(stderr, "master port %d\n", port); - sock = master_connect(port); - return master(sock); + if (trace) { + master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } else { + fprintf(stderr, "master port %d\n", port); + master_fd = master_connect(port); + } + return master(); } else { - fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - sock = apprentice_connect(hostname, port); - return apprentice(sock); + if (trace) { + apprentice_fd = open(trace_fn, O_RDONLY); + } else { + fprintf(stderr, "apprentice host %s port %d\n", hostname, port); + apprentice_fd = apprentice_connect(hostname, port); + } + return apprentice(); } } From patchwork Wed Jun 21 15:42:41 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: 106107 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1997143qgd; Wed, 21 Jun 2017 08:48:57 -0700 (PDT) X-Received: by 10.55.212.199 with SMTP id s68mr42499551qks.88.1498060137158; Wed, 21 Jun 2017 08:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060137; cv=none; d=google.com; s=arc-20160816; b=PPfejPowlk6GbZD/YnjvbOCBB8xvWz+1QLXJxNIRLCh8Z1G5ZpNgWfYBZbCGgww6Im ayLRSq7cQRp3Ut77lbD6YIqDtIr1kwllOGfol19gDC4qbFelGFKgdzQjBMBVYWGfuyFv peGQTot5uaFji9qZMgU5S8IuqVu89OGGHAXyDCFkTM4Jv7jYGJEbGFghmQ3+EdEuFM+D JHhq1+GPVM/hVROYbwG/+I29CaMDTKlaTOTbgFn0iLVIarHVrzyZsutZD7gdzyiLba8P xtuMjokQvLkMSmOP+LrTEs/rFbj67U4XNxEdVvzOkTL5avqmUKd18l7IcpO7yoeM06bk 2jFA== 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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=al82mFFRp/lYro27UcTCGEUhLv0CDSBFPoA7bCvyi8vIAQ0/nvOhiSLkSOEtrN5cNQ 5/QHW70VYz26fDLvAhDuhyUL7md/63+pPA5xGWEaRjrgNVUPu76iQVj0KXtMnV2BsHEO h5wiEsIY9ffYUNAUHc6QZQfwZ8/mm5ITwYuNo223uKINDL6WACHLcEhHwXOIyfrTuSou EaFHaIvUrPkQtSEY/eXpJRg75jAVaZF8o/IjiV8Lj3d9YHRSnfagNdqHn2zhmDzN3k/J i+YVfD2bYcuCJUxlbOgxtL5GJapqGyN58KuxtyppH48xpktcbqqVDeTUy5KiqSkEksL6 A0gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=ZRHvQTap; 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 r25si14956690qtb.66.2017.06.21.08.48.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:48:57 -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.b=ZRHvQTap; 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]:54768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhsE-0003pQ-Lo for patch@linaro.org; Wed, 21 Jun 2017 11:48:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlq-0006Gd-5T for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlp-0002s4-CT for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlp-0002rl-69 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: by mail-wr0-x22b.google.com with SMTP id 77so140153625wrb.1 for ; Wed, 21 Jun 2017 08:42:17 -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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=ZRHvQTappTkTBIiJgCGxdwP8ZJn4VTNAjpb32yNBiOmJgR/rFFZRm5NVsH3AMcumIX ahF5YEP5/qN0lgU6WaS4gXxo4JImLL+4xHA1/lc+iZlPpEVUTubE5Mc2UZUlyKovmJLQ f10sF6pV+CoXUvdH8BkqnoIRPBqD4af44S/gE= 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=/v7qEn9OUH4Ho5RKpb1O3APGA9roAlKy9N6ZoVROiGI=; b=N+pZRqtRVwIQvpdeipFhrzf1QRds9fpNWfY4ugLSPVHHbyg5s9tMJIN/gN9hQRLtx6 bcjv66+qggiTmphQhHiUf7g9pmdwwPHmYUdJAb9IJgcVptNOcRIli/sqgNOXJXk7vi+a 2rRq9SXaGlYdMU6EsiVOs0YRhBghSQ3IM7CO6AfGqI970A1GfHB7AM9b28egM0exhZle tIOwWKBK9f/QF4kSms9tXs9TpH/+Oy7owwFCaF8xq02uMo9vziKRdZlqbVzj2MzUSN7w QfFs+8e7bfwH0ixt8pTYMd/sVO7g63zCwn/29GgzOwg1NvcMQKFFjIfu6zPnbOKC/eJx VNtg== X-Gm-Message-State: AKS2vOzq0m4qZe90hk7B/HJ6rSjHRFR8f+tOYZF8Gdx1T15GN/FwgJrZ wSGTUa73xPuAxZ2F X-Received: by 10.28.52.15 with SMTP id b15mr1091003wma.123.1498059736035; Wed, 21 Jun 2017 08:42:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y89sm16343701wmh.13.2017.06.21.08.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 72A623E0F8B; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:41 +0100 Message-Id: <20170621154244.28309-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::22b Subject: [Qemu-devel] [RISU PATCH v6 07/10] risu: handle trace through stdin/stdout 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Trace files can get quite large so it would be useful to be able to just capture the trace stream with stdin/stdout for processing in a pipe line. The sort of case where this is useful is for building static binaries where zlib support is missing for whatever reason. It can also be used in testing pipelines. Signed-off-by: Alex Bennée --- v6 - use STDIN/OUT_FILENO instead of fileno(foo) - strcmp instead of strncmp --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.13.0 diff --git a/risu.c b/risu.c index 93c274b..476475c 100644 --- a/risu.c +++ b/risu.c @@ -312,7 +312,11 @@ int main(int argc, char **argv) if (ismaster) { if (trace) { - master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + if (strcmp(trace_fn, "-")==0) { + master_fd = STDOUT_FILENO; + } else { + master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } } else { fprintf(stderr, "master port %d\n", port); master_fd = master_connect(port); @@ -320,7 +324,11 @@ int main(int argc, char **argv) return master(); } else { if (trace) { - apprentice_fd = open(trace_fn, O_RDONLY); + if (strcmp(trace_fn, "-")==0) { + apprentice_fd = STDIN_FILENO; + } else { + apprentice_fd = open(trace_fn, O_RDONLY); + } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); apprentice_fd = apprentice_connect(hostname, port); From patchwork Wed Jun 21 15:42:42 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: 106106 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1996952qgd; Wed, 21 Jun 2017 08:48:32 -0700 (PDT) X-Received: by 10.237.61.153 with SMTP id i25mr10053314qtf.239.1498060112203; Wed, 21 Jun 2017 08:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060112; cv=none; d=google.com; s=arc-20160816; b=WahbL6MrXmbErDSEE9mKaC+jB/9zVl5nIhkH8O68rIdTmGQIb+Qy/4AiwybYqTj4fK iCuOgehuDFvML0Y6vaa3Vy0PWromvBmf+vOGDF4o9J01T97TWmFhsSSQF3ZrfkFAQ7BW qzsVrVKKFlIJJYjiqCCZux6Y3D4h7+MHQiwRg/vvqCOX1FaM9sPh3u/F5xazxvLhKh8f HrvRkRtkZr5Y3SIs979IeD/hemuo5EjVk4JbENsqdYO2C5zGvGOyd45ej0W1fo9nCZbc j3rcGde7YhAlYtgxlDPo9NtXqSO6fSpcfs1YIAw2ic40XgoeaiSrUi1NyhY+klnkWfWA I1lw== 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=TRQ9xQL7UydABoEzt+l7InX1CtycIHDBFIhRZGNlsS0=; b=s/36DKURsRa9YeM8cPfLtNL2KmGijpjutghSK1p3g+9YIeB3GdtcpI3xqaiMcZppCK 9pyPkLiPNgY6dOc0LFr+VT5A/dzLtH7DDIsPCPPZe4iSdm+CRGUhSMDoyfS0D/FsjQ5s H9y6xQDQzgo0RBPeo9kGqQct40MAKBnnC5P6TcH19Ob2y+Sel0cvqwk1fkbgZj/6tIvF CSgKE159bmMiaNHUOc6uaibDwow1HROWZqYixYY3D9U37bClby0cdYMrBJ7YmtbRHaKk 6qhm1+tg7zs3P8i0jIFq4kRWOOixqX6mVDuIDoFAgy5L6wu9puKVo+u20yfkzZz38jgl v/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=jujg+k2S; 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 v41si4453959qta.244.2017.06.21.08.48.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:48:32 -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.b=jujg+k2S; 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]:54766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhrp-0003ci-Ko for patch@linaro.org; Wed, 21 Jun 2017 11:48:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlr-0006Ii-Te for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlq-0002sX-CV for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:19 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:34189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlq-0002s8-2k for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: by mail-wr0-x22d.google.com with SMTP id 77so140154192wrb.1 for ; Wed, 21 Jun 2017 08:42:17 -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=TRQ9xQL7UydABoEzt+l7InX1CtycIHDBFIhRZGNlsS0=; b=jujg+k2SXJdY/G6yl4CxEvawgjSBpYNil3XlKu0CwlSkqfLSRYz6qRA1prcVtA/ii3 XIgnMfZ12+q/Qa3M2Ss81Nn2g4dZLNgxUFo85F37dER5+z+1xNnoBDPiz138h28kXfiu GzmWzNsyBS9NKKvI5hG51pr6u5AKvrqBEs64A= 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=TRQ9xQL7UydABoEzt+l7InX1CtycIHDBFIhRZGNlsS0=; b=bN8sLXVDbbtzwHmKxKvlOWa1nIprAdYe3vMo+MJIlBOsa2xByIe5cWAn50gDVx70gu TbUjPyETLC3k8JYDnJPnEGmYAOs3mXQIC9vqBLKtSNJZyjmmQnO7Rb92Px0S48j11Nvh vNVfTwj8jVGJFibu+sCRREJKbVs4Q7Snkhrni/dLb7vzCtiqedwRe0hppVq/NXgOrpJM /VoAtnDQ96m1A5/8dtQkL2fpuup10twxvh1ntE3eFByjNqFEgy4+2cMidC5WHqZHFuur IHfm0cNoPmI7f9VZabJMZ+c67IfN0n/u/LEKjhbXkQ09ghDCXqHgWAvw38DpNcDdhZwm IUIA== X-Gm-Message-State: AKS2vOzS+LWbmYusHMFViZfk9rldqsDhYGQDdtz/kSBxwpQ6+scXuFL/ xOGmPcKzQJgAKAX2f8c8qQ== X-Received: by 10.223.151.155 with SMTP id s27mr12019460wrb.159.1498059736870; Wed, 21 Jun 2017 08:42:16 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 201sm15986870wmr.4.2017.06.21.08.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7C69D3E0F98; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:42 +0100 Message-Id: <20170621154244.28309-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::22d Subject: [Qemu-devel] [RISU PATCH v6 08/10] risu: add support compressed tracefiles 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This uses the magic of zlib's gzread/write interface to wrap the tracefile in compression. The code changes are tiny. I spent more time messing about with the configure/linker stuff to auto-detect bits. As you need decent multi-arch support or a correctly setup cross toolchain we fall back if we can't compile with zlib. This unfortunately needs some #ifdef hackery around the zlib bits in risu.c. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell -- v5 - re-base - also don't use zlib if using stdio fds v4 - removed redundant config.h output, added HAVE_ZLIB - added BUILD_INC to deal with out-of-tree builds --- Makefile | 4 ++-- configure | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- risu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 101 insertions(+), 6 deletions(-) -- 2.13.0 diff --git a/Makefile b/Makefile index 9a29bb4..ca80eef 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ VPATH=$(SRCDIR) CFLAGS ?= -g -ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) $(CFLAGS) $(EXTRA_CFLAGS) +ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) $(BUILD_INC) $(CFLAGS) $(EXTRA_CFLAGS) PROG=risu SRCS=risu.c comms.c reginfo.c risu_$(ARCH).c risu_reginfo_$(ARCH).c @@ -35,7 +35,7 @@ all: $(PROG) $(BINS) dump: $(RISU_ASMS) $(PROG): $(OBJS) - $(CC) $(STATIC) $(ALL_CFLAGS) -o $@ $^ + $(CC) $(STATIC) $(ALL_CFLAGS) -o $@ $^ $(LDFLAGS) %.risu.asm: %.risu.bin ${OBJDUMP} -b binary -m $(ARCH) -D $^ > $@ diff --git a/configure b/configure index c4b5adb..1dc527b 100755 --- a/configure +++ b/configure @@ -32,6 +32,10 @@ compile() { $CC $CFLAGS -c -o ${1}.o ${1}.c 2>/dev/null } +link() { + $LD $LDFLAGS -l${2} -o ${1} ${1}.o 2>/dev/null +} + check_define() { c=${tmp_dir}/check_define_${1} cat > ${c}.c < ${c}.c < +#include +#include +#include + +int main(void) { $1 thisone; return 0; } +EOF + compile $c +} + +check_lib() { + c=${tmp_dir}/check_lib${1} + cat > ${c}.c < +#include <$2.h> + +int main(void) { $3; return 0; } +EOF + compile $c && link $c $1 +} + +generate_config() { + cfg=config.h + echo "generating config.h..." + + echo "/* config.h - generated by the 'configure' script */" > $cfg + echo "#ifndef CONFIG_H" >> $cfg + echo "#define CONFIG_H 1" >> $cfg + + if check_lib z zlib "zlibVersion()"; then + echo "#define HAVE_ZLIB 1" >> $cfg + LDFLAGS=-lz + fi + + echo "#endif /* CONFIG_H */" >> $cfg + + echo "...done" +} + generate_makefilein() { m=Makefile.in echo "generating Makefile.in..." @@ -65,11 +111,13 @@ generate_makefilein() { echo "# Makefile.in - generated by the 'configure' script" > $m echo "ARCH:=${ARCH}" >> $m echo "CC:=${CC}" >> $m + echo "LDFLAGS:=${LDFLAGS}" >> $m echo "AS:=${AS}" >> $m echo "OBJCOPY:=${OBJCOPY}" >> $m echo "OBJDUMP:=${OBJDUMP}" >> $m echo "STATIC:=${STATIC}" >> $m echo "SRCDIR:=${SRCDIR}" >> $m + echo "BUILD_INC:=${BUILD_INC}" >> $m echo "...done" } @@ -118,6 +166,7 @@ done CC="${CC-${CROSS_PREFIX}gcc}" AS="${AS-${CROSS_PREFIX}as}" +LD="${LD-${CROSS_PREFIX}ld}" OBJCOPY="${OBJCOPY-${CROSS_PREFIX}objcopy}" OBJDUMP="${OBJDUMP-${CROSS_PREFIX}objdump}" @@ -125,15 +174,17 @@ if test "x${ARCH}" = "x"; then guess_arch fi -generate_makefilein - # Are we in a separate build tree? If so, link the Makefile # so that 'make' works. if test ! -e Makefile; then echo "linking Makefile..." + BUILD_INC="-I $(pwd)" ln -s "${SRCDIR}/Makefile" . fi +generate_config +generate_makefilein + rm -r "$tmp_dir" echo "type 'make' to start the build" diff --git a/risu.c b/risu.c index 476475c..47e50ad 100644 --- a/risu.c +++ b/risu.c @@ -26,6 +26,8 @@ #include #include +#include "config.h" + #include "risu.h" void *memblock; @@ -34,6 +36,11 @@ int apprentice_fd, master_fd; int trace; size_t signal_count; +#ifdef HAVE_ZLIB +#include +gzFile gz_trace_file; +#endif + sigjmp_buf jmpbuf; /* Should we test for FP exception status bits? */ @@ -48,7 +55,17 @@ int read_sock(void *ptr, size_t bytes) int write_trace(void *ptr, size_t bytes) { - size_t res = write(master_fd, ptr, bytes); + size_t res; + +#ifdef HAVE_ZLIB + if (master_fd == STDOUT_FILENO) { +#endif + res = write(master_fd, ptr, bytes); +#ifdef HAVE_ZLIB + } else { + res = gzwrite(gz_trace_file, ptr, bytes); + } +#endif return (res == bytes) ? 0 : 1; } @@ -66,7 +83,18 @@ int write_sock(void *ptr, size_t bytes) int read_trace(void *ptr, size_t bytes) { - size_t res = read(apprentice_fd, ptr, bytes); + size_t res; + +#ifdef HAVE_ZLIB + if (apprentice_fd == STDIN_FILENO) { +#endif + res = read(apprentice_fd, ptr, bytes); +#ifdef HAVE_ZLIB + } else { + res = gzread(gz_trace_file, ptr, bytes); + } +#endif + return (res == bytes) ? 0 : 1; } @@ -189,6 +217,11 @@ void load_image(const char *imgfile) int master(void) { if (sigsetjmp(jmpbuf, 1)) { +#ifdef HAVE_ZLIB + if (trace && master_fd != STDOUT_FILENO) { + gzclose(gz_trace_file); + } +#endif close(master_fd); if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", signal_count); @@ -209,6 +242,11 @@ int master(void) int apprentice(void) { if (sigsetjmp(jmpbuf, 1)) { +#ifdef HAVE_ZLIB + if (trace && apprentice_fd != STDIN_FILENO) { + gzclose(gz_trace_file); + } +#endif close(apprentice_fd); fprintf(stderr, "finished early after %zd checkpoints\n", signal_count); return report_match_status(); @@ -316,6 +354,9 @@ int main(int argc, char **argv) master_fd = STDOUT_FILENO; } else { master_fd = open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); +#ifdef HAVE_ZLIB + gz_trace_file = gzdopen(master_fd, "wb9"); +#endif } } else { fprintf(stderr, "master port %d\n", port); @@ -328,6 +369,9 @@ int main(int argc, char **argv) apprentice_fd = STDIN_FILENO; } else { apprentice_fd = open(trace_fn, O_RDONLY); +#ifdef HAVE_ZLIB + gz_trace_file = gzdopen(apprentice_fd, "rb"); +#endif } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port); From patchwork Wed Jun 21 15:42:43 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: 106109 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1998473qgd; Wed, 21 Jun 2017 08:52:07 -0700 (PDT) X-Received: by 10.55.120.1 with SMTP id t1mr38988630qkc.171.1498060327793; Wed, 21 Jun 2017 08:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060327; cv=none; d=google.com; s=arc-20160816; b=tr0uL9emOFZnhG+uPBBpbw+iHYimrGt1aorxDsevDcnP3HI3FeOWghWND5jQyuqjKY L0yygvuJuxcNHP/y/CaQj6QkohuT9SXBal64rLAywMY+1tHCCCwAOmA/TN1uProPZgwk DFL/dvauZd9tdia8eY++StAamJysXkucWAOUrBMszFDIiYYLetMYkSUTYpK2RROLjVGX ztrru3nuGiYjWFewHKf6lz3W/6h3NGxXk8AIrDglrbRFF08w1x1eVtLLYPiYdXrcOmCa UNtQgA7wFmuivbtgkWlAN7mAKd2BBLJLdMeJoCcML/AS7AHGZ7Tw4Dyk9E7BZrQpBGXD iumQ== 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=VHjaHXwZN5H2T0HQTezWT4fu4LV4/bi4RRsfJKfr5ww=; b=a33moGeYBaUQb3eO6EndsdnWQFTwJ0YvZn+oF7I7I5ZGpuUwhuaJnnFl5EnE/IaYNm Z0hXtAENBFNSQ2K1JX2nOYE28mkG0CwMl6NID1RNaB4/ZxmLkXvwlGH+VNQvfd2ICP3D H4lSf0PZJNys0svd6lqsMdFJA4BhezoFO/pc3n90t+TJZoh0hRW9ECcbguPb74OuCf5h tAZJT+M03VXBqw6PMlZ29BvLyyT+BNgpdmlvwFkzxJ6lXwKLmZP1a542IVWQgCn/ImF3 WzZpxisnJCeDqdQOW98jU30gvrRjHgKQA789h2amSGyYNNCwR+yJJ5fE83eIL0SPNEsI Jxjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=OyiAtqwC; 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 2si15349269qtm.342.2017.06.21.08.52.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:52:07 -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.b=OyiAtqwC; 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]:54782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhvJ-0007mw-Df for patch@linaro.org; Wed, 21 Jun 2017 11:52:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlw-0006O2-HB for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhls-0002tK-5w for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:24 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:36712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlr-0002t3-VB for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:20 -0400 Received: by mail-wr0-x231.google.com with SMTP id c11so84699427wrc.3 for ; Wed, 21 Jun 2017 08:42:19 -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=VHjaHXwZN5H2T0HQTezWT4fu4LV4/bi4RRsfJKfr5ww=; b=OyiAtqwCwtDeZx+ooO0/CS1tUPwU9N5y2Ad9R1Ame0D8JFOenxkc/YzeCuqphLyY/z +WJRO/eFjdaab+22oPfG6Epsrzo+zk4ACnXy4q/aCxw9FI24HI1RDKPGMLa2iP3ouBlG xDxQhK82TxSANkRA1KVGh+19XJ8boqs+MQTJg= 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=VHjaHXwZN5H2T0HQTezWT4fu4LV4/bi4RRsfJKfr5ww=; b=WkUHDqqxk8LPz+auJnCuFG6fEIb5PLbR9TEUl1AiW9T/L6jCq92VfVRxS6WVN4mmCW CjXvQSdA/ny9CCMEhcC5celYnfasJWrFer6JPSLZsFdqCWbLxP7NmUl43hr501C/RiWf hxccN7whSN2RRp4JkuflmWe9gpSHtSK8PaIn9c6B+k/GAG0F/sss699M73Z55cC3VEBL 64pdzLKvBeRW3WD/Ng0RY6imSTP7vbH3CeoBsAwfDclOFv6eLA/vp8DyRbXSAGqAjo+L lfKZ3zO4fdzUP9xYQ0xFzSNUisPvMhSui71z1qVXukDn+pZJfqzDaTNQIussxwrFgDrZ yItA== X-Gm-Message-State: AKS2vOzD5Wr+54ypbR68QCpgSaAtb8jZh50iyCHXHq8V/pLPcLH4lCH5 ftMAsc0ZvK1NyBl6oPYYcw== X-Received: by 10.223.166.196 with SMTP id t62mr22925299wrc.52.1498059738850; Wed, 21 Jun 2017 08:42:18 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a99sm21455174wrc.64.2017.06.21.08.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 862B93E0F9D; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:43 +0100 Message-Id: <20170621154244.28309-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::231 Subject: [Qemu-devel] [RISU PATCH v6 09/10] new: record_traces.sh helper script 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A simple script to run through a bunch of binaries and generate their trace files. Signed-off-by: Alex Bennée --- v6 - moved into contrib/ v5 - author, license and usage header v3 - allow overriding of RISU binary --- contrib/record_traces.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 contrib/record_traces.sh -- 2.13.0 diff --git a/contrib/record_traces.sh b/contrib/record_traces.sh new file mode 100755 index 0000000..1234a61 --- /dev/null +++ b/contrib/record_traces.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# A risu helper script to batch process a bunch of binaries and record their outputs +# +# Copyright (c) 2017 Linaro Limited +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Alex Bennée - initial implementation +# +# Usage: +# export RISU=/path/to/risu +# ./record_traces.sh ./testcases.aarch64/*.bin +# + +set -e + +if test -z "$RISU"; then + script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) + RISU=${script_dir}/risu +fi + +for f in $@; do + echo "Running risu against $f" + t="$f.trace" + ${RISU} --master $f -t $t + echo "Checking trace file OK" + ${RISU} $f -t $t +done From patchwork Wed Jun 21 15:42:44 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: 106108 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1997857qgd; Wed, 21 Jun 2017 08:50:35 -0700 (PDT) X-Received: by 10.200.3.222 with SMTP id z30mr2073163qtg.185.1498060235793; Wed, 21 Jun 2017 08:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060235; cv=none; d=google.com; s=arc-20160816; b=VYvZarm2u0ZJR9sk5G58aZI63lB8xz3cwZaYqVL/H7cnI3yFCYxyeYWTTN4OIO/+Es /wMvGuqLrkWa7pD8aHMFUypzOJ7eOiHY3AJ5vZSTzE9JHsYLWJ8V1I7dCadv+zIkGmON AbPJDrBl5GrlbFuHPUqH7a4yNrV99JWSgw/1bRQ8N5YWpQYgnRUUZoGqXrPxkIsNSVuX MqHU274lJGjpmEH9Rren1X7EwkDNoRF6CvM1fjtrMpBAQ41CI/v6lclLi4zuJcKfFsTS 9x1AqW2hDIA2M3J63iBvT162ZS4LKBris/ptiMBmG+5KjfKqalmAMb4voYom+kAtdBAT jsgw== 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=TS8I+7Fd2WGVDf15A4Nyo0UTKamV+GqrLlmrO6dVpaM=; b=KAkUVfrDz/KtK0wd7rH/urDTcWsjsCGIilaB/eGrQTwXSX4prCtlwTqdSsMBye1UFv VPkA6xzpkUg2xn+a6O3chfCP3SjRmdfyRPB17cUDIeu+JT+pJe7PsB9EPrj1v4nXpxST ezWbNOhYLCzWSCkUPNlvKHeL3nh5KempxxIkB1G7uS6U4tdiYGqifEbtHZi0sg3TGWx3 Zroq7jST8Qx/6fMb45WNQ3c7ojQSZLUpcheX8Wn4SgVUYUIl8OtJZY1BepNf4EAewlsX uWTMGdtTKPUbD+sAsp2gPq779ZWuAIDEIP/oApILfkVVZeLPnBJW2vD1zlXH7BPbZqeC nBuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=dvilbpLP; 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 q51si15025256qtc.220.2017.06.21.08.50.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:50:35 -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.b=dvilbpLP; 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]:54778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhtp-0005nr-BQ for patch@linaro.org; Wed, 21 Jun 2017 11:50:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhls-0006Iq-1J for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlr-0002sv-0y for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:20 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:33594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhlq-0002sP-RL for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: by mail-wr0-x230.google.com with SMTP id r103so140136018wrb.0 for ; Wed, 21 Jun 2017 08:42:18 -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=TS8I+7Fd2WGVDf15A4Nyo0UTKamV+GqrLlmrO6dVpaM=; b=dvilbpLPd943omd8FNXlrfxRjjoRFU+qd6aBl8xKu1qGIKwdv6wCrl+8Fq86ssuUfS AZFXC63HF6zULAnnyf6EIqrbp8qEM7iVV57a9cUX2ova9VnF4+srw/dlK9ue3yXozt47 P1m7UEMQSpa8Pg1kt2EN4My6mgg1ryAvb9Bys= 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=TS8I+7Fd2WGVDf15A4Nyo0UTKamV+GqrLlmrO6dVpaM=; b=Zlywn9p2ccQ7zTrEwtcxYtzy4peGy4NT9sSF0rI0ys465pSBltZxyWqtPMWWC5jrpu r/lX/zBRQK8fkt5EKF2gjaZXKEb9AHszTM0IOmbVQyuEfB/uC8YfHlplveQMulvg3+9v 5mqmJUuMNZRABhdk+t5KxT+6aPSkiMmDmM4ABoU/a3cCSkDXJe/nM7wlMvbCZ7nnfRHO mK6jdWjxYUtEF33NE3/3r2QM3MKevplMOms+3+jbN27E1bJjGy93+EO9Dswt/RUvGueg 0/BO1l175UzbDw9amzRzjuCakX82xkYcXBXh9XBJSvkQWDhg6mJfveOydV7txt7ndUOA zWfg== X-Gm-Message-State: AKS2vOxOS0f71lzA57ynaqEtZJjRotusm/UVDfrFETV28OY2niCk9ijm OcGJFMohZTDPLYlY X-Received: by 10.223.128.80 with SMTP id 74mr25291492wrk.9.1498059737782; Wed, 21 Jun 2017 08:42:17 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u18sm13460209wrc.14.2017.06.21.08.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 8FEA63E0FA1; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:44 +0100 Message-Id: <20170621154244.28309-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-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::230 Subject: [Qemu-devel] [RISU PATCH v6 10/10] new: run_risu.sh script 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-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A simple script to work through running all of a bunch of files with record/playback traces. Dumps a summary and the number of failed tests at the end. Signed-off-by: Alex Bennée --- v6 - moved into contrib/ v5 - author, license, usage header v3 - tweak to allow specifying RISU binary --- contrib/run_risu.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 contrib/run_risu.sh -- 2.13.0 diff --git a/contrib/run_risu.sh b/contrib/run_risu.sh new file mode 100755 index 0000000..439cd36 --- /dev/null +++ b/contrib/run_risu.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# Run risu against a set of binaries + trace files +# +# Copyright (c) 2017 Linaro Limited +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Alex Bennée - initial implementation +# +# Usage: +# (optional) export QEMU=/path/to/qemu +# (optional) export RISU=/path/to/risu +# ./run_risu.sh ./testcases.aarch64/*.bin + +set -e + +passed=() +failed=() +missing=() + +if test -z "$RISU"; then + script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) + RISU=${script_dir}/risu +fi + +for f in $@; do + t="$f.trace" + echo "Running $f against $t" + if [ -e $t ]; then + ${QEMU} ${RISU} $f -t $t + if [ $? == 0 ]; then + passed=( "${passed[@]}" $f ) + else + failed=( "${failed[@]}" $f ) + fi + else + missing=( "${missing[@]}" $f ) + fi +done + +if test ${#missing[@]} -gt 0; then + echo "Tests missing ${#missing[@]} trace files:" + for m in "${missing[@]}"; do + echo "$m" + done +fi + +if test ${#passed[@]} -gt 0; then + echo "Passed ${#passed[@]} tests:" + for p in "${passed[@]}"; do + echo "$p" + done +fi + +if test ${#failed[@]} -gt 0; then + echo "Failed ${#failed[@]} tests:" + for f in "${failed[@]}"; do + echo "$f" + done +fi + +exit ${#failed[@]}