From: Richard Henderson <richard.henderson@linaro.org>
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 [thread overview]
Message-ID: <20240511115400.7587-5-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240511115400.7587-1-richard.henderson@linaro.org>
These allow the inspection of the trace files.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
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 <ip>] [--port <port>] <image file>"
- "\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 <ip>] [--port <port>] <image file>\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");
--
2.34.1
next prev parent reply other threads:[~2024-05-11 11:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 11:53 [PATCH 00/17] RISU misc updates Richard Henderson
2024-05-11 11:53 ` [PATCH 01/17] ppc64: Fix <sys/user.h> include order Richard Henderson
2024-05-15 13:11 ` Philippe Mathieu-Daudé
2024-05-15 13:53 ` Richard Henderson
2024-05-15 16:55 ` Philippe Mathieu-Daudé
2024-05-16 13:32 ` Richard Henderson
2024-05-11 11:53 ` [PATCH 02/17] Fix load_image error check for mmap Richard Henderson
2024-05-15 12:51 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 03/17] Standardize reginfo_dump_mismatch printing Richard Henderson
2024-05-21 12:20 ` Peter Maydell
2024-05-11 11:53 ` Richard Henderson [this message]
2024-05-11 11:53 ` [PATCH 05/17] Remove return value from reginfo_dump Richard Henderson
2024-05-15 12:52 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 06/17] ppc64: Clean register values in reginfo_init Richard Henderson
2024-05-21 12:22 ` Peter Maydell
2024-05-11 11:53 ` [PATCH 07/17] ppc64: Compare all bits of CCR Richard Henderson
2024-05-15 12:54 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 08/17] ppc64: Simplify reginfo_is_eq Richard Henderson
2024-05-21 12:23 ` Peter Maydell
2024-05-11 11:53 ` [PATCH 09/17] ppc64: Clean up reginfo_dump Richard Henderson
2024-05-21 12:25 ` Peter Maydell
2024-05-11 11:53 ` [PATCH 10/17] aarch64: Tidy reginfo dumping ahead of ZA state Richard Henderson
2024-05-15 12:55 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 11/17] aarch64: Add support for ZA storage Richard Henderson
2024-05-11 11:53 ` [PATCH 12/17] aarch64: Trivial SME test Richard Henderson
2024-05-21 12:27 ` Peter Maydell
2024-05-11 11:53 ` [PATCH 13/17] Use bool for reginfo_is_eq Richard Henderson
2024-05-15 12:56 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 14/17] aarch64: Use bool for sve_{z,p}reg_is_eq Richard Henderson
2024-05-15 12:56 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 15/17] risu: Allow use of ELF test files Richard Henderson
2024-05-15 13:03 ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 16/17] configure: Enable loongarch64 Richard Henderson
2024-05-15 13:06 ` Philippe Mathieu-Daudé
2024-05-15 13:08 ` Philippe Mathieu-Daudé
2024-05-11 11:54 ` [PATCH 17/17] Build elf test cases instead of raw binaries Richard Henderson
2024-05-15 13:08 ` Philippe Mathieu-Daudé
2024-05-21 12:46 ` [PATCH 00/17] RISU misc updates Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240511115400.7587-5-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).