From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149805999406296.33528201177865; Wed, 21 Jun 2017 08:46:34 -0700 (PDT) Received: from localhost ([::1]:54760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhpu-0001KX-HN for importer@patchew.org; Wed, 21 Jun 2017 11:46:30 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 We also include the an Emacs .dir-locals (as per QEMU) that enforces this layout. Signed-off-by: Alex Benn=C3=A9e --- .dir-locals.el | 2 ++ README | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 .dir-locals.el 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 c= ompiler installed for. This is useful for confirming that your changes to risu haven't broken anything. =20 +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 ----- =20 --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498059848650656.5012533876103; Wed, 21 Jun 2017 08:44:08 -0700 (PDT) Received: from localhost ([::1]:54748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhnZ-0007VY-Ch for importer@patchew.org; Wed, 21 Jun 2017 11:44:05 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- v5 - swapped with --static patch so this can be dropped if desired --- build-all-archs | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) 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 =20 -# 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() { =20 Options include: --static build a static binary + --use-docker[=3Dtags] use docker cross compile =20 + 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" =3D -* ]]; do --static) CONF=3D"--static" ;; + --use-docker) + if [ -z "$arg" ]; then + default_tags=3D$(docker images qemu --format "{{.Repositor= y}}:{{.Tag}}" | grep "\(arm\|power\).*cross$") + docker_tags=3D$(echo $default_tags | sed 's/\n/\s/g' ) + else + docker_tags=3D"$arg" + fi + ;; --help) usage ;; @@ -48,10 +56,24 @@ done =20 # 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=3D"docker run --rm -t -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)" =20 program_exists() { + if [ ! -z "$docker_tags" ]; then + use_docker_tag=3D"" + for tag in $docker_tags; do + if ${DOCKER_RUN} ${tag} /bin/bash -c "command -v $1 >/dev/null= "; then + use_docker_tag=3D$tag + return + fi + done + fi + command -v "$1" >/dev/null 2>&1 } =20 @@ -62,19 +84,29 @@ for triplet in aarch64-linux-gnu arm-linux-gnueabihf m6= 8k-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 =20 # Do a complete rebuild from scratch, because it's cheap enough. rm -rf build/${triplet} mkdir -p build/${triplet} =20 - (cd build/${triplet} && CROSS_PREFIX=3D"${triplet}-" ../../configure = ${CONF}) - make -C build/${triplet} EXTRA_CFLAGS=3D-Werror + CONFIGURE=3D"cd build/${triplet} && CROSS_PREFIX=3D"${triplet}-" ../.= ./configure ${CONF}" + MAKE=3D"make -C build/${triplet} EXTRA_CFLAGS=3D-Werror" =20 + 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 =20 # Now run risugen for all architectures mkdir -p build/risuout +set -o pipefail # detect failures in pipeline =20 for f in *.risu; do echo "Running risugen on $f..." --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14980599116171004.4114002497284; Wed, 21 Jun 2017 08:45:11 -0700 (PDT) Received: from localhost ([::1]:54750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhob-0008R2-Ba for importer@patchew.org; Wed, 21 Jun 2017 11:45:09 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 When debugging faults it is useful to know where the generated instructions are living. Signed-off-by: Alex Benn=C3=A9e --- 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(+) 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 =3D 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 =3D 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"); --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498059840139299.2653869256677; Wed, 21 Jun 2017 08:44:00 -0700 (PDT) Received: from localhost ([::1]:54747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhnS-0007QQ-KH for importer@patchew.org; Wed, 21 Jun 2017 11:43:58 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- 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(-) 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; =20 -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 =3D get_risuop(&ri); =20 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 =3D (void *) (uintptr_t) get_reginfo_paramreg(&ri); + memblock =3D (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)membl= ock); 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, vo= id *uc) { int resp =3D 0, op; =20 @@ -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 =3D 1; resp =3D 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { /* register mismatch */ resp =3D 2; - } else if (op =3D=3D OP_TESTEND) { resp =3D 1; } - send_response_byte(sock, resp); + resp_fn(resp); break; case OP_SETMEMBLOCK: - memblock =3D (void *) (uintptr_t) get_reginfo_paramreg(&master_ri); + memblock =3D (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 =3D 1; - if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) { + if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { packet_mismatch =3D 1; resp =3D 2; } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) !=3D= 0) { /* memory mismatch */ resp =3D 2; } - send_response_byte(sock, resp); + resp_fn(resp); break; } =20 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; =20 +/* 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) =20 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; =20 /* Functions operating on reginfo */ =20 +/* 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); =20 /* 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, vo= id *uc); =20 /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498059998989948.614442708033; Wed, 21 Jun 2017 08:46:38 -0700 (PDT) Received: from localhost ([::1]:54762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhq1-0001RQ-B8 for importer@patchew.org; Wed, 21 Jun 2017 11:46:37 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e 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(-) 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 =3D get_risuop(&ri); =20 + /* Write a header with PC/op to keep in sync */ + header.pc =3D get_pc(&ri); + header.risu_op =3D op; + if (write_fn(&header, sizeof(header)) !=3D 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, vo= id *uc) { int resp =3D 0, op; + trace_header_t header; =20 reginfo_init(&master_ri, uc); op =3D get_risuop(&master_ri); =20 - 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 =3D 1; - resp =3D 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - /* register mismatch */ - resp =3D 2; - } else if (op =3D=3D OP_TESTEND) { - resp =3D 1; - } - resp_fn(resp); - break; - case OP_SETMEMBLOCK: - memblock =3D (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 =3D 1; - if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { - packet_mismatch =3D 1; - resp =3D 2; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) !=3D= 0) { - /* memory mismatch */ - resp =3D 2; + if (read_fn(&header, sizeof(header)) !=3D 0) { + return -1; + } + + if (header.risu_op =3D=3D 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 =3D 1; + resp =3D 2; + + } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + /* register mismatch */ + resp =3D 2; + + } else if (op =3D=3D OP_TESTEND) { + resp =3D 1; + } + resp_fn(resp); + break; + case OP_SETMEMBLOCK: + memblock =3D (void *)(uintptr_t)get_reginfo_paramreg(&master_r= i); + break; + case OP_GETMEMBLOCK: + set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + + (uintptr_t)memblock); + break; + case OP_COMPAREMEM: + mem_used =3D 1; + if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { + packet_mismatch =3D 1; + resp =3D 2; + } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) = !=3D 0) { + /* memory mismatch */ + resp =3D 2; + } + resp_fn(resp); + break; } + } else { + /* We are out of sync */ + resp =3D 2; resp_fn(resp); - break; } =20 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; =20 struct reginfo; =20 +typedef struct +{ + uintptr_t pc; + uint32_t risu_op; +} trace_header_t; + /* Functions operating on reginfo */ =20 /* 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); =20 +/* 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); =20 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 =3D 0x00005af0; return (key !=3D 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 =3D (isz =3D=3D 2) ? 0xdee0 : 0xe7fe5af0; return (key !=3D 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 =3D 0x4afc7000; return (key !=3D 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 =3D 0x00005af0; return (key !=3D risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->nip; +} --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498059993573414.7643984794921; Wed, 21 Jun 2017 08:46:33 -0700 (PDT) Received: from localhost ([::1]:54761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhpv-0001Kx-2N for importer@patchew.org; Wed, 21 Jun 2017 11:46:31 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e 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(-) diff --git a/risu.c b/risu.c index 88e586c..93c274b 100644 --- a/risu.c +++ b/risu.c @@ -30,7 +30,9 @@ =20 void *memblock; =20 -int apprentice_socket, master_socket; +int apprentice_fd, master_fd; +int trace; +size_t signal_count; =20 sigjmp_buf jmpbuf; =20 @@ -41,24 +43,60 @@ int test_fp_exc; =20 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 =3D write(master_fd, ptr, bytes); + return (res =3D=3D bytes) ? 0 : 1; } =20 void respond_sock(int r) { - send_response_byte(master_socket, r); + send_response_byte(master_fd, r); } =20 /* Apprentice function */ =20 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 =3D read(apprentice_fd, ptr, bytes); + return (res =3D=3D 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; + } } =20 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 =3D send_register_info(write_trace, uc); + } else { + r =3D 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) =20 void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - switch (send_register_info(write_sock, uc)) { + int r; + signal_count++; + + if (trace) { + r =3D recv_and_compare_register_info(read_trace, respond_trace, uc= ); + } else { + r =3D 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 =3D (uintptr_t) addr; } =20 -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", sign= al_count); + return 0; + } else { + return report_match_status(); + } } - master_socket =3D 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); } =20 -int apprentice(int sock) +int apprentice(void) { - apprentice_socket =3D sock; + if (sigsetjmp(jmpbuf, 1)) { + close(apprentice_fd); + fprintf(stderr, "finished early after %zd checkpoints\n", signal_c= ount); + 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=3DFILE Record/playback trace file\n"); fprintf(stderr, " -h, --host=3DHOST Specify master host machine (apprentice= only)" "\n"); @@ -189,7 +249,7 @@ int main(int argc, char **argv) uint16_t port =3D 9191; char *hostname =3D "localhost"; char *imgfile; - int sock; + char *trace_fn =3D NULL; =20 /* TODO clean this up later */ =20 @@ -203,7 +263,7 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; int optidx =3D 0; - int c =3D getopt_long(argc, argv, "h:p:", longopts, &optidx); + int c =3D getopt_long(argc, argv, "h:p:t:", longopts, &optidx); if (c =3D=3D -1) { break; } @@ -214,6 +274,12 @@ int main(int argc, char **argv) /* flag set by getopt_long, do nothing */ break; } + case 't': + { + trace_fn =3D optarg; + trace =3D 1; + break; + } case 'h': { hostname =3D optarg; @@ -245,12 +311,20 @@ int main(int argc, char **argv) load_image(imgfile); =20 if (ismaster) { - fprintf(stderr, "master port %d\n", port); - sock =3D master_connect(port); - return master(sock); + if (trace) { + master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } else { + fprintf(stderr, "master port %d\n", port); + master_fd =3D master_connect(port); + } + return master(); } else { - fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - sock =3D apprentice_connect(hostname, port); - return apprentice(sock); + if (trace) { + apprentice_fd =3D open(trace_fn, O_RDONLY); + } else { + fprintf(stderr, "apprentice host %s port %d\n", hostname, port= ); + apprentice_fd =3D apprentice_connect(hostname, port); + } + return apprentice(); } } --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498060131106599.1174965889813; Wed, 21 Jun 2017 08:48:51 -0700 (PDT) Received: from localhost ([::1]:54768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhs7-0003pQ-TJ for importer@patchew.org; Wed, 21 Jun 2017 11:48:47 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- v6 - use STDIN/OUT_FILENO instead of fileno(foo) - strcmp instead of strncmp --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) =20 if (ismaster) { if (trace) { - master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + if (strcmp(trace_fn, "-")=3D=3D0) { + master_fd =3D STDOUT_FILENO; + } else { + master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); + } } else { fprintf(stderr, "master port %d\n", port); master_fd =3D master_connect(port); @@ -320,7 +324,11 @@ int main(int argc, char **argv) return master(); } else { if (trace) { - apprentice_fd =3D open(trace_fn, O_RDONLY); + if (strcmp(trace_fn, "-")=3D=3D0) { + apprentice_fd =3D STDIN_FILENO; + } else { + apprentice_fd =3D open(trace_fn, O_RDONLY); + } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port= ); apprentice_fd =3D apprentice_connect(hostname, port); --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498060166998751.3173521607879; Wed, 21 Jun 2017 08:49:26 -0700 (PDT) Received: from localhost ([::1]:54769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhsi-0004FO-Hu for importer@patchew.org; Wed, 21 Jun 2017 11:49:24 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e 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(-) diff --git a/Makefile b/Makefile index 9a29bb4..ca80eef 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ VPATH=3D$(SRCDIR) =20 CFLAGS ?=3D -g =20 -ALL_CFLAGS =3D -Wall -D_GNU_SOURCE -DARCH=3D$(ARCH) $(CFLAGS) $(EXTRA_CFLA= GS) +ALL_CFLAGS =3D -Wall -D_GNU_SOURCE -DARCH=3D$(ARCH) $(BUILD_INC) $(CFLAGS)= $(EXTRA_CFLAGS) =20 PROG=3Drisu SRCS=3Drisu.c comms.c reginfo.c risu_$(ARCH).c risu_reginfo_$(ARCH).c @@ -35,7 +35,7 @@ all: $(PROG) $(BINS) dump: $(RISU_ASMS) =20 $(PROG): $(OBJS) - $(CC) $(STATIC) $(ALL_CFLAGS) -o $@ $^ + $(CC) $(STATIC) $(ALL_CFLAGS) -o $@ $^ $(LDFLAGS) =20 %.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 } =20 +link() { + $LD $LDFLAGS -l${2} -o ${1} ${1}.o 2>/dev/null +} + check_define() { c=3D${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=3D${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=3Dconfig.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=3D-lz + fi + + echo "#endif /* CONFIG_H */" >> $cfg + + echo "...done" +} + generate_makefilein() { m=3DMakefile.in echo "generating Makefile.in..." @@ -65,11 +111,13 @@ generate_makefilein() { echo "# Makefile.in - generated by the 'configure' script" > $m echo "ARCH:=3D${ARCH}" >> $m echo "CC:=3D${CC}" >> $m + echo "LDFLAGS:=3D${LDFLAGS}" >> $m echo "AS:=3D${AS}" >> $m echo "OBJCOPY:=3D${OBJCOPY}" >> $m echo "OBJDUMP:=3D${OBJDUMP}" >> $m echo "STATIC:=3D${STATIC}" >> $m echo "SRCDIR:=3D${SRCDIR}" >> $m + echo "BUILD_INC:=3D${BUILD_INC}" >> $m =20 echo "...done" } @@ -118,6 +166,7 @@ done =20 CC=3D"${CC-${CROSS_PREFIX}gcc}" AS=3D"${AS-${CROSS_PREFIX}as}" +LD=3D"${LD-${CROSS_PREFIX}ld}" OBJCOPY=3D"${OBJCOPY-${CROSS_PREFIX}objcopy}" OBJDUMP=3D"${OBJDUMP-${CROSS_PREFIX}objdump}" =20 @@ -125,15 +174,17 @@ if test "x${ARCH}" =3D "x"; then guess_arch fi =20 -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=3D"-I $(pwd)" ln -s "${SRCDIR}/Makefile" . fi =20 +generate_config +generate_makefilein + rm -r "$tmp_dir" =20 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 =20 +#include "config.h" + #include "risu.h" =20 void *memblock; @@ -34,6 +36,11 @@ int apprentice_fd, master_fd; int trace; size_t signal_count; =20 +#ifdef HAVE_ZLIB +#include +gzFile gz_trace_file; +#endif + sigjmp_buf jmpbuf; =20 /* Should we test for FP exception status bits? */ @@ -48,7 +55,17 @@ int read_sock(void *ptr, size_t bytes) =20 int write_trace(void *ptr, size_t bytes) { - size_t res =3D write(master_fd, ptr, bytes); + size_t res; + +#ifdef HAVE_ZLIB + if (master_fd =3D=3D STDOUT_FILENO) { +#endif + res =3D write(master_fd, ptr, bytes); +#ifdef HAVE_ZLIB + } else { + res =3D gzwrite(gz_trace_file, ptr, bytes); + } +#endif return (res =3D=3D bytes) ? 0 : 1; } =20 @@ -66,7 +83,18 @@ int write_sock(void *ptr, size_t bytes) =20 int read_trace(void *ptr, size_t bytes) { - size_t res =3D read(apprentice_fd, ptr, bytes); + size_t res; + +#ifdef HAVE_ZLIB + if (apprentice_fd =3D=3D STDIN_FILENO) { +#endif + res =3D read(apprentice_fd, ptr, bytes); +#ifdef HAVE_ZLIB + } else { + res =3D gzread(gz_trace_file, ptr, bytes); + } +#endif + return (res =3D=3D bytes) ? 0 : 1; } =20 @@ -189,6 +217,11 @@ void load_image(const char *imgfile) int master(void) { if (sigsetjmp(jmpbuf, 1)) { +#ifdef HAVE_ZLIB + if (trace && master_fd !=3D STDOUT_FILENO) { + gzclose(gz_trace_file); + } +#endif close(master_fd); if (trace) { fprintf(stderr, "trace complete after %zd checkpoints\n", sign= al_count); @@ -209,6 +242,11 @@ int master(void) int apprentice(void) { if (sigsetjmp(jmpbuf, 1)) { +#ifdef HAVE_ZLIB + if (trace && apprentice_fd !=3D STDIN_FILENO) { + gzclose(gz_trace_file); + } +#endif close(apprentice_fd); fprintf(stderr, "finished early after %zd checkpoints\n", signal_c= ount); return report_match_status(); @@ -316,6 +354,9 @@ int main(int argc, char **argv) master_fd =3D STDOUT_FILENO; } else { master_fd =3D open(trace_fn, O_WRONLY|O_CREAT, S_IRWXU); +#ifdef HAVE_ZLIB + gz_trace_file =3D 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 =3D STDIN_FILENO; } else { apprentice_fd =3D open(trace_fn, O_RDONLY); +#ifdef HAVE_ZLIB + gz_trace_file =3D gzdopen(apprentice_fd, "rb"); +#endif } } else { fprintf(stderr, "apprentice host %s port %d\n", hostname, port= ); --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498060325431237.23094306599228; Wed, 21 Jun 2017 08:52:05 -0700 (PDT) Received: from localhost ([::1]:54782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhvF-0007mw-2H for importer@patchew.org; Wed, 21 Jun 2017 11:52:01 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 A simple script to run through a bunch of binaries and generate their trace files. Signed-off-by: Alex Benn=C3=A9e --- 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 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 the= ir 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=C3=A9e - initial implementation +# +# Usage: +# export RISU=3D/path/to/risu +# ./record_traces.sh ./testcases.aarch64/*.bin +# + +set -e + +if test -z "$RISU"; then + script_dir=3D$(CDPATH=3D cd -- "$(dirname -- "$0")" && pwd -P) + RISU=3D${script_dir}/risu +fi + +for f in $@; do + echo "Running risu against $f" + t=3D"$f.trace" + ${RISU} --master $f -t $t + echo "Checking trace file OK" + ${RISU} $f -t $t +done --=20 2.13.0 From nobody Wed Nov 5 11:51:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498060227783867.7685318183364; Wed, 21 Jun 2017 08:50:27 -0700 (PDT) Received: from localhost ([::1]:54778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhti-0005nr-KL for importer@patchew.org; Wed, 21 Jun 2017 11:50:26 -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) 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) 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) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::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=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- 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 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=C3=A9e - initial implementation +# +# Usage: +# (optional) export QEMU=3D/path/to/qemu +# (optional) export RISU=3D/path/to/risu +# ./run_risu.sh ./testcases.aarch64/*.bin + +set -e + +passed=3D() +failed=3D() +missing=3D() + +if test -z "$RISU"; then + script_dir=3D$(CDPATH=3D cd -- "$(dirname -- "$0")" && pwd -P) + RISU=3D${script_dir}/risu +fi + +for f in $@; do + t=3D"$f.trace" + echo "Running $f against $t" + if [ -e $t ]; then + ${QEMU} ${RISU} $f -t $t + if [ $? =3D=3D 0 ]; then + passed=3D( "${passed[@]}" $f ) + else + failed=3D( "${failed[@]}" $f ) + fi + else + missing=3D( "${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[@]} --=20 2.13.0