[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 15/53] target/m68k: convert to use format_state instead of
From: |
Laurent Vivier |
Subject: |
Re: [PATCH v2 15/53] target/m68k: convert to use format_state instead of dump_state |
Date: |
Tue, 14 Sep 2021 21:58:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
Le 14/09/2021 à 16:20, Daniel P. Berrangé a écrit :
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> target/m68k/cpu.c | 2 +-
> target/m68k/cpu.h | 2 +-
> target/m68k/translate.c | 92 ++++++++++++++++++++++-------------------
> 3 files changed, 51 insertions(+), 45 deletions(-)
>
> diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
> index 72de6e9726..4ccf572a68 100644
> --- a/target/m68k/cpu.c
> +++ b/target/m68k/cpu.c
> @@ -536,7 +536,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void
> *data)
>
> cc->class_by_name = m68k_cpu_class_by_name;
> cc->has_work = m68k_cpu_has_work;
> - cc->dump_state = m68k_cpu_dump_state;
> + cc->format_state = m68k_cpu_format_state;
> cc->set_pc = m68k_cpu_set_pc;
> cc->gdb_read_register = m68k_cpu_gdb_read_register;
> cc->gdb_write_register = m68k_cpu_gdb_write_register;
> diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
> index 997d588911..b0641f6d0d 100644
> --- a/target/m68k/cpu.h
> +++ b/target/m68k/cpu.h
> @@ -168,7 +168,7 @@ struct M68kCPU {
>
> void m68k_cpu_do_interrupt(CPUState *cpu);
> bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
> -void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> +void m68k_cpu_format_state(CPUState *cpu, GString *buf, int flags);
> hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
> int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> diff --git a/target/m68k/translate.c b/target/m68k/translate.c
> index c34d9aed61..951bbed6bf 100644
> --- a/target/m68k/translate.c
> +++ b/target/m68k/translate.c
> @@ -6316,75 +6316,81 @@ static double floatx80_to_double(CPUM68KState *env,
> uint16_t high, uint64_t low)
> return u.d;
> }
>
> -void m68k_cpu_dump_state(CPUState *cs, FILE *f, int flags)
> +void m68k_cpu_format_state(CPUState *cs, GString *buf, int flags)
> {
> M68kCPU *cpu = M68K_CPU(cs);
> CPUM68KState *env = &cpu->env;
> int i;
> uint16_t sr;
> for (i = 0; i < 8; i++) {
> - qemu_fprintf(f, "D%d = %08x A%d = %08x "
> - "F%d = %04x %016"PRIx64" (%12g)\n",
> - i, env->dregs[i], i, env->aregs[i],
> - i, env->fregs[i].l.upper, env->fregs[i].l.lower,
> - floatx80_to_double(env, env->fregs[i].l.upper,
> - env->fregs[i].l.lower));
> - }
> - qemu_fprintf(f, "PC = %08x ", env->pc);
> + g_string_append_printf(buf, "D%d = %08x A%d = %08x "
> + "F%d = %04x %016"PRIx64" (%12g)\n",
> + i, env->dregs[i], i, env->aregs[i],
> + i, env->fregs[i].l.upper,
> env->fregs[i].l.lower,
> + floatx80_to_double(env, env->fregs[i].l.upper,
> + env->fregs[i].l.lower));
> + }
> + g_string_append_printf(buf, "PC = %08x ", env->pc);
> sr = env->sr | cpu_m68k_get_ccr(env);
> - qemu_fprintf(f, "SR = %04x T:%x I:%x %c%c %c%c%c%c%c\n",
> - sr, (sr & SR_T) >> SR_T_SHIFT, (sr & SR_I) >> SR_I_SHIFT,
> - (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I',
> - (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-',
> - (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-',
> - (sr & CCF_C) ? 'C' : '-');
> - qemu_fprintf(f, "FPSR = %08x %c%c%c%c ", env->fpsr,
> - (env->fpsr & FPSR_CC_A) ? 'A' : '-',
> - (env->fpsr & FPSR_CC_I) ? 'I' : '-',
> - (env->fpsr & FPSR_CC_Z) ? 'Z' : '-',
> - (env->fpsr & FPSR_CC_N) ? 'N' : '-');
> - qemu_fprintf(f, "\n "
> - "FPCR = %04x ", env->fpcr);
> + g_string_append_printf(buf, "SR = %04x T:%x I:%x %c%c %c%c%c%c%c\n",
> + sr, (sr & SR_T) >> SR_T_SHIFT,
> + (sr & SR_I) >> SR_I_SHIFT,
> + (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I',
> + (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' :
> '-',
> + (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' :
> '-',
> + (sr & CCF_C) ? 'C' : '-');
> + g_string_append_printf(buf, "FPSR = %08x %c%c%c%c ", env->fpsr,
> + (env->fpsr & FPSR_CC_A) ? 'A' : '-',
> + (env->fpsr & FPSR_CC_I) ? 'I' : '-',
> + (env->fpsr & FPSR_CC_Z) ? 'Z' : '-',
> + (env->fpsr & FPSR_CC_N) ? 'N' : '-');
> + g_string_append_printf(buf, "\n "
> + "FPCR = %04x ", env->fpcr);
> switch (env->fpcr & FPCR_PREC_MASK) {
> case FPCR_PREC_X:
> - qemu_fprintf(f, "X ");
> + g_string_append_printf(buf, "X ");
> break;
> case FPCR_PREC_S:
> - qemu_fprintf(f, "S ");
> + g_string_append_printf(buf, "S ");
> break;
> case FPCR_PREC_D:
> - qemu_fprintf(f, "D ");
> + g_string_append_printf(buf, "D ");
> break;
> }
> switch (env->fpcr & FPCR_RND_MASK) {
> case FPCR_RND_N:
> - qemu_fprintf(f, "RN ");
> + g_string_append_printf(buf, "RN ");
> break;
> case FPCR_RND_Z:
> - qemu_fprintf(f, "RZ ");
> + g_string_append_printf(buf, "RZ ");
> break;
> case FPCR_RND_M:
> - qemu_fprintf(f, "RM ");
> + g_string_append_printf(buf, "RM ");
> break;
> case FPCR_RND_P:
> - qemu_fprintf(f, "RP ");
> + g_string_append_printf(buf, "RP ");
> break;
> }
> - qemu_fprintf(f, "\n");
> + g_string_append_printf(buf, "\n");
> #ifdef CONFIG_SOFTMMU
> - qemu_fprintf(f, "%sA7(MSP) = %08x %sA7(USP) = %08x %sA7(ISP) = %08x\n",
> - env->current_sp == M68K_SSP ? "->" : " ",
> env->sp[M68K_SSP],
> - env->current_sp == M68K_USP ? "->" : " ",
> env->sp[M68K_USP],
> - env->current_sp == M68K_ISP ? "->" : " ",
> env->sp[M68K_ISP]);
> - qemu_fprintf(f, "VBR = 0x%08x\n", env->vbr);
> - qemu_fprintf(f, "SFC = %x DFC %x\n", env->sfc, env->dfc);
> - qemu_fprintf(f, "SSW %08x TCR %08x URP %08x SRP %08x\n",
> - env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp);
> - qemu_fprintf(f, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n",
> - env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTTR1],
> - env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITTR1]);
> - qemu_fprintf(f, "MMUSR %08x, fault at %08x\n",
> - env->mmu.mmusr, env->mmu.ar);
> + g_string_append_printf(buf, "%sA7(MSP) = %08x %sA7(USP) = %08x "
> + "%sA7(ISP) = %08x\n",
> + env->current_sp == M68K_SSP ?
> + "->" : " ", env->sp[M68K_SSP],
> + env->current_sp == M68K_USP ?
> + "->" : " ", env->sp[M68K_USP],
> + env->current_sp == M68K_ISP ?
> + "->" : " ", env->sp[M68K_ISP]);
> + g_string_append_printf(buf, "VBR = 0x%08x\n", env->vbr);
> + g_string_append_printf(buf, "SFC = %x DFC %x\n", env->sfc, env->dfc);
> + g_string_append_printf(buf, "SSW %08x TCR %08x URP %08x SRP %08x\n",
> + env->mmu.ssw, env->mmu.tcr,
> + env->mmu.urp, env->mmu.srp);
> + g_string_append_printf(buf, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n",
> + env->mmu.ttr[M68K_DTTR0],
> env->mmu.ttr[M68K_DTTR1],
> + env->mmu.ttr[M68K_ITTR0],
> env->mmu.ttr[M68K_ITTR1]);
> + g_string_append_printf(buf, "MMUSR %08x, fault at %08x\n",
> + env->mmu.mmusr, env->mmu.ar);
> #endif
> }
>
>
Acked-by: Laurent Vivier <laurent@vivier.eu>
- Re: [PATCH v2 10/53] target/cris: convert to use format_state instead of dump_state, (continued)
- [PATCH v2 11/53] target/hexagon: delete unused hexagon_debug() method, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 12/53] target/hexagon: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 13/53] target/hppa: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 14/53] target/i386: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 15/53] target/m68k: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 16/53] target/microblaze: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 17/53] target/mips: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 18/53] target/nios2: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 19/53] target/openrisc: convert to use format_state instead of dump_state, Daniel P . Berrangé, 2021/09/14