summaryrefslogtreecommitdiff
path: root/target/riscv
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-04-17 21:18:02 +0200
committerMarkus Armbruster <armbru@redhat.com>2019-04-18 22:18:59 +0200
commit90c84c56006747537e9e4240271523c4c3b7a481 (patch)
tree7cb7cc06e9dfae5c89d0581e6b9458349ed82260 /target/riscv
parent19aaa4c3fd15eeb82f10c35ffc7d53e103d10787 (diff)
downloadqemu-90c84c56006747537e9e4240271523c4c3b7a481.zip
qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
CPUClass method dump_statistics() takes an fprintf()-like callback and a FILE * to pass to it. Most callers pass fprintf() and stderr. log_cpu_state() passes fprintf() and qemu_log_file. hmp_info_registers() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The callback gets passed around a lot, which is tiresome. The type-punning around monitor_fprintf() is ugly. Drop the callback, and call qemu_fprintf() instead. Also gets rid of the type-punning, since qemu_fprintf() takes NULL instead of the current monitor cast to FILE *. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20190417191805.28198-15-armbru@redhat.com>
Diffstat (limited to 'target/riscv')
-rw-r--r--target/riscv/cpu.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 104e676ab0..1bcf4eaeb8 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -194,40 +194,39 @@ static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
return oc;
}
-static void riscv_cpu_dump_state(CPUState *cs, FILE *f,
- fprintf_function cpu_fprintf, int flags)
+static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
int i;
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc);
#ifndef CONFIG_USER_ONLY
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", env->mstatus);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ",
- (target_ulong)atomic_read(&env->mip));
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc);
- cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", env->mstatus);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ",
+ (target_ulong)atomic_read(&env->mip));
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause);
#endif
for (i = 0; i < 32; i++) {
- cpu_fprintf(f, " %s " TARGET_FMT_lx,
- riscv_int_regnames[i], env->gpr[i]);
+ qemu_fprintf(f, " %s " TARGET_FMT_lx,
+ riscv_int_regnames[i], env->gpr[i]);
if ((i & 3) == 3) {
- cpu_fprintf(f, "\n");
+ qemu_fprintf(f, "\n");
}
}
if (flags & CPU_DUMP_FPU) {
for (i = 0; i < 32; i++) {
- cpu_fprintf(f, " %s %016" PRIx64,
- riscv_fpr_regnames[i], env->fpr[i]);
+ qemu_fprintf(f, " %s %016" PRIx64,
+ riscv_fpr_regnames[i], env->fpr[i]);
if ((i & 3) == 3) {
- cpu_fprintf(f, "\n");
+ qemu_fprintf(f, "\n");
}
}
}