Hoist the "master vs apprentice" label to apprentice(), since
we will want different labels for dumping. Remove all of the
"mismatch" text from reginfo_dump_mismatch -- just print "vs".
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
risu.h | 4 ++--
risu.c | 1 +
risu_reginfo_aarch64.c | 12 +++++-------
risu_reginfo_arm.c | 18 +++++++++---------
risu_reginfo_i386.c | 6 +-----
risu_reginfo_loongarch64.c | 11 ++++-------
risu_reginfo_m68k.c | 23 +++++++----------------
risu_reginfo_ppc64.c | 25 ++++++++++++-------------
risu_reginfo_s390x.c | 18 +++++++-----------
9 files changed, 48 insertions(+), 70 deletions(-)
diff --git a/risu.h b/risu.h
index 2c43384..1b87af2 100644
--- a/risu.h
+++ b/risu.h
@@ -123,8 +123,8 @@ 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);
-/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
+/* reginfo_dump_mismatch: print mismatch details to a stream */
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
/* return size of reginfo */
int reginfo_size(struct reginfo *ri);
diff --git a/risu.c b/risu.c
index 6b6295c..9c31b8c 100644
--- a/risu.c
+++ b/risu.c
@@ -448,6 +448,7 @@ static int apprentice(void)
reginfo_dump(&ri[MASTER], stderr);
fprintf(stderr, "apprentice reginfo:\n");
reginfo_dump(&ri[APPRENTICE], stderr);
+ fprintf(stderr, "mismatch detail (master : apprentice):\n");
reginfo_dump_mismatch(&ri[MASTER], &ri[APPRENTICE], stderr);
return EXIT_FAILURE;
diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c
index 1244454..da221d5 100644
--- a/risu_reginfo_aarch64.c
+++ b/risu_reginfo_aarch64.c
@@ -275,15 +275,15 @@ int reginfo_dump(struct reginfo *ri, FILE * f)
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)
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
{
int i;
- fprintf(f, "mismatch detail (master : apprentice):\n");
+
if (m->faulting_insn != a->faulting_insn) {
- fprintf(f, " faulting insn mismatch %08x vs %08x\n",
+ fprintf(f, " faulting insn: %08x vs %08x\n",
m->faulting_insn, a->faulting_insn);
}
+
for (i = 0; i < 31; i++) {
if (m->regs[i] != a->regs[i]) {
fprintf(f, " X%-2d : %016" PRIx64 " vs %016" PRIx64 "\n",
@@ -342,7 +342,7 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
sve_dump_preg_diff(f, vq, pm, pa);
}
}
- return !ferror(f);
+ return;
}
for (i = 0; i < 32; i++) {
@@ -356,6 +356,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
i, mv[1], mv[0], av[1], av[0]);
}
}
-
- return !ferror(f);
}
diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c
index 85a39ac..221bd8a 100644
--- a/risu_reginfo_arm.c
+++ b/risu_reginfo_arm.c
@@ -183,32 +183,33 @@ int reginfo_dump(struct reginfo *ri, FILE *f)
return !ferror(f);
}
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
+void 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",
+ fprintf(f, " faulting insn size: %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",
+ fprintf(f, " faulting insn: %04x vs %04x\n",
m->faulting_insn, a->faulting_insn);
} else {
- fprintf(f, " faulting insn mismatch %08x vs %08x\n",
+ fprintf(f, " faulting insn: %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]);
+ 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,
@@ -216,9 +217,8 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
(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_i386.c b/risu_reginfo_i386.c
index 834b2ed..18d15ca 100644
--- a/risu_reginfo_i386.c
+++ b/risu_reginfo_i386.c
@@ -349,14 +349,12 @@ int reginfo_dump(struct reginfo *ri, FILE *f)
return !ferror(f);
}
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
{
int i, j, n, w;
uint64_t features;
char r;
- fprintf(f, "Mismatch (master v apprentice):\n");
-
for (i = 0; i < NGREG; i++) {
if (m->gregs[i] != a->gregs[i]) {
assert(regname[i]);
@@ -399,6 +397,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
i, m->kregs[i], a->kregs[i]);
}
}
-
- return !ferror(f);
}
diff --git a/risu_reginfo_loongarch64.c b/risu_reginfo_loongarch64.c
index 09a1eb6..630d6b2 100644
--- a/risu_reginfo_loongarch64.c
+++ b/risu_reginfo_loongarch64.c
@@ -195,18 +195,17 @@ int reginfo_dump(struct reginfo *ri, FILE * f)
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)
+/* reginfo_dump_mismatch: print mismatch details to a stream */
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
{
int i;
- fprintf(f, "mismatch detail (master : apprentice):\n");
if (m->vl != a->vl) {
- fprintf(f, " vl mismatch %08lx vs %08lx\n", m->vl, a->vl);
+ fprintf(f, " vl : %08lx vs %08lx\n", m->vl, a->vl);
}
if (m->faulting_insn != a->faulting_insn) {
- fprintf(f, " faulting insn mismatch %08x vs %08x\n",
+ fprintf(f, " insn : %08x vs %08x\n",
m->faulting_insn, a->faulting_insn);
}
/* r2:tp, r3:sp */
@@ -263,6 +262,4 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
}
}
}
-
- return !ferror(f);
}
diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c
index e29da84..18ae1d8 100644
--- a/risu_reginfo_m68k.c
+++ b/risu_reginfo_m68k.c
@@ -118,13 +118,12 @@ int reginfo_dump(struct reginfo *ri, FILE *f)
return !ferror(f);
}
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
+void 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",
+ fprintf(f, " PS: %08x vs %08x\n",
m->gregs[R_PS], a->gregs[R_PS]);
}
@@ -133,22 +132,18 @@ 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, " %c%d: %08x vs %08x\n",
+ i < 8 ? 'D' : 'A', i % 8, m->gregs[i], a->gregs[i]);
}
}
if (m->fpregs.f_pcr != a->fpregs.f_pcr) {
- fprintf(f, "Mismatch: Register FPCR\n");
- fprintf(f, "m: [%04x] != a: [%04x]\n",
+ fprintf(f, " FPCR: %04x vs %04x\n",
m->fpregs.f_pcr, a->fpregs.f_pcr);
}
if (m->fpregs.f_psr != a->fpregs.f_psr) {
- fprintf(f, "Mismatch: Register FPSR\n");
- fprintf(f, "m: [%08x] != a: [%08x]\n",
+ fprintf(f, " FPSR: %04x vs %04x\n",
m->fpregs.f_psr, a->fpregs.f_psr);
}
@@ -156,14 +151,10 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f)
if (m->fpregs.f_fpregs[i][0] != a->fpregs.f_fpregs[i][0] ||
m->fpregs.f_fpregs[i][1] != a->fpregs.f_fpregs[i][1] ||
m->fpregs.f_fpregs[i][2] != a->fpregs.f_fpregs[i][2]) {
- fprintf(f, "Mismatch: Register FP%d\n", i);
- fprintf(f, "m: [%08x %08x %08x] != a: [%08x %08x %08x]\n",
+ fprintf(f, " FP%d: %08x%08x%08x vs %08x%08x%08x\n", i,
m->fpregs.f_fpregs[i][0], m->fpregs.f_fpregs[i][1],
m->fpregs.f_fpregs[i][2], a->fpregs.f_fpregs[i][0],
a->fpregs.f_fpregs[i][1], a->fpregs.f_fpregs[i][2]);
}
}
-
-
- return !ferror(f);
}
diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c
index bbdd63c..486bbf9 100644
--- a/risu_reginfo_ppc64.c
+++ b/risu_reginfo_ppc64.c
@@ -147,35 +147,35 @@ int reginfo_dump(struct reginfo *ri, FILE * f)
return !ferror(f);
}
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
{
int i;
+
for (i = 0; i < 32; i++) {
if (i == 1 || i == 13) {
continue;
}
-
if (m->gregs[i] != a->gregs[i]) {
- fprintf(f, "Mismatch: Register r%d\n", i);
- fprintf(f, "master: [%lx] - apprentice: [%lx]\n",
+ fprintf(f, "%*s%d: %016lx vs %016lx\n",
+ 6 - (1 < 10 ? 1 : 2), "r", i,
m->gregs[i], a->gregs[i]);
}
}
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, "%6s: %016lx vs %016lx\n",
+ "xer", 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, "%6s: %016lx vs %016lx\n",
+ "ccr", m->gregs[CCR], a->gregs[CCR]);
}
for (i = 0; i < 32; i++) {
if (m->fpregs[i] != a->fpregs[i]) {
- fprintf(f, "Mismatch: Register f%d\n", i);
- fprintf(f, "m: [%016lx] != a: [%016lx]\n",
+ fprintf(f, "%*s%d: %016lx vs %016lx\n",
+ 6 - (i < 10 ? 1 : 2), "f", i,
m->fpregs[i], a->fpregs[i]);
}
}
@@ -186,13 +186,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
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",
+ fprintf(f, "%*s%d: %08x%08x%08x%08x vs %08x%08x%08x%08x\n",
+ 6 - (i < 10 ? 1 : 2), "vr", i,
m->vrregs.vrregs[i][0], m->vrregs.vrregs[i][1],
m->vrregs.vrregs[i][2], m->vrregs.vrregs[i][3],
a->vrregs.vrregs[i][0], a->vrregs.vrregs[i][1],
a->vrregs.vrregs[i][2], a->vrregs.vrregs[i][3]);
}
}
- return !ferror(f);
}
diff --git a/risu_reginfo_s390x.c b/risu_reginfo_s390x.c
index 3fd91b9..9c8fcfd 100644
--- a/risu_reginfo_s390x.c
+++ b/risu_reginfo_s390x.c
@@ -107,34 +107,30 @@ int reginfo_dump(struct reginfo *ri, FILE * f)
return !ferror(f);
}
-int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
+void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f)
{
int i;
if (m->pc_offset != a->pc_offset) {
- fprintf(f, "Mismatch: PC offset master: [%016lx] - PC offset apprentice: [%016lx]\n",
+ fprintf(f, " PC : %016lx vs %016lx\n",
m->pc_offset, a->pc_offset);
}
for (i = 0; i < 16; i++) {
if (m->gprs[i] != a->gprs[i]) {
- fprintf(f, "Mismatch: r%d master: [%016lx] - r%d apprentice: [%016lx]\n",
- i, m->gprs[i], i, a->gprs[i]);
+ fprintf(f, " r%-2d : %016lx vs %016lx\n",
+ i, m->gprs[i], a->gprs[i]);
}
}
for (i = 0; i < 16; i++) {
if (*(uint64_t *)&m->fprs[i] != *(uint64_t *)&a->fprs[i]) {
- fprintf(f, "Mismatch: f%d master: [%016lx] - f%d apprentice: [%016lx]\n",
- i, *(uint64_t *)&m->fprs[i],
- i, *(uint64_t *)&a->fprs[i]);
+ fprintf(f, " f%-2d : %016lx vs %016lx\n",
+ i, *(uint64_t *)&m->fprs[i], *(uint64_t *)&a->fprs[i]);
}
}
if (m->fpc != a->fpc) {
- fprintf(f, "Mismatch: FPC master: [%08x] - FPC apprentice: [%08x]\n",
- m->fpc, a->fpc);
+ fprintf(f, " FPC : %08x vs %08x\n", m->fpc, a->fpc);
}
-
- return !ferror(f);
}
--
2.34.1
On Sat, 11 May 2024 at 12:54, Richard Henderson <richard.henderson@linaro.org> wrote: > > Hoist the "master vs apprentice" label to apprentice(), since > we will want different labels for dumping. Remove all of the > "mismatch" text from reginfo_dump_mismatch -- just print "vs". > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > risu.h | 4 ++-- > risu.c | 1 + > risu_reginfo_aarch64.c | 12 +++++------- > risu_reginfo_arm.c | 18 +++++++++--------- > risu_reginfo_i386.c | 6 +----- > risu_reginfo_loongarch64.c | 11 ++++------- > risu_reginfo_m68k.c | 23 +++++++---------------- > risu_reginfo_ppc64.c | 25 ++++++++++++------------- > risu_reginfo_s390x.c | 18 +++++++----------- > 9 files changed, 48 insertions(+), 70 deletions(-) > > diff --git a/risu.h b/risu.h > index 2c43384..1b87af2 100644 > --- a/risu.h > +++ b/risu.h > @@ -123,8 +123,8 @@ 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); > > -/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ > -int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); > +/* reginfo_dump_mismatch: print mismatch details to a stream */ > +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); This commit is also changing the return type of the function, which the commit message doesn't say anything about. Since this is only risu, not QEMU proper, I don't think we strictly need to disentangle this into two commits, but we should describe both changes in the commit message. (Since the only callsite doesn't check the return value and in any case if it cared it could call ferror() itself, switching to 'void' is fine.) thanks -- PMM
© 2016 - 2024 Red Hat, Inc.