summaryrefslogtreecommitdiffstats
path: root/target/xtensa
diff options
context:
space:
mode:
authorMarkus Armbruster2019-04-17 21:18:02 +0200
committerMarkus Armbruster2019-04-18 22:18:59 +0200
commit90c84c56006747537e9e4240271523c4c3b7a481 (patch)
tree7cb7cc06e9dfae5c89d0581e6b9458349ed82260 /target/xtensa
parentqemu-print: New qemu_fprintf(), qemu_vfprintf() (diff)
downloadqemu-90c84c56006747537e9e4240271523c4c3b7a481.tar.gz
qemu-90c84c56006747537e9e4240271523c4c3b7a481.tar.xz
qemu-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/xtensa')
-rw-r--r--target/xtensa/cpu.h3
-rw-r--r--target/xtensa/translate.c40
2 files changed, 22 insertions, 21 deletions
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 86f6d6d72c..5d23e1345b 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -560,8 +560,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
unsigned size, MMUAccessType access_type,
int mmu_idx, MemTxAttrs attrs,
MemTxResult response, uintptr_t retaddr);
-void xtensa_cpu_dump_state(CPUState *cpu, FILE *f,
- fprintf_function cpu_fprintf, int flags);
+void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
void xtensa_count_regs(const XtensaConfig *config,
unsigned *n_regs, unsigned *n_core_regs);
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 65561d2c49..43a5e94daa 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -35,6 +35,7 @@
#include "disas/disas.h"
#include "tcg-op.h"
#include "qemu/log.h"
+#include "qemu/qemu-print.h"
#include "sysemu/sysemu.h"
#include "exec/cpu_ldst.h"
#include "exec/semihost.h"
@@ -1640,60 +1641,61 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb);
}
-void xtensa_cpu_dump_state(CPUState *cs, FILE *f,
- fprintf_function cpu_fprintf, int flags)
+void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{
XtensaCPU *cpu = XTENSA_CPU(cs);
CPUXtensaState *env = &cpu->env;
int i, j;
- cpu_fprintf(f, "PC=%08x\n\n", env->pc);
+ qemu_fprintf(f, "PC=%08x\n\n", env->pc);
for (i = j = 0; i < 256; ++i) {
if (xtensa_option_bits_enabled(env->config, sregnames[i].opt_bits)) {
- cpu_fprintf(f, "%12s=%08x%c", sregnames[i].name, env->sregs[i],
- (j++ % 4) == 3 ? '\n' : ' ');
+ qemu_fprintf(f, "%12s=%08x%c",
+ sregnames[i].name, env->sregs[i],
+ (j++ % 4) == 3 ? '\n' : ' ');
}
}
- cpu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
+ qemu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
for (i = j = 0; i < 256; ++i) {
if (xtensa_option_bits_enabled(env->config, uregnames[i].opt_bits)) {
- cpu_fprintf(f, "%s=%08x%c", uregnames[i].name, env->uregs[i],
- (j++ % 4) == 3 ? '\n' : ' ');
+ qemu_fprintf(f, "%s=%08x%c",
+ uregnames[i].name, env->uregs[i],
+ (j++ % 4) == 3 ? '\n' : ' ');
}
}
- cpu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
+ qemu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
for (i = 0; i < 16; ++i) {
- cpu_fprintf(f, " A%02d=%08x%c", i, env->regs[i],
- (i % 4) == 3 ? '\n' : ' ');
+ qemu_fprintf(f, " A%02d=%08x%c",
+ i, env->regs[i], (i % 4) == 3 ? '\n' : ' ');
}
xtensa_sync_phys_from_window(env);
- cpu_fprintf(f, "\n");
+ qemu_fprintf(f, "\n");
for (i = 0; i < env->config->nareg; ++i) {
- cpu_fprintf(f, "AR%02d=%08x ", i, env->phys_regs[i]);
+ qemu_fprintf(f, "AR%02d=%08x ", i, env->phys_regs[i]);
if (i % 4 == 3) {
bool ws = (env->sregs[WINDOW_START] & (1 << (i / 4))) != 0;
bool cw = env->sregs[WINDOW_BASE] == i / 4;
- cpu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=' : ' ');
+ qemu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=' : ' ');
}
}
if ((flags & CPU_DUMP_FPU) &&
xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) {
- cpu_fprintf(f, "\n");
+ qemu_fprintf(f, "\n");
for (i = 0; i < 16; ++i) {
- cpu_fprintf(f, "F%02d=%08x (%+10.8e)%c", i,
- float32_val(env->fregs[i].f32[FP_F32_LOW]),
- *(float *)(env->fregs[i].f32 + FP_F32_LOW),
- (i % 2) == 1 ? '\n' : ' ');
+ qemu_fprintf(f, "F%02d=%08x (%+10.8e)%c", i,
+ float32_val(env->fregs[i].f32[FP_F32_LOW]),
+ *(float *)(env->fregs[i].f32 + FP_F32_LOW),
+ (i % 2) == 1 ? '\n' : ' ');
}
}
}