From patchwork Sat May 11 11:53:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796233 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp1236249wra; Sat, 11 May 2024 04:56:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWKyT9Ddi5gUyBtMlg9Gwsx18mag5/C/5i64D4Xlrrl+y97Y1uEETKIVazW05u2K3lb7CPbwR14ifdR6A95tmmE X-Google-Smtp-Source: AGHT+IH2tGPIq4POycczFaHKL13RWA8H11zXjzKjxfW6I4aji5JHGe7Z9TwcbANll2kwybV9AXAc X-Received: by 2002:ac8:574d:0:b0:43a:ee9f:8ff0 with SMTP id d75a77b69052e-43dfdb70bc2mr64683321cf.38.1715428593725; Sat, 11 May 2024 04:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715428593; cv=none; d=google.com; s=arc-20160816; b=0iHHuFBhkWNn2pJdL6lD8m4VwUizVHPyX4tSDupzxvyOnDOssiV5Ps+j8Od9uJDF8Z YLHooUyRfpL83Y019kP8txiDatq474DFLGmV0TSSSgwS4lO+Yz+kGIfhi6H5+XdFcr6i RK7bsC44j6US1Vy4FRL00qY1CqdgRqxI1pq0yBmgmZ3HbwFcQy3pgmE8ICi8kGtMlF1J nOx8Kk81oebY4t5Fp4c95sSGC/ZqMqMO6fcBGdDS7jT6b5UWfgMv9pyhijqzf6sW8tXB rvuHWkMrG1ScvRz8ZGFQ83A+ShV7wY2AnZshUjb4StsvWk+IIHB28j75aYff+NYUlzGp K0Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=3X3XgI50snZLtrZ7HC0OWfW96V7yOplWwRGvCG/f16A=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=HJnvfFywS7ywoLpt5YHA8P+CN8qH4Li9jhaA/QdNwOtiW6z18zD75ZMR5sE85BpiKq v2GiE+28/+99Bt2Q06xypy0rxnraIkmq01ZHY/+o0MisuiqaRqDnu/q3yrMIgRTI/IaQ UWI43vjib+YbO+BZF0RJrR2xRVt/SbD8CeVexmeBJ4LFma+Ul14zEvk3nFjnc6jmsxR0 Y7yAxgSfaqttUmpS3DQO2qr+XDMpm8LHF4LIAl4cWZN5waEkor3iwb/bGjsgAk5ziAfh pni+hwj7hjUiVz2EgggAhV4bQqlnuQ5IbqWP8LZrVt45FGDl3I17qHHd6TFpPw/wvMP4 v+4g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oy7HA8sT; 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 d75a77b69052e-43df56e6078si55827451cf.764.2024.05.11.04.56.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 11 May 2024 04:56:33 -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=oy7HA8sT; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5lIp-0000IK-IU; Sat, 11 May 2024 07:54:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5lIo-0000HM-67 for qemu-devel@nongnu.org; Sat, 11 May 2024 07:54:10 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5lIm-0006xN-8a for qemu-devel@nongnu.org; Sat, 11 May 2024 07:54:09 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-34e0d8b737eso2208509f8f.1 for ; Sat, 11 May 2024 04:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715428447; x=1716033247; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3X3XgI50snZLtrZ7HC0OWfW96V7yOplWwRGvCG/f16A=; b=oy7HA8sTwvYL1PsdUzrbFRMI7a8Ha8FeajpE9YJSLELz4Td8NtGJu1ONBbLLGQ2InN zAkerhVN44JSrmBHF8YOfBavNphAT1l9KBF10xzRrifam07w7uhuWlR6OiHQI8o3WqVt wPxvmLxi0W4gFPuWclEzDcUIBHmihIxenzl5DOdu1t6lH1/OT/DZC6TI4DtsYa7P7Ezo pNV/NM65synx3Z25l+Ac42AHB9EC4lUnv2ooZyfYGg2L0C52ABhVudm4Bom1Kcuo0qpu Jo5/v8YD3awYVdlS1TaQpwdJE6RdutbPaRU+RidGhOhQoSHy3RgzOeQvobRSD9eC9EUJ hXwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715428447; x=1716033247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3X3XgI50snZLtrZ7HC0OWfW96V7yOplWwRGvCG/f16A=; b=SsGj1Zf1e+dArXI46O3gUKxd01rq1OuVYvFR6F+UmP6Ct7Z4B7g1p+ZdK+o7wARCwI 5E82rNyl5nIWemjiV1PfXWV0w0Ip6fVjsLUEbK3I25E/VBB7eMJLS/Nle6L3jQPM7Fss qTDGOPwhc6SiTEPJ/TJDeDpmH9jtf5t7y+NNB9WymgV/AMzxPuJY5nccFbaNdVpXGHYh h441ndNO+ygSauBYW0sVadZYnR5xxmDMWZeNyaydp4p/pubSSe/Yo34R1knr/F96rYkM smGfZND5SjQY6/MO3HhY6hMRYjjZDraNeQl6U0rzeUBePxV3UT4hme3rTW0B59qOCymV 80kA== X-Gm-Message-State: AOJu0Yw9xxsDAJZ/3Vw8yZIgDD54EkiQGaqP3ZDx3yIoFFpX6/mw/GOy 5gm4G4si21pGIbHxSNpXa1BvchLxgCOOfcHn4l/ZcMyfxUQt2oXvv2SbDKw17MLiazzVyk1lFDc bbL0= X-Received: by 2002:a5d:6a42:0:b0:34d:d5e5:6816 with SMTP id ffacd0b85a97d-35018113161mr6982872f8f.8.1715428446910; Sat, 11 May 2024 04:54:06 -0700 (PDT) Received: from stoup.. ([195.76.196.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbbbf20sm6764797f8f.93.2024.05.11.04.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 04:54:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 04/17] Add --fulldump and --diffdup options Date: Sat, 11 May 2024 13:53:47 +0200 Message-Id: <20240511115400.7587-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511115400.7587-1-richard.henderson@linaro.org> References: <20240511115400.7587-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These allow the inspection of the trace files. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- risu.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/risu.c b/risu.c index 9c31b8c..c28b4a5 100644 --- a/risu.c +++ b/risu.c @@ -483,23 +483,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) { @@ -511,7 +589,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'}, @@ -519,7 +599,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) struct option *longopts; char *shortopts; stack_t ss; + 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");