From patchwork Mon Jun 19 10:46: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: 105816 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp809055qgd; Mon, 19 Jun 2017 03:46:49 -0700 (PDT) X-Received: by 10.159.48.214 with SMTP id k22mr2463904uab.31.1497869209702; Mon, 19 Jun 2017 03:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869209; cv=none; d=google.com; s=arc-20160816; b=qsrA1mVssgrNpz6o5gHky+nDLdefMcW0ywHulOJ4Xcf/P6UQ6Cj+a7euwELeX9yW3d wdWDFft1ZdED6b8F8XG6SBQ3L/cfk5mIPG+LYB7sOXXbIZnAOoZKH/QNh6iq1e2O1CUe Aw2b0yTN9VWCvqgnktJIG0pWh84ixqvtI65Hjbf1cGjqMoGcCIcpaIqeKmwYriK+Dlcb iLOlZ0X2HR31HhR9ipzjVEBY3iTCLH5q5RHxlu/ij1JjKHjxE0gcUD1H8W/a+7j9BJQ0 U71NwspoopZHMuntqInAVZx3kSVFeIxRCoypXPAyrnOSEPxPmFW27rCVMZ17mxh1l7Lb XgmA== 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=8wNP7/glMUULLxZwwF4HlEv4IiPSYCuPTNq68uXDxXU=; b=I4XYxQQz05MPPY/wyXSqK+2OK/4770jTu/6kb1Wv3kiE9BjkqALf2CwqeZzmP6nsdV FAwMiE7o20BD5O+Qeh+d3MI3XRBIFu1h/BMx4W5Uh/ciRTqAkcmkGi2ino++fXzhsBOc 4SjEjhIsMkWzNlMyQ/UMwQz4sgVIZcuMDNh2jg35+N+naaHFxR/5Clex8Rvzf/rkg4oE KpzECAUZAuJ+3xYKOxYVP2pvr8dgA6fPhR7yqSp2mFA3vMNXz3fyNFrG9EEJtWS06qaV //gTtMhItGxwOTdbzoj7L3fBdYkXCcfv5ATfkVJTiJMAKC9cZYS18SXcFNPX0fDuP5ef yHFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=T8JBAL1e; 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 k19si4232643vkd.225.2017.06.19.03.46.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:46: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=T8JBAL1e; 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]:41649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCn-0007Le-5A for patch@linaro.org; Mon, 19 Jun 2017 06:46:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCQ-0007KV-91 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCL-0004oe-Li for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:35126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCL-0004nh-FS for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:21 -0400 Received: by mail-wm0-x22a.google.com with SMTP id x70so75449477wme.0 for ; Mon, 19 Jun 2017 03:46:21 -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=8wNP7/glMUULLxZwwF4HlEv4IiPSYCuPTNq68uXDxXU=; b=T8JBAL1eG2yPIZqYjw7MPraR2SYT7X7Cc+WkDZddSmru1NUxQzCPeTNCsL0dSNwQE8 RKPXj3rg30eN9hcIUJ0f7p+M0cwC1VyAuNAdQqPpG4VQUuyjJsotZwrQDJxUC8Hx3Bv4 a+3RcwCAd7OQe2nxqPnBX+gC+TCscSusXmA0g= 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=8wNP7/glMUULLxZwwF4HlEv4IiPSYCuPTNq68uXDxXU=; b=IZuM0CIaUPXUzyy+DcoZa3x6kJ+pTx41TpA/SDqoo3zfpHq9lCxy8UbPw/ftvEW0bp 2N2UMhzUDFpSDeLzQD0HXYfV6by4JzMbz5J3wchRvlYDm/simEkILp2LoUTx3EJ+mOiF YHoLfG2CG3JI6SgA2WzG9mlTM3SOdCp9Dd9I2qPvG9j2wdvzITfmKfD6F01LcVOH9/5i wMOo9ndQD8clamXkSnH6iAIh5HySsQmXxpufJwhz//lQTHBfDP8EOI7/IvI6BUdfyBBK vP41OB1qlpp5txIsKDJufpF86IZCpvzv4RUZ+LynutnWupLsib1G5o7vq6v+zkTAoVOT 5VUw== X-Gm-Message-State: AKS2vOzyRCbOPsZFO//VOUH/QtZ0/yhX0S2UQvM96hnZU7q3oen2JwV7 eosKyZaNTVBtkQJyO6PAzQ== X-Received: by 10.28.8.72 with SMTP id 69mr14655447wmi.102.1497869180377; Mon, 19 Jun 2017 03:46:20 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q143sm7917675wmg.14.2017.06.19.03.46.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:18 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1D0623E0807; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:43 +0100 Message-Id: <20170619104655.31104-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22a Subject: [Qemu-devel] [RISU PATCH v5 01/13] .gitignore: ignore build directories 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" These are generated by the build-all-arches script. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell --- .gitignore | 1 + 1 file changed, 1 insertion(+) -- 2.13.0 diff --git a/.gitignore b/.gitignore index fc84419..fca9128 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ risu core config.h Makefile.in +build From patchwork Mon Jun 19 10:46: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: 105818 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp809628qgd; Mon, 19 Jun 2017 03:48:37 -0700 (PDT) X-Received: by 10.31.165.210 with SMTP id o201mr13318170vke.37.1497869317906; Mon, 19 Jun 2017 03:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869317; cv=none; d=google.com; s=arc-20160816; b=sC0WbLT3PEUJ9aozeRz1yMq1LfjdbbaiX4vbQcHvMngNkghliEACZSgbsyFpYHOZtH wo+GiizrVr6QwqQcxAjsXv/DMUee5H9oRkyQwaYsg8DC58EwbgEJFH7ol9n+nJID3GU2 xGbyD/AqRKAMqaWdn91oBDsHoRKP+i/A9BRDDO/102/NmLa+DoWKc5Nx0XnFIBoEbwrZ DANsEdD2RdnXJAcjkvPhZIMrCQRuUPKY6URtTXh6X/PkLUtRrwLttU6rzdsfG2icpHXs njs9bHYLOX1abk1OVr3IvG7jpEdsh6eSUy7owZN4i2JbOy67Qv9nixHgC2+PM+VmZYkW oP/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=KIzeihXmYJoDPmvc++cepWspnAnRTwkkvUe5QMRl8ao=; b=GAMHwMieqX9NhTuuwIeFnlkzdhUg+EGmpspdC0aYUPWk8MHb7wt7U/pFUw7F0yJL19 qu+oHwWtfKQeqhgTK1IBb6yeTy4HbnWMHsOifnlRe/isog0sdrbMmPA9q4YdPXn2UI5g atWQ2FsQ6Xh+E2pFjFH1FPTU+FEZN8qSUa+mGbE7iNIPZv5TWyvlkj0cTuR/reJA1bkp LrAt+rrLAxwye6kQCJDYWD+C/UNQXvXrbas4eMO2mN7rI+HovyKVUKkAxnwRnhUNvrRY /JAQLl2gN9ZJIpzfJ7YCf+ut9Wi+opQLr1ptWLvFc2pw7Q9yfeDmgm9hiqIoXOD9CFNt g1VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=YcBPnxyv; 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 v10si4880128uae.44.2017.06.19.03.48.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:48:37 -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=YcBPnxyv; 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]:41655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuEX-0000fm-BN for patch@linaro.org; Mon, 19 Jun 2017 06:48:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCQ-0007KY-Jt for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCM-0004q3-IQ for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:33472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCM-0004ok-Br for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:22 -0400 Received: by mail-wr0-x229.google.com with SMTP id r103so69638700wrb.0 for ; Mon, 19 Jun 2017 03:46:22 -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=YcBPnxyvVESGX48SLUPBaPnfVm37TwxWvLDq8F06tEU3vQKjp2fOc3TToVdXd8VTsg uAV0022nJGwL6lB7jlr4bmu2dIdQIZwyRUydE+YZYB+Bzzzev8HqIGDDVZJFRHHt6Kz9 HFnPp0IrtDYx+uvHx2WgIO+LZ581j6Mf8wIhU= 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=ZC/6BhACKGWiOx+eUH3oMXAQUULN/yApgdZcJeAkk5yY6mTxSxG6c4JjdFapyAs8Et veHXQffuChNENksBf0O7PtBZj5zNi0rB/SEozYAI6VcPgU572CQ/qiojEHAwyzQnH/2f vIDZdy8Qf1vuFul2niI4NIJkTnVFiEDuHi8Ef+zKyIC8YZWv4A4i3BCj7TTu9haAdo0M rXZLFDJ3zfUgJgBDg6doITAoe4IVQM7E6tvfccNiKm4Irmsqw48BJTf5lMbXyS6VMzSq Z0R0U2aMkBCVjuwj6K/PP+KvrCTjx4FRi+TSE1WEv5/Vm47hLdbLPyHQUZNqxt+CuFxM GR6Q== X-Gm-Message-State: AKS2vOyYjGMhF9nFXGRSNyGjkwfLD0QIgC6tXbKVrVkofv1l9TkmkQIn p8k1oHHGFTj4eZT6 X-Received: by 10.223.163.85 with SMTP id d21mr1326694wrb.95.1497869181237; Mon, 19 Jun 2017 03:46:21 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b32sm14439207wrd.40.2017.06.19.03.46.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:18 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 277303E080A; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:44 +0100 Message-Id: <20170619104655.31104-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 02/13] 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 Mon Jun 19 10:46:45 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: 105823 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp810838qgd; Mon, 19 Jun 2017 03:52:16 -0700 (PDT) X-Received: by 10.31.36.19 with SMTP id k19mr13090322vkk.78.1497869536304; Mon, 19 Jun 2017 03:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869536; cv=none; d=google.com; s=arc-20160816; b=MDhndSAeDwBpDV6KSySi0XgnqEUZHWfPxfb6CxVezVFWX8AJCP421dvzPDmnDxk73L WN1bTuDwVHiJBBUYA4tS1F6xVyizfs5/UQkcbTzhVQjRg9z9gTTJcLzdKPMspWOKzdzp TbhPCMg51DO0jJsrwgvSyOW5Vwd0i7wjOBEo7LL8NrKV06+lOFJ1ESyUa9BZO/4pex14 nIVQR1EBjZvLvQcMRcSrcMZev6x4TG+2dICO76M37xJeeiEOL3hOjyQsOC/KPBfhEPR0 PEyq9/z0QW+rrl3fhf08u9Z0YP2cteooRB7Xf6vFg7GpJkW19i8AdvV9dSRWQBetQTec x0IQ== 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=BGrRJBgyqUG//KVAoAprfQNkXoqKma8YBGtAgKDMDQQ=; b=lokJ+KcSIUfRI+lin+x/SD0JeOUgSbIbVgtMGv/pCj7mPtLg/p8/SADMb+jnpvctXL 6FfjK2gM4uzL4UF/KCKpHiPICOqYe/XGybW9ySUfsJGUDkJcB8OZ3tfLD51eGR+rKji8 zbczWl0IiDRd1Rb5q5dqDvq0ig0zWfdJdWCGH4cCYRJJt5eHIarcpRWefFAXB3qfx0Mo jvQu7EBlHRJtI2MB/i4lRhiXrZnAriCXhVu8EQ1r0ygacMpnH8z7sfffA1rlAgfeiP+q Wt3T4uPW3sJ8XhIU+8TfKIY7VQzlKDOa55RLWHrCGkgGHNjoDye/WwgFz3OeaQQUISek EoJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=FpHMMBst; 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 x5si1221504uag.177.2017.06.19.03.52.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:52:16 -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=FpHMMBst; 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]:41672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuI3-0003m3-L6 for patch@linaro.org; Mon, 19 Jun 2017 06:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCV-0007Nx-7R for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCP-0004rX-Pb for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:31 -0400 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:35278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCP-0004qe-A2 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:25 -0400 Received: by mail-wr0-x235.google.com with SMTP id y25so30273557wrd.2 for ; Mon, 19 Jun 2017 03:46:25 -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=BGrRJBgyqUG//KVAoAprfQNkXoqKma8YBGtAgKDMDQQ=; b=FpHMMBstoxWnz5bEQjh9bRHv7noj8sj2EngC/xJ6wvzv0bCD4HHtIccDikaQE41D5K MSySBDtkzMSqzgtxWLsvZtdCM+hLfIKfL2nCwLShD326mktZOGpR+YJO5tphF6U9mjJU OZ4NtHGE6sJEuXUY9z8xM81eVWvFa5p1l8soo= 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=BGrRJBgyqUG//KVAoAprfQNkXoqKma8YBGtAgKDMDQQ=; b=f52IEhBwezbWIj0BkhrLfwG6LhfHNkgzfxqkBXMdBdrlFDpSeOqqB00lCEyYxoI3dG fgsFzVrEBiDwDidfthX+ehjWQXOhaXPfMqFhu9QSPOa5lrQyK9Q+3cgW7I2hqq3IvPHN 7/PnfxOxLFVfLWT9xKovUzhfmgS/MF4Ge8o09V5vl7CBpuPxHZ7I9qH2wwtmX8tgi0+A vxkXU2sZ4ys43U0o8xaYw+BpFqppcacsunZww7kpMLkc68sRvYNSEL89ZHpo9B15W782 qJD9cJHDxGrd4bBdTqB54kde/E+PsduVcdaQki+cyYRB5vpAtO0mPxg00Hku4MXTeB6b v3CA== X-Gm-Message-State: AKS2vOzTvBzpscOFYjSnwSdvUZZ33kt6ia8pwjI/R/xqckmutxyBs3Po /VMF37Ym9zxSIpJ3 X-Received: by 10.223.161.89 with SMTP id r25mr4103306wrr.162.1497869183401; Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 201sm5670885wmt.28.2017.06.19.03.46.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:18 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3249B3E0873; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:45 +0100 Message-Id: <20170619104655.31104-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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::235 Subject: [Qemu-devel] [RISU PATCH v5 03/13] all: fix up code consitency 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 pretty much a mechanical change where I ran: indent -kr Across all the files and then fixed up all but a few violations of: ../../qemu.git/scripts/checkpatch.pl -f *.c *.h > checkpatch.out Along with heavy use of M-x untabify to make everything consistent. Signed-off-by: Alex Bennée --- comms.c | 325 +++++++++++++++++++++++-------------------------- reginfo.c | 114 ++++++++--------- risu.c | 310 +++++++++++++++++++++++----------------------- risu.h | 4 +- risu_arm.c | 58 +++++---- risu_i386.c | 150 +++++++++++------------ risu_m68k.c | 2 +- risu_ppc64.c | 2 +- risu_reginfo_aarch64.c | 60 +++++---- risu_reginfo_aarch64.h | 3 +- risu_reginfo_arm.c | 290 +++++++++++++++++++++---------------------- risu_reginfo_arm.h | 3 +- risu_reginfo_m68k.c | 20 +-- risu_reginfo_m68k.h | 3 +- risu_reginfo_ppc64.c | 29 ++--- risu_reginfo_ppc64.h | 3 +- 16 files changed, 672 insertions(+), 704 deletions(-) -- 2.13.0 diff --git a/comms.c b/comms.c index 31be846..2900c33 100644 --- a/comms.c +++ b/comms.c @@ -7,7 +7,7 @@ * * Contributors: * Peter Maydell (Linaro) - initial implementation - *******************************************************************************/ + ******************************************************************************/ /* Routines for the socket communication between master and apprentice. */ @@ -24,76 +24,70 @@ int apprentice_connect(const char *hostname, int port) { - /* We are the client end of the TCP connection */ - int sock; - struct sockaddr_in sa; - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - perror("socket"); - exit(1); - } - struct hostent *hostinfo; - sa.sin_family = AF_INET; - sa.sin_port = htons(port); - hostinfo = gethostbyname(hostname); - if (!hostinfo) - { - fprintf(stderr, "Unknown host %s\n", hostname); - exit(1); - } - sa.sin_addr = *(struct in_addr*)hostinfo->h_addr; - if (connect(sock, (struct sockaddr*)&sa, sizeof(sa)) < 0) - { - perror("connect"); - exit(1); - } - return sock; + /* We are the client end of the TCP connection */ + int sock; + struct sockaddr_in sa; + sock = socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror("socket"); + exit(1); + } + struct hostent *hostinfo; + sa.sin_family = AF_INET; + sa.sin_port = htons(port); + hostinfo = gethostbyname(hostname); + if (!hostinfo) { + fprintf(stderr, "Unknown host %s\n", hostname); + exit(1); + } + sa.sin_addr = *(struct in_addr *) hostinfo->h_addr; + if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { + perror("connect"); + exit(1); + } + return sock; } int master_connect(int port) { - int sock; - struct sockaddr_in sa; - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - perror("socket"); - exit(1); - } - int sora = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &sora, sizeof(sora)) != 0) - { - perror("setsockopt(SO_REUSEADDR)"); - exit(1); - } + int sock; + struct sockaddr_in sa; + sock = socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror("socket"); + exit(1); + } + int sora = 1; + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &sora, sizeof(sora)) != + 0) { + perror("setsockopt(SO_REUSEADDR)"); + exit(1); + } - sa.sin_family = AF_INET; - sa.sin_port = htons(port); - sa.sin_addr.s_addr = htonl(INADDR_ANY); - if (bind(sock, (struct sockaddr*)&sa, sizeof(sa)) < 0) - { - perror("bind"); - exit(1); - } - if (listen(sock, 1) < 0) - { - perror("listen"); - exit(1); - } - /* Just block until we get a connection */ - fprintf(stderr, "master: waiting for connection on port %d...\n", port); - struct sockaddr_in csa; - socklen_t csasz = sizeof(csa); - int nsock = accept(sock, (struct sockaddr*)&csa, &csasz); - if (nsock < 0) - { - perror("accept"); - exit(1); - } - /* We're done with the server socket now */ - close(sock); - return nsock; + sa.sin_family = AF_INET; + sa.sin_port = htons(port); + sa.sin_addr.s_addr = htonl(INADDR_ANY); + if (bind(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { + perror("bind"); + exit(1); + } + if (listen(sock, 1) < 0) { + perror("listen"); + exit(1); + } + /* Just block until we get a connection */ + fprintf(stderr, "master: waiting for connection on port %d...\n", + port); + struct sockaddr_in csa; + socklen_t csasz = sizeof(csa); + int nsock = accept(sock, (struct sockaddr *) &csa, &csasz); + if (nsock < 0) { + perror("accept"); + exit(1); + } + /* We're done with the server socket now */ + close(sock); + return nsock; } /* Utility functions which are just wrappers around read and writev @@ -101,77 +95,68 @@ int master_connect(int port) */ static void recv_bytes(int sock, void *pkt, int pktlen) { - char *p = pkt; - while (pktlen) - { - int i = read(sock, p, pktlen); - if (i <= 0) - { - if (errno == EINTR) - { - continue; - } - perror("read failed"); - exit(1); - } - pktlen -= i; - p += i; - } + char *p = pkt; + while (pktlen) { + int i = read(sock, p, pktlen); + if (i <= 0) { + if (errno == EINTR) { + continue; + } + perror("read failed"); + exit(1); + } + pktlen -= i; + p += i; + } } static void recv_and_discard_bytes(int sock, int pktlen) { - /* Read and discard bytes */ - char dumpbuf[64]; - while (pktlen) - { - int i; - int len = sizeof(dumpbuf); - if (len > pktlen) - { - len = pktlen; - } - i = read(sock, dumpbuf, len); - if (i <= 0) - { - if (errno == EINTR) - { - continue; - } - perror("read failed"); - exit(1); - } - pktlen -= i; - } + /* Read and discard bytes */ + char dumpbuf[64]; + while (pktlen) { + int i; + int len = sizeof(dumpbuf); + if (len > pktlen) { + len = pktlen; + } + i = read(sock, dumpbuf, len); + if (i <= 0) { + if (errno == EINTR) { + continue; + } + perror("read failed"); + exit(1); + } + pktlen -= i; + } } ssize_t safe_writev(int fd, struct iovec *iov_in, int iovcnt) { - /* writev, retrying for EINTR and short writes */ - int r = 0; - struct iovec *iov = iov_in; - for (;;) - { - ssize_t i = writev(fd, iov, iovcnt); - if (i == -1) - { - if (errno == EINTR) - continue; - return -1; - } - r += i; - /* Move forward through iov to account for data transferred */ - while (i >= iov->iov_len) - { - i -= iov->iov_len; - iov++; - iovcnt--; - if (iovcnt == 0) { - return r; - } - } - iov->iov_len -= i; - } + /* writev, retrying for EINTR and short writes */ + int r = 0; + struct iovec *iov = iov_in; + for (;;) { + ssize_t i = writev(fd, iov, iovcnt); + if (i == -1) { + if (errno == EINTR) { + continue; + } + return -1; + } + r += i; + /* Move forward through iov to account for data transferred */ + while (i >= iov->iov_len) { + i -= iov->iov_len; + iov++; + iovcnt--; + if (iovcnt == 0) { + return r; + } + } + iov->iov_len -= i; + } } /* Low level comms routines: @@ -184,57 +169,53 @@ ssize_t safe_writev(int fd, struct iovec *iov_in, int iovcnt) */ int send_data_pkt(int sock, void *pkt, int pktlen) { - unsigned char resp; - /* First we send the packet length as a network-order 32 bit value. - * This avoids silent deadlocks if the two sides disagree over - * what size data packet they are transferring. We use writev() - * so that both length and packet are sent in one packet; otherwise - * we get 300x slowdown because we hit Nagle's algorithm. - */ - uint32_t net_pktlen = htonl(pktlen); - struct iovec iov[2]; - iov[0].iov_base = &net_pktlen; - iov[0].iov_len = sizeof(net_pktlen); - iov[1].iov_base = pkt; - iov[1].iov_len = pktlen; + unsigned char resp; + /* First we send the packet length as a network-order 32 bit value. + * This avoids silent deadlocks if the two sides disagree over + * what size data packet they are transferring. We use writev() + * so that both length and packet are sent in one packet; otherwise + * we get 300x slowdown because we hit Nagle's algorithm. + */ + uint32_t net_pktlen = htonl(pktlen); + struct iovec iov[2]; + iov[0].iov_base = &net_pktlen; + iov[0].iov_len = sizeof(net_pktlen); + iov[1].iov_base = pkt; + iov[1].iov_len = pktlen; - if (safe_writev(sock, iov, 2) == -1) - { - perror("writev failed"); - exit(1); - } + if (safe_writev(sock, iov, 2) == -1) { + perror("writev failed"); + exit(1); + } - if (read(sock, &resp, 1) != 1) - { - perror("read failed"); - exit(1); - } - return resp; + if (read(sock, &resp, 1) != 1) { + perror("read failed"); + exit(1); + } + return resp; } int recv_data_pkt(int sock, void *pkt, int pktlen) { - uint32_t net_pktlen; - recv_bytes(sock, &net_pktlen, sizeof(net_pktlen)); - net_pktlen = ntohl(net_pktlen); - if (pktlen != net_pktlen) - { - /* Mismatch. Read the data anyway so we can send - * a response back. - */ - recv_and_discard_bytes(sock, net_pktlen); - return 1; - } - recv_bytes(sock, pkt, pktlen); - return 0; + uint32_t net_pktlen; + recv_bytes(sock, &net_pktlen, sizeof(net_pktlen)); + net_pktlen = ntohl(net_pktlen); + if (pktlen != net_pktlen) { + /* Mismatch. Read the data anyway so we can send + * a response back. + */ + recv_and_discard_bytes(sock, net_pktlen); + return 1; + } + recv_bytes(sock, pkt, pktlen); + return 0; } void send_response_byte(int sock, int resp) { - unsigned char r = resp; - if (write(sock, &r, 1) != 1) - { - perror("write failed"); - exit(1); - } + unsigned char r = resp; + if (write(sock, &r, 1) != 1) { + perror("write failed"); + exit(1); + } } diff --git a/reginfo.c b/reginfo.c index 96c6342..31bb99f 100644 --- a/reginfo.c +++ b/reginfo.c @@ -18,8 +18,8 @@ struct reginfo master_ri, apprentice_ri; uint8_t apprentice_memblock[MEMBLOCKLEN]; -static int mem_used = 0; -static int packet_mismatch = 0; +static int mem_used; +static int packet_mismatch; int send_register_info(int sock, void *uc) { @@ -37,11 +37,12 @@ int send_register_info(int sock, void *uc) */ return send_data_pkt(sock, &ri, sizeof(ri)); case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&ri); - break; + 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); @@ -85,25 +86,25 @@ int recv_and_compare_register_info(int sock, void *uc) } send_response_byte(sock, 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 (recv_data_pkt(sock, 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); - 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 (recv_data_pkt(sock, 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); + break; + } return resp; } @@ -116,36 +117,37 @@ int recv_and_compare_register_info(int sock, void *uc) */ int report_match_status(void) { - int resp = 0; - fprintf(stderr, "match status...\n"); - if (packet_mismatch) { - fprintf(stderr, "packet mismatch (probably disagreement " - "about UNDEF on load/store)\n"); - /* We don't have valid reginfo from the apprentice side - * so stop now rather than printing anything about it. - */ - fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); - return 1; - } - if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - fprintf(stderr, "mismatch on regs!\n"); - resp = 1; - } - if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) { - fprintf(stderr, "mismatch on memory!\n"); - resp = 1; - } - if (!resp) { - fprintf(stderr, "match!\n"); - return 0; - } - - fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); - fprintf(stderr, "apprentice reginfo:\n"); - reginfo_dump(&apprentice_ri, stderr); - - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); - return resp; + int resp = 0; + fprintf(stderr, "match status...\n"); + if (packet_mismatch) { + fprintf(stderr, "packet mismatch (probably disagreement " + "about UNDEF on load/store)\n"); + /* We don't have valid reginfo from the apprentice side + * so stop now rather than printing anything about it. + */ + fprintf(stderr, "master reginfo:\n"); + reginfo_dump(&master_ri, stderr); + return 1; + } + if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + fprintf(stderr, "mismatch on regs!\n"); + resp = 1; + } + if (mem_used + && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) { + fprintf(stderr, "mismatch on memory!\n"); + resp = 1; + } + if (!resp) { + fprintf(stderr, "match!\n"); + return 0; + } + + fprintf(stderr, "master reginfo:\n"); + reginfo_dump(&master_ri, stderr); + fprintf(stderr, "apprentice reginfo:\n"); + reginfo_dump(&apprentice_ri, stderr); + + reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); + return resp; } diff --git a/risu.c b/risu.c index 7e42160..2cd6d22 100644 --- a/risu.c +++ b/risu.c @@ -28,59 +28,56 @@ #include "risu.h" -void *memblock = 0; +void *memblock; int apprentice_socket, master_socket; sigjmp_buf jmpbuf; /* Should we test for FP exception status bits? */ -int test_fp_exc = 0; +int test_fp_exc; void master_sigill(int sig, siginfo_t *si, void *uc) { - switch (recv_and_compare_register_info(master_socket, uc)) - { - case 0: - /* match OK */ - advance_pc(uc); - return; - default: - /* mismatch, or end of test */ - siglongjmp(jmpbuf, 1); - } + switch (recv_and_compare_register_info(master_socket, uc)) { + case 0: + /* match OK */ + advance_pc(uc); + return; + default: + /* mismatch, or end of test */ + siglongjmp(jmpbuf, 1); + } } void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - switch (send_register_info(apprentice_socket, uc)) - { - case 0: - /* match OK */ - advance_pc(uc); - return; - case 1: - /* end of test */ - exit(0); - default: - /* mismatch */ - exit(1); - } + switch (send_register_info(apprentice_socket, uc)) { + case 0: + /* match OK */ + advance_pc(uc); + return; + case 1: + /* end of test */ + exit(0); + default: + /* mismatch */ + exit(1); + } } -static void set_sigill_handler(void (*fn)(int, siginfo_t *, void *)) +static void set_sigill_handler(void (*fn) (int, siginfo_t *, void *)) { - struct sigaction sa; - memset(&sa, 0, sizeof(struct sigaction)); - - sa.sa_sigaction = fn; - sa.sa_flags = SA_SIGINFO; - sigemptyset(&sa.sa_mask); - if (sigaction(SIGILL, &sa, 0) != 0) - { - perror("sigaction"); - exit(1); - } + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + + sa.sa_sigaction = fn; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGILL, &sa, 0) != 0) { + perror("sigaction"); + exit(1); + } } typedef void entrypoint_fn(void); @@ -90,152 +87,147 @@ entrypoint_fn *image_start; void load_image(const char *imgfile) { - /* Load image file into memory as executable */ - struct stat st; - fprintf(stderr, "loading test image %s...\n", imgfile); - int fd = open(imgfile, O_RDONLY); - if (fd < 0) - { - fprintf(stderr, "failed to open image file %s\n", imgfile); - exit(1); - } - if (fstat(fd, &st) != 0) - { - perror("fstat"); - exit(1); - } - size_t len = st.st_size; - void *addr; - - /* Map writable because we include the memory area for store - * testing in the image. - */ - addr = mmap(0, len, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); - if (!addr) - { - perror("mmap"); - exit(1); - } - close(fd); - image_start = addr; - image_start_address = (uintptr_t)addr; + /* Load image file into memory as executable */ + struct stat st; + fprintf(stderr, "loading test image %s...\n", imgfile); + int fd = open(imgfile, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "failed to open image file %s\n", imgfile); + exit(1); + } + if (fstat(fd, &st) != 0) { + perror("fstat"); + exit(1); + } + size_t len = st.st_size; + void *addr; + + /* Map writable because we include the memory area for store + * testing in the image. + */ + addr = + mmap(0, len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, + 0); + if (!addr) { + perror("mmap"); + exit(1); + } + close(fd); + image_start = addr; + image_start_address = (uintptr_t) addr; } int master(int sock) { - if (sigsetjmp(jmpbuf, 1)) - { - return report_match_status(); - } - master_socket = sock; - set_sigill_handler(&master_sigill); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + if (sigsetjmp(jmpbuf, 1)) { + return report_match_status(); + } + master_socket = sock; + set_sigill_handler(&master_sigill); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + exit(1); } int apprentice(int sock) { - apprentice_socket = sock; - set_sigill_handler(&apprentice_sigill); - fprintf(stderr, "starting image\n"); - image_start(); - fprintf(stderr, "image returned unexpectedly\n"); - exit(1); + apprentice_socket = sock; + set_sigill_handler(&apprentice_sigill); + fprintf(stderr, "starting image\n"); + image_start(); + fprintf(stderr, "image returned unexpectedly\n"); + exit(1); } int ismaster; -void usage (void) +void usage(void) { - fprintf(stderr, "Usage: risu [--master] [--host ] [--port ] \n\n"); - fprintf(stderr, "Run through the pattern file verifying each instruction\n"); - fprintf(stderr, "between master and apprentice risu processes.\n\n"); - fprintf(stderr, "Options:\n"); - fprintf(stderr, " --master Be the master (server)\n"); - fprintf(stderr, " -h, --host=HOST Specify master host machine (apprentice only)\n"); - fprintf(stderr, " -p, --port=PORT Specify the port to connect to/listen on (default 9191)\n"); + fprintf(stderr, + "Usage: risu [--master] [--host ] [--port ] " + "\n\n"); + fprintf(stderr, + "Run through the pattern file verifying each instruction\n"); + fprintf(stderr, "between master and apprentice risu processes.\n\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " --master Be the master (server)\n"); + fprintf(stderr, + " -h, --host=HOST Specify master host machine (apprentice only)" + "\n"); + fprintf(stderr, + " -p, --port=PORT Specify the port to connect to/listen on " + "(default 9191)\n"); } int main(int argc, char **argv) { - // some handy defaults to make testing easier - uint16_t port = 9191; - char *hostname = "localhost"; - char *imgfile; - int sock; - - // TODO clean this up later - - for (;;) - { - static struct option longopts[] = - { - { "help", no_argument, 0, '?'}, - { "master", no_argument, &ismaster, 1 }, - { "host", required_argument, 0, 'h' }, - { "port", required_argument, 0, 'p' }, - { "test-fp-exc", no_argument, &test_fp_exc, 1 }, - { 0,0,0,0 } - }; - int optidx = 0; - int c = getopt_long(argc, argv, "h:p:", longopts, &optidx); - if (c == -1) - { - break; - } - - switch (c) - { - case 0: - { + /* some handy defaults to make testing easier */ + uint16_t port = 9191; + char *hostname = "localhost"; + char *imgfile; + int sock; + + /* TODO clean this up later */ + + for (;;) { + static struct option longopts[] = { + {"help", no_argument, 0, '?'}, + {"master", no_argument, &ismaster, 1}, + {"host", required_argument, 0, 'h'}, + {"port", required_argument, 0, 'p'}, + {"test-fp-exc", no_argument, &test_fp_exc, 1}, + {0, 0, 0, 0} + }; + int optidx = 0; + int c = getopt_long(argc, argv, "h:p:", longopts, &optidx); + if (c == -1) { + break; + } + + switch (c) { + case 0: + { /* flag set by getopt_long, do nothing */ break; - } - case 'h': - { + } + case 'h': + { hostname = optarg; break; - } - case 'p': - { - // FIXME err handling + } + case 'p': + { + /* FIXME err handling */ port = strtol(optarg, 0, 10); break; - } - case '?': - { + } + case '?': + { usage(); exit(1); - } - default: + } + default: abort(); - } - } - - imgfile = argv[optind]; - if (!imgfile) - { - fprintf(stderr, "Error: must specify image file name\n\n"); - usage(); - exit(1); - } - - load_image(imgfile); - - if (ismaster) - { - fprintf(stderr, "master port %d\n", port); - sock = master_connect(port); - return master(sock); - } - else - { - fprintf(stderr, "apprentice host %s port %d\n", hostname, port); - sock = apprentice_connect(hostname, port); - return apprentice(sock); - } + } + } + + imgfile = argv[optind]; + if (!imgfile) { + fprintf(stderr, "Error: must specify image file name\n\n"); + usage(); + exit(1); + } + + load_image(imgfile); + + if (ismaster) { + fprintf(stderr, "master port %d\n", port); + sock = master_connect(port); + return master(sock); + } else { + fprintf(stderr, "apprentice host %s port %d\n", hostname, port); + sock = apprentice_connect(hostname, port); + return apprentice(sock); + } } - - diff --git a/risu.h b/risu.h index 883bcf7..3fbeda8 100644 --- a/risu.h +++ b/risu.h @@ -7,7 +7,7 @@ * * Contributors: * Peter Maydell (Linaro) - initial implementation - *******************************************************************************/ + ******************************************************************************/ #ifndef RISU_H #define RISU_H @@ -99,7 +99,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc); int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2); /* print reginfo state to a stream, returns 1 on success, 0 on failure */ -int reginfo_dump(struct reginfo *ri, FILE *f); +int reginfo_dump(struct reginfo *ri, FILE * f); /* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); diff --git a/risu_arm.c b/risu_arm.c index f570828..a55c6c2 100644 --- a/risu_arm.c +++ b/risu_arm.c @@ -7,7 +7,7 @@ * * Contributors: * Peter Maydell (Linaro) - initial implementation - *******************************************************************************/ + ******************************************************************************/ #include #include @@ -18,39 +18,37 @@ int insnsize(ucontext_t *uc) { - /* Return instruction size in bytes of the - * instruction at PC - */ - if (uc->uc_mcontext.arm_cpsr & 0x20) - { - uint16_t faulting_insn = *((uint16_t*)uc->uc_mcontext.arm_pc); - switch (faulting_insn & 0xF800) - { - case 0xE800: - case 0xF000: - case 0xF800: + /* Return instruction size in bytes of the + * instruction at PC + */ + if (uc->uc_mcontext.arm_cpsr & 0x20) { + uint16_t faulting_insn = *((uint16_t *) uc->uc_mcontext.arm_pc); + switch (faulting_insn & 0xF800) { + case 0xE800: + case 0xF000: + case 0xF800: /* 32 bit Thumb2 instruction */ return 4; - default: + default: /* 16 bit Thumb instruction */ return 2; - } - } - /* ARM instruction */ - return 4; + } + } + /* ARM instruction */ + return 4; } void advance_pc(void *vuc) { - ucontext_t *uc = vuc; - uc->uc_mcontext.arm_pc += insnsize(uc); + ucontext_t *uc = vuc; + uc->uc_mcontext.arm_pc += insnsize(uc); } void set_ucontext_paramreg(void *vuc, uint64_t value) { - ucontext_t *uc = vuc; - uc->uc_mcontext.arm_r0 = value; + ucontext_t *uc = vuc; + uc->uc_mcontext.arm_r0 = value; } uint64_t get_reginfo_paramreg(struct reginfo *ri) @@ -60,13 +58,13 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri) int get_risuop(struct reginfo *ri) { - /* Return the risuop we have been asked to do - * (or -1 if this was a SIGILL for a non-risuop insn) - */ - uint32_t insn = ri->faulting_insn; - int isz = ri->faulting_insn_size; - uint32_t op = insn & 0xf; - uint32_t key = insn & ~0xf; - uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0; - return (key != risukey) ? -1 : op; + /* Return the risuop we have been asked to do + * (or -1 if this was a SIGILL for a non-risuop insn) + */ + uint32_t insn = ri->faulting_insn; + int isz = ri->faulting_insn_size; + uint32_t op = insn & 0xf; + uint32_t key = insn & ~0xf; + uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0; + return (key != risukey) ? -1 : op; } diff --git a/risu_i386.c b/risu_i386.c index bfcb4e1..5e7e01d 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -7,7 +7,7 @@ * * Contributors: * Peter Maydell (Linaro) - initial implementation - *******************************************************************************/ + ******************************************************************************/ #include #include @@ -19,10 +19,9 @@ * It is a simplified and reduced subset of what can * be obtained with a ucontext_t* */ -struct reginfo -{ - uint32_t faulting_insn; - gregset_t gregs; +struct reginfo { + uint32_t faulting_insn; + gregset_t gregs; }; #ifndef REG_GS @@ -42,34 +41,32 @@ struct reginfo master_ri, apprentice_ri; static int insn_is_ud2(uint32_t insn) { - return ((insn & 0xffff) == 0x0b0f); + return ((insn & 0xffff) == 0x0b0f); } void advance_pc(void *vuc) { - /* We assume that this is either UD1 or UD2. - * This would need tweaking if we want to test - * expected undefs on x86. - */ - ucontext_t *uc = vuc; - uc->uc_mcontext.gregs[REG_EIP] += 2; + /* We assume that this is either UD1 or UD2. + * This would need tweaking if we want to test + * expected undefs on x86. + */ + ucontext_t *uc = vuc; + uc->uc_mcontext.gregs[REG_EIP] += 2; } -static void fill_reginfo(struct reginfo *ri, ucontext_t *uc) +static void fill_reginfo(struct reginfo *ri, ucontext_t * uc) { - int i; - for (i = 0; i < NGREG; i++) - { - switch(i) - { - case REG_ESP: - case REG_UESP: - case REG_GS: - case REG_FS: - case REG_ES: - case REG_DS: - case REG_TRAPNO: - case REG_EFL: + int i; + for (i = 0; i < NGREG; i++) { + switch (i) { + case REG_ESP: + case REG_UESP: + case REG_GS: + case REG_FS: + case REG_ES: + case REG_DS: + case REG_TRAPNO: + case REG_EFL: /* Don't store these registers as it results in mismatches. * In particular valgrind has different values for some * segment registers, and they're boring anyway. @@ -78,27 +75,27 @@ static void fill_reginfo(struct reginfo *ri, ucontext_t *uc) */ ri->gregs[i] = 0xDEADBEEF; break; - case REG_EIP: + case REG_EIP: /* Store the offset from the start of the test image */ ri->gregs[i] = uc->uc_mcontext.gregs[i] - image_start_address; break; - default: + default: ri->gregs[i] = uc->uc_mcontext.gregs[i]; break; - } - } - /* x86 insns aren't 32 bit but we're not really testing x86 so - * this is just to distinguish 'do compare' from 'stop' - */ - ri->faulting_insn = *((uint32_t*)uc->uc_mcontext.gregs[REG_EIP]); + } + } + /* x86 insns aren't 32 bit but we're not really testing x86 so + * this is just to distinguish 'do compare' from 'stop' + */ + ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.gregs[REG_EIP]); } int send_register_info(int sock, void *uc) { - struct reginfo ri; - fill_reginfo(&ri, uc); - return send_data_pkt(sock, &ri, sizeof(ri)); + struct reginfo ri; + fill_reginfo(&ri, uc); + return send_data_pkt(sock, &ri, sizeof(ri)); } /* Read register info from the socket and compare it with that from the @@ -107,43 +104,37 @@ int send_register_info(int sock, void *uc) */ int recv_and_compare_register_info(int sock, void *uc) { - int resp; - fill_reginfo(&master_ri, uc); - recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri)); - if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) != 0) - { - /* mismatch */ - resp = 2; - } - else if (insn_is_ud2(master_ri.faulting_insn)) - { - /* end of test */ - resp = 1; - } - else - { - /* either successful match or expected undef */ - resp = 0; - } - send_response_byte(sock, resp); - return resp; + int resp; + fill_reginfo(&master_ri, uc); + recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri)); + if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) != 0) { + /* mismatch */ + resp = 2; + } else if (insn_is_ud2(master_ri.faulting_insn)) { + /* end of test */ + resp = 1; + } else { + /* either successful match or expected undef */ + resp = 0; + } + send_response_byte(sock, resp); + return resp; } -static char *regname[] = -{ - "GS", "FS", "ES" ,"DS", "EDI", "ESI", "EBP", "ESP", - "EBX", "EDX", "ECX", "EAX", "TRAPNO", "ERR", "EIP", - "CS", "EFL", "UESP", "SS", 0 +static char *regname[] = { + "GS", "FS", "ES", "DS", "EDI", "ESI", "EBP", "ESP", + "EBX", "EDX", "ECX", "EAX", "TRAPNO", "ERR", "EIP", + "CS", "EFL", "UESP", "SS", 0 }; static void dump_reginfo(struct reginfo *ri) { - int i; - fprintf(stderr, " faulting insn %x\n", ri->faulting_insn); - for (i = 0; i < NGREG; i++) - { - fprintf(stderr, " %s: %x\n", regname[i] ? regname[i] : "???", ri->gregs[i]); - } + int i; + fprintf(stderr, " faulting insn %x\n", ri->faulting_insn); + for (i = 0; i < NGREG; i++) { + fprintf(stderr, " %s: %x\n", regname[i] ? regname[i] : "???", + ri->gregs[i]); + } } @@ -155,16 +146,15 @@ static void dump_reginfo(struct reginfo *ri) */ int report_match_status(void) { - fprintf(stderr, "match status...\n"); - fprintf(stderr, "master reginfo:\n"); - dump_reginfo(&master_ri); - fprintf(stderr, "apprentice reginfo:\n"); - dump_reginfo(&apprentice_ri); - if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) == 0) - { - fprintf(stderr, "match!\n"); - return 0; - } - fprintf(stderr, "mismatch!\n"); - return 1; + fprintf(stderr, "match status...\n"); + fprintf(stderr, "master reginfo:\n"); + dump_reginfo(&master_ri); + fprintf(stderr, "apprentice reginfo:\n"); + dump_reginfo(&apprentice_ri); + if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) == 0) { + fprintf(stderr, "match!\n"); + return 0; + } + fprintf(stderr, "mismatch!\n"); + return 1; } diff --git a/risu_m68k.c b/risu_m68k.c index f84ac7a..0bf5c14 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -10,7 +10,7 @@ void advance_pc(void *vuc) { - ucontext_t *uc = (ucontext_t*)vuc; + ucontext_t *uc = (ucontext_t *) vuc; uc->uc_mcontext.gregs[R_PC] += 4; } diff --git a/risu_ppc64.c b/risu_ppc64.c index b575078..eb60573 100644 --- a/risu_ppc64.c +++ b/risu_ppc64.c @@ -15,7 +15,7 @@ void advance_pc(void *vuc) { - ucontext_t *uc = (ucontext_t*)vuc; + ucontext_t *uc = (ucontext_t *) vuc; uc->uc_mcontext.regs->nip += 4; } diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index fe567de..e3fadde 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -26,33 +26,36 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) /* necessary to be able to compare with memcmp later */ memset(ri, 0, sizeof(*ri)); - for (i = 0; i < 31; i++) + for (i = 0; i < 31; i++) { ri->regs[i] = uc->uc_mcontext.regs[i]; + } ri->sp = 0xdeadbeefdeadbeef; ri->pc = uc->uc_mcontext.pc - image_start_address; - ri->flags = uc->uc_mcontext.pstate & 0xf0000000; /* get only flags */ + ri->flags = uc->uc_mcontext.pstate & 0xf0000000; /* get only flags */ ri->fault_address = uc->uc_mcontext.fault_address; - ri->faulting_insn = *((uint32_t *)uc->uc_mcontext.pc); + ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.pc); - ctx = (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved[0]; + ctx = (struct _aarch64_ctx *) &uc->uc_mcontext.__reserved[0]; while (ctx->magic != FPSIMD_MAGIC && ctx->size != 0) { ctx += (ctx->size + sizeof(*ctx) - 1) / sizeof(*ctx); } if (ctx->magic != FPSIMD_MAGIC || ctx->size != sizeof(*fp)) { - fprintf(stderr, "risu_reginfo_aarch64: failed to get FP/SIMD state\n"); + fprintf(stderr, + "risu_reginfo_aarch64: failed to get FP/SIMD state\n"); return; } - fp = (struct fpsimd_context *)ctx; + fp = (struct fpsimd_context *) ctx; ri->fpsr = fp->fpsr; ri->fpcr = fp->fpcr; - for (i = 0; i < 32; i++) + for (i = 0; i < 32; i++) { ri->vregs[i] = fp->vregs[i]; + } }; /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ @@ -62,13 +65,14 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) } /* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE *f) +int reginfo_dump(struct reginfo *ri, FILE * f) { int i; fprintf(f, " faulting insn %08x\n", ri->faulting_insn); - for (i = 0; i < 31; i++) + for (i = 0; i < 31; i++) { fprintf(f, " X%2d : %016" PRIx64 "\n", i, ri->regs[i]); + } fprintf(f, " sp : %016" PRIx64 "\n", ri->sp); fprintf(f, " pc : %016" PRIx64 "\n", ri->pc); @@ -76,16 +80,17 @@ int reginfo_dump(struct reginfo *ri, FILE *f) fprintf(f, " fpsr : %08x\n", ri->fpsr); fprintf(f, " fpcr : %08x\n", ri->fpcr); - for (i = 0; i < 32; i++) + for (i = 0; i < 32; i++) { fprintf(f, " V%2d : %016" PRIx64 "%016" PRIx64 "\n", i, - (uint64_t)(ri->vregs[i] >> 64), - (uint64_t)(ri->vregs[i] & 0xffffffffffffffff)); + (uint64_t) (ri->vregs[i] >> 64), + (uint64_t) (ri->vregs[i] & 0xffffffffffffffff)); + } return !ferror(f); } /* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) { int i; fprintf(f, "mismatch detail (master : apprentice):\n"); @@ -94,37 +99,44 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) m->faulting_insn, a->faulting_insn); } for (i = 0; i < 31; i++) { - if (m->regs[i] != a->regs[i]) + if (m->regs[i] != a->regs[i]) { fprintf(f, " X%2d : %016" PRIx64 " vs %016" PRIx64 "\n", i, m->regs[i], a->regs[i]); + } } - if (m->sp != a->sp) + if (m->sp != a->sp) { fprintf(f, " sp : %016" PRIx64 " vs %016" PRIx64 "\n", m->sp, a->sp); + } - if (m->pc != a->pc) + if (m->pc != a->pc) { fprintf(f, " pc : %016" PRIx64 " vs %016" PRIx64 "\n", m->pc, a->pc); + } - if (m->flags != a->flags) + if (m->flags != a->flags) { fprintf(f, " flags : %08x vs %08x\n", m->flags, a->flags); + } - if (m->fpsr != a->fpsr) + if (m->fpsr != a->fpsr) { fprintf(f, " fpsr : %08x vs %08x\n", m->fpsr, a->fpsr); + } - if (m->fpcr != a->fpcr) + if (m->fpcr != a->fpcr) { fprintf(f, " fpcr : %08x vs %08x\n", m->fpcr, a->fpcr); + } for (i = 0; i < 32; i++) { - if (m->vregs[i] != a->vregs[i]) + if (m->vregs[i] != a->vregs[i]) { fprintf(f, " V%2d : " "%016" PRIx64 "%016" PRIx64 " vs " "%016" PRIx64 "%016" PRIx64 "\n", i, - (uint64_t)(m->vregs[i] >> 64), - (uint64_t)(m->vregs[i] & 0xffffffffffffffff), - (uint64_t)(a->vregs[i] >> 64), - (uint64_t)(a->vregs[i] & 0xffffffffffffffff)); + (uint64_t) (m->vregs[i] >> 64), + (uint64_t) (m->vregs[i] & 0xffffffffffffffff), + (uint64_t) (a->vregs[i] >> 64), + (uint64_t) (a->vregs[i] & 0xffffffffffffffff)); + } } return !ferror(f); diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index 3d1b2fd..a05fb4e 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -13,8 +13,7 @@ #ifndef RISU_REGINFO_AARCH64_H #define RISU_REGINFO_AARCH64_H -struct reginfo -{ +struct reginfo { uint64_t fault_address; uint64_t regs[31]; uint64_t sp; diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 5309f3a..8e6736b 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -26,173 +26,173 @@ extern int insnsize(ucontext_t *uc); static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) { - // Read VFP registers. These live in uc->uc_regspace, which is - // a sequence of - // u32 magic - // u32 size - // data.... - // blocks. We have to skip through to find the one for VFP. - unsigned long *rs = uc->uc_regspace; - - for (;;) - { - switch (*rs++) - { - case 0: - { - /* We didn't find any VFP at all (probably a no-VFP - * kernel). Zero out all the state to avoid mismatches. - */ - int j; - for (j = 0; j < 32; j++) - ri->fpregs[j] = 0; - ri->fpscr = 0; - return; - } - case 0x56465001: /* VFP_MAGIC */ - { - /* This is the one we care about. The format (after the size word) - * is 32 * 64 bit registers, then the 32 bit fpscr, then some stuff - * we don't care about. - */ - int i; - /* Skip if it's smaller than we expected (should never happen!) */ - if (*rs < ((32*2)+1)) + /* Read VFP registers. These live in uc->uc_regspace, which is + * a sequence of + * u32 magic + * u32 size + * data.... + * blocks. We have to skip through to find the one for VFP. + */ + unsigned long *rs = uc->uc_regspace; + + for (;;) { + switch (*rs++) { + case 0: { - rs += (*rs / 4); - break; + /* We didn't find any VFP at all (probably a no-VFP + * kernel). Zero out all the state to avoid mismatches. + */ + int j; + for (j = 0; j < 32; j++) { + ri->fpregs[j] = 0; + } + ri->fpscr = 0; + return; } - rs++; - for (i = 0; i < 32; i++) + case 0x56465001: /* VFP_MAGIC */ { - ri->fpregs[i] = *rs++; - ri->fpregs[i] |= (uint64_t)(*rs++) << 32; + /* This is the one we care about. The format (after + * the size word is 32 * 64 bit registers, then the + * 32 bit fpscr, then some stuff we don't care about. + */ + int i; + /* Skip if it's smaller than we expected (should never happen!) */ + if (*rs < ((32 * 2) + 1)) { + rs += (*rs / 4); + break; + } + rs++; + for (i = 0; i < 32; i++) { + ri->fpregs[i] = *rs++; + ri->fpregs[i] |= (uint64_t) (*rs++) << 32; + } + /* Ignore the UNK/SBZP bits. We also ignore the cumulative + * exception bits unless we were specifically asked to test + * them on the risu command line -- too much of qemu gets + * them wrong and they aren't actually very important. + */ + ri->fpscr = (*rs) & 0xffff9f9f; + if (!test_fp_exc) { + ri->fpscr &= ~0x9f; + } + /* Clear the cumulative exception flags. This is a bit + * unclean, but makes sense because otherwise we'd have to + * insert explicit bit-clearing code in the generated code + * to avoid the test becoming useless once all the bits + * get set. + */ + (*rs) &= ~0x9f; + return; } - /* Ignore the UNK/SBZP bits. We also ignore the cumulative - * exception bits unless we were specifically asked to test - * them on the risu command line -- too much of qemu gets - * them wrong and they aren't actually very important. - */ - ri->fpscr = (*rs) & 0xffff9f9f; - if (!test_fp_exc) { - ri->fpscr &= ~0x9f; - } - /* Clear the cumulative exception flags. This is a bit - * unclean, but makes sense because otherwise we'd have to - * insert explicit bit-clearing code in the generated code - * to avoid the test becoming useless once all the bits - * get set. - */ - (*rs) &= ~0x9f; - return; - } - default: + default: /* Some other kind of block, ignore it */ rs += (*rs / 4); break; - } - } + } + } } void reginfo_init(struct reginfo *ri, ucontext_t *uc) { - memset(ri, 0, sizeof(*ri)); /* necessary for memcmp later */ - - ri->gpreg[0] = uc->uc_mcontext.arm_r0; - ri->gpreg[1] = uc->uc_mcontext.arm_r1; - ri->gpreg[2] = uc->uc_mcontext.arm_r2; - ri->gpreg[3] = uc->uc_mcontext.arm_r3; - ri->gpreg[4] = uc->uc_mcontext.arm_r4; - ri->gpreg[5] = uc->uc_mcontext.arm_r5; - ri->gpreg[6] = uc->uc_mcontext.arm_r6; - ri->gpreg[7] = uc->uc_mcontext.arm_r7; - ri->gpreg[8] = uc->uc_mcontext.arm_r8; - ri->gpreg[9] = uc->uc_mcontext.arm_r9; - ri->gpreg[10] = uc->uc_mcontext.arm_r10; - ri->gpreg[11] = uc->uc_mcontext.arm_fp; - ri->gpreg[12] = uc->uc_mcontext.arm_ip; - ri->gpreg[14] = uc->uc_mcontext.arm_lr; - ri->gpreg[13] = 0xdeadbeef; - ri->gpreg[15] = uc->uc_mcontext.arm_pc - image_start_address; - // Mask out everything except NZCVQ GE - // In theory we should be OK to compare everything - // except the reserved bits, but valgrind for one - // doesn't fill in enough fields yet. - ri->cpsr = uc->uc_mcontext.arm_cpsr & 0xF80F0000; - - ri->faulting_insn = *((uint16_t*)uc->uc_mcontext.arm_pc); - ri->faulting_insn_size = insnsize(uc); - if (ri->faulting_insn_size != 2) - { - ri->faulting_insn |= (*((uint16_t*)uc->uc_mcontext.arm_pc+1)) << 16; - } - - reginfo_init_vfp(ri, uc); + memset(ri, 0, sizeof(*ri)); /* necessary for memcmp later */ + + ri->gpreg[0] = uc->uc_mcontext.arm_r0; + ri->gpreg[1] = uc->uc_mcontext.arm_r1; + ri->gpreg[2] = uc->uc_mcontext.arm_r2; + ri->gpreg[3] = uc->uc_mcontext.arm_r3; + ri->gpreg[4] = uc->uc_mcontext.arm_r4; + ri->gpreg[5] = uc->uc_mcontext.arm_r5; + ri->gpreg[6] = uc->uc_mcontext.arm_r6; + ri->gpreg[7] = uc->uc_mcontext.arm_r7; + ri->gpreg[8] = uc->uc_mcontext.arm_r8; + ri->gpreg[9] = uc->uc_mcontext.arm_r9; + ri->gpreg[10] = uc->uc_mcontext.arm_r10; + ri->gpreg[11] = uc->uc_mcontext.arm_fp; + ri->gpreg[12] = uc->uc_mcontext.arm_ip; + ri->gpreg[14] = uc->uc_mcontext.arm_lr; + ri->gpreg[13] = 0xdeadbeef; + ri->gpreg[15] = uc->uc_mcontext.arm_pc - image_start_address; + /* Mask out everything except NZCVQ GE + * In theory we should be OK to compare everything + * except the reserved bits, but valgrind for one + * doesn't fill in enough fields yet. + */ + ri->cpsr = uc->uc_mcontext.arm_cpsr & 0xF80F0000; + + ri->faulting_insn = *((uint16_t *) uc->uc_mcontext.arm_pc); + ri->faulting_insn_size = insnsize(uc); + if (ri->faulting_insn_size != 2) { + ri->faulting_insn |= + (*((uint16_t *) uc->uc_mcontext.arm_pc + 1)) << 16; + } + + reginfo_init_vfp(ri, uc); } /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) { - return memcmp(r1, r2, sizeof(*r1)) == 0; /* ok since we memset 0 */ + return memcmp(r1, r2, sizeof(*r1)) == 0; /* ok since we memset 0 */ } /* reginfo_dump: print the state to a stream, returns nonzero on success */ int reginfo_dump(struct reginfo *ri, FILE *f) { - int i; - if (ri->faulting_insn_size == 2) - fprintf(f, " faulting insn %04x\n", ri->faulting_insn); - else - fprintf(f, " faulting insn %08x\n", ri->faulting_insn); - for (i = 0; i < 16; i++) - { - fprintf(f, " r%d: %08x\n", i, ri->gpreg[i]); - } - fprintf(f, " cpsr: %08x\n", ri->cpsr); - for (i = 0; i < 32; i++) - { - fprintf(f, " d%d: %016llx\n", - i, (unsigned long long)ri->fpregs[i]); - } - fprintf(f, " fpscr: %08x\n", ri->fpscr); - - return !ferror(f); + int i; + if (ri->faulting_insn_size == 2) { + fprintf(f, " faulting insn %04x\n", ri->faulting_insn); + } else { + fprintf(f, " faulting insn %08x\n", ri->faulting_insn); + } + for (i = 0; i < 16; i++) { + fprintf(f, " r%d: %08x\n", i, ri->gpreg[i]); + } + fprintf(f, " cpsr: %08x\n", ri->cpsr); + for (i = 0; i < 32; i++) { + fprintf(f, " d%d: %016llx\n", + i, (unsigned long long) ri->fpregs[i]); + } + fprintf(f, " fpscr: %08x\n", ri->fpscr); + + return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, - FILE *f) +int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { - int i; - fprintf(f, "mismatch detail (master : apprentice):\n"); - - if (m->faulting_insn_size != a->faulting_insn_size) - fprintf(f, " faulting insn size mismatch %d vs %d\n", - m->faulting_insn_size, a->faulting_insn_size); - else if (m->faulting_insn != a->faulting_insn) - { - if (m->faulting_insn_size == 2) - fprintf(f, " faulting insn mismatch %04x vs %04x\n", - m->faulting_insn, a->faulting_insn); - else - fprintf(f, " faulting insn mismatch %08x vs %08x\n", - m->faulting_insn, a->faulting_insn); - } - for (i = 0; i < 16; i++) - { - if (m->gpreg[i] != a->gpreg[i]) - fprintf(f, " r%d: %08x vs %08x\n", i, m->gpreg[i], a->gpreg[i]); - } - if (m->cpsr != a->cpsr) - fprintf(f, " cpsr: %08x vs %08x\n", m->cpsr, a->cpsr); - for (i = 0; i < 32; i++) - { - if (m->fpregs[i] != a->fpregs[i]) - fprintf(f, " d%d: %016llx vs %016llx\n", i, - (unsigned long long)m->fpregs[i], - (unsigned long long)a->fpregs[i]); - } - if (m->fpscr != a->fpscr) - fprintf(f, " fpscr: %08x vs %08x\n", m->fpscr, a->fpscr); - - return !ferror(f); + int i; + fprintf(f, "mismatch detail (master : apprentice):\n"); + + if (m->faulting_insn_size != a->faulting_insn_size) { + fprintf(f, " faulting insn size mismatch %d vs %d\n", + m->faulting_insn_size, a->faulting_insn_size); + } else if (m->faulting_insn != a->faulting_insn) { + if (m->faulting_insn_size == 2) { + fprintf(f, " faulting insn mismatch %04x vs %04x\n", + m->faulting_insn, a->faulting_insn); + } else { + fprintf(f, " faulting insn mismatch %08x vs %08x\n", + m->faulting_insn, a->faulting_insn); + } + } + for (i = 0; i < 16; i++) { + if (m->gpreg[i] != a->gpreg[i]) { + fprintf(f, " r%d: %08x vs %08x\n", i, m->gpreg[i], + a->gpreg[i]); + } + } + if (m->cpsr != a->cpsr) { + fprintf(f, " cpsr: %08x vs %08x\n", m->cpsr, a->cpsr); + } + for (i = 0; i < 32; i++) { + if (m->fpregs[i] != a->fpregs[i]) { + fprintf(f, " d%d: %016llx vs %016llx\n", i, + (unsigned long long) m->fpregs[i], + (unsigned long long) a->fpregs[i]); + } + } + if (m->fpscr != a->fpscr) { + fprintf(f, " fpscr: %08x vs %08x\n", m->fpscr, a->fpscr); + } + + return !ferror(f); } diff --git a/risu_reginfo_arm.h b/risu_reginfo_arm.h index 96e5791..60754a9 100644 --- a/risu_reginfo_arm.h +++ b/risu_reginfo_arm.h @@ -13,8 +13,7 @@ #ifndef RISU_REGINFO_ARM_H #define RISU_REGINFO_ARM_H -struct reginfo -{ +struct reginfo { uint64_t fpregs[32]; uint32_t faulting_insn; uint32_t faulting_insn_size; diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 45950b1..4ff0aa8 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -20,7 +20,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) int i; memset(ri, 0, sizeof(*ri)); - ri->faulting_insn = *((uint32_t *)uc->uc_mcontext.gregs[R_PC]); + ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.gregs[R_PC]); ri->pc = uc->uc_mcontext.gregs[R_PC] - image_start_address; for (i = 0; i < NGREG; i++) { @@ -78,8 +78,7 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) int reginfo_dump(struct reginfo *ri, FILE *f) { int i; - fprintf(f, " pc \e[1;101;37m0x%08x\e[0m\n", - ri->pc); + fprintf(f, " pc \e[1;101;37m0x%08x\e[0m\n", ri->pc); fprintf(f, "\tPC: %08x\n", ri->gregs[R_PC]); fprintf(f, "\tPS: %04x\n", ri->gregs[R_PS]); @@ -101,14 +100,14 @@ int reginfo_dump(struct reginfo *ri, FILE *f) return !ferror(f); } -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) { int i; if (m->gregs[R_PS] != a->gregs[R_PS]) { - fprintf(f, "Mismatch: Register PS\n"); - fprintf(f, "master: [%x] - apprentice: [%x]\n", - m->gregs[R_PS], a->gregs[R_PS]); + fprintf(f, "Mismatch: Register PS\n"); + fprintf(f, "master: [%x] - apprentice: [%x]\n", + m->gregs[R_PS], a->gregs[R_PS]); } for (i = 0; i < 16; i++) { @@ -116,9 +115,10 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) continue; } if (m->gregs[i] != a->gregs[i]) { - fprintf(f, "Mismatch: Register %c%d\n", i < 8 ? 'D' : 'A', i % 8); - fprintf(f, "master: [%x] - apprentice: [%x]\n", - m->gregs[i], a->gregs[i]); + fprintf(f, "Mismatch: Register %c%d\n", i < 8 ? 'D' : 'A', + i % 8); + fprintf(f, "master: [%x] - apprentice: [%x]\n", m->gregs[i], + a->gregs[i]); } } diff --git a/risu_reginfo_m68k.h b/risu_reginfo_m68k.h index 06ea61d..c1c9fe6 100644 --- a/risu_reginfo_m68k.h +++ b/risu_reginfo_m68k.h @@ -9,8 +9,7 @@ #ifndef RISU_REGINFO_M68K_H #define RISU_REGINFO_M68K_H -struct reginfo -{ +struct reginfo { uint32_t faulting_insn; uint32_t pc; gregset_t gregs; diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index ae86263..eb9c12b 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -28,7 +28,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) int i; memset(ri, 0, sizeof(*ri)); - ri->faulting_insn = *((uint32_t *)uc->uc_mcontext.regs->nip); + ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.regs->nip); ri->nip = uc->uc_mcontext.regs->nip - image_start_address; for (i = 0; i < NGREG; i++) { @@ -76,16 +76,16 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) continue; } - if (m->fpregs[i] != a->fpregs[i]) { + if (m->fpregs[i] != a->fpregs[i]) { return 0; } } for (i = 0; i < 32; i++) { if (m->vrregs.vrregs[i][0] != a->vrregs.vrregs[i][0] || - m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] || - m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || - m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { + m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] || + m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || + m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { return 0; } } @@ -93,7 +93,7 @@ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) } /* reginfo_dump: print state to a stream, returns nonzero on success */ -int reginfo_dump(struct reginfo *ri, FILE *f) +int reginfo_dump(struct reginfo *ri, FILE * f) { int i; @@ -153,14 +153,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) if (m->gregs[XER] != a->gregs[XER]) { fprintf(f, "Mismatch: XER\n"); - fprintf(f, "m: [%lx] != a: [%lx]\n", - m->gregs[XER], a->gregs[XER]); + fprintf(f, "m: [%lx] != a: [%lx]\n", m->gregs[XER], a->gregs[XER]); } if (m->gregs[CCR] != a->gregs[CCR]) { fprintf(f, "Mismatch: Cond. Register\n"); - fprintf(f, "m: [%lx] != a: [%lx]\n", - m->gregs[CCR], a->gregs[CCR]); + fprintf(f, "m: [%lx] != a: [%lx]\n", m->gregs[CCR], a->gregs[CCR]); } for (i = 0; i < 32; i++) { @@ -168,18 +166,17 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) continue; } - if (m->fpregs[i] != a->fpregs[i]) { + if (m->fpregs[i] != a->fpregs[i]) { fprintf(f, "Mismatch: Register r%d\n", i); - fprintf(f, "m: [%f] != a: [%f]\n", - m->fpregs[i], a->fpregs[i]); + fprintf(f, "m: [%f] != a: [%f]\n", m->fpregs[i], a->fpregs[i]); } } for (i = 0; i < 32; i++) { if (m->vrregs.vrregs[i][0] != a->vrregs.vrregs[i][0] || - m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] || - m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || - m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { + m->vrregs.vrregs[i][1] != a->vrregs.vrregs[i][1] || + m->vrregs.vrregs[i][2] != a->vrregs.vrregs[i][2] || + m->vrregs.vrregs[i][3] != a->vrregs.vrregs[i][3]) { fprintf(f, "Mismatch: Register vr%d\n", i); fprintf(f, "m: [%x, %x, %x, %x] != a: [%x, %x, %x, %x]\n", diff --git a/risu_reginfo_ppc64.h b/risu_reginfo_ppc64.h index 826143e..7f2c962 100644 --- a/risu_reginfo_ppc64.h +++ b/risu_reginfo_ppc64.h @@ -14,8 +14,7 @@ #ifndef RISU_REGINFO_PPC64LE_H #define RISU_REGINFO_PPC64LE_H -struct reginfo -{ +struct reginfo { uint32_t faulting_insn; uint32_t prev_insn; uint64_t nip; From patchwork Mon Jun 19 10:46:46 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: 105817 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp809062qgd; Mon, 19 Jun 2017 03:46:51 -0700 (PDT) X-Received: by 10.31.132.13 with SMTP id g13mr12416279vkd.34.1497869211458; Mon, 19 Jun 2017 03:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869211; cv=none; d=google.com; s=arc-20160816; b=Aqpxi+Fi+llfffAaZRFVYOQ6ZJRhXY1XHkqHI/UiwuJxJiCoqtqcxtmgR7TxYaMZ/q 1X1VQ1B+gp9+A1mH9gzesJ//hZDRrPoBANQu4EEQ5tQcZdqt1e/1A4t8Aggef+utSrSN hQbo/uEUxtIlGxPSbmLELVkg1sWpa33ldBiVggij2PpQnqRaCGeJJ6rDuDPPfUvJVyCD XF1arv1bLH8qfxHhSzM/tcxM7MgBv/VGneh6vMo4Z5QAlBB+IjUXpe2D3Y9bQZgOExmC SE1UBVEtZv4hqLaciOVcR9LnXCbMqDAXqV/9ZEKsK7Jr6DZzBoyYjQnpimQUR/zTm7xd vWdQ== 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=EaXjEPaPU/HwNQabLYoBQXA4+RM8jhO9DSKSt1LRQ0U=; b=tDxxjyo/G/G78cWJYQK2czRrb8D4ytfTkvGhsvvmG6dtdSm80eSP61wylcDMbcM2DN NGfs04yOb+3ehAVpmuglK4K/xUxI5ZP0DZIJERsc8ZITrazA8+Cy2foQpu3nXWyi2a4j oJYIosaMnULu2PmCGuQsfhNgal/I4leEION7ie7Yd/U++8JQ6c50G0jLzhvDnhd8riCk ll57KKaHB+yqqjtu6lc7FjFNt4cWyntAS4a/qKtAWOUABmjl9gYNBiDF6Eox90yO0ulA ip0FTT4FJfChwrApTaPORnj6WItBgFTCnmviBXiFMYMqqdAnTOWKb80s6YAFH608P86i bEUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=UzHmYtVk; 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 65si4759413uaw.281.2017.06.19.03.46.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03: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=UzHmYtVk; 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]:41651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCp-0007Mp-0C for patch@linaro.org; Mon, 19 Jun 2017 06:46:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCQ-0007KX-Jh for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCN-0004qK-IA for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:33476) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCN-0004q7-BP for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:23 -0400 Received: by mail-wr0-x229.google.com with SMTP id r103so69638948wrb.0 for ; Mon, 19 Jun 2017 03:46:23 -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=EaXjEPaPU/HwNQabLYoBQXA4+RM8jhO9DSKSt1LRQ0U=; b=UzHmYtVkMVKEyVZ7T+tW1+5E1aZnNE16n+aVRrsuD2yva/8wFxl6TakF4boUw3TDDF qUexxwddGqmUbNCeO0NA3lfZpmmq/P9OSRPCCCMoihf9G6zZkzTfvpjc9lvymipcO3AZ oGzxpsQH/HUe9EoT4aWSlxNsIO3GPZRtgC4WQ= 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=EaXjEPaPU/HwNQabLYoBQXA4+RM8jhO9DSKSt1LRQ0U=; b=Kvu4ZFPiW+fxXoEecP/PzW09TyVhBPdz8zFc3ERQlG7tF2j7XY834xD4tXDnIcd3TW rB6MPYQPpFS0Im/zagbuUYpzSXxA/Iy1toxzEJvXJfh+WbvAIZUkd97pCyAoChYC3zyZ BQ66RSw8eJYbu3Ay1V8R6DzbDo471WgkOnuQMZs1eNsLYMWT2e4gzhEv747r5a9KD8kP HbmJOc9DfI03JC8sOnS5QDlkSbrQJxqv7t9yUT5aH5CSGlfWBfkVzj8titxtoQNtzh8K iNRBSYG6TAIYWefvsDPM08lEec5oaowcvOO71DgUCKK5x6FLhXf+Fuf8JSrHftC9La85 6gMA== X-Gm-Message-State: AKS2vOxnTPda+EZB5ATMF3dOAdX9nuJPKg4JJsLQzmy1qK4Y/dOMOFwH f3ZxSQKbBBWjEhdKLSqwfw== X-Received: by 10.223.175.204 with SMTP id y12mr10276078wrd.61.1497869182329; Mon, 19 Jun 2017 03:46:22 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p99sm15890120wrb.6.2017.06.19.03.46.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:18 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3D3793E0B2A; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:46 +0100 Message-Id: <20170619104655.31104-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 04/13] build-all-archs: support --static flag 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" Signed-off-by: Alex Bennée --- v5 - swap with docker patch so later can be dropped if not wanted --- build-all-archs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) -- 2.13.0 diff --git a/build-all-archs b/build-all-archs index 2768727..581a1b4 100755 --- a/build-all-archs +++ b/build-all-archs @@ -14,6 +14,38 @@ # So we notice risugen failing even though it's in a pipeline set -o pipefail +# Simple usage +usage() { + cat <<-EOF + Usage: $0 [options] + + Options include: + --static build a static binary + +EOF + exit 1 +} + +while [[ "$1" = -* ]]; do + opt="$1"; shift + arg= + if [[ "$opt" = *=* ]]; then + arg="${opt#*=}" + opt="${opt%%=*}" + fi + case "$opt" in + --static) + CONF="--static" + ;; + --help) + usage + ;; + *) + usage + ;; + esac +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 @@ -36,7 +68,7 @@ for triplet in aarch64-linux-gnu arm-linux-gnueabihf m68k-linux-gnu \ rm -rf build/${triplet} mkdir -p build/${triplet} - (cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure) + (cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure ${CONF}) make -C build/${triplet} EXTRA_CFLAGS=-Werror done From patchwork Mon Jun 19 10:46:47 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: 105821 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp810500qgd; Mon, 19 Jun 2017 03:51:16 -0700 (PDT) X-Received: by 10.159.48.1 with SMTP id h1mr14651714uab.102.1497869476815; Mon, 19 Jun 2017 03:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869476; cv=none; d=google.com; s=arc-20160816; b=J3RO6aaRm+YhD32ubkBMGaqkElVF2dClA2SxkBKgnXyzh8CZr3MhKPpFbrGqw6Z0IW 5FbsDxu5RubJnF9AOcxxQdNm9d65aOK2PV1U2l0YZRVt3kpADrUopdnZluBCxMiybSEs 5PoD3OyWT7WsHcSnJKuydEoJlNF/ID/re0cMNcEzxup1U+SGGFkfIRcB0nwIa+tTxH3f bm89X0dA6LU/+6QEwN9SY57AvRG3VvPC1R7WEbMsqWThyXWmzGdQavJBI63A1BiZBS4q qwRryjJCIVRvt74DBbZy+KdnjDuCBuvUoLWmZeV+wX2nyummpHcMFyJG3vNMw0zGeDSW qpNw== 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=x5KgEScRJqebmYdpsDN8pZW2D8Y3kd+8W2o4mSNzyHkpQ/KFS2BRqBX+x7GBeGSUU1 qs5nJOfsrYkPYkJhHesudYiuCix+oWqBoyNS9KxRkmKL8/txZdIKKGwCRl9ISQd66i8X Bb8+1GSLWvb9ORodHadHfVZ/ucpWSrf0WE5CaBtEu7w+20e0GfAOq/hBF8vTvCs9lnC0 PYfPT5rdZdvEnFAcUCl+CeNKF1fSmZcKPkEGORkYmjPElHgtsDqJS+XJX5ZQGiNANF0j 2zndgKNwzBxc+VvpJPNjDfKoQNehX4aywiM8x7JzAlkbqsZXBrWA9ZpvPbki7pv+MTql 6agA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=Et0Vx7Nk; 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 u125si4385197vke.14.2017.06.19.03.51.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:51:16 -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=Et0Vx7Nk; 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]:41666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuH6-0002nH-7n for patch@linaro.org; Mon, 19 Jun 2017 06:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCR-0007Ki-AH for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCQ-0004rw-65 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:27 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35280) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCP-0004r2-W4 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: by mail-wr0-x234.google.com with SMTP id y25so30273710wrd.2 for ; Mon, 19 Jun 2017 03:46:25 -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=Et0Vx7NkoNl5yRSt8hvnwlzNs3ZlrT89pWPj7gNsXxutR7p4euTPHTHJgiCHe05sV5 Bivgyb5K8ENch69kV98KrQsalis3Y2CrKTTmD2wJhu3HyjQaq/xi6Wzhl9koWK7AxUHU otm3wqlVtGB3OpjoVuCFsv+OD0lMxUivfMlC8= 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=jaVFzHuIqqDVdhZEdP9MT5ENi3L8NnyUOhCOLupNW8/RlcqRFNzsZpDc0zhlmVM0Xu d8z75MIJv8VWyZLpKBVKvjVNABCkdwa70YNfo9Ltofm/GlNi3L8CvAbSf4O7NkrANDqW WhvxXMO9JmYUuam0x7utjEQ5oQQqHvZlvZ4o0dv3UlRabU2pjnmxbAMfVUHunhw4vOGy ESruswFDjTe9tvvBeF3KJZJuTayFY6MP66kQnTdIEptaEwQkPTwEmCMfqVKp0xnP7atm +tXKF6CpbZz2yIrhTDyoN6MVRMT9cXva5dKPfM0V/85AxEh4UtHfirZuHpI/lGUYbp45 +iaA== X-Gm-Message-State: AKS2vOzsvGQfdYPLESjWduAdTDYddTjjeNAVay6Z3ghZK+sse+1eRcJu lh08jEYyKZA8Lhzi X-Received: by 10.223.146.166 with SMTP id 35mr15769241wrn.104.1497869184821; Mon, 19 Jun 2017 03:46:24 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c55sm7365285wrc.7.2017.06.19.03.46.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 47BCB3E0BA1; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:47 +0100 Message-Id: <20170619104655.31104-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 05/13] 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 Mon Jun 19 10:46:48 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: 105819 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp809973qgd; Mon, 19 Jun 2017 03:49:39 -0700 (PDT) X-Received: by 10.159.51.74 with SMTP id a10mr11442804uac.44.1497869379309; Mon, 19 Jun 2017 03:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869379; cv=none; d=google.com; s=arc-20160816; b=lYQPRuew1Uz/ezbEd+eKHH9PMHTpycaPNLsIMYhGq8+BdTLb2P77gzcHoCAPOGlTDp s9BAEopuEyA5d2AFmb63fam8QdvaR+PwXvxxvXwUMFLo+6VHORnp/Q8JKxbUeZfkytbJ 8j80G3+89B+21Xwjfolv8Vn2064Rd3gU0i1XWzisaDxkXQyKJiw9SLDoYF0LxkBbtFj6 81Be7OnstfkPKoKyWwJ+f3HtHUoFLqaV2FqEzPeanz0i/Hle1EZo6uPOf+MrVObXc4L2 05aFgrRTXfpiouJ7ck9ZWPp5Y1ORd1qcidu2yVLigLuYx35oJq9WCXF3AvQVyhZsGW8J fZgg== 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=G0jYWQl98Xzhmjtst8ebkQ7kBgF2b2Ech4GOnB9rk1c=; b=BbVpt0oIXJA/rjx2sxnhnwC540hHLr5D4cblM/O9jecH4SmGDz6Y+U/Kej47xnCvY+ cTUKigmjHgAxP85uQ54tXx4y6+ZJZF2wNnvgmXrfnycdgTj1da84ML9K82KpD0Nk13ly WwGCbePblCroSeWFqUEfbDw3LjGzHFtxMy343lq9l4eV2mwY8EODuSYtJbcDO6pg/oZd DWo4FSMsxTDmxPH1zPJ9rmLiMD3Phf1q1vmde0uVYlo1jQSGp5PdCMxUrfmJ+kN8RD1L 7LzuHVOVzk/4x6DDbKORojmrss7xdW/ZShdDGyeukqzEIKAuecld13VhJnBH5zz460L9 aoAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=aHQ8B0D9; 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 e188si4972507vka.19.2017.06.19.03.49.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=aHQ8B0D9; 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]:41658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuFW-0001e1-PO for patch@linaro.org; Mon, 19 Jun 2017 06:49:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCS-0007L5-3c for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCR-0004sh-0s for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:28 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:36326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCQ-0004ru-Qj for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: by mail-wr0-x22d.google.com with SMTP id c11so14026259wrc.3 for ; Mon, 19 Jun 2017 03:46:26 -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=G0jYWQl98Xzhmjtst8ebkQ7kBgF2b2Ech4GOnB9rk1c=; b=aHQ8B0D90kpYyxro2h4Qzqx67ZFHAKOGtdTwXAmDMOcXG/vj4HKM3wOfN52sl9SmOq JcZOcIOtMSRYCpvsociMwtB+fPBjU9EGjkHKg+qrGEj1rAI8xPm5WGEQxBBqPl2NItRt 6LZk6qV45v0nmVJS9o84AHLvGT72qqr4Tjhgo= 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=G0jYWQl98Xzhmjtst8ebkQ7kBgF2b2Ech4GOnB9rk1c=; b=DaERRO08agczgbFVnMHfqOhINkzlS1neu/DeXcZWszizEG47sHa+KJBRTcVaFvEM+R W3PlgZcBxzzVtwnb7Fo8GWZjJmdE9hfQrpZ+FPU3w3xdrlEf7cf0a7uflGQBr5JfqSeM uLOnLCxM2byay8a+vS2G99Slbl+eKpppUOxKk3SyvCsbTNKoGh/aqEqHIlbxK6MdbtUd BtL/+7bdx2qRCTkirf1svckdZne20JQ48xdarlC+87wSwU9Gibm9kWc004Q2NWYkbdae 4xnlX6HJcNF10p/gZDKgDdaWpWvpaHBn/zoFLXacxJVNClrj5mlWlQjIsNYHe8BzJclt Mj/g== X-Gm-Message-State: AKS2vOwRvvIsvP9J8cZqf9XzJ6ibcQL8xjxC1noE6ErLzWx0yMS4tl54 ZBKT8msnZda06zAn X-Received: by 10.223.181.135 with SMTP id c7mr15840869wre.150.1497869185717; Mon, 19 Jun 2017 03:46:25 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m143sm10070951wmg.27.2017.06.19.03.46.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 527CD3E0BC5; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:48 +0100 Message-Id: <20170619104655.31104-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 06/13] 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 -- 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 ++++ risu.h | 3 +++ 2 files changed, 7 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"); diff --git a/risu.h b/risu.h index 3fbeda8..78a7313 100644 --- a/risu.h +++ b/risu.h @@ -37,6 +37,7 @@ extern uintptr_t image_start_address; extern void *memblock; extern int test_fp_exc; +extern int ismaster; /* Ops code under test can request from risu: */ #define OP_COMPARE 0 @@ -72,6 +73,8 @@ int recv_and_compare_register_info(int sock, void *uc); */ int report_match_status(void); +void report_test_status(void *pc); + /* Interface provided by CPU-specific code: */ /* Move the PC past this faulting insn by adjusting ucontext From patchwork Mon Jun 19 10:46:49 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: 105822 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp810518qgd; Mon, 19 Jun 2017 03:51:21 -0700 (PDT) X-Received: by 10.176.95.197 with SMTP id g5mr4615858uaj.71.1497869481306; Mon, 19 Jun 2017 03:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869481; cv=none; d=google.com; s=arc-20160816; b=DQWFQSXZ9d7/JlsVc7q6vc75viTGwtW+0qoNNr7Bvw8Nd9fmeC12T2k+Zi1toGCYgk WWpUqXmggjsSBXiQiyvODjIIC/DCUvh70KA0LNEWMqZNujCKz1PSAGiMaE6lnj2On5yD HDAd8x56tDkook5YmHXBTrhOFUj1+pQx5LJdLQj9HoQbJIH4IGeudAhEXn8Nok5p/mxj AHvroebPM6rmrh0peh5Y2QyGBUeFA/14MToK8YBOt6CsOaB7FHq4etrWfqCcRXmE8iR/ XYlKx8Q5em9NenWSpSkfGfOiifGF0TWrbrRgtM73xAcp3ZNs8N0DCFSm/7UAvbrYfBjp 6w8g== 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=TBIRtBraaZUoWYnyV2EFHQ+IcMfM6qc8m1AGLo5N1X4=; b=Ai9OGb8or/82zAsQup2MoCU1LUYE9DyRu/V9cfR/dOEKtYo8UEcnum6TrOm8B8fFpl oCafDA6YV3cJa4uPW2An/mi6W/OA17nfNGYv9bzym6VJ10vmTOwNrMU0Vn4r1/fUKJW8 yEJ3IpeIfviC3F93nJyVg+VhqjkFy9DVr/AjxI+AFqDovAtNHk4y3BZWHWIu2CXNLi7x OSsSklBJfFYNPUaqcvujYzdNyP0u9fL9oMuYwMyE6cuw+PJxX+SZoBslj9LIo9IAAiZN kqm1H9XOQgGYcS22QQvJMaK1N3ZWjSSdfzGEPAUPgl5GDOOGVwtU/cj5GkAaVIG+og28 ro8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=ExelOIS0; 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 p22si5314803uah.107.2017.06.19.03.51.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:51:21 -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=ExelOIS0; 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]:41668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuHA-0002qW-Pk for patch@linaro.org; Mon, 19 Jun 2017 06:51:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCT-0007Lo-ED for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCS-0004tY-6L for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:29 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:34411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCR-0004su-TK for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:28 -0400 Received: by mail-wr0-x22a.google.com with SMTP id 77so69495261wrb.1 for ; Mon, 19 Jun 2017 03:46:27 -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=TBIRtBraaZUoWYnyV2EFHQ+IcMfM6qc8m1AGLo5N1X4=; b=ExelOIS0OcleU5avgD5I3iPr/7lBPtgEe8t6Qeuf6CHT6gF8zF1dbsiw8BW7JOzvgF wx8Sx2xhXcf8RoKR+ImiMabuIbv3IAHKX/kuA+FzniXQLlErkRAQXhLOCoGx+KTs+kqu TstJM3xXe4IsdMEX5P8r89YyUzbVEpIuFAGIM= 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=TBIRtBraaZUoWYnyV2EFHQ+IcMfM6qc8m1AGLo5N1X4=; b=s9rNJrS6w00eaYSTlReVRAHg8CR1SWaqByingmTtqFIvfYWPiYM55r5J7qAz/THJ4x dMHW/jVam5YyHiT7fESo/oGMbyZQCYnFExfKT68IzVAW1gXPkedw3H6RATF9m/+QGXXH CnVu7BQVCeyr/JpZb31aT/K+V7nrLh9oOeIsCAWARNOHVDDlU7Wb0yx0RCE8llsn1ouc 77lG32Qd3ko9zwoxBKeBHfp4LHT3/YshncF1xR0sIiOyJjCY9IkZFXLn5DZHW73vfu+P mUpX1h/kCLzj/lDJrDEEp2vXLH/j6Sr8HMZlTgYS+sop6gR0PuzHMqTB/3PVFmKqdBev 5lew== X-Gm-Message-State: AKS2vOxK0mni/55O3pp84SsvCHrmwVtgLZ7k8ahWjeOEJbUUrWnCJ0TV w6pEmrLMEUHvyIBZ X-Received: by 10.223.167.15 with SMTP id c15mr17784668wrd.79.1497869186724; Mon, 19 Jun 2017 03:46:26 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 139sm11629578wmw.15.2017.06.19.03.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5D38F3E0BD4; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:49 +0100 Message-Id: <20170619104655.31104-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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::22a Subject: [Qemu-devel] [RISU PATCH v5 07/13] 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 --- 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 | 39 +++++++++++++++++++-------------------- risu.c | 23 +++++++++++++++++++++-- risu.h | 11 +++++++++-- 3 files changed, 49 insertions(+), 24 deletions(-) -- 2.13.0 diff --git a/reginfo.c b/reginfo.c index 31bb99f..90cea8f 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,25 @@ 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)); + write_fn(&ri, sizeof(ri)); + return 1; 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 +60,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 +74,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 78a7313..32241bc 100644 --- a/risu.h +++ b/risu.h @@ -53,17 +53,24 @@ struct reginfo; /* Functions operating on reginfo */ +/* To keep the read/write logic from multiplying across all arches + * we wrap up the function here to keep all the changes in one place + */ +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 Mon Jun 19 10:46:50 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: 105824 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp811264qgd; Mon, 19 Jun 2017 03:53:42 -0700 (PDT) X-Received: by 10.31.134.203 with SMTP id i194mr11585641vkd.93.1497869622732; Mon, 19 Jun 2017 03:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869622; cv=none; d=google.com; s=arc-20160816; b=BLf29cHiXila/vdH0g320c/hiEI01f7EYTmbYNFYvjnf7yEm+COJf6RB1jhJj2YtAt utn21HVnGdPwNNHBjVqsZymPZr+5e1HfxIK4Sca8ee/JwkrqIalvOHEFkAZRE112+C+5 SgnOGiVpWGdPFGuvnCmlhqQPeCZ3kFppzK46K4gqyNSDGQpimdJzWi7NJN1NiFeBqB+g UR4ghH2Y2ODaYyVLnpArDoOdqsO/iFC1wXLk/VPPH+apx0RiwgKQ701j5P7QjVWysHg8 hurkAHD2/IwLuPFicGMOyHFsfktwlzU0AAUgln2HYx/hdUbFlwdAU9y/QRO9wVMUxaqS R20g== 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=uMCKcSAJEv9E1m93eqmne+Mnp3bcYvmVZ3HdkhhaY4s=; b=uNdz0YgUljctFHBrGagZRdeZwvSaEcaa2zCLvCFqxPvK5fMpQKu02s9GGANYmXqobK hhdPktw9ULwrzInpx657TW4X5ZdwX0enmmcd0mQAMNhJpmTdIY468z6TIUn0gP6dqy1j 2PVuTJFToD9EhaClb4ZxJWJimvLF0Swymp1qJyptSb0ccavl9pA7QhgMaAk4zdxmSOAu 4qxG6m8TSc3m11+j1EV5IUz6Mpl6sTrIkxlGqLk6J/IMDuk9F3dAjIVNQZkuhxQlOYZh /BWiOQUTocl/EQ05GeX52TFYLfenobFji8ak1cO/5cxotupGLKyPMAB6U2Rc3lQIoaD0 xVWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=Evc1vx3C; 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 b2si2583768uaj.91.2017.06.19.03.53.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:53:42 -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=Evc1vx3C; 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]:41676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuJS-0004tt-9Z for patch@linaro.org; Mon, 19 Jun 2017 06:53:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCU-0007Mt-Ej for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCT-0004un-DD for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:30 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCT-0004tt-3w for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:29 -0400 Received: by mail-wr0-x22b.google.com with SMTP id 77so69495531wrb.1 for ; Mon, 19 Jun 2017 03:46:28 -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=uMCKcSAJEv9E1m93eqmne+Mnp3bcYvmVZ3HdkhhaY4s=; b=Evc1vx3C4OWiPfJW+1jaP5DxxqsyHsAVOjYgHIw8oqOaPDWe2/rABiU0E0+smweNW0 yQvqIttb9kMWhYacYogZM4og0FIfwIzGTZOlSKmXDlPUOfgKoFMcNa43eq6k4FJ6c2UP aV2U04cFc4UAk43ZusNRCBABYLVsnVxV/PwOE= 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=uMCKcSAJEv9E1m93eqmne+Mnp3bcYvmVZ3HdkhhaY4s=; b=sKa77KIZb+Dn5/nyYxVdvsarNrx1C4aBTiZbpk/gKwMfqjA6w/nAu6QiAJ7VzgIqQY 6+4bMfnzZKWqMS1Dq1E6YJBtBKvM/YmCARiNN0Qsci36du/f4sNqbC9GRKY/+He239vq FxFJmI7CuzV+ceYGJX0/gAHuO52xtbvJWvjp2e/sbkEfdDqg3zv7LT7+WwfTF4SEjACc JrQLEZecnrg3ao8kywzPeftKwFkAo75VSg4Oq7IAtGtApLk9jLePhEv0zLarMQ+ZeokG zAVbqotpwZz+YSMFdorC28oYDlKau1Dv3rHxQqFchQKkhQ9dZEDYul71k9tnSzrYT3WF EDSQ== X-Gm-Message-State: AKS2vOyTNnhyiw5aHzXw1YTNMVKwGaze2UWLFMITB93PrtwC0ylbo1Db 0b35DC7z2P7cNgss X-Received: by 10.223.132.130 with SMTP id 2mr17290538wrg.157.1497869187934; Mon, 19 Jun 2017 03:46:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q143sm7917773wmg.14.2017.06.19.03.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 67F693E0BE2; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:50 +0100 Message-Id: <20170619104655.31104-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 08/13] 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 --- 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 Reviewed-by: Peter Maydell diff --git a/reginfo.c b/reginfo.c index 90cea8f..4ff937f 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: write_fn(&ri, sizeof(ri)); @@ -63,46 +72,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 32241bc..e9e70ab 100644 --- a/risu.h +++ b/risu.h @@ -51,6 +51,12 @@ extern int ismaster; struct reginfo; +typedef struct +{ + uintptr_t pc; + uint32_t risu_op; +} trace_header_t; + /* Functions operating on reginfo */ /* To keep the read/write logic from multiplying across all arches @@ -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 Mon Jun 19 10:46:51 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: 105827 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp812065qgd; Mon, 19 Jun 2017 03:56:10 -0700 (PDT) X-Received: by 10.31.190.145 with SMTP id o139mr11045823vkf.35.1497869770377; Mon, 19 Jun 2017 03:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869770; cv=none; d=google.com; s=arc-20160816; b=Oe/uN6ghBGpTay1umh4NEboqO72LjAeSJr5xjZWlwpU9HuCz224/z0qvnyzPmmkEQV gAfB7di8vYELxAMMVHu6wn6gD1fdneMf05WWSq4BhLuBLsBXxGryvSfs1zgeutbWrHtG wDlaASB/UaBUxg8EYTK68FB4ybH4WbvhAqh50pSI6XyH9YyFwgCi9RVJqoX/SgDVsp7o m2QkoBhx/E0i7xDLM2RPZIg8SqnDTiU1fTuwHfC3lDL1h6+vKlqsMsATK404Ki8vWhoA cfPl+FF2MbxNV4UlakEFiPvrzYepPlpU+vGzm8QGTJEGCX6MS0V+mklAbqPR7ZS1bEJv 5x0g== 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=DN2lth0mZkE3XcXUeN/mzEOFF3RlDTUzep1rbK4HGDA=; b=exF6hVblcUK7L1IZQbD2Cue3S3hHF0i73KgQ/mwNM2NyZRtFmfgBP/RWaR1E88ZCVe /qGwiO0uDlvxXnzgZOMEWCq9Y8ynUUPjYfZAFhyJgN+/0fBLShFcrMV5RHOUW9viP65I aXlOb7UBhVsmkTKbNEI6NN4GiSrGbD+hlQLfVo5tbTMjo/P1vOYT4i24PkzWaRIrDHy/ nE8tQlJbJJYc+LZ1KkogvApzWed6bNEKczAPpHCLXrIirGpMpgMjAj2r9Zo4o4zFXslE 3uFlfiLNmcNRMMPzdVnyQk/7bjbvAyStB5V/Ny+KbRxElgJKwixGCnZBxrtqWl0oAldW f3Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=eToI4tm7; 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 e33si5061547uah.276.2017.06.19.03.56.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:56:10 -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=eToI4tm7; 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]:41690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuLp-0007G5-Su for patch@linaro.org; Mon, 19 Jun 2017 06:56:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCW-0007Pb-RB for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCV-0004wS-I6 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:32 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:35191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCV-0004vk-9F for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:31 -0400 Received: by mail-wm0-x236.google.com with SMTP id x70so75453819wme.0 for ; Mon, 19 Jun 2017 03:46:31 -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=DN2lth0mZkE3XcXUeN/mzEOFF3RlDTUzep1rbK4HGDA=; b=eToI4tm7bih3MEtg5qoiVz4hKrkYaRkrvTvebILv9R1JC4gIRU6rBYIlNGUMw1N22R D3HGs01dgcLs4+kNG/uo0U2IETiv1cB0Eyw2+avxDGFGoLvJvw/+u+VWZf7ufzhKn1ji uaGK0w9vtPm14U5wN3o4Xu/6snsr1avSKi/0g= 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=DN2lth0mZkE3XcXUeN/mzEOFF3RlDTUzep1rbK4HGDA=; b=qoBhXWyMLZ5wb6iwuAw1uGypIumxig0CEM8eo48qnVfmR2k9lEjZBaqV9n3vXcNpxy OlkeahVfj6zcMT7jQywWrzFB57b87I7Bua6qK4vBWS6nOyHzz+QL6l5em4x764bJVO7+ jiCXzuaROtlnLz7+SO8ondxUJ3bfMgepBzX2teB6dAxPIbGyY/3Wzb6IAjpzbQ1Q6tbK Gf4/+UHZR90x7+6saipfMyUD9Vp/shiWcYlwm/LosGmz0FpEg6x52Bot5TRhesqQ487w RVaKxppHjHNORF8JfHc86ODc2vUE+2QTJEP29Tu+v1yfFCo4g0NYVFrrCLWnK2oZ11hX 58Gg== X-Gm-Message-State: AKS2vOz4GtfFql5XdwGhgcHz6Q4DWV9SXkcCLi+qosWMHQiGIisaOwzx EeUJUil3dgxzgchy X-Received: by 10.28.230.153 with SMTP id e25mr13888679wmi.41.1497869190033; Mon, 19 Jun 2017 03:46:30 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m63sm6976749wma.18.2017.06.19.03.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 72A333E0BE6; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:51 +0100 Message-Id: <20170619104655.31104-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [RISU PATCH v5 09/13] 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 --- 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 Reviewed-by: Peter Maydell 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 Mon Jun 19 10:46:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 105825 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp811285qgd; Mon, 19 Jun 2017 03:53:46 -0700 (PDT) X-Received: by 10.176.92.198 with SMTP id z6mr15082644uaf.27.1497869626385; Mon, 19 Jun 2017 03:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869626; cv=none; d=google.com; s=arc-20160816; b=KUizhyIdWlP/uHC7Qhm3hSJD6el+67rfgoD0t61t3GqTqUYmIzLdnObIl3LdYt9cQK Rm7vgUhmGm5b9/YsRlyu70XzLBP6byuGnlvCSvrK2/7nSq9GCkAv27r8afa+LNsNDb2e nuyAw6ENoq2rYhN6cvY7QjnyfNlUrO5VC/7G2lRTSOL0TIaMcHL7betAYpWSGnMocDLl ea/qvuRAnbfqkbnLbGo9SaCmm2BWHV4150AiYZT5s0oD/j+AQrDeqaCTq38W3JG5Kc+y c2cxFhAWLtaGp7+GbHFqczaY5IAC4sUIrAoewDSN+45gCaCHpSNNtwezEAE1bqYBuIRy NBSQ== 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=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=DtLfHo4twFP6amuhkireC7NspMV0wd6V5e7eUz2UvrDQfUwb68vPF64DIarJxshLvm AOLtOWd60X8edXoyJjep2aYUEWibf5Mn/XWqp22xjJbXw4UBQ/LeCwEpLGvVZgzW5VUA qyKJ7YU8eS3N0E8K5eW6ePL5UWnct5KsV8YUgF+PVxYuAHKn7+IRkmG+kT2DgQ/me2n7 4YF9rsdZ5zhRmlzI482naB/zvAQiQ+VJHq+y4SRbkJN6A7R8znEj4AxkCurndzieDbc2 KZeYlBiQA0r4lSwnyf7t/3YzrJgaWW+MV/u+61c4D+U0Y0XHsv0Mdcj0sLaLFaAfZ4nv GZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=NS/8LoUK; 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 v70si4076130vkv.226.2017.06.19.03.53.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:53:46 -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=NS/8LoUK; 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]:41677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuJW-0004xS-0P for patch@linaro.org; Mon, 19 Jun 2017 06:53:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCV-0007O8-E8 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCU-0004vZ-EM for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:31 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:35297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCU-0004v5-7I for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:30 -0400 Received: by mail-wr0-x22e.google.com with SMTP id y25so30274708wrd.2 for ; Mon, 19 Jun 2017 03:46:30 -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=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=NS/8LoUKGRtjq1XYMmnLZ+vD3+WcDlajlqomSpO2Vh/SqvF9IYKXH3+aoZSbo7SXHC L08xYcHLnBMGM82exOTWsHP3TOAglHHPk0lmv43BXwuvnih/jvi+7RG7aVviQKxNTBOS 4d+SpMhDDVhXtVH/7tDlOFgdcMYmBQ0cELFEo= 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=ysmko3BJIBdfWyUXjgI9a9ZqdVXmJ/oPPt98TGkAqoM=; b=aiIDSjHO1kD4vks7AdIr2h/aH0I4fcqmJ4g0PrACLUA736UCTGdawmSSaIOsL2qy/C zBvc+K41fWs1zrMliimfMTb380XZGYmQh4WxyBrYU4llpnObpH6EliA8dIuy+6nrATKP B38hDHXbCMAMD5ghLXFgQRI09h/vLfeFJ4k3Eq6bgfmcdYp6YBeqVinhrKnNyzwJZtON df2gJnLbxQ1Cuuju4pSgFa6kaDXzd4XT1S1SR6TiqMP6LzgcT2dEP/ow+5x3p1juKk0B N1ECmqwBCBooHgcCK3aoHqlLSnyc11TyEk1z5ga1/AOrDO30V1U7x0l5kLRKexqlwESB U0xg== X-Gm-Message-State: AKS2vOz65sCaGM3MLVbRgszJnoRFcwCsigTd+HtFLckVsEkqb2hDjtm6 lPNsz55mumXVX6is X-Received: by 10.223.165.13 with SMTP id i13mr12985815wrb.35.1497869189096; Mon, 19 Jun 2017 03:46:29 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a99sm16465094wrc.64.2017.06.19.03.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7C8393E0C03; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:52 +0100 Message-Id: <20170619104655.31104-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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::22e Subject: [Qemu-devel] [RISU PATCH v5 10/13] 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 --- risu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.13.0 diff --git a/risu.c b/risu.c index 93c274b..e94b54b 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 (strncmp(trace_fn, "-", strlen(trace_fn))==0) { + master_fd = fileno(stdout); + } 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 (strncmp(trace_fn, "-", strlen(trace_fn))==0) { + apprentice_fd = fileno(stdin); + } 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 Mon Jun 19 10:46:53 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: 105826 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp811662qgd; Mon, 19 Jun 2017 03:54:55 -0700 (PDT) X-Received: by 10.31.172.88 with SMTP id v85mr9443245vke.57.1497869695478; Mon, 19 Jun 2017 03:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869695; cv=none; d=google.com; s=arc-20160816; b=pqI1gT4/NfeT0VpVE6i2BzqG9M1BwMZCxLVjsdW64aBGbFusOE2Quioupcb/kJyStu HnWOk/27EziQNVsvaC6VSPJrIWhghmwY7V6pZDLQG6S3NVhxM8g+eHBIg2A/TzB6TIru WLNmg+rBTvfAK2fn4xjIIVQCVZJNrWfWSAS+0ulp7mZrh/PIXqpehAs95YHfCr+lA8pr vHHQEDapfb44tOjBXnFUfn0bVaH2Y3RBbe6ycG6AvElo+rx7wIqhIUh+/ZHyJKCXbZK1 5zRqo6Nr5bexoJsFIoI5w0V4FyV9oCxKYmJSEc8UetYk0/JaPi97LekbtWGCCkT3gbQJ PByQ== 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=DGEbXD9mMXbBGln9tuuvpUF13T88QmXb9vdOIGA4H+c=; b=domTNYabps57NRCeD3/Dd1RxUldulL1aAAwb+VTgpOxdn/fvNJXOmBmAmPCJjx/bNw T0iZgH1DwNA/ngEqyk6p8Cnw5mh0AUxFKW2xTifQ3ASIZhNPHrjPldsyyFEZXU3idXlD /X8sP2CQN5HBDLH1T72xMbE3xEpSPNIcyEu/hI47Zq8R8hUSKV6uheCCJpkUL7dy8g/S 7tkiB35YF62kvvRFbRqaNewAJ3l+BJDcHMull9yZOFbNmomPPonh6HycSOVhC51UJESl FI3fCxvC9UlZV50hqvEfMG6ziTvb16WYYOksMeEBfeawEZX6Mfid5ADf2qwTEYfd3PMj 7sHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=D7XXAbks; 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 j70si4405349vki.192.2017.06.19.03.54.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:54:55 -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=D7XXAbks; 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]:41683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuKc-0006Hm-VA for patch@linaro.org; Mon, 19 Jun 2017 06:54:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuIT-0004TO-K7 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuIS-0000NX-0k for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:41 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuIR-0000Mh-N2 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:39 -0400 Received: by mail-wr0-x22d.google.com with SMTP id 77so69584091wrb.1 for ; Mon, 19 Jun 2017 03:52:39 -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=DGEbXD9mMXbBGln9tuuvpUF13T88QmXb9vdOIGA4H+c=; b=D7XXAbksIPAFUN+tRpS9Rcj+w2Hee5k84EmxB+acVsvZP2PVcIGBh6EIIQ3pfG59pI H7rPOhDST17qf7z+vUNRkj2uEfmJt8mK45ADUnptCuk8RNJ3aGpj5zHEaUqhojFPJwSm YwA+T7mND89xMOLJz7xjtvgAPCxhjgZS1/QMg= 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=DGEbXD9mMXbBGln9tuuvpUF13T88QmXb9vdOIGA4H+c=; b=MoWE1+ixeAr6Kq0k9THidOf0mxMUtzZ6IDCIx6q7oIyvlFnpchvoeq6QwP74IczwZy aEUQEfSrxv2DP5sT2w00d8XpCV6d7z87tGMoHtrVWI/30i307YK4Za8aCsLZZMh8MV7C mdxxYzJSpfBQBu6RiaRD7sRCHmJOkIlZBtzEIKiqurxugQpuSUg8mgBG5Ygu+KDGPovw vFyQRAxBjJHfNkkRK2x2ZY+7jjgy+9AfQVh4w2GStzE1SXRa/utR8aR45FF1r/5VGhIl wXhD8o5m9+1ikgSVO+hSK/E6gREHaVQl0HsV7Z1r65NRh5hkdSvQN6gQ9CY/uZtqnZmb RalA== X-Gm-Message-State: AKS2vOxw2KAqk5qB9iP/VSSAJLJIJTo0+qeEb64y406nOnzKT9PL6Vv1 ZeLohSiIBIGNF76hx8i87Q== X-Received: by 10.223.128.200 with SMTP id 66mr14333710wrl.99.1497869558181; Mon, 19 Jun 2017 03:52:38 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a99sm16483319wrc.64.2017.06.19.03.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:52:37 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 873E63E0C96; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:53 +0100 Message-Id: <20170619104655.31104-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 11/13] 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 -- 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 Reviewed-by: Peter Maydell 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 e94b54b..6986e4c 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 = fileno(stdout); } 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 = fileno(stdin); } 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 Mon Jun 19 10:46:54 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: 105828 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp812734qgd; Mon, 19 Jun 2017 03:58:21 -0700 (PDT) X-Received: by 10.176.86.2 with SMTP id y2mr14591736uaa.90.1497869901439; Mon, 19 Jun 2017 03:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869901; cv=none; d=google.com; s=arc-20160816; b=G0v2YTX92MjA+ROSQ2nlmfB/bTrpFRpE3EhXwqX92h5lZRlrDDXvz6Jq2vZjmtQ/xv /VmVGv9QDremHJwC+GJZOx5YwIZu7sPgSwJ5qK0a1PoKBkyMItIAXsDL+yigs0pcfCfI 2renSLvUnYN+mEVRv9+mAf5aTfPPlBbyxwsGFH02YbAb2qzmzon95uuevnLEKeIDCrj4 PNJHbZzQWxdxm9mEiJzP6vpP9z8hfIUwLr1appcz6uWAw7+iF4nmUyUaqpKVHr6ufAcE gcuyIBIHOGSSed5QUOhAYJqr0/y/SRpHM//9dvnY3r5Q9TxlzmsNktjx/sIRWnOMl05s Dxjw== 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=ujzFI5IGCWcRzNwSIP7fYZR4XrH/oau+XxV8wgZ2p+E=; b=het5W1d9d5BZZMV5RqbxpDkIXKAJisKYgOS2HUzJX+dzhNI+TvZrHbPtqaKnAAvcDU uWiBYptSqqVxJgf1Ajnn8rJ+40CcW5pluoeC+N6BSmyXiuOLcYGHZ2R10s7ZZcDaorkD mVDDYTMOKsSOR2Uw72h0/hSiUA0+4kKEjfYQ4fjU5623/slxfqes9Oo/xzG/AmEyf+CA vZNlf84EJATcOVw9zwR33vLFJTwFDRdF9ZTRXCao5wCNAnCqOL3Bg9RHPihaEngFRtfC wEls+8x6GuI904no3t/FV5JjXnhCm1kh5Gvf+OPd8WJVOlhihORnQmV2P3b97EPTEZVl wP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=eStVjS9q; 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 x19si5096173uax.147.2017.06.19.03.58.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:58:21 -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=eStVjS9q; 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]:41700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuNx-0000wZ-1Y for patch@linaro.org; Mon, 19 Jun 2017 06:58:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuIT-0004TP-KC for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuIS-0000Nl-CD for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:41 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:33905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuIS-0000N1-5k for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:52:40 -0400 Received: by mail-wr0-x234.google.com with SMTP id 77so69584236wrb.1 for ; Mon, 19 Jun 2017 03:52:39 -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=ujzFI5IGCWcRzNwSIP7fYZR4XrH/oau+XxV8wgZ2p+E=; b=eStVjS9qn7gfG6eEJIrRzAz6Z8IjeOksskNg2WvNiO087apR/U508v+2cQscEuIgts Q6oIRbxlo7XGCbnkTRqoa4G6hIVoWOzF2enZBRwc1hRg8Wqro8Uhegxy3Ifm4c/IME1y I9zKSiJAcfJwKA3YZzkkGtprvOYnGJjan3BuI= 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=ujzFI5IGCWcRzNwSIP7fYZR4XrH/oau+XxV8wgZ2p+E=; b=MkHS6qCfWsX6nxJt40tDxsn/aIvW/RlyYlMLlcCRw/40O9a9nW5OBb3pEME9gAOnz4 wyQRQlgu5XV/d4ovUn2gAt9LANLcaGX0Lb2ZYwXkNlpssKMCjugttIsyD52sw4rW/lBx +kVx2DxKJT8A8BwPKm9h3S4sx+pJuChiaEOuPd+WBLm63Y1aHw+Xb0DWgxzCVlba8EDy +0aZE+HC7qZIhVSTtPiQfj9enFsqmxx99h/QUl4dJPkWs7xxHyGgKH7fe8mw17kpXB/v 42oPU+v4AqqH6EuTJv8/oCiHGC0ys2xJ27gRDuyvQh4RVoRRGlhq2NytBIerEZt+69Ne 9z4Q== X-Gm-Message-State: AKS2vOyD9gz5sSmz3oL9mPKtdAaRbT7EbRCFz9o0b1x0uKIxQEV435tz C+i3HhItkjivVdy3 X-Received: by 10.223.150.89 with SMTP id c25mr15018132wra.15.1497869559011; Mon, 19 Jun 2017 03:52:39 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 201sm4955519wmy.15.2017.06.19.03.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:52:37 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 91E323E0CC0; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:54 +0100 Message-Id: <20170619104655.31104-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-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 v5 12/13] 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 --- v5 - author, license and usage header v3 - allow overriding of RISU binary --- record_traces.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 record_traces.sh -- 2.13.0 diff --git a/record_traces.sh b/record_traces.sh new file mode 100755 index 0000000..1234a61 --- /dev/null +++ b/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 Mon Jun 19 10:46:55 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: 105820 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp810304qgd; Mon, 19 Jun 2017 03:50:43 -0700 (PDT) X-Received: by 10.31.223.129 with SMTP id w123mr12787754vkg.84.1497869443724; Mon, 19 Jun 2017 03:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869443; cv=none; d=google.com; s=arc-20160816; b=t2pXEPHHNymCYoBzfYI5V2GGE0Kx5DfyEXBn8akwZl3790fRnTmG7EVeNoYZclLApr NczBvfH44XMp/OZgX6uu7gJ+V/iKize+QL7AVWjjcLGeeRes6RmBuCPaAJNI3toDFgyC rBNZ3D6oXvgFgGF6NlmpQoZq/ds41c1sxOoN48V0MWre2f//FFhHkszZhLPGlwgbHr4y LJDRCGSC63RFZt0OmivCKVeqMmt/YKkmeg4sqbmw9iiqCvZGFsmzYCdxuFeY8Py9roBX MbBudBvJ85J/MPYEBI8HPnTBeRzR2giB9WyOPIiAkKS0kOA07FZBhf2AyHH1ANMnKCZ+ KkWg== 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=1Ok/BKHGAzCqK7vI7/u/MjjM5SPi7nSgtGgFSdHiU/U=; b=ZmJvzpEhCRf/aKrcvf3VmYSsSiYWeRbTX3v9TJzzSEMIqRw5T0ZMGjlLTJiPxaVUzr WwFk7JzorDqgOaf+qeyJLffhpGclneXYm/UaHALulOdMH0STQNvOfsoWlqQ5tVeoGnSx ThcMSsaJCT1d3dSjQlBkc3sf/QBue82/EWA2zd9H1LXlKRD0a+RnDUWea/BMWUIpSum3 IHsx9roDN308iWTJU+brAoZViHfmAIyIy2kNl9XK+X8I+I69wEiLGoUnpHjIvKv+Ux4f Wyo4yaRVl8MCGt/BHNqnBkCJRsg5wRZUArtXCsY3v5rfg1pRrmTTjtVVz9yZ2IVlI3AN eEBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=cgzwW5ln; 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 l22si4754560uah.284.2017.06.19.03.50.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:50:43 -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=cgzwW5ln; 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]:41665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuGZ-0002WJ-82 for patch@linaro.org; Mon, 19 Jun 2017 06:50:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCa-0007Tl-MC for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCW-0004xP-Ah for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:36 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:35197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCW-0004wG-4W for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:32 -0400 Received: by mail-wm0-x235.google.com with SMTP id x70so75454190wme.0 for ; Mon, 19 Jun 2017 03:46:31 -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=1Ok/BKHGAzCqK7vI7/u/MjjM5SPi7nSgtGgFSdHiU/U=; b=cgzwW5lnlIDP8xuBwl67KwTJhtqVP6UUyL126k+nv/3ekSjL80SVi3EOUVp6p8huv1 kSX0ZUlKuAUC7mfSBfe+Xnuof/x8WlCHoSfwO/uMmH4ZSSfn1V+XhJ2JrNFmVnFgDDWc 9tvZW6scoA1pDfn1+yB7iAaFvLUNuksakeiJ8= 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=1Ok/BKHGAzCqK7vI7/u/MjjM5SPi7nSgtGgFSdHiU/U=; b=arUcf4SDTd0MFtQ6JjT/ohN3TlEbYCI5i7+Od72FhA98Whic0aRNfa3cVP2gdRgLBv 4M1ZotkOn4A0hp2qpzA42VteoYrBcvUpsT8+oxiJjkxIgfbpfKjSxgF8e61M4XWcqd/g j51GU3hHMtp6mQqJ1R6642GzpyCVlxar2lMXKGVmAjEQWLZLyfHp5m21ktdJKhAV9xst UDyFy4OUQvOo288WZfnhT7PjJVS1urt/KIJALrSZaoFr7wQy3BMvyyKOxDNlW7GNCzFS RxwP/2OUTk0FFe3g655Lmxq9oS7HRkcV02JUcmBJWPufR+7M+LERVjtYIqDQJHeyCsiI 6WxQ== X-Gm-Message-State: AKS2vOwPF89bPA+f3frJPg+T82aYChua157MmbGo8tRNzPQwWjhO+jKW RZIUi4fpIOw5UOg9 X-Received: by 10.28.236.134 with SMTP id h6mr14600755wmi.1.1497869191010; Mon, 19 Jun 2017 03:46:31 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a128sm8612423wmh.8.2017.06.19.03.46.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:26 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 9BA2E3E0CEF; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:55 +0100 Message-Id: <20170619104655.31104-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::235 Subject: [Qemu-devel] [RISU PATCH v5 13/13] 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 --- v5 - author, license, usage header v3 - tweak to allow specifying RISU binary --- run_risu.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 run_risu.sh -- 2.13.0 diff --git a/run_risu.sh b/run_risu.sh new file mode 100755 index 0000000..439cd36 --- /dev/null +++ b/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[@]}