From patchwork Fri May 22 02:34:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187128 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2105088ilb; Thu, 21 May 2020 19:41:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJCvKZIyCZZWoWMf+Fh2U2xV56RgrYnM6D6mhvwiWiYDBG7tjvqu1B93iVLGkuBsD9x1ai X-Received: by 2002:a25:8b83:: with SMTP id j3mr19192737ybl.450.1590115278161; Thu, 21 May 2020 19:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115278; cv=none; d=google.com; s=arc-20160816; b=PKTy8BfWQgZkT0AQCxE7jl0RohM8t0FS32E12guL9R5FPycapcF9sAS8B47yIMkuiM Mz4VhXmGAlCm5nF/FOO5osMwMMHjHkVXcRqPoNr2b3qJw5UqjC/40sEm82O8vGP2iMq7 Z2VnNmK+ZQ1KnhI9h5K86TVJzJaAvie53fK2KX5VBrjFoLeMsA5dMWoAXUg1AnvEuJjB fxuvGjd5ruYvoATyTgwvufUJzYrm2M+jAZNeROLFA/kKacTyDqYs4SUwn5M9beGuIIDT EKcFIW3BAh7E57g2nUxdj2XvpsI7ar6cd6QOP0hnI59QUztzxlPncUBiw6v94d5doIrM /TzA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=tw6kaS7cgnv9ojaevwAQsz7Pzb9OgphIdJHXfmoaatWXfMu5GLM57Cxf1uu8DAg5w9 JslphnYRogcwuO9HPL0V1k4202zaJzxqseyMHawSExdiZvqurBTUO+RC4eSV36N6lF2M SLuVWFYgsIsERpeCeVX6YjGqmd5F1uSVN5P3xZ0Usk65qibXjPYqMgMHubZ/TI84/D+p fgZope10ngJMCymfktHxaDv+somCZccPv1aCzGNO5IgNiQKHJl5IOIk3BLnVubvu3TCo m4GRicwduAIo6rt66MdD2l0h9DQhV3vQKjw5NbTgEu7/Umil5hgtJsOz6xtvxdcyeFVz fTfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d+o7d75w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n190si6727241ybf.130.2020.05.21.19.41.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:41:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d+o7d75w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxcb-0000J9-MO for patch@linaro.org; Thu, 21 May 2020 22:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWk-0003FK-8o for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:14 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:55060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWi-00059D-ST for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:13 -0400 Received: by mail-pj1-x1042.google.com with SMTP id s69so4293967pjb.4 for ; Thu, 21 May 2020 19:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=d+o7d75w1dlN4N2FIq8e4q06qpBJmNEHlzIZHEEsXlgvTpu/1E3VoqzuVXTJlqRk7r Q1dohYUTIFDY7W/ugezO08NFd8RXBhXZj8yVQhFOzhXy494BR8HjI3GBrjPkzQjrfgfp Ky0Z+CaWObUzM6P0ZIoJMiSwKPneobr5q8+v7ENzoKCdoevuYUWCEKfvqoMp1sMJcJ74 Fj70aNxhBWy5wJcnFeuABxs+bWflcgMla8v2SxVmU0Q2CAVWX6B3ssi/ardvAdaEIv4j PIWIg7vJgPw19zmrOIR1fDANVl9ZW1bu69e7qsfz+IQKJQvxP7QnD2JVolqbq1iVHrhj N0lg== 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=BrFduBNmLob/ZHyXbyYHj/vlX7R48tWvfDpwxlGRg/0=; b=SfvVHAsVl2Fc/B+UgR2aKN2+qdk59JYDYEHwuAfxfUm41KplCLUDxZYke4O1mwOV14 y7dWFv85ENnTO7t05I7A9E+jOmyAhN+c0ylO/WTpJY1n35x1LBNY+FdF+WIT6OeC5qtL 2Yq0tMvH9AXKBU1dTulYUjiGITOpCjV5g17Sk1cap3CKarCB1vYtbwjYroeliI6JNwvB sJ9F/ZtnwU3fWeyE1ixpM1/72QdTu/X1C/k6dc3SX08WcNL5ywRKrzONqNvVgb1iYGSZ /91FVKC8i95BwzTX2Hb9EJ6nl+W5vv7YIjvLXeQck2xu4N9AbDC1Ezp4ODacipwJlXiK D/wQ== X-Gm-Message-State: AOAM532WW8FBHP9cBtdrJyqn2UiUBTCDT6+C9bscFRwGxhYjEFI+yn7U cGbEvud770FZiYRww7P0aSEStfACx/4= X-Received: by 2002:a17:902:bccc:: with SMTP id o12mr11723535pls.162.1590114911034; Thu, 21 May 2020 19:35:11 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/25] Add --fulldump and --diffdup options Date: Thu, 21 May 2020 19:34:38 -0700 Message-Id: <20200522023440.26261-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These allow the inspection of the trace files. Signed-off-by: Richard Henderson --- risu.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 15 deletions(-) -- 2.20.1 diff --git a/risu.c b/risu.c index f613fa9..8d907d9 100644 --- a/risu.c +++ b/risu.c @@ -484,23 +484,101 @@ static int apprentice(void) } } -static int ismaster; +static int dump_trace(bool isfull) +{ + RisuResult res; + int tick = 0; + + while (1) { + struct reginfo *this_ri; + + this_ri = &ri[tick & 1]; + res = recv_register_info(this_ri); + + switch (res) { + case RES_OK: + switch (header.risu_op) { + case OP_COMPARE: + case OP_TESTEND: + case OP_SIGILL: + printf("%s: (pc %#lx)\n", op_name(header.risu_op), + (unsigned long)header.pc); + + if (isfull || tick == 0) { + reginfo_dump(this_ri, stdout); + } else { + struct reginfo *prev_ri = &ri[(tick - 1) & 1]; + + if (reginfo_is_eq(prev_ri, this_ri)) { + /* + * ??? There should never be no change -- at minimum + * PC should have advanced. But for completeness... + */ + printf("change detail: none\n"); + } else { + printf("change detail (prev : next):\n"); + reginfo_dump_mismatch(prev_ri, this_ri, stdout); + } + } + putchar('\n'); + if (header.risu_op == OP_TESTEND) { + return EXIT_SUCCESS; + } + tick++; + break; + + case OP_COMPAREMEM: + /* TODO: Dump 8k of data? */ + /* fall through */ + default: + printf("%s\n", op_name(header.risu_op)); + break; + } + break; + + case RES_BAD_IO: + fprintf(stderr, "I/O error\n"); + return EXIT_FAILURE; + case RES_BAD_MAGIC: + fprintf(stderr, "Unexpected magic number: %#08x\n", header.magic); + return EXIT_FAILURE; + case RES_BAD_SIZE: + fprintf(stderr, "Unexpected payload size: %u\n", header.size); + return EXIT_FAILURE; + case RES_BAD_OP: + fprintf(stderr, "Unexpected opcode: %d\n", header.risu_op); + return EXIT_FAILURE; + default: + fprintf(stderr, "Unexpected recv result %d\n", res); + return EXIT_FAILURE; + } + } +} + +enum { + DO_APPRENTICE, + DO_MASTER, + DO_FULLDUMP, + DO_DIFFDUMP, +}; + +static int operation = DO_APPRENTICE; static 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, " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n"); - fprintf(stderr, - " -h, --host=HOST Specify master host machine (apprentice only)" - "\n"); - fprintf(stderr, + "Usage: risu [--master|--fulldump|--diffdump]\n" + " [--host ] [--port ] \n" + "\n" + "Run through the pattern file verifying each instruction\n" + "between master and apprentice risu processes.\n" + "\n" + "Options:\n" + " --master Be the master (server)\n" + " --fulldump Dump each record\n" + " --diffdump Dump difference between each record\n" + " -t, --trace=FILE Record/playback " TRACE_TYPE " trace file\n" + " -h, --host=HOST Specify master host machine\n" " -p, --port=PORT Specify the port to connect to/listen on " "(default 9191)\n"); if (arch_extra_help) { @@ -512,7 +590,9 @@ static struct option * setup_options(char **short_opts) { static struct option default_longopts[] = { {"help", no_argument, 0, '?'}, - {"master", no_argument, &ismaster, 1}, + {"master", no_argument, &operation, DO_MASTER}, + {"fulldump", no_argument, &operation, DO_FULLDUMP}, + {"diffdump", no_argument, &operation, DO_DIFFDUMP}, {"host", required_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"trace", required_argument, 0, 't'}, @@ -520,7 +600,7 @@ static struct option * setup_options(char **short_opts) }; struct option *lopts = &default_longopts[0]; - *short_opts = "h:p:t:"; + *short_opts = "d:h:p:t:"; if (arch_long_opts) { const size_t osize = sizeof(struct option); @@ -551,6 +631,7 @@ int main(int argc, char **argv) char *trace_fn = NULL; struct option *longopts; char *shortopts; + bool ismaster; longopts = setup_options(&shortopts); @@ -586,6 +667,8 @@ int main(int argc, char **argv) } } + ismaster = operation == DO_MASTER; + if (trace) { if (strcmp(trace_fn, "-") == 0) { comm_fd = ismaster ? STDOUT_FILENO : STDIN_FILENO; @@ -609,6 +692,10 @@ int main(int argc, char **argv) } } + if (operation == DO_FULLDUMP || operation == DO_DIFFDUMP) { + return dump_trace(operation == DO_FULLDUMP); + } + imgfile = argv[optind]; if (!imgfile) { fprintf(stderr, "Error: must specify image file name\n\n");