qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 18/53] target/nios2: convert to use format_state instead o


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 18/53] target/nios2: convert to use format_state instead of dump_state
Date: Wed, 15 Sep 2021 09:08:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 9/14/21 4:20 PM, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  target/nios2/cpu.c       |  2 +-
>  target/nios2/cpu.h       |  2 +-
>  target/nios2/translate.c | 20 ++++++++++----------
>  3 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c
> index 5e37defef8..cbf15fb1c9 100644
> --- a/target/nios2/cpu.c
> +++ b/target/nios2/cpu.c
> @@ -241,7 +241,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void 
> *data)
>  
>      cc->class_by_name = nios2_cpu_class_by_name;
>      cc->has_work = nios2_cpu_has_work;
> -    cc->dump_state = nios2_cpu_dump_state;
> +    cc->format_state = nios2_cpu_format_state;
>      cc->set_pc = nios2_cpu_set_pc;
>      cc->disas_set_info = nios2_cpu_disas_set_info;
>  #ifndef CONFIG_USER_ONLY
> diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
> index 2ab82fdc71..3b16cd1f3c 100644
> --- a/target/nios2/cpu.h
> +++ b/target/nios2/cpu.h
> @@ -195,7 +195,7 @@ void nios2_tcg_init(void);
>  void nios2_cpu_do_interrupt(CPUState *cs);
>  int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);
>  void dump_mmu(CPUNios2State *env);
> -void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
> +void nios2_cpu_format_state(CPUState *cpu, GString *buf, int flags);
>  hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
>  void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
>                                     MMUAccessType access_type,
> diff --git a/target/nios2/translate.c b/target/nios2/translate.c
> index 08d7ac5398..a5f0f56e1a 100644
> --- a/target/nios2/translate.c
> +++ b/target/nios2/translate.c
> @@ -855,7 +855,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock 
> *tb, int max_insns)
>      translator_loop(&nios2_tr_ops, &dc.base, cs, tb, max_insns);
>  }
>  
> -void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags)
> +void nios2_cpu_format_state(CPUState *cs, GString *buf, int flags)
>  {
>      Nios2CPU *cpu = NIOS2_CPU(cs);
>      CPUNios2State *env = &cpu->env;
> @@ -865,22 +865,22 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int 
> flags)
>          return;
>      }
>  
> -    qemu_fprintf(f, "IN: PC=%x %s\n",
> -                 env->regs[R_PC], lookup_symbol(env->regs[R_PC]));
> +    g_string_append_printf(buf, "IN: PC=%x %s\n",
> +                           env->regs[R_PC], lookup_symbol(env->regs[R_PC]));

Note 1:

Interesting to call lookup_symbol() in dump_state(). Other targets
could do that too, but even better doing this in cpu_format_state().

Note 2:

format_state() doesn't belong to translate.c IMO and should be moved
to cpu.c.

Anyhow, unrelated to your patch, so:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]