Clean up and simplify around fprintf_function
Subsystems (2)
cover Clean up and simplify around fprintf_function
We pass around fprintf_function callbacks together a FILE * argument. Three cases:
* We pass fprintf() and stdout, stderr or qemu_log_file. Okay.
* We pass monitor_fprintf() together with the current monitor cast to FILE *. The type-punning is ugly.
* We pass monitor_printf() cast to fprintf_function together with the current monitor cast to FILE *. Even uglier.
All but two instances can be replaced by using qemu_printf() directly instead of printing through a callback.
One more can be replace by using new qemu_fprintf() directly.
The last one can use qemu_fprintf() to at least avoid the type-punning.
Based-on: <[email protected]>
Markus Armbruster (17):
include: Include fprintf-fn.h only where needed
trace: Simplify how st_print_trace_file_status() prints
tcg: Simplify how dump_opcount_info() prints
tcg: Simplify how dump_exec_info() prints
tcg: Simplify how dump_drift_info() prints
qsp: Simplify how qsp_report() prints
block/qapi: Clean up how we print to monitor or stdout
memory: Clean up how mtree_info() prints
target: Simplify how the TARGET_cpu_list() print
target: Clean up how the dump_mmu() print
target/i386: Simplify how x86_cpu_dump_local_apic_state() prints qom/cpu: Simplify how CPUClass::dump_statistics() prints
qemu-print: New qemu_fprintf(), qemu_vfprintf() qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
monitor: Clean up how monitor_disas() funnels output to monitor
disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h
include: Move fprintf_function to disas/
accel/kvm/kvm-all.c | 4 +-
accel/tcg/translate-all.c | 49 ++--
block/qapi.c | 120 +++++-----
bsd-user/main.c | 4 +-
cpus.c | 21 +-
disas.c | 5 +-
disas/alpha.c | 2 +-
disas/arm-a64.cc | 2 +-
disas/arm.c | 2 +-
disas/cris.c | 2 +-
disas/hppa.c | 2 +-
disas/i386.c | 2 +-
disas/lm32.c | 2 +-
disas/m68k.c | 2 +-
disas/microblaze.c | 2 +-
disas/mips.c | 2 +-
disas/moxie.c | 2 +-
disas/nanomips.cpp | 2 +-
disas/nios2.c | 2 +-
disas/ppc.c | 2 +-
disas/riscv.c | 2 +-
disas/s390.c | 2 +-
disas/sh4.c | 2 +-
disas/sparc.c | 2 +-
disas/tci.c | 2 +-
disas/xtensa.c | 2 +-
exec.c | 42 ++--
hmp.c | 12 +-
include/block/qapi.h | 9 +-
include/disas/{bfd.h => dis-asm.h} | 5 +-
include/exec/cpu-all.h | 4 +-
include/exec/cpu-common.h | 13 --
include/exec/log.h | 2 +-
include/exec/memory-internal.h | 3 +-
include/exec/memory.h | 3 +-
include/monitor/monitor.h | 1 -
include/qemu-common.h | 2 -
include/qemu/cutils.h | 2 -
include/qemu/fprintf-fn.h | 14 --
include/qemu/qemu-print.h | 4 +
include/qemu/qsp.h | 6 +-
include/qom/cpu.h | 24 +-
include/sysemu/cpus.h | 4 +-
linux-user/alpha/cpu_loop.c | 2 +-
linux-user/cpu_loop-common.h | 2 +-
linux-user/cris/cpu_loop.c | 2 +-
linux-user/main.c | 2 +-
linux-user/microblaze/cpu_loop.c | 4 +-
linux-user/s390x/cpu_loop.c | 4 +-
linux-user/sh4/cpu_loop.c | 2 +-
linux-user/sparc/cpu_loop.c | 2 +-
memory.c | 156 ++++++-------
monitor.c | 30 +--
qemu-img.c | 6 +-
qemu-io-cmds.c | 2 +-
qom/cpu.c | 11 +-
target/alpha/cpu.c | 15 +-
target/alpha/cpu.h | 5 +-
target/alpha/helper.c | 24 +-
target/arm/arm-semi.c | 2 +-
target/arm/cpu.c | 1 -
target/arm/cpu.h | 5 +-
target/arm/helper.c | 15 +-
target/arm/translate-a64.c | 82 +++----
target/arm/translate.c | 58 ++---
target/arm/translate.h | 7 +-
target/cris/cpu.c | 14 +-
target/cris/cpu.h | 5 +-
target/cris/helper.c | 2 +-
target/cris/translate.c | 36 +--
target/hppa/cpu.c | 14 +-
target/hppa/cpu.h | 4 +-
target/hppa/helper.c | 24 +-
target/i386/cpu.c | 29 +--
target/i386/cpu.h | 8 +-
target/i386/hax-all.c | 4 +-
target/i386/helper.c | 356 ++++++++++++++---------------
target/i386/monitor.c | 3 +-
target/lm32/cpu.c | 14 +-
target/lm32/cpu.h | 5 +-
target/lm32/translate.c | 36 +--
target/m68k/cpu.h | 8 +-
target/m68k/helper.c | 129 +++++------
target/m68k/monitor.c | 2 +-
target/m68k/translate.c | 86 +++----
target/microblaze/cpu.h | 3 +-
target/microblaze/helper.c | 2 +-
target/microblaze/translate.c | 39 ++--
target/mips/cpu.h | 2 +-
target/mips/internal.h | 3 +-
target/mips/translate.c | 77 ++++---
target/mips/translate_init.inc.c | 5 +-
target/moxie/cpu.h | 3 +-
target/moxie/helper.c | 2 +-
target/moxie/translate.c | 22 +-
target/nios2/cpu.h | 5 +-
target/nios2/helper.c | 2 +-
target/nios2/mmu.c | 7 +-
target/nios2/monitor.c | 2 +-
target/nios2/translate.c | 24 +-
target/openrisc/cpu.c | 15 +-
target/openrisc/cpu.h | 5 +-
target/openrisc/disas.c | 2 +-
target/openrisc/translate.c | 11 +-
target/ppc/cpu.h | 10 +-
target/ppc/mmu-hash64.c | 7 +-
target/ppc/mmu-hash64.h | 2 +-
target/ppc/mmu_helper.c | 70 +++---
target/ppc/monitor.c | 2 +-
target/ppc/translate.c | 170 +++++++-------
target/ppc/translate_init.inc.c | 28 +--
target/riscv/cpu.c | 54 ++---
target/riscv/cpu.h | 2 +-
target/s390x/cpu.h | 2 +-
target/s390x/cpu_models.c | 21 +-
target/s390x/helper.c | 42 ++--
target/s390x/internal.h | 3 +-
target/sh4/cpu.c | 17 +-
target/sh4/cpu.h | 5 +-
target/sh4/translate.c | 27 +--
target/sparc/cpu.c | 133 ++++++-----
target/sparc/cpu.h | 7 +-
target/sparc/ldst_helper.c | 18 +-
target/sparc/mmu_helper.c | 97 ++++----
target/sparc/monitor.c | 2 +-
target/tilegx/cpu.c | 14 +-
target/tricore/cpu.h | 5 +-
target/tricore/helper.c | 15 +-
target/tricore/translate.c | 26 +--
target/unicore32/cpu.h | 3 +-
target/unicore32/translate.c | 39 ++--
target/xtensa/cpu.h | 7 +-
target/xtensa/helper.c | 7 +-
target/xtensa/mmu_helper.c | 24 +-
target/xtensa/monitor.c | 2 +-
target/xtensa/translate.c | 40 ++--
tcg/tcg.c | 50 ++--
tcg/tcg.h | 4 +-
trace/simple.c | 7 +-
trace/simple.h | 2 +-
util/qemu-print.c | 27 +++
util/qsp.c | 21 +-
vl.c | 2 +-
143 files changed, 1353 insertions(+), 1503 deletions(-)
rename include/disas/{bfd.h => dis-asm.h} (99%)
delete mode 100644 include/qemu/fprintf-fn.hSignature · 1 line
2.17.2
PATCH 1/17 include: Include fprintf-fn.h only where needed
--- include/qemu-common.h | 2 -- include/qemu/cutils.h | 2 -- include/sysemu/cpus.h | 1 + 3 files changed, 1 insertion(+), 4 deletions(-)
include/qemu-common.h +0 -2
@@ -12,8 +12,6 @@#ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "qemu/fprintf-fn.h" -#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)/* Copyright string for -version arguments, About dialogs, etc */
include/qemu/cutils.h +0 -2
@@ -1,8 +1,6 @@#ifndef QEMU_CUTILS_H #define QEMU_CUTILS_H -#include "qemu/fprintf-fn.h" -/** * pstrcpy: * @buf: buffer to copy string into
include/sysemu/cpus.h +1 -0
@@ -1,6 +1,7 @@#ifndef QEMU_CPUS_H #define QEMU_CPUS_H +#include "qemu/fprintf-fn.h" #include "qemu/timer.h" /* cpus.c */
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 01/17] include: Include fprintf-fn.h only where needed
Quoted 1 line · * Markus Armbruster ([email protected]) wrote:
Signed-off-by Markus Armbruster <[email protected]>
Quoted 47 lines
--- include/qemu-common.h | 2 -- include/qemu/cutils.h | 2 -- include/sysemu/cpus.h | 1 + 3 files changed, 1 insertion(+), 4 deletions(-)include/qemu-common.h +0
-2@@ -12,8 +12,6 @@#ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "qemu/fprintf-fn.h" -#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)/* Copyright string for -version arguments, About dialogs, etc */ include/qemu/cutils.h +0
-2@@ -1,8 +1,6 @@#ifndef QEMU_CUTILS_H #define QEMU_CUTILS_H -#include "qemu/fprintf-fn.h" -/** * pstrcpy: * @buf: buffer to copy string into include/sysemu/cpus.h +1
-0@@ -1,6 +1,7 @@#ifndef QEMU_CPUS_H #define QEMU_CPUS_H +#include "qemu/fprintf-fn.h" #include "qemu/timer.h" /* cpus.c */ Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 2/17 trace: Simplify how st_print_trace_file_status() prints
In reply to Markus Armbrusterst_print_trace_file_status() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_trace_file() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- monitor.c | 2 +- trace/simple.c | 7 ++++--- trace/simple.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
monitor.c +1 -1
@@ -1056,7 +1056,7 @@ static void hmp_trace_file(Monitor *mon, const QDict *qdict)const char *arg =qdict_get_try_str (qdict,"arg" );if (!op) { -st_print_trace_file_status ((FILE *)mon, &monitor_fprintf); +st_print_trace_file_status (); }else if (!strcmp (op,"on" )) {st_set_trace_file_enabled (true); }else if (!strcmp (op,"off" )) {
trace/simple.c +4 -3
@@ -16,6 +16,7 @@#include "trace/control.h" #include "trace/simple.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" /** Trace file header event ID, picked to avoid conflict with real event IDs */ #define HEADER_EVENT_ID (~(uint64_t)0)
@@ -363,10 +364,10 @@ void st_set_trace_file(const char *file)st_set_trace_file_enabled (true); } -void st_print_trace_file_status (FILE *stream,int (*stream_printf)(FILE *stream,const char *fmt, ...)) +void st_print_trace_file_status (void ) { -stream_printf (stream,"Trace file \"%s\" %s.\n" , - trace_file_name, trace_fp ?"on" :"off" ); +qemu_printf ("Trace file \"%s\" %s.\n" , + trace_file_name, trace_fp ?"on" :"off" ); }void st_flush_trace_buffer (void )
trace/simple.h +1 -1
@@ -11,7 +11,7 @@#ifndef TRACE_SIMPLE_H #define TRACE_SIMPLE_H -void st_print_trace_file_status (FILE *stream,fprintf_function stream_printf); +void st_print_trace_file_status (void );void st_set_trace_file_enabled (bool enable);void st_set_trace_file (const char *file);bool st_init (void );
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 02/17] trace: Simplify how st_print_trace_file_status() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
st_print_trace_file_status()takes an fprintf()-like callback and a FILE * to pass to it.Its only caller
hmp_trace_file()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 61 lines
--- monitor.c | 2 +- trace/simple.c | 7 ++++--- trace/simple.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)monitor.c +1
-1@@ -1056,7 +1056,7 @@ static void hmp_trace_file(Monitor *mon, const QDict *qdict)const char *arg =qdict_get_try_str (qdict,"arg" );if (!op) { -st_print_trace_file_status ((FILE *)mon, &monitor_fprintf); +st_print_trace_file_status (); }else if (!strcmp (op,"on" )) {st_set_trace_file_enabled (true); }else if (!strcmp (op,"off" )) {trace/simple.c +4
-3@@ -16,6 +16,7 @@#include "trace/control.h" #include "trace/simple.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" /** Trace file header event ID, picked to avoid conflict with real event IDs */ #define HEADER_EVENT_ID (~(uint64_t)0)@@ -363,10 +364,10 @@ void st_set_trace_file(const char *file)st_set_trace_file_enabled (true); } -void st_print_trace_file_status (FILE *stream,int (*stream_printf)(FILE *stream,const char *fmt, ...)) +void st_print_trace_file_status (void ) { -stream_printf (stream,"Trace file \"%s\" %s.\n" , - trace_file_name, trace_fp ?"on" :"off" ); +qemu_printf ("Trace file \"%s\" %s.\n" , + trace_file_name, trace_fp ?"on" :"off" ); }void st_flush_trace_buffer (void )trace/simple.h +1
-1@@ -11,7 +11,7 @@#ifndef TRACE_SIMPLE_H #define TRACE_SIMPLE_H -void st_print_trace_file_status (FILE *stream,fprintf_function stream_printf); +void st_print_trace_file_status (void );void st_set_trace_file_enabled (bool enable);void st_set_trace_file (const char *file);bool st_init (void );Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 3/17 tcg: Simplify how dump_opcount_info() prints
In reply to Markus Armbrusterdump_opcount_info() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_info_opcount() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- accel/tcg/translate-all.c | 4 ++-- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 9 +++++---- tcg/tcg.h | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-)
accel/tcg/translate-all.c +2 -2
@@ -2333,9 +2333,9 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) tcg_dump_info(f, cpu_fprintf); } -void dump_opcount_info (FILE *f,fprintf_function cpu_fprintf) +void dump_opcount_info (void ) { -tcg_dump_op_count (f, cpu_fprintf); +tcg_dump_op_count (); }#else /* CONFIG_USER_ONLY */
include/exec/cpu-all.h +1 -1
@@ -363,7 +363,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr) }void dump_exec_info (FILE *f,fprintf_function cpu_fprintf); -void dump_opcount_info (FILE *f,fprintf_function cpu_fprintf); +void dump_opcount_info (void );#endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
monitor.c +1 -1
@@ -1324,7 +1324,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict)static void hmp_info_opcount (Monitor *mon,const QDict *qdict) { -dump_opcount_info ((FILE *)mon, monitor_fprintf); +dump_opcount_info (); }#endif
tcg/tcg.c +5 -4
@@ -33,6 +33,7 @@#include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/host-utils.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" /* Note: the long term plan is to reduce the dependencies on the QEMU
@@ -3768,14 +3769,14 @@ static void tcg_profile_snapshot_table(TCGProfile *prof)tcg_profile_snapshot (prof, false, true); } -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_op_count (void ) {TCGProfile prof = {};int i;tcg_profile_snapshot_table (&prof);for (i =0 ; i <NB_OPS ; i++) { -cpu_fprintf (f,"%s %" PRId64"\n" , tcg_op_defs[i].name, +qemu_printf ("%s %" PRId64"\n" , tcg_op_defs[i].name, prof.table_op_count[i]); } }
@@ -3795,9 +3796,9 @@ int64_t tcg_cpu_exec_time(void) return ret; }#else -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_op_count (void ) { -cpu_fprintf (f,"[TCG profiler not compiled]\n" ); +qemu_printf ("[TCG profiler not compiled]\n" ); }int64_t tcg_cpu_exec_time (void )
tcg/tcg.h +1 -1
@@ -1018,7 +1018,7 @@ int tcg_check_temp_count(void);int64_t tcg_cpu_exec_time (void );void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf); -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf); +void tcg_dump_op_count (void );#define TCG_CT_ALIAS 0x80#define TCG_CT_IALIAS 0x40
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 03/17] tcg: Simplify how dump_opcount_info() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
dump_opcount_info()takes an fprintf()-like callback and a FILE * to pass to it.Its only caller
hmp_info_opcount()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 107 lines
--- accel/tcg/translate-all.c | 4 ++-- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 9 +++++---- tcg/tcg.h | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-)accel/tcg/translate-all.c +2
-2@@ -2333,9 +2333,9 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) tcg_dump_info(f, cpu_fprintf); } -void dump_opcount_info (FILE *f,fprintf_function cpu_fprintf) +void dump_opcount_info (void ) { -tcg_dump_op_count (f, cpu_fprintf); +tcg_dump_op_count (); }#else /* CONFIG_USER_ONLY */ include/exec/cpu-all.h +1
-1@@ -363,7 +363,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr) }void dump_exec_info (FILE *f,fprintf_function cpu_fprintf); -void dump_opcount_info (FILE *f,fprintf_function cpu_fprintf); +void dump_opcount_info (void );#endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,monitor.c +1
-1@@ -1324,7 +1324,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict)static void hmp_info_opcount (Monitor *mon,const QDict *qdict) { -dump_opcount_info ((FILE *)mon, monitor_fprintf); +dump_opcount_info (); }#endif tcg/tcg.c +5
-4@@ -33,6 +33,7 @@#include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/host-utils.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" /* Note: the long term plan is to reduce the dependencies on the QEMU @@ -3768,14 +3769,14 @@ static void tcg_profile_snapshot_table(TCGProfile *prof)tcg_profile_snapshot (prof, false, true); } -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_op_count (void ) {TCGProfile prof = {};int i;tcg_profile_snapshot_table (&prof);for (i =0 ; i <NB_OPS ; i++) { -cpu_fprintf (f,"%s %" PRId64"\n" , tcg_op_defs[i].name, +qemu_printf ("%s %" PRId64"\n" , tcg_op_defs[i].name, prof.table_op_count[i]); } }@@ -3795,9 +3796,9 @@ int64_t tcg_cpu_exec_time(void) return ret; }#else -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_op_count (void ) { -cpu_fprintf (f,"[TCG profiler not compiled]\n" ); +qemu_printf ("[TCG profiler not compiled]\n" ); }int64_t tcg_cpu_exec_time (void )tcg/tcg.h +1
-1@@ -1018,7 +1018,7 @@ int tcg_check_temp_count(void);int64_t tcg_cpu_exec_time (void );void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf); -void tcg_dump_op_count (FILE *f,fprintf_function cpu_fprintf); +void tcg_dump_op_count (void );#define TCG_CT_ALIAS 0x80#define TCG_CT_IALIAS 0x40Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 4/17 tcg: Simplify how dump_exec_info() prints
In reply to Markus Armbrusterdump_exec_info() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_info_jit() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- accel/tcg/translate-all.c | 45 ++++++++++++++++++++------------------- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 41 ++++++++++++++++++----------------- tcg/tcg.h | 2 +- 5 files changed, 47 insertions(+), 45 deletions(-)
accel/tcg/translate-all.c +23 -22
@@ -50,6 +50,7 @@#include "translate-all.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/main-loop.h" #include "exec/log.h"
@@ -2214,8 +2215,7 @@ void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr)tb_jmp_cache_clear_page (cpu, addr); } -static void print_qht_statistics (FILE *f,fprintf_function cpu_fprintf, -struct qht_stats hst) +static void print_qht_statistics (struct qht_stats hst) {uint32_t hgram_opts;size_t hgram_bins;
@@ -2224,7 +2224,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf,if (!hst.head_buckets) {return ; } -cpu_fprintf (f,"TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n" , +qemu_printf ("TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n" , hst.used_head_buckets, hst.head_buckets, (double )hst.used_head_buckets / hst.head_buckets *100 );
@@ -2234,7 +2234,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, hgram_opts |=QDIST_PR_NODECIMAL ; } hgram =qdist_pr (&hst.occupancy,10 , hgram_opts); -cpu_fprintf (f,"TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\n" , +qemu_printf ("TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\n" ,qdist_avg (&hst.occupancy) *100 , hgram);g_free (hgram);
@@ -2247,7 +2247,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, hgram_opts |=QDIST_PR_NODECIMAL |QDIST_PR_NOBINRANGE ; } hgram =qdist_pr (&hst.chain, hgram_bins, hgram_opts); -cpu_fprintf (f,"TB hash avg chain %0.3f buckets. Histogram: %s\n" , +qemu_printf ("TB hash avg chain %0.3f buckets. Histogram: %s\n" ,qdist_avg (&hst.chain), hgram);g_free (hgram); }
@@ -2285,7 +2285,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)return false; } -void dump_exec_info (FILE *f,fprintf_function cpu_fprintf) +void dump_exec_info (void ) {struct tb_tree_stats tst = {};struct qht_stats hst;
@@ -2294,43 +2294,44 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)tcg_tb_foreach (tb_tree_stats_iter, &tst); nb_tbs = tst.nb_tbs;/* XXX: avoid using doubles ? */ -cpu_fprintf (f,"Translation buffer state:\n" ); +qemu_printf ("Translation buffer state:\n" );/* * Report total code size including the padding and TB structs; * otherwise users might think "-tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats though. */ -cpu_fprintf (f,"gen code size %zu/%zu\n" , +qemu_printf ("gen code size %zu/%zu\n" ,tcg_code_size (),tcg_code_capacity ()); -cpu_fprintf (f,"TB count %zu\n" , nb_tbs); -cpu_fprintf (f,"TB avg target size %zu max=%zu bytes\n" , +qemu_printf ("TB count %zu\n" , nb_tbs); +qemu_printf ("TB avg target size %zu max=%zu bytes\n" , nb_tbs ? tst.target_size / nb_tbs :0 , tst.max_target_size); -cpu_fprintf (f,"TB avg host size %zu bytes (expansion ratio: %0.1f)\n" , +qemu_printf ("TB avg host size %zu bytes (expansion ratio: %0.1f)\n" , nb_tbs ? tst.host_size / nb_tbs :0 , tst.target_size ? (double )tst.host_size / tst.target_size :0 ); -cpu_fprintf (f,"cross page TB count %zu (%zu%%)\n" , tst.cross_page, - nb_tbs ? (tst.cross_page *100 ) / nb_tbs :0 ); -cpu_fprintf (f,"direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n" , +qemu_printf ("cross page TB count %zu (%zu%%)\n" , tst.cross_page, + nb_tbs ? (tst.cross_page *100 ) / nb_tbs :0 ); +qemu_printf ("direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n" , tst.direct_jmp_count, nb_tbs ? (tst.direct_jmp_count *100 ) / nb_tbs :0 , tst.direct_jmp2_count, nb_tbs ? (tst.direct_jmp2_count *100 ) / nb_tbs :0 );qht_statistics_init (&tb_ctx.htable, &hst); -print_qht_statistics (f, cpu_fprintf, hst); +print_qht_statistics (hst);qht_statistics_destroy (&hst); -cpu_fprintf (f,"\nStatistics:\n" ); -cpu_fprintf (f,"TB flush count %u\n" , +qemu_printf ("\nStatistics:\n" ); +qemu_printf ("TB flush count %u\n" ,atomic_read (&tb_ctx.tb_flush_count)); -cpu_fprintf (f,"TB invalidate count %zu\n" ,tcg_tb_phys_invalidate_count ()); +qemu_printf ("TB invalidate count %zu\n" , +tcg_tb_phys_invalidate_count ());tlb_flush_counts (&flush_full, &flush_part, &flush_elide); -cpu_fprintf (f,"TLB full flushes %zu\n" , flush_full); -cpu_fprintf (f,"TLB partial flushes %zu\n" , flush_part); -cpu_fprintf (f,"TLB elided flushes %zu\n" , flush_elide); -tcg_dump_info (f, cpu_fprintf); +qemu_printf ("TLB full flushes %zu\n" , flush_full); +qemu_printf ("TLB partial flushes %zu\n" , flush_part); +qemu_printf ("TLB elided flushes %zu\n" , flush_elide); +tcg_dump_info (); }void dump_opcount_info (void )
include/exec/cpu-all.h +1 -1
@@ -362,7 +362,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr) return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); } -void dump_exec_info (FILE *f,fprintf_function cpu_fprintf); +void dump_exec_info (void );void dump_opcount_info (void );#endif /* !CONFIG_USER_ONLY */
monitor.c +1 -1
@@ -1318,7 +1318,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict)return ; } -dump_exec_info ((FILE *)mon, monitor_fprintf); +dump_exec_info ();dump_drift_info ((FILE *)mon, monitor_fprintf); }
tcg/tcg.c +21 -20
80 lines not on this page · raw message
tcg/tcg.h +1 -1
@@ -1017,7 +1017,7 @@ int tcg_check_temp_count(void);#endif int64_t tcg_cpu_exec_time (void ); -void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf); +void tcg_dump_info (void );void tcg_dump_op_count (void );#define TCG_CT_ALIAS 0x80
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 04/17] tcg: Simplify how dump_exec_info() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
dump_exec_info()takes an fprintf()-like callback and a FILE * to pass to it.Its only caller
hmp_info_jit()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 255 lines
--- accel/tcg/translate-all.c | 45 ++++++++++++++++++++------------------- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 41 ++++++++++++++++++----------------- tcg/tcg.h | 2 +- 5 files changed, 47 insertions(+), 45 deletions(-)accel/tcg/translate-all.c +23
-22@@ -50,6 +50,7 @@#include "translate-all.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/main-loop.h" #include "exec/log.h" @@ -2214,8 +2215,7 @@ void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr)tb_jmp_cache_clear_page (cpu, addr); } -static void print_qht_statistics (FILE *f,fprintf_function cpu_fprintf, -struct qht_stats hst) +static void print_qht_statistics (struct qht_stats hst) {uint32_t hgram_opts;size_t hgram_bins;@@ -2224,7 +2224,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf,if (!hst.head_buckets) {return ; } -cpu_fprintf (f,"TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n" , +qemu_printf ("TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n" , hst.used_head_buckets, hst.head_buckets, (double )hst.used_head_buckets / hst.head_buckets *100 );@@ -2234,7 +2234,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, hgram_opts |=QDIST_PR_NODECIMAL ; } hgram =qdist_pr (&hst.occupancy,10 , hgram_opts); -cpu_fprintf (f,"TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\n" , +qemu_printf ("TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\n" ,qdist_avg (&hst.occupancy) *100 , hgram);g_free (hgram);@@ -2247,7 +2247,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, hgram_opts |=QDIST_PR_NODECIMAL |QDIST_PR_NOBINRANGE ; } hgram =qdist_pr (&hst.chain, hgram_bins, hgram_opts); -cpu_fprintf (f,"TB hash avg chain %0.3f buckets. Histogram: %s\n" , +qemu_printf ("TB hash avg chain %0.3f buckets. Histogram: %s\n" ,qdist_avg (&hst.chain), hgram);g_free (hgram); }@@ -2285,7 +2285,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)return false; } -void dump_exec_info (FILE *f,fprintf_function cpu_fprintf) +void dump_exec_info (void ) {struct tb_tree_stats tst = {};struct qht_stats hst;@@ -2294,43 +2294,44 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)tcg_tb_foreach (tb_tree_stats_iter, &tst); nb_tbs = tst.nb_tbs;/* XXX: avoid using doubles ? */ -cpu_fprintf (f,"Translation buffer state:\n" ); +qemu_printf ("Translation buffer state:\n" );/* * Report total code size including the padding and TB structs; * otherwise users might think "-tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats though. */ -cpu_fprintf (f,"gen code size %zu/%zu\n" , +qemu_printf ("gen code size %zu/%zu\n" ,tcg_code_size (),tcg_code_capacity ()); -cpu_fprintf (f,"TB count %zu\n" , nb_tbs); -cpu_fprintf (f,"TB avg target size %zu max=%zu bytes\n" , +qemu_printf ("TB count %zu\n" , nb_tbs); +qemu_printf ("TB avg target size %zu max=%zu bytes\n" , nb_tbs ? tst.target_size / nb_tbs :0 , tst.max_target_size); -cpu_fprintf (f,"TB avg host size %zu bytes (expansion ratio: %0.1f)\n" , +qemu_printf ("TB avg host size %zu bytes (expansion ratio: %0.1f)\n" , nb_tbs ? tst.host_size / nb_tbs :0 , tst.target_size ? (double )tst.host_size / tst.target_size :0 ); -cpu_fprintf (f,"cross page TB count %zu (%zu%%)\n" , tst.cross_page, - nb_tbs ? (tst.cross_page *100 ) / nb_tbs :0 ); -cpu_fprintf (f,"direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n" , +qemu_printf ("cross page TB count %zu (%zu%%)\n" , tst.cross_page, + nb_tbs ? (tst.cross_page *100 ) / nb_tbs :0 ); +qemu_printf ("direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n" , tst.direct_jmp_count, nb_tbs ? (tst.direct_jmp_count *100 ) / nb_tbs :0 , tst.direct_jmp2_count, nb_tbs ? (tst.direct_jmp2_count *100 ) / nb_tbs :0 );qht_statistics_init (&tb_ctx.htable, &hst); -print_qht_statistics (f, cpu_fprintf, hst); +print_qht_statistics (hst);qht_statistics_destroy (&hst); -cpu_fprintf (f,"\nStatistics:\n" ); -cpu_fprintf (f,"TB flush count %u\n" , +qemu_printf ("\nStatistics:\n" ); +qemu_printf ("TB flush count %u\n" ,atomic_read (&tb_ctx.tb_flush_count)); -cpu_fprintf (f,"TB invalidate count %zu\n" ,tcg_tb_phys_invalidate_count ()); +qemu_printf ("TB invalidate count %zu\n" , +tcg_tb_phys_invalidate_count ());tlb_flush_counts (&flush_full, &flush_part, &flush_elide); -cpu_fprintf (f,"TLB full flushes %zu\n" , flush_full); -cpu_fprintf (f,"TLB partial flushes %zu\n" , flush_part); -cpu_fprintf (f,"TLB elided flushes %zu\n" , flush_elide); -tcg_dump_info (f, cpu_fprintf); +qemu_printf ("TLB full flushes %zu\n" , flush_full); +qemu_printf ("TLB partial flushes %zu\n" , flush_part); +qemu_printf ("TLB elided flushes %zu\n" , flush_elide); +tcg_dump_info (); }void dump_opcount_info (void )include/exec/cpu-all.h +1
-1@@ -362,7 +362,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, target_ulong addr) return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); } -void dump_exec_info (FILE *f,fprintf_function cpu_fprintf); +void dump_exec_info (void );void dump_opcount_info (void );#endif /* !CONFIG_USER_ONLY */ monitor.c +1
-1@@ -1318,7 +1318,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict)return ; } -dump_exec_info ((FILE *)mon, monitor_fprintf); +dump_exec_info ();dump_drift_info ((FILE *)mon, monitor_fprintf); }tcg/tcg.c +21
-20@@ -4015,7 +4015,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) }#ifdef CONFIG_PROFILER -void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_info (void ) {TCGProfile prof = {};const TCGProfile *s;@@ -4029,52 +4029,53 @@ void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) tb_div_count = tb_count ? tb_count :1 ; tot = s->interm_time + s->code_time; -cpu_fprintf (f,"JIT cycles %" PRId64" (%0.3f s at 2.4 GHz)\n" , +qemu_printf ("JIT cycles %" PRId64" (%0.3f s at 2.4 GHz)\n" , tot, tot /2.4e9 ); -cpu_fprintf (f,"translated TBs %" PRId64" (aborted=%" PRId64" %0.1f%%)\n" , +qemu_printf ("translated TBs %" PRId64" (aborted=%" PRId64 +" %0.1f%%)\n" , tb_count, s->tb_count1 - tb_count, (double )(s->tb_count1 - s->tb_count) / (s->tb_count1 ? s->tb_count1 :1 ) *100.0 ); -cpu_fprintf (f,"avg ops/TB %0.1f max=%d\n" , +qemu_printf ("avg ops/TB %0.1f max=%d\n" , (double )s->op_count / tb_div_count, s->op_count_max); -cpu_fprintf (f,"deleted ops/TB %0.2f\n" , +qemu_printf ("deleted ops/TB %0.2f\n" , (double )s->del_op_count / tb_div_count); -cpu_fprintf (f,"avg temps/TB %0.2f max=%d\n" , +qemu_printf ("avg temps/TB %0.2f max=%d\n" , (double )s->temp_count / tb_div_count, s->temp_count_max); -cpu_fprintf (f,"avg host code/TB %0.1f\n" , +qemu_printf ("avg host code/TB %0.1f\n" , (double )s->code_out_len / tb_div_count); -cpu_fprintf (f,"avg search data/TB %0.1f\n" , +qemu_printf ("avg search data/TB %0.1f\n" , (double )s->search_out_len / tb_div_count); -cpu_fprintf (f,"cycles/op %0.1f\n" , +qemu_printf ("cycles/op %0.1f\n" , s->op_count ? (double )tot / s->op_count :0 ); -cpu_fprintf (f,"cycles/in byte %0.1f\n" , +qemu_printf ("cycles/in byte %0.1f\n" , s->code_in_len ? (double )tot / s->code_in_len :0 ); -cpu_fprintf (f,"cycles/out byte %0.1f\n" , +qemu_printf ("cycles/out byte %0.1f\n" , s->code_out_len ? (double )tot / s->code_out_len :0 ); -cpu_fprintf (f,"cycles/search byte %0.1f\n" , +qemu_printf ("cycles/search byte %0.1f\n" , s->search_out_len ? (double )tot / s->search_out_len :0 );if (tot ==0 ) { tot =1 ; } -cpu_fprintf (f," gen_interm time %0.1f%%\n" , +qemu_printf (" gen_interm time %0.1f%%\n" , (double )s->interm_time / tot *100.0 ); -cpu_fprintf (f," gen_code time %0.1f%%\n" , +qemu_printf (" gen_code time %0.1f%%\n" , (double )s->code_time / tot *100.0 ); -cpu_fprintf (f,"optim./code time %0.1f%%\n" , +qemu_printf ("optim./code time %0.1f%%\n" , (double )s->opt_time / (s->code_time ? s->code_time :1 ) *100.0 ); -cpu_fprintf (f,"liveness/code time %0.1f%%\n" , +qemu_printf ("liveness/code time %0.1f%%\n" , (double )s->la_time / (s->code_time ? s->code_time :1 ) *100.0 ); -cpu_fprintf (f,"cpu_restore count %" PRId64"\n" , +qemu_printf ("cpu_restore count %" PRId64"\n" , s->restore_count); -cpu_fprintf (f," avg cycles %0.1f\n" , +qemu_printf (" avg cycles %0.1f\n" , s->restore_count ? (double)s->restore_time / s->restore_count : 0); }#else -void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf) +void tcg_dump_info (void ) { -cpu_fprintf (f,"[TCG profiler not compiled]\n" ); +qemu_printf ("[TCG profiler not compiled]\n" ); }#endif tcg/tcg.h +1
-1@@ -1017,7 +1017,7 @@ int tcg_check_temp_count(void);#endif int64_t tcg_cpu_exec_time (void ); -void tcg_dump_info (FILE *f,fprintf_function cpu_fprintf); +void tcg_dump_info (void );void tcg_dump_op_count (void );#define TCG_CT_ALIAS 0x80Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 5/17 tcg: Simplify how dump_drift_info() prints
In reply to Markus Armbrusterdump_drift_info() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_info_jit() passes monitor_fprintf() and a Monitor
* cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- cpus.c | 15 +++++++++------ include/sysemu/cpus.h | 2 +- monitor.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-)
cpus.c +9 -6
@@ -31,6 +31,7 @@#include "qapi/qapi-events-run-state.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" #include "exec/gdbstub.h"
@@ -2454,19 +2455,21 @@ void qmp_inject_nmi(Error **errp)nmi_monitor_handle (monitor_get_cpu_index (), errp); } -void dump_drift_info (FILE *f,fprintf_function cpu_fprintf) +void dump_drift_info (void ) {if (!use_icount) {return ; } -cpu_fprintf (f,"Host - Guest clock %" PRIi64" ms\n" , +qemu_printf ("Host - Guest clock %" PRIi64" ms\n" , (cpu_get_clock () -cpu_get_icount ())/SCALE_MS );if (icount_align_option) { -cpu_fprintf (f,"Max guest delay %" PRIi64" ms\n" , -max_delay/SCALE_MS ); -cpu_fprintf (f,"Max guest advance %" PRIi64" ms\n" , max_advance/SCALE_MS ); +qemu_printf ("Max guest delay %" PRIi64" ms\n" , + -max_delay /SCALE_MS ); +qemu_printf ("Max guest advance %" PRIi64" ms\n" , + max_advance /SCALE_MS ); }else { -cpu_fprintf (f,"Max guest delay NA\n" ); -cpu_fprintf (f,"Max guest advance NA\n" ); +qemu_printf ("Max guest delay NA\n" ); +qemu_printf ("Max guest advance NA\n" ); } }
include/sysemu/cpus.h +1 -1
@@ -19,7 +19,7 @@ extern int icount_align_option;/* drift information for info jit command */ extern int64_t max_delay;extern int64_t max_advance; -void dump_drift_info (FILE *f,fprintf_function cpu_fprintf); +void dump_drift_info (void );/* Unblock cpu */ void qemu_cpu_kick_self (void );
monitor.c +1 -1
@@ -1319,7 +1319,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict) }dump_exec_info (); -dump_drift_info ((FILE *)mon, monitor_fprintf); +dump_drift_info (); }static void hmp_info_opcount (Monitor *mon,const QDict *qdict)
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 05/17] tcg: Simplify how dump_drift_info() prints
Quoted 2 lines · * Markus Armbruster ([email protected]) wrote:
dump_drift_info()takes an fprintf()-like callback and a FILE * to pass to it.
Me thinks there's a pattern here....
Quoted 7 lines
Its only caller
hmp_info_jit()passesmonitor_fprintf()and a Monitor
* cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 75 lines
--- cpus.c | 15 +++++++++------ include/sysemu/cpus.h | 2 +- monitor.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-)cpus.c +9
-6@@ -31,6 +31,7 @@#include "qapi/qapi-events-run-state.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" #include "exec/gdbstub.h" @@ -2454,19 +2455,21 @@ void qmp_inject_nmi(Error **errp)nmi_monitor_handle (monitor_get_cpu_index (), errp); } -void dump_drift_info (FILE *f,fprintf_function cpu_fprintf) +void dump_drift_info (void ) {if (!use_icount) {return ; } -cpu_fprintf (f,"Host - Guest clock %" PRIi64" ms\n" , +qemu_printf ("Host - Guest clock %" PRIi64" ms\n" , (cpu_get_clock () -cpu_get_icount ())/SCALE_MS );if (icount_align_option) { -cpu_fprintf (f,"Max guest delay %" PRIi64" ms\n" , -max_delay/SCALE_MS ); -cpu_fprintf (f,"Max guest advance %" PRIi64" ms\n" , max_advance/SCALE_MS ); +qemu_printf ("Max guest delay %" PRIi64" ms\n" , + -max_delay /SCALE_MS ); +qemu_printf ("Max guest advance %" PRIi64" ms\n" , + max_advance /SCALE_MS ); }else { -cpu_fprintf (f,"Max guest delay NA\n" ); -cpu_fprintf (f,"Max guest advance NA\n" ); +qemu_printf ("Max guest delay NA\n" ); +qemu_printf ("Max guest advance NA\n" ); } }include/sysemu/cpus.h +1
-1@@ -19,7 +19,7 @@ extern int icount_align_option;/* drift information for info jit command */ extern int64_t max_delay;extern int64_t max_advance; -void dump_drift_info (FILE *f,fprintf_function cpu_fprintf); +void dump_drift_info (void );/* Unblock cpu */ void qemu_cpu_kick_self (void );monitor.c +1
-1@@ -1319,7 +1319,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdict) }dump_exec_info (); -dump_drift_info ((FILE *)mon, monitor_fprintf); +dump_drift_info (); }static void hmp_info_opcount (Monitor *mon,const QDict *qdict)Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 6/17 qsp: Simplify how qsp_report() prints
In reply to Markus Armbrusterqsp_report() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_sync_profile() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- include/block/qapi.h | 1 + include/qemu/qsp.h | 6 ++---- monitor.c | 2 +- util/qsp.c | 21 +++++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-)
include/block/qapi.h +1 -0
@@ -27,6 +27,7 @@#include "block/block.h" #include "block/snapshot.h" +#include "qemu/fprintf-fn.h" BlockDeviceInfo *bdrv_block_device_info (BlockBackend *blk,BlockDriverState *bs,Error **errp);
include/qemu/qsp.h +2 -4
@@ -11,15 +11,13 @@#ifndef QEMU_QSP_H #define QEMU_QSP_H -#include "qemu/fprintf-fn.h" -enum QSPSortBy {QSP_SORT_BY_TOTAL_WAIT_TIME ,QSP_SORT_BY_AVG_WAIT_TIME , }; -void qsp_report (FILE *f,fprintf_function cpu_fprintf,size_t max, -enum QSPSortBy sort_by,bool callsite_coalesce); +void qsp_report (size_t max,enum QSPSortBy sort_by, +bool callsite_coalesce);bool qsp_is_enabled (void );void qsp_enable (void );
monitor.c +1 -1
@@ -1336,7 +1336,7 @@ static void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)enum QSPSortBy sort_by; sort_by = mean ?QSP_SORT_BY_AVG_WAIT_TIME :QSP_SORT_BY_TOTAL_WAIT_TIME ; -qsp_report ((FILE *)mon, monitor_fprintf, max, sort_by, coalesce); +qsp_report (max, sort_by, coalesce); }static void hmp_info_history (Monitor *mon,const QDict *qdict)
util/qsp.c +11 -10
@@ -56,7 +56,9 @@* Critical-Section Execution to Improve the Performance of Multithreaded * Applications", USENIX ATC'12. */ +#include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/thread.h" #include "qemu/timer.h" #include "qemu/qht.h"
@@ -678,8 +680,7 @@ static gboolean qsp_tree_report(gpointer key, gpointer value, gpointer udata)return FALSE; } -static void -pr_report (const QSPReport *rep,FILE *f,fprintf_function pr) +static void pr_report (const QSPReport *rep) {char *dashes;size_t max_len =0 ;
@@ -702,15 +703,15 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_function pr)/* white space to leave to the right of "Call site" */ callsite_rspace = callsite_len -strlen ("Call site" ); -pr (f,"Type Object Call site%*s Wait Time (s) " -" Count Average (us)\n" , callsite_rspace,"" ); +qemu_printf ("Type Object Call site%*s Wait Time (s) " +" Count Average (us)\n" , callsite_rspace,"" );/* build a horizontal rule with dashes */ n_dashes =79 + callsite_rspace; dashes =g_malloc (n_dashes +1 );memset (dashes,'-' , n_dashes); dashes[n_dashes] ='\0' ; -pr (f,"%s\n" , dashes); +qemu_printf ("%s\n" , dashes);for (i =0 ; i < rep->n_entries; i++) {const QSPReportEntry *e = &rep->entries[i];
@@ -726,11 +727,11 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_function pr) e->callsite_at, callsite_len - (int )strlen (e->callsite_at),"" , e->time_s, e->n_acqs, e->ns_avg * 1e-3); -pr (f,"%s" , s->str); +qemu_printf ("%s" , s->str);g_string_free (s, TRUE); } -pr (f,"%s\n" , dashes); +qemu_printf ("%s\n" , dashes);g_free (dashes); }
@@ -746,8 +747,8 @@ static void report_destroy(QSPReport *rep)g_free (rep->entries); } -void qsp_report (FILE *f,fprintf_function cpu_fprintf,size_t max, -enum QSPSortBy sort_by,bool callsite_coalesce) +void qsp_report (size_t max,enum QSPSortBy sort_by, +bool callsite_coalesce) {GTree *tree =g_tree_new_full (qsp_tree_cmp, &sort_by, g_free,NULL );QSPReport rep;
@@ -762,7 +763,7 @@ void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,g_tree_foreach (tree, qsp_tree_report, &rep);g_tree_destroy (tree); -pr_report (&rep, f, cpu_fprintf); +pr_report (&rep);report_destroy (&rep); }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 06/17] qsp: Simplify how qsp_report() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
qsp_report()takes an fprintf()-like callback and a FILE * to pass to it.Its only caller
hmp_sync_profile()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 134 lines
--- include/block/qapi.h | 1 + include/qemu/qsp.h | 6 ++---- monitor.c | 2 +- util/qsp.c | 21 +++++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-)include/block/qapi.h +1
-0@@ -27,6 +27,7 @@#include "block/block.h" #include "block/snapshot.h" +#include "qemu/fprintf-fn.h" BlockDeviceInfo *bdrv_block_device_info (BlockBackend *blk,BlockDriverState *bs,Error **errp);include/qemu/qsp.h +2
-4@@ -11,15 +11,13 @@#ifndef QEMU_QSP_H #define QEMU_QSP_H -#include "qemu/fprintf-fn.h" -enum QSPSortBy {QSP_SORT_BY_TOTAL_WAIT_TIME ,QSP_SORT_BY_AVG_WAIT_TIME , }; -void qsp_report (FILE *f,fprintf_function cpu_fprintf,size_t max, -enum QSPSortBy sort_by,bool callsite_coalesce); +void qsp_report (size_t max,enum QSPSortBy sort_by, +bool callsite_coalesce);bool qsp_is_enabled (void );void qsp_enable (void );monitor.c +1
-1@@ -1336,7 +1336,7 @@ static void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)enum QSPSortBy sort_by; sort_by = mean ?QSP_SORT_BY_AVG_WAIT_TIME :QSP_SORT_BY_TOTAL_WAIT_TIME ; -qsp_report ((FILE *)mon, monitor_fprintf, max, sort_by, coalesce); +qsp_report (max, sort_by, coalesce); }static void hmp_info_history (Monitor *mon,const QDict *qdict)util/qsp.c +11
-10@@ -56,7 +56,9 @@* Critical-Section Execution to Improve the Performance of Multithreaded * Applications", USENIX ATC'12. */ +#include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/thread.h" #include "qemu/timer.h" #include "qemu/qht.h" @@ -678,8 +680,7 @@ static gboolean qsp_tree_report(gpointer key, gpointer value, gpointer udata)return FALSE; } -static void -pr_report (const QSPReport *rep,FILE *f,fprintf_function pr) +static void pr_report (const QSPReport *rep) {char *dashes;size_t max_len =0 ;@@ -702,15 +703,15 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_function pr)/* white space to leave to the right of "Call site" */ callsite_rspace = callsite_len -strlen ("Call site" ); -pr (f,"Type Object Call site%*s Wait Time (s) " -" Count Average (us)\n" , callsite_rspace,"" ); +qemu_printf ("Type Object Call site%*s Wait Time (s) " +" Count Average (us)\n" , callsite_rspace,"" );/* build a horizontal rule with dashes */ n_dashes =79 + callsite_rspace; dashes =g_malloc (n_dashes +1 );memset (dashes,'-' , n_dashes); dashes[n_dashes] ='\0' ; -pr (f,"%s\n" , dashes); +qemu_printf ("%s\n" , dashes);for (i =0 ; i < rep->n_entries; i++) {const QSPReportEntry *e = &rep->entries[i];@@ -726,11 +727,11 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_function pr) e->callsite_at, callsite_len - (int )strlen (e->callsite_at),"" , e->time_s, e->n_acqs, e->ns_avg * 1e-3); -pr (f,"%s" , s->str); +qemu_printf ("%s" , s->str);g_string_free (s, TRUE); } -pr (f,"%s\n" , dashes); +qemu_printf ("%s\n" , dashes);g_free (dashes); }@@ -746,8 +747,8 @@ static void report_destroy(QSPReport *rep)g_free (rep->entries); } -void qsp_report (FILE *f,fprintf_function cpu_fprintf,size_t max, -enum QSPSortBy sort_by,bool callsite_coalesce) +void qsp_report (size_t max,enum QSPSortBy sort_by, +bool callsite_coalesce) {GTree *tree =g_tree_new_full (qsp_tree_cmp, &sort_by, g_free,NULL );QSPReport rep;@@ -762,7 +763,7 @@ void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,g_tree_foreach (tree, qsp_tree_report, &rep);g_tree_destroy (tree); -pr_report (&rep, f, cpu_fprintf); +pr_report (&rep);report_destroy (&rep); }Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 7/17 block/qapi: Clean up how we print to monitor or stdout
In reply to Markus Armbrusterbdrv_snapshot_dump(), bdrv_image_info_specific_dump(), bdrv_image_info_dump() and their helpers take an fprintf()-like callback and a FILE * to pass to it.
hmp.c passes monitor_printf() cast to fprintf_function and the current monitor cast to FILE *.
qemu-img.c and qemu-io-cmds.c pass fprintf and stdout.
The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead.
--- block/qapi.c | 120 ++++++++++++++++++++----------------------- hmp.c | 12 ++--- include/block/qapi.h | 10 ++-- qemu-img.c | 6 +-- qemu-io-cmds.c | 2 +- 5 files changed, 67 insertions(+), 83 deletions(-)
block/qapi.c +55 -65
@@ -36,6 +36,7 @@#include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h"
@@ -660,8 +661,7 @@ static char *get_human_readable_size(char *buf, int buf_size, int64_t size)return buf; } -void bdrv_snapshot_dump (fprintf_function func_fprintf,void *f, -QEMUSnapshotInfo *sn) +void bdrv_snapshot_dump (QEMUSnapshotInfo *sn) {char buf1[128 ], date_buf[128 ], clock_buf[128 ];struct tm tm;
@@ -669,9 +669,8 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,int64_t secs;if (!sn) { -func_fprintf (f, -"%-10s%-20s%7s%20s%15s" , -"ID" ,"TAG" ,"VM SIZE" ,"DATE" ,"VM CLOCK" ); +qemu_printf ("%-10s%-20s%7s%20s%15s" , +"ID" ,"TAG" ,"VM SIZE" ,"DATE" ,"VM CLOCK" ); }else { ti = sn->date_sec;localtime_r (&ti, &tm);
@@ -684,50 +683,46 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, (int )((secs /60 ) %60 ), (int )(secs %60 ), (int)((sn->vm_clock_nsec / 1000000) % 1000)); -func_fprintf (f, -"%-10s%-20s%7s%20s%15s" , - sn->id_str, sn->name, -get_human_readable_size (buf1,sizeof (buf1), - sn->vm_state_size), - date_buf, - clock_buf); +qemu_printf ("%-10s%-20s%7s%20s%15s" , + sn->id_str, sn->name, +get_human_readable_size (buf1,sizeof (buf1), + sn->vm_state_size), + date_buf, + clock_buf); } } -static void dump_qdict (fprintf_function func_fprintf,void *f,int indentation, -QDict *dict); -static void dump_qlist (fprintf_function func_fprintf,void *f,int indentation, -QList *list); +static void dump_qdict (int indentation,QDict *dict); +static void dump_qlist (int indentation,QList *list); -static void dump_qobject (fprintf_function func_fprintf,void *f, -int comp_indent,QObject *obj) +static void dump_qobject (int comp_indent,QObject *obj) {switch (qobject_type (obj)) {case QTYPE_QNUM : {QNum *value =qobject_to (QNum, obj);char *tmp =qnum_to_string (value); -func_fprintf (f,"%s" , tmp); +qemu_printf ("%s" , tmp);g_free (tmp);break ; }case QTYPE_QSTRING : {QString *value =qobject_to (QString, obj); -func_fprintf (f,"%s" ,qstring_get_str (value)); +qemu_printf ("%s" ,qstring_get_str (value));break ; }case QTYPE_QDICT : {QDict *value =qobject_to (QDict, obj); -dump_qdict (func_fprintf, f, comp_indent, value); +dump_qdict (comp_indent, value);break ; }case QTYPE_QLIST : {QList *value =qobject_to (QList, obj); -dump_qlist (func_fprintf, f, comp_indent, value); +dump_qlist (comp_indent, value);break ; }case QTYPE_QBOOL : {QBool *value =qobject_to (QBool, obj); -func_fprintf (f,"%s" ,qbool_get_bool (value) ?"true" :"false" ); +qemu_printf ("%s" ,qbool_get_bool (value) ?"true" :"false" );break ; }default :
@@ -735,8 +730,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f, } } -static void dump_qlist (fprintf_function func_fprintf,void *f,int indentation, -QList *list) +static void dump_qlist (int indentation,QList *list) {const QListEntry *entry;int i =0 ;
@@ -744,17 +738,16 @@ static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,for (entry =qlist_first (list); entry; entry =qlist_next (entry), i++) {QType type =qobject_type (entry->value);bool composite = (type ==QTYPE_QDICT || type ==QTYPE_QLIST ); -func_fprintf (f,"%*s[%i]:%c" , indentation *4 ,"" , i, - composite ?'\n' :' ' ); -dump_qobject (func_fprintf, f, indentation +1 , entry->value); +qemu_printf ("%*s[%i]:%c" , indentation *4 ,"" , i, + composite ?'\n' :' ' ); +dump_qobject (indentation +1 , entry->value);if (!composite) { -func_fprintf (f,"\n" ); +qemu_printf ("\n" ); } } } -static void dump_qdict (fprintf_function func_fprintf,void *f,int indentation, -QDict *dict) +static void dump_qdict (int indentation,QDict *dict) {const QDictEntry *entry;
@@ -769,18 +762,17 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, key[i] = entry->key[i] =='-' ?' ' : entry->key[i]; } key[i] =0 ; -func_fprintf (f,"%*s%s:%c" , indentation *4 ,"" , key, - composite ?'\n' :' ' ); -dump_qobject (func_fprintf, f, indentation +1 , entry->value); +qemu_printf ("%*s%s:%c" , indentation *4 ,"" , key, + composite ?'\n' :' ' ); +dump_qobject (indentation +1 , entry->value);if (!composite) { -func_fprintf (f,"\n" ); +qemu_printf ("\n" ); }g_free (key); } } -void bdrv_image_info_specific_dump (fprintf_function func_fprintf,void *f, -ImageInfoSpecific *info_spec) +void bdrv_image_info_specific_dump (ImageInfoSpecific *info_spec) {QObject *obj, *data;Visitor *v =qobject_output_visitor_new (&obj);
@@ -788,13 +780,12 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,visit_type_ImageInfoSpecific (v,NULL , &info_spec, &error_abort);visit_complete (v, &obj); data =qdict_get (qobject_to (QDict, obj),"data" ); -dump_qobject (func_fprintf, f,1 , data); +dump_qobject (1 , data);qobject_unref (obj);visit_free (v); } -void bdrv_image_info_dump (fprintf_function func_fprintf,void *f, -ImageInfo *info) +void bdrv_image_info_dump (ImageInfo *info) {char size_buf[128 ], dsize_buf[128 ];if (!info->has_actual_size) {
@@ -804,49 +795,48 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, info->actual_size); }get_human_readable_size (size_buf,sizeof (size_buf), info->virtual_size); -func_fprintf (f, -"image: %s\n" -"file format: %s\n" -"virtual size: %s (%" PRId64" bytes)\n" -"disk size: %s\n" , - info->filename, info->format, size_buf, - info->virtual_size, - dsize_buf); +qemu_printf ("image: %s\n" +"file format: %s\n" +"virtual size: %s (%" PRId64" bytes)\n" +"disk size: %s\n" , + info->filename, info->format, size_buf, + info->virtual_size, + dsize_buf);if (info->has_encrypted && info->encrypted) { -func_fprintf (f,"encrypted: yes\n" ); +qemu_printf ("encrypted: yes\n" ); }if (info->has_cluster_size) { -func_fprintf (f,"cluster_size: %" PRId64"\n" , - info->cluster_size); +qemu_printf ("cluster_size: %" PRId64"\n" , + info->cluster_size); }if (info->has_dirty_flag && info->dirty_flag) { -func_fprintf (f,"cleanly shut down: no\n" ); +qemu_printf ("cleanly shut down: no\n" ); }if (info->has_backing_filename) { -func_fprintf (f,"backing file: %s" , info->backing_filename); +qemu_printf ("backing file: %s" , info->backing_filename);if (!info->has_full_backing_filename) { -func_fprintf (f," (cannot determine actual path)" ); +qemu_printf (" (cannot determine actual path)" ); }else if (strcmp (info->backing_filename, info->full_backing_filename) !=0 ) { -func_fprintf (f," (actual path: %s)" , info->full_backing_filename); +qemu_printf (" (actual path: %s)" , info->full_backing_filename); } -func_fprintf (f,"\n" ); +qemu_printf ("\n" );if (info->has_backing_filename_format) { -func_fprintf (f,"backing file format: %s\n" , - info->backing_filename_format); +qemu_printf ("backing file format: %s\n" , + info->backing_filename_format); } }if (info->has_snapshots) {SnapshotInfoList *elem; -func_fprintf (f,"Snapshot list:\n" ); -bdrv_snapshot_dump (func_fprintf, f,NULL ); -func_fprintf (f,"\n" ); +qemu_printf ("Snapshot list:\n" ); +bdrv_snapshot_dump (NULL ); +qemu_printf ("\n" );/* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but * we convert to the block layer's native QEMUSnapshotInfo for now.
@@ -862,13 +852,13 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f,pstrcpy (sn.id_str,sizeof (sn.id_str), elem->value->id);pstrcpy (sn.name,sizeof (sn.name), elem->value->name); -bdrv_snapshot_dump (func_fprintf, f, &sn); -func_fprintf (f,"\n" ); +bdrv_snapshot_dump (&sn); +qemu_printf ("\n" ); } }if (info->has_format_specific) { -func_fprintf (f,"Format specific information:\n" ); -bdrv_image_info_specific_dump (func_fprintf, f, info->format_specific); +qemu_printf ("Format specific information:\n" ); +bdrv_image_info_specific_dump (info->format_specific); } }
hmp.c +5 -7
@@ -580,8 +580,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,monitor_printf (mon,"\nImages:\n" ); image_info = inserted->image;while (1 ) { -bdrv_image_info_dump ((fprintf_function )monitor_printf, - mon, image_info); +bdrv_image_info_dump (image_info);if (image_info->has_backing_image) { image_info = image_info->backing_image; }else {
@@ -1586,7 +1585,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)monitor_printf (mon,"List of snapshots present on all disks:\n" );if (total >0 ) { -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon,NULL ); +bdrv_snapshot_dump (NULL );monitor_printf (mon,"\n" );for (i =0 ; i < total; i++) { sn = &sn_tab[global_snapshots[i]];
@@ -1594,7 +1593,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)* overwrite it. */ pstrcpy (sn->id_str,sizeof (sn->id_str),"--" ); -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon, sn); +bdrv_snapshot_dump (sn);monitor_printf (mon,"\n" ); } }else {
@@ -1608,11 +1607,10 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)monitor_printf (mon,"\nList of partial (non-loadable) snapshots on '%s':\n" , image_entry->imagename); -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon,NULL ); +bdrv_snapshot_dump (NULL );monitor_printf (mon,"\n" ); QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) { -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon, - &snapshot_entry->sn); +bdrv_snapshot_dump (&snapshot_entry->sn);monitor_printf (mon,"\n" ); } }
include/block/qapi.h +3 -7
@@ -27,7 +27,6 @@#include "block/block.h" #include "block/snapshot.h" -#include "qemu/fprintf-fn.h" BlockDeviceInfo *bdrv_block_device_info (BlockBackend *blk,BlockDriverState *bs,Error **errp);
@@ -38,10 +37,7 @@ void bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, Error **errp); -void bdrv_snapshot_dump (fprintf_function func_fprintf,void *f, -QEMUSnapshotInfo *sn); -void bdrv_image_info_specific_dump (fprintf_function func_fprintf,void *f, -ImageInfoSpecific *info_spec); -void bdrv_image_info_dump (fprintf_function func_fprintf,void *f, -ImageInfo *info); +void bdrv_snapshot_dump (QEMUSnapshotInfo *sn); +void bdrv_image_info_specific_dump (ImageInfoSpecific *info_spec); +void bdrv_image_info_dump (ImageInfo *info);#endif
qemu-img.c +3 -3
@@ -2483,11 +2483,11 @@ static void dump_snapshots(BlockDriverState *bs)if (nb_sns <=0 )return ;printf ("Snapshot list:\n" ); -bdrv_snapshot_dump (fprintf, stdout,NULL ); +bdrv_snapshot_dump (NULL );printf ("\n" );for (i =0 ; i < nb_sns; i++) { sn = &sn_tab[i]; -bdrv_snapshot_dump (fprintf, stdout, sn); +bdrv_snapshot_dump (sn);printf ("\n" ); }g_free (sn_tab);
@@ -2536,7 +2536,7 @@ static void dump_human_image_info_list(ImageInfoList *list) } delim = true; -bdrv_image_info_dump (fprintf, stdout, elem->value); +bdrv_image_info_dump (elem->value); } }
qemu-io-cmds.c +1 -1
@@ -1699,7 +1699,7 @@ static int info_f(BlockBackend *blk, int argc, char **argv) }if (spec_info) {printf ("Format specific information:\n" ); -bdrv_image_info_specific_dump (fprintf, stdout, spec_info); +bdrv_image_info_specific_dump (spec_info);qapi_free_ImageInfoSpecific (spec_info); }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 07/17] block/qapi: Clean up how we print to monitor or stdout
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
bdrv_snapshot_dump(),bdrv_image_info_specific_dump(),bdrv_image_info_dump()and their helpers take an fprintf()-like callback and a FILE * to pass to it.
hmp.cpassesmonitor_printf()cast tofprintf_functionand the current monitor cast to FILE *.
Quoted 7 lines
qemu-img.candqemu-io-cmds.cpass fprintf and stdout.The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 383 lines
--- block/qapi.c | 120 ++++++++++++++++++++----------------------- hmp.c | 12 ++--- include/block/qapi.h | 10 ++-- qemu-img.c | 6 +-- qemu-io-cmds.c | 2 +- 5 files changed, 67 insertions(+), 83 deletions(-)block/qapi.c +55
-65@@ -36,6 +36,7 @@#include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h" @@ -660,8 +661,7 @@ static char *get_human_readable_size(char *buf, int buf_size, int64_t size)return buf; } -void bdrv_snapshot_dump (fprintf_function func_fprintf,void *f, -QEMUSnapshotInfo *sn) +void bdrv_snapshot_dump (QEMUSnapshotInfo *sn) {char buf1[128 ], date_buf[128 ], clock_buf[128 ];struct tm tm;@@ -669,9 +669,8 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,int64_t secs;if (!sn) { -func_fprintf (f, -"%-10s%-20s%7s%20s%15s" , -"ID" ,"TAG" ,"VM SIZE" ,"DATE" ,"VM CLOCK" ); +qemu_printf ("%-10s%-20s%7s%20s%15s" , +"ID" ,"TAG" ,"VM SIZE" ,"DATE" ,"VM CLOCK" ); }else { ti = sn->date_sec;localtime_r (&ti, &tm);@@ -684,50 +683,46 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, (int )((secs /60 ) %60 ), (int )(secs %60 ), (int)((sn->vm_clock_nsec / 1000000) % 1000)); -func_fprintf (f, -"%-10s%-20s%7s%20s%15s" , - sn->id_str, sn->name, -get_human_readable_size (buf1,sizeof (buf1), - sn->vm_state_size), - date_buf, - clock_buf); +qemu_printf ("%-10s%-20s%7s%20s%15s" , + sn->id_str, sn->name, +get_human_readable_size (buf1,sizeof (buf1), + sn->vm_state_size), + date_buf, + clock_buf); } } -static void dump_qdict (fprintf_function func_fprintf,void *f,int indentation, -QDict *dict); -static void dump_qlist (fprintf_function func_fprintf,void *f,int indentation, -QList *list); +static void dump_qdict (int indentation,QDict *dict); +static void dump_qlist (int indentation,QList *list); -static void dump_qobject (fprintf_function func_fprintf,void *f, -int comp_indent,QObject *obj) +static void dump_qobject (int comp_indent,QObject *obj) {switch (qobject_type (obj)) {case QTYPE_QNUM : {QNum *value =qobject_to (QNum, obj);char *tmp =qnum_to_string (value); -func_fprintf (f,"%s" , tmp); +qemu_printf ("%s" , tmp);g_free (tmp);break ; }case QTYPE_QSTRING : {QString *value =qobject_to (QString, obj); -func_fprintf (f,"%s" ,qstring_get_str (value)); +qemu_printf ("%s" ,qstring_get_str (value));break ; }case QTYPE_QDICT : {QDict *value =qobject_to (QDict, obj); -dump_qdict (func_fprintf, f, comp_indent, value); +dump_qdict (comp_indent, value);break ; }case QTYPE_QLIST : {QList *value =qobject_to (QList, obj); -dump_qlist (func_fprintf, f, comp_indent, value); +dump_qlist (comp_indent, value);break ; }case QTYPE_QBOOL : {QBool *value =qobject_to (QBool, obj); -func_fprintf (f,"%s" ,qbool_get_bool (value) ?"true" :"false" ); +qemu_printf ("%s" ,qbool_get_bool (value) ?"true" :"false" );break ; }default :@@ -735,8 +730,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f, } } -static void dump_qlist (fprintf_function func_fprintf,void *f,int indentation, -QList *list) +static void dump_qlist (int indentation,QList *list) {const QListEntry *entry;int i =0 ;@@ -744,17 +738,16 @@ static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,for (entry =qlist_first (list); entry; entry =qlist_next (entry), i++) {QType type =qobject_type (entry->value);bool composite = (type ==QTYPE_QDICT || type ==QTYPE_QLIST ); -func_fprintf (f,"%*s[%i]:%c" , indentation *4 ,"" , i, - composite ?'\n' :' ' ); -dump_qobject (func_fprintf, f, indentation +1 , entry->value); +qemu_printf ("%*s[%i]:%c" , indentation *4 ,"" , i, + composite ?'\n' :' ' ); +dump_qobject (indentation +1 , entry->value);if (!composite) { -func_fprintf (f,"\n" ); +qemu_printf ("\n" ); } } } -static void dump_qdict (fprintf_function func_fprintf,void *f,int indentation, -QDict *dict) +static void dump_qdict (int indentation,QDict *dict) {const QDictEntry *entry;@@ -769,18 +762,17 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, key[i] = entry->key[i] =='-' ?' ' : entry->key[i]; } key[i] =0 ; -func_fprintf (f,"%*s%s:%c" , indentation *4 ,"" , key, - composite ?'\n' :' ' ); -dump_qobject (func_fprintf, f, indentation +1 , entry->value); +qemu_printf ("%*s%s:%c" , indentation *4 ,"" , key, + composite ?'\n' :' ' ); +dump_qobject (indentation +1 , entry->value);if (!composite) { -func_fprintf (f,"\n" ); +qemu_printf ("\n" ); }g_free (key); } } -void bdrv_image_info_specific_dump (fprintf_function func_fprintf,void *f, -ImageInfoSpecific *info_spec) +void bdrv_image_info_specific_dump (ImageInfoSpecific *info_spec) {QObject *obj, *data;Visitor *v =qobject_output_visitor_new (&obj);@@ -788,13 +780,12 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,visit_type_ImageInfoSpecific (v,NULL , &info_spec, &error_abort);visit_complete (v, &obj); data =qdict_get (qobject_to (QDict, obj),"data" ); -dump_qobject (func_fprintf, f,1 , data); +dump_qobject (1 , data);qobject_unref (obj);visit_free (v); } -void bdrv_image_info_dump (fprintf_function func_fprintf,void *f, -ImageInfo *info) +void bdrv_image_info_dump (ImageInfo *info) {char size_buf[128 ], dsize_buf[128 ];if (!info->has_actual_size) {@@ -804,49 +795,48 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, info->actual_size); }get_human_readable_size (size_buf,sizeof (size_buf), info->virtual_size); -func_fprintf (f, -"image: %s\n" -"file format: %s\n" -"virtual size: %s (%" PRId64" bytes)\n" -"disk size: %s\n" , - info->filename, info->format, size_buf, - info->virtual_size, - dsize_buf); +qemu_printf ("image: %s\n" +"file format: %s\n" +"virtual size: %s (%" PRId64" bytes)\n" +"disk size: %s\n" , + info->filename, info->format, size_buf, + info->virtual_size, + dsize_buf);if (info->has_encrypted && info->encrypted) { -func_fprintf (f,"encrypted: yes\n" ); +qemu_printf ("encrypted: yes\n" ); }if (info->has_cluster_size) { -func_fprintf (f,"cluster_size: %" PRId64"\n" , - info->cluster_size); +qemu_printf ("cluster_size: %" PRId64"\n" , + info->cluster_size); }if (info->has_dirty_flag && info->dirty_flag) { -func_fprintf (f,"cleanly shut down: no\n" ); +qemu_printf ("cleanly shut down: no\n" ); }if (info->has_backing_filename) { -func_fprintf (f,"backing file: %s" , info->backing_filename); +qemu_printf ("backing file: %s" , info->backing_filename);if (!info->has_full_backing_filename) { -func_fprintf (f," (cannot determine actual path)" ); +qemu_printf (" (cannot determine actual path)" ); }else if (strcmp (info->backing_filename, info->full_backing_filename) !=0 ) { -func_fprintf (f," (actual path: %s)" , info->full_backing_filename); +qemu_printf (" (actual path: %s)" , info->full_backing_filename); } -func_fprintf (f,"\n" ); +qemu_printf ("\n" );if (info->has_backing_filename_format) { -func_fprintf (f,"backing file format: %s\n" , - info->backing_filename_format); +qemu_printf ("backing file format: %s\n" , + info->backing_filename_format); } }if (info->has_snapshots) {SnapshotInfoList *elem; -func_fprintf (f,"Snapshot list:\n" ); -bdrv_snapshot_dump (func_fprintf, f,NULL ); -func_fprintf (f,"\n" ); +qemu_printf ("Snapshot list:\n" ); +bdrv_snapshot_dump (NULL ); +qemu_printf ("\n" );/* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but * we convert to the block layer's native QEMUSnapshotInfo for now. @@ -862,13 +852,13 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f,pstrcpy (sn.id_str,sizeof (sn.id_str), elem->value->id);pstrcpy (sn.name,sizeof (sn.name), elem->value->name); -bdrv_snapshot_dump (func_fprintf, f, &sn); -func_fprintf (f,"\n" ); +bdrv_snapshot_dump (&sn); +qemu_printf ("\n" ); } }if (info->has_format_specific) { -func_fprintf (f,"Format specific information:\n" ); -bdrv_image_info_specific_dump (func_fprintf, f, info->format_specific); +qemu_printf ("Format specific information:\n" ); +bdrv_image_info_specific_dump (info->format_specific); } }hmp.c +5
-7@@ -580,8 +580,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,monitor_printf (mon,"\nImages:\n" ); image_info = inserted->image;while (1 ) { -bdrv_image_info_dump ((fprintf_function )monitor_printf, - mon, image_info); +bdrv_image_info_dump (image_info);if (image_info->has_backing_image) { image_info = image_info->backing_image; }else {@@ -1586,7 +1585,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)monitor_printf (mon,"List of snapshots present on all disks:\n" );if (total >0 ) { -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon,NULL ); +bdrv_snapshot_dump (NULL );monitor_printf (mon,"\n" );for (i =0 ; i < total; i++) { sn = &sn_tab[global_snapshots[i]];@@ -1594,7 +1593,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)* overwrite it. */ pstrcpy (sn->id_str,sizeof (sn->id_str),"--" ); -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon, sn); +bdrv_snapshot_dump (sn);monitor_printf (mon,"\n" ); } }else {@@ -1608,11 +1607,10 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)monitor_printf (mon,"\nList of partial (non-loadable) snapshots on '%s':\n" , image_entry->imagename); -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon,NULL ); +bdrv_snapshot_dump (NULL );monitor_printf (mon,"\n" ); QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) { -bdrv_snapshot_dump ((fprintf_function )monitor_printf, mon, - &snapshot_entry->sn); +bdrv_snapshot_dump (&snapshot_entry->sn);monitor_printf (mon,"\n" ); } }include/block/qapi.h +3
-7@@ -27,7 +27,6 @@#include "block/block.h" #include "block/snapshot.h" -#include "qemu/fprintf-fn.h" BlockDeviceInfo *bdrv_block_device_info (BlockBackend *blk,BlockDriverState *bs,Error **errp);@@ -38,10 +37,7 @@ void bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, Error **errp); -void bdrv_snapshot_dump (fprintf_function func_fprintf,void *f, -QEMUSnapshotInfo *sn); -void bdrv_image_info_specific_dump (fprintf_function func_fprintf,void *f, -ImageInfoSpecific *info_spec); -void bdrv_image_info_dump (fprintf_function func_fprintf,void *f, -ImageInfo *info); +void bdrv_snapshot_dump (QEMUSnapshotInfo *sn); +void bdrv_image_info_specific_dump (ImageInfoSpecific *info_spec); +void bdrv_image_info_dump (ImageInfo *info);#endif qemu-img.c +3
-3@@ -2483,11 +2483,11 @@ static void dump_snapshots(BlockDriverState *bs)if (nb_sns <=0 )return ;printf ("Snapshot list:\n" ); -bdrv_snapshot_dump (fprintf, stdout,NULL ); +bdrv_snapshot_dump (NULL );printf ("\n" );for (i =0 ; i < nb_sns; i++) { sn = &sn_tab[i]; -bdrv_snapshot_dump (fprintf, stdout, sn); +bdrv_snapshot_dump (sn);printf ("\n" ); }g_free (sn_tab);@@ -2536,7 +2536,7 @@ static void dump_human_image_info_list(ImageInfoList *list) } delim = true; -bdrv_image_info_dump (fprintf, stdout, elem->value); +bdrv_image_info_dump (elem->value); } }qemu-io-cmds.c +1
-1@@ -1699,7 +1699,7 @@ static int info_f(BlockBackend *blk, int argc, char **argv) }if (spec_info) {printf ("Format specific information:\n" ); -bdrv_image_info_specific_dump (fprintf, stdout, spec_info); +bdrv_image_info_specific_dump (spec_info);qapi_free_ImageInfoSpecific (spec_info); }Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 8/17 memory: Clean up how mtree_info() prints
In reply to Markus Armbrusterdump_drift_info() takes an fprintf()-like callback and a FILE * to pass to it, and so do its helper functions. Passing around callback and argument is rather tiresome.
Its only caller hmp_info_mtree() passes monitor_printf() cast to fprintf_function and the current monitor cast to FILE *.
The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead.
--- exec.c | 40 ++++----- include/exec/memory-internal.h | 3 +- include/exec/memory.h | 3 +- memory.c | 156 ++++++++++++++++----------------- monitor.c | 3 +- 5 files changed, 98 insertions(+), 107 deletions(-)
exec.c +20 -20
@@ -35,6 +35,7 @@#include "qemu/timer.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #if defined(CONFIG_USER_ONLY )#include "qemu.h" #else /* !CONFIG_USER_ONLY */
@@ -4117,42 +4118,41 @@ void page_size_init(void)#if !defined(CONFIG_USER_ONLY ) -static void mtree_print_phys_entries (fprintf_function mon,void *f, -int start,int end,int skip,int ptr) +static void mtree_print_phys_entries (int start,int end,int skip,int ptr) {if (start == end -1 ) { -mon (f,"\t%3d " , start); +qemu_printf ("\t%3d " , start); }else { -mon (f,"\t%3d..%-3d " , start, end -1 ); +qemu_printf ("\t%3d..%-3d " , start, end -1 ); } -mon (f," skip=%d " , skip); +qemu_printf (" skip=%d " , skip);if (ptr ==PHYS_MAP_NODE_NIL ) { -mon (f," ptr=NIL" ); +qemu_printf (" ptr=NIL" ); }else if (!skip) { -mon (f," ptr=#%d" , ptr); +qemu_printf (" ptr=#%d" , ptr); }else { -mon (f," ptr=[%d]" , ptr); +qemu_printf (" ptr=[%d]" , ptr); } -mon (f,"\n" ); +qemu_printf ("\n" ); }#define MR_SIZE (size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0) -void mtree_print_dispatch (fprintf_function mon,void *f, -AddressSpaceDispatch *d,MemoryRegion *root) +void mtree_print_dispatch (AddressSpaceDispatch *d,MemoryRegion *root) {int i; -mon (f," Dispatch\n" ); -mon (f," Physical sections\n" ); +qemu_printf (" Dispatch\n" ); +qemu_printf (" Physical sections\n" );for (i =0 ; i < d->map.sections_nb; ++i) {MemoryRegionSection *s = d->map.sections + i;const char *names[] = {" [unassigned]" ," [not dirty]" ," [ROM]" ," [watch]" }; - mon(f, " #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx " %s%s%s%s%s", + qemu_printf(" #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx + " %s%s%s%s%s", i, s->offset_within_address_space, s->offset_within_address_space + MR_SIZE(s->mr->size),
@@ -4163,20 +4163,20 @@ void mtree_print_dispatch(fprintf_function mon, void *f, s->mr->is_iommu ? " [iommu]" : "");if (s->mr->alias) { -mon (f," alias=%s" , s->mr->alias->name ? +qemu_printf (" alias=%s" , s->mr->alias->name ? s->mr->alias->name :"noname" ); } -mon (f,"\n" ); +qemu_printf ("\n" ); } -mon (f," Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\n" , +qemu_printf (" Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\n" ,P_L2_BITS ,P_L2_LEVELS , d->phys_map.ptr, d->phys_map.skip);for (i =0 ; i < d->map.nodes_nb; ++i) {int j, jprev;PhysPageEntry prev;Node *n = d->map.nodes + i; -mon (f," [%d]\n" , i); +qemu_printf (" [%d]\n" , i);for (j =0 , jprev =0 , prev = *n[0 ]; j <ARRAY_SIZE (*n); ++j) {PhysPageEntry *pe = *n + j;
@@ -4185,14 +4185,14 @@ void mtree_print_dispatch(fprintf_function mon, void *f,continue ; } -mtree_print_phys_entries (mon, f, jprev, j, prev.skip, prev.ptr); +mtree_print_phys_entries (jprev, j, prev.skip, prev.ptr); jprev = j; prev = *pe; }if (jprev !=ARRAY_SIZE (*n)) { -mtree_print_phys_entries (mon, f, jprev, j, prev.skip, prev.ptr); +mtree_print_phys_entries (jprev, j, prev.skip, prev.ptr); } } }
include/exec/memory-internal.h +1 -2
@@ -45,8 +45,7 @@ AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);void address_space_dispatch_compact (AddressSpaceDispatch *d);void address_space_dispatch_free (AddressSpaceDispatch *d); -void mtree_print_dispatch (fprintf_function mon,void *f, -struct AddressSpaceDispatch *d, +void mtree_print_dispatch (struct AddressSpaceDispatch *d,MemoryRegion *root);struct page_collection ;
include/exec/memory.h +1 -2
@@ -1720,8 +1720,7 @@ void memory_global_dirty_log_start(void);*/ void memory_global_dirty_log_stop (void ); -void mtree_info (fprintf_function mon_printf,void *f,bool flatview, -bool dispatch_tree,bool owner); +void mtree_info (bool flatview,bool dispatch_tree,bool owner);/** * memory_region_dispatch_read: perform a read directly to the specified
memory.c +75 -81
293 lines not on this page · raw message
monitor.c +1 -2
@@ -1907,8 +1907,7 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict)bool dispatch_tree =qdict_get_try_bool (qdict,"dispatch_tree" , false);bool owner =qdict_get_try_bool (qdict,"owner" , false); -mtree_info ((fprintf_function )monitor_printf, mon, flatview, dispatch_tree, - owner); +mtree_info (flatview, dispatch_tree, owner); }static void hmp_info_numa (Monitor *mon,const QDict *qdict)
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 08/17] memory: Clean up how mtree_info() prints
Quoted 1 line · * Markus Armbruster ([email protected]) wrote:
dump_drift_info()takes an fprintf()-like callback and a FILE * to
^^^^^^^^^^^^^^^^^^^ looks like the wrong function for this patch?
Quoted 11 lines
pass to it, and so do its helper functions. Passing around callback and argument is rather tiresome.
Its only caller
hmp_info_mtree()passesmonitor_printf()cast tofprintf_functionand the current monitor cast to FILE *.The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Other than the function name above,
Quoted 471 lines
--- exec.c | 40 ++++----- include/exec/memory-internal.h | 3 +- include/exec/memory.h | 3 +- memory.c | 156 ++++++++++++++++----------------- monitor.c | 3 +- 5 files changed, 98 insertions(+), 107 deletions(-)exec.c +20
-20@@ -35,6 +35,7 @@#include "qemu/timer.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #if defined(CONFIG_USER_ONLY )#include "qemu.h" #else /* !CONFIG_USER_ONLY */ @@ -4117,42 +4118,41 @@ void page_size_init(void)#if !defined(CONFIG_USER_ONLY ) -static void mtree_print_phys_entries (fprintf_function mon,void *f, -int start,int end,int skip,int ptr) +static void mtree_print_phys_entries (int start,int end,int skip,int ptr) {if (start == end -1 ) { -mon (f,"\t%3d " , start); +qemu_printf ("\t%3d " , start); }else { -mon (f,"\t%3d..%-3d " , start, end -1 ); +qemu_printf ("\t%3d..%-3d " , start, end -1 ); } -mon (f," skip=%d " , skip); +qemu_printf (" skip=%d " , skip);if (ptr ==PHYS_MAP_NODE_NIL ) { -mon (f," ptr=NIL" ); +qemu_printf (" ptr=NIL" ); }else if (!skip) { -mon (f," ptr=#%d" , ptr); +qemu_printf (" ptr=#%d" , ptr); }else { -mon (f," ptr=[%d]" , ptr); +qemu_printf (" ptr=[%d]" , ptr); } -mon (f,"\n" ); +qemu_printf ("\n" ); }#define MR_SIZE (size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0) -void mtree_print_dispatch (fprintf_function mon,void *f, -AddressSpaceDispatch *d,MemoryRegion *root) +void mtree_print_dispatch (AddressSpaceDispatch *d,MemoryRegion *root) {int i; -mon (f," Dispatch\n" ); -mon (f," Physical sections\n" ); +qemu_printf (" Dispatch\n" ); +qemu_printf (" Physical sections\n" );for (i =0 ; i < d->map.sections_nb; ++i) {MemoryRegionSection *s = d->map.sections + i;const char *names[] = {" [unassigned]" ," [not dirty]" ," [ROM]" ," [watch]" }; - mon(f, " #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx " %s%s%s%s%s", + qemu_printf(" #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx + " %s%s%s%s%s", i, s->offset_within_address_space, s->offset_within_address_space + MR_SIZE(s->mr->size),@@ -4163,20 +4163,20 @@ void mtree_print_dispatch(fprintf_function mon, void *f, s->mr->is_iommu ? " [iommu]" : "");if (s->mr->alias) { -mon (f," alias=%s" , s->mr->alias->name ? +qemu_printf (" alias=%s" , s->mr->alias->name ? s->mr->alias->name :"noname" ); } -mon (f,"\n" ); +qemu_printf ("\n" ); } -mon (f," Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\n" , +qemu_printf (" Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\n" ,P_L2_BITS ,P_L2_LEVELS , d->phys_map.ptr, d->phys_map.skip);for (i =0 ; i < d->map.nodes_nb; ++i) {int j, jprev;PhysPageEntry prev;Node *n = d->map.nodes + i; -mon (f," [%d]\n" , i); +qemu_printf (" [%d]\n" , i);for (j =0 , jprev =0 , prev = *n[0 ]; j <ARRAY_SIZE (*n); ++j) {PhysPageEntry *pe = *n + j;@@ -4185,14 +4185,14 @@ void mtree_print_dispatch(fprintf_function mon, void *f,continue ; } -mtree_print_phys_entries (mon, f, jprev, j, prev.skip, prev.ptr); +mtree_print_phys_entries (jprev, j, prev.skip, prev.ptr); jprev = j; prev = *pe; }if (jprev !=ARRAY_SIZE (*n)) { -mtree_print_phys_entries (mon, f, jprev, j, prev.skip, prev.ptr); +mtree_print_phys_entries (jprev, j, prev.skip, prev.ptr); } } }include/exec/memory-internal.h +1
-2@@ -45,8 +45,7 @@ AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);void address_space_dispatch_compact (AddressSpaceDispatch *d);void address_space_dispatch_free (AddressSpaceDispatch *d); -void mtree_print_dispatch (fprintf_function mon,void *f, -struct AddressSpaceDispatch *d, +void mtree_print_dispatch (struct AddressSpaceDispatch *d,MemoryRegion *root);struct page_collection ;include/exec/memory.h +1
-2@@ -1720,8 +1720,7 @@ void memory_global_dirty_log_start(void);*/ void memory_global_dirty_log_stop (void ); -void mtree_info (fprintf_function mon_printf,void *f,bool flatview, -bool dispatch_tree,bool owner); +void mtree_info (bool flatview,bool dispatch_tree,bool owner);/** * memory_region_dispatch_read: perform a read directly to the specified memory.c +75
-81@@ -22,6 +22,7 @@#include "qapi/visitor.h" #include "qemu/bitops.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qom/object.h" #include "trace-root.h" @@ -2800,46 +2801,43 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead; int128_sub((size), int128_one())) : 0)#define MTREE_INDENT " " -static void mtree_expand_owner (fprintf_function mon_printf,void *f, -const char *label,Object *obj) +static void mtree_expand_owner (const char *label,Object *obj) {DeviceState *dev = (DeviceState *)object_dynamic_cast (obj,TYPE_DEVICE ); -mon_printf (f," %s:{%s" , label, dev ?"dev" :"obj" ); +qemu_printf (" %s:{%s" , label, dev ?"dev" :"obj" );if (dev && dev->id) { -mon_printf (f," id=%s" , dev->id); +qemu_printf (" id=%s" , dev->id); }else {gchar *canonical_path =object_get_canonical_path (obj);if (canonical_path) { -mon_printf (f," path=%s" , canonical_path); +qemu_printf (" path=%s" , canonical_path);g_free (canonical_path); }else { -mon_printf (f," type=%s" ,object_get_typename (obj)); +qemu_printf (" type=%s" ,object_get_typename (obj)); } } -mon_printf (f,"}" ); +qemu_printf ("}" ); } -static void mtree_print_mr_owner (fprintf_function mon_printf,void *f, -const MemoryRegion *mr) +static void mtree_print_mr_owner (const MemoryRegion *mr) {Object *owner = mr->owner;Object *parent =memory_region_owner ((MemoryRegion *)mr);if (!owner && !parent) { -mon_printf (f," orphan" ); +qemu_printf (" orphan" );return ; }if (owner) { -mtree_expand_owner (mon_printf, f,"owner" , owner); +mtree_expand_owner ("owner" , owner); }if (parent && parent != owner) { -mtree_expand_owner (mon_printf, f,"parent" , parent); +mtree_expand_owner ("parent" , parent); } } -static void mtree_print_mr (fprintf_function mon_printf,void *f, -const MemoryRegion *mr,unsigned int level, +static void mtree_print_mr (const MemoryRegion *mr,unsigned int level,hwaddr base,MemoryRegionListHead *alias_print_queue,bool owner)@@ -2855,7 +2853,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, }for (i =0 ; i < level; i++) { -mon_printf (f,MTREE_INDENT ); +qemu_printf (MTREE_INDENT ); } cur_start = base + mr->addr;@@ -2867,7 +2865,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,* user who is observing this. */ if (cur_start < base || cur_end < cur_start) { -mon_printf (f,"[DETECTED OVERFLOW!] " ); +qemu_printf ("[DETECTED OVERFLOW!] " ); }if (mr->alias) {@@ -2886,35 +2884,35 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, ml->mr = mr->alias;QTAILQ_INSERT_TAIL (alias_print_queue, ml, mrqueue); } -mon_printf (f, TARGET_FMT_plx"-" TARGET_FMT_plx -" (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx -"-" TARGET_FMT_plx"%s" , - cur_start, cur_end, - mr->priority, - mr->nonvolatile ?"nv-" :"" , -memory_region_type ((MemoryRegion *)mr), -memory_region_name (mr), -memory_region_name (mr->alias), - mr->alias_offset, - mr->alias_offset +MR_SIZE (mr->size), - mr->enabled ?"" :" [disabled]" ); +qemu_printf (TARGET_FMT_plx"-" TARGET_FMT_plx +" (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx +"-" TARGET_FMT_plx"%s" , + cur_start, cur_end, + mr->priority, + mr->nonvolatile ?"nv-" :"" , +memory_region_type ((MemoryRegion *)mr), +memory_region_name (mr), +memory_region_name (mr->alias), + mr->alias_offset, + mr->alias_offset +MR_SIZE (mr->size), + mr->enabled ?"" :" [disabled]" );if (owner) { -mtree_print_mr_owner (mon_printf, f, mr); +mtree_print_mr_owner (mr); } }else { -mon_printf (f, - TARGET_FMT_plx"-" TARGET_FMT_plx" (prio %d, %s%s): %s%s" , - cur_start, cur_end, - mr->priority, - mr->nonvolatile ?"nv-" :"" , -memory_region_type ((MemoryRegion *)mr), -memory_region_name (mr), - mr->enabled ?"" :" [disabled]" ); +qemu_printf (TARGET_FMT_plx"-" TARGET_FMT_plx +" (prio %d, %s%s): %s%s" , + cur_start, cur_end, + mr->priority, + mr->nonvolatile ?"nv-" :"" , +memory_region_type ((MemoryRegion *)mr), +memory_region_name (mr), + mr->enabled ?"" :" [disabled]" );if (owner) { -mtree_print_mr_owner (mon_printf, f, mr); +mtree_print_mr_owner (mr); } } -mon_printf (f,"\n" ); +qemu_printf ("\n" );QTAILQ_INIT (&submr_print_queue);@@ -2936,7 +2934,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, } QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { -mtree_print_mr (mon_printf, f, ml->mr, level +1 , cur_start, +mtree_print_mr (ml->mr, level +1 , cur_start, alias_print_queue, owner); }@@ -2946,8 +2944,6 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, }struct FlatViewInfo { -fprintf_function mon_printf; -void *f;int counter;bool dispatch_tree;bool owner;@@ -2959,70 +2955,71 @@ static void mtree_print_flatview(gpointer key, gpointer value,FlatView *view = key;GArray *fv_address_spaces = value;struct FlatViewInfo *fvi = user_data; -fprintf_function p = fvi->mon_printf; -void *f = fvi->f;FlatRange *range = &view->ranges[0 ];MemoryRegion *mr;int n = view->nr;int i;AddressSpace *as; -p (f,"FlatView #%d\n" , fvi->counter); +qemu_printf ("FlatView #%d\n" , fvi->counter); ++fvi->counter;for (i =0 ; i < fv_address_spaces->len; ++i) { as = g_array_index(fv_address_spaces, AddressSpace*, i); -p (f," AS \"%s\", root: %s" , as->name,memory_region_name (as->root)); +qemu_printf (" AS \"%s\", root: %s" , + as->name,memory_region_name (as->root));if (as->root->alias) { -p (f,", alias %s" ,memory_region_name (as->root->alias)); +qemu_printf (", alias %s" ,memory_region_name (as->root->alias)); } -p (f,"\n" ); +qemu_printf ("\n" ); } -p (f," Root memory region: %s\n" , +qemu_printf (" Root memory region: %s\n" , view->root ?memory_region_name (view->root) :"(none)" );if (n <=0 ) { -p (f,MTREE_INDENT "No rendered FlatView\n\n" ); +qemu_printf (MTREE_INDENT "No rendered FlatView\n\n" );return ; }while (n--) { mr = range->mr;if (range->offset_in_region) { - p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx" (prio %d, %s%s): %s @" TARGET_FMT_plx, -int128_get64 (range->addr.start), -int128_get64 (range->addr.start) +MR_SIZE (range->addr.size), - mr->priority, - range->nonvolatile ?"nv-" :"" , - range->readonly ?"rom" :memory_region_type (mr), -memory_region_name (mr), - range->offset_in_region); + qemu_printf(MTREE_INDENT TARGET_FMT_plx "-" TARGET_FMT_plx +" (prio %d, %s%s): %s @" TARGET_FMT_plx, +int128_get64 (range->addr.start), +int128_get64 (range->addr.start) + +MR_SIZE (range->addr.size), + mr->priority, + range->nonvolatile ?"nv-" :"" , + range->readonly ?"rom" :memory_region_type (mr), +memory_region_name (mr), + range->offset_in_region); }else { - p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx" (prio %d, %s%s): %s" , -int128_get64 (range->addr.start), -int128_get64 (range->addr.start) +MR_SIZE (range->addr.size), - mr->priority, - range->nonvolatile ?"nv-" :"" , - range->readonly ?"rom" :memory_region_type (mr), -memory_region_name (mr)); + qemu_printf(MTREE_INDENT TARGET_FMT_plx "-" TARGET_FMT_plx +" (prio %d, %s%s): %s" , +int128_get64 (range->addr.start), +int128_get64 (range->addr.start) + +MR_SIZE (range->addr.size), + mr->priority, + range->nonvolatile ?"nv-" :"" , + range->readonly ?"rom" :memory_region_type (mr), + memory_region_name(mr)); }if (fvi->owner) { -mtree_print_mr_owner (p, f, mr); +mtree_print_mr_owner (mr); } -p (f,"\n" ); +qemu_printf ("\n" ); range++; }#if !defined(CONFIG_USER_ONLY )if (fvi->dispatch_tree && view->root) { -mtree_print_dispatch (p, f, view->dispatch, view->root); +mtree_print_dispatch (view->dispatch, view->root); }#endif -p (f,"\n" ); +qemu_printf ("\n" ); } static gboolean mtree_info_flatview_free(gpointer key, gpointer value,@@ -3037,8 +3034,7 @@ static gboolean mtree_info_flatview_free(gpointer key, gpointer value,return true; } -void mtree_info (fprintf_function mon_printf,void *f,bool flatview, -bool dispatch_tree,bool owner) +void mtree_info (bool flatview,bool dispatch_tree,bool owner) {MemoryRegionListHead ml_head;MemoryRegionList *ml, *ml2;@@ -3047,8 +3043,6 @@ void mtree_info(fprintf_function mon_printf, void *f, bool flatview,if (flatview) {FlatView *view;struct FlatViewInfo fvi = { - .mon_printf = mon_printf, - .f = f, .counter =0 , .dispatch_tree = dispatch_tree, .owner = owner,@@ -3082,16 +3076,16 @@ void mtree_info(fprintf_function mon_printf, void *f, bool flatview,QTAILQ_INIT (&ml_head); QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -mon_printf (f,"address-space: %s\n" , as->name); -mtree_print_mr (mon_printf, f, as->root,1 ,0 , &ml_head, owner); -mon_printf (f,"\n" ); +qemu_printf ("address-space: %s\n" , as->name); +mtree_print_mr (as->root,1 ,0 , &ml_head, owner); +qemu_printf ("\n" ); }/* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { -mon_printf (f,"memory-region: %s\n" ,memory_region_name (ml->mr)); -mtree_print_mr (mon_printf, f, ml->mr,1 ,0 , &ml_head, owner); -mon_printf (f,"\n" ); +qemu_printf ("memory-region: %s\n" ,memory_region_name (ml->mr)); +mtree_print_mr (ml->mr,1 ,0 , &ml_head, owner); +qemu_printf ("\n" ); } QTAILQ_FOREACH_SAFE(ml, &ml_head, mrqueue, ml2) {monitor.c +1
-2@@ -1907,8 +1907,7 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict)bool dispatch_tree =qdict_get_try_bool (qdict,"dispatch_tree" , false);bool owner =qdict_get_try_bool (qdict,"owner" , false); -mtree_info ((fprintf_function )monitor_printf, mon, flatview, dispatch_tree, - owner); +mtree_info (flatview, dispatch_tree, owner); }static void hmp_info_numa (Monitor *mon,const QDict *qdict)Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 08/17] memory: Clean up how mtree_info() prints
Quoted 4 lines · Dr. David Alan Gilbert
Quoted 1 line · * Markus Armbruster ([email protected]) wrote:
dump_drift_info()takes an fprintf()-like callback and a FILE * to^^^^^^^^^^^^^^^^^^^ looks like the wrong function for this patch?
Pasto, will fix.
Quoted 10 lines
Quoted 10 lines
pass to it, and so do its helper functions. Passing around callback and argument is rather tiresome.
Its only caller
hmp_info_mtree()passesmonitor_printf()cast tofprintf_functionand the current monitor cast to FILE *.The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call
qemu_printf()instead.
Quoted 6 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>Other than the function name above,
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks!
PATCH 9/17 target: Simplify how the TARGET_cpu_list() print
In reply to Markus ArmbrusterThe various TARGET_cpu_list() take an fprintf()-like callback and a FILE * to pass to it. Their callers (vl.c's main() via list_cpus(), bsd-user/main.c's main(), linux-user/main.c's main()) all pass fprintf() and stdout. Thus, the flexibility provided by the (rather tiresome) indirection isn't actually used.
Drop the callback, and call qemu_fprintf() instead.
Calling printf() would also work, but would make the code unsuitable for monitor context without making it simpler.
--- bsd-user/main.c | 2 +- cpus.c | 4 +-- include/exec/cpu-common.h | 13 --------- include/sysemu/cpus.h | 3 +- linux-user/main.c | 2 +- target/alpha/cpu.c | 15 ++++------ target/alpha/cpu.h | 2 +- target/arm/cpu.c | 1 - target/arm/cpu.h | 2 +- target/arm/helper.c | 15 ++++------ target/cris/cpu.c | 14 ++++----- target/cris/cpu.h | 2 +- target/hppa/cpu.c | 14 ++++----- target/hppa/cpu.h | 2 +- target/i386/cpu.c | 29 ++++++++----------- target/i386/cpu.h | 2 +- target/lm32/cpu.c | 14 ++++----- target/lm32/cpu.h | 2 +- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 14 +++------ target/mips/cpu.h | 2 +- target/mips/translate.c | 1 + target/mips/translate_init.inc.c | 5 ++-- target/openrisc/cpu.c | 15 ++++------ target/openrisc/cpu.h | 2 +- target/ppc/cpu.h | 2 +- target/ppc/translate_init.inc.c | 26 +++++++---------- target/riscv/cpu.c | 17 +++-------- target/riscv/cpu.h | 2 +- target/s390x/cpu.h | 2 +- target/s390x/cpu_models.c | 21 ++++++-------- target/sh4/cpu.c | 17 +++-------- target/sh4/cpu.h | 2 +- target/sparc/cpu.c | 49 +++++++++++++++----------------- target/sparc/cpu.h | 2 +- target/tricore/cpu.h | 2 +- target/tricore/helper.c | 15 ++++------ target/xtensa/cpu.h | 2 +- target/xtensa/helper.c | 7 +++-- vl.c | 2 +- 40 files changed, 129 insertions(+), 218 deletions(-)
bsd-user/main.c +1 -1
@@ -817,7 +817,7 @@ int main(int argc, char **argv)if (is_help_option (cpu_model)) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (stdout, &fprintf); +cpu_list ();#endif exit (1 ); }
cpus.c +2 -2
@@ -2181,11 +2181,11 @@ int vm_stop_force_state(RunState state) } } -void list_cpus (FILE *f,fprintf_function cpu_fprintf,const char *optarg) +void list_cpus (const char *optarg) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (f, cpu_fprintf); +cpu_list ();#endif }
include/exec/cpu-common.h +0 -13
@@ -9,19 +9,6 @@#include "qemu/bswap.h" #include "qemu/queue.h" -#include "qemu/fprintf-fn.h" - -/** -* CPUListState: -* @cpu_fprintf: Print function. -* @file: File to print to using @cpu_fprint. -* -* State commonly used for iterating over CPU models. -*/ -typedef struct CPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}CPUListState ;/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ void qemu_init_cpu_list (void );
include/sysemu/cpus.h +1 -2
@@ -1,7 +1,6 @@#ifndef QEMU_CPUS_H #define QEMU_CPUS_H -#include "qemu/fprintf-fn.h" #include "qemu/timer.h" /* cpus.c */
@@ -39,7 +38,7 @@ extern int smp_cores;extern int smp_threads;#endif -void list_cpus (FILE *f,fprintf_function cpu_fprintf,const char *optarg); +void list_cpus (const char *optarg);void qemu_tcg_configure (QemuOpts *opts,Error **errp);
linux-user/main.c +1 -1
@@ -316,7 +316,7 @@ static void handle_arg_cpu(const char *arg)if (cpu_model ==NULL ||is_help_option (cpu_model)) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (stdout, &fprintf); +cpu_list ();#endif exit (EXIT_FAILURE ); }
target/alpha/cpu.c +5 -10
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h"
@@ -74,23 +75,17 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)static void alpha_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data; - (*s->cpu_fprintf)(s->file," %s\n" , -object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); } -void alpha_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void alpha_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_ALPHA_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, alpha_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, alpha_cpu_list_entry,NULL );g_slist_free (list); }
target/alpha/cpu.h +1 -1
@@ -470,7 +470,7 @@ void alpha_translate_init(void);#define ALPHA_CPU_TYPE_NAME (model) model ALPHA_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU -void alpha_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void alpha_cpu_list (void );/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target/arm/cpu.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/osdep.h" #include "target/arm/idau.h" -#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "cpu.h"
target/arm/cpu.h +1 -1
@@ -1936,7 +1936,7 @@ static inline bool access_secure_reg(CPUARMState *env) (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \ (_val)) -void arm_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void arm_cpu_list (void );uint32_t arm_phys_excp_target_el (CPUState *cs,uint32_t excp_idx,uint32_t cur_el,bool secure);
target/arm/helper.c +5 -10
@@ -10,6 +10,7 @@#include "sysemu/sysemu.h" #include "qemu/bitops.h" #include "qemu/crc32c.h" +#include "qemu/qemu-print.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "arm_ldst.h"
@@ -6724,29 +6725,23 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)static void arm_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_ARM_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void arm_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void arm_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_ARM_CPU , false); list =g_slist_sort (list, arm_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, arm_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, arm_cpu_list_entry,NULL );g_slist_free (list); }
target/cris/cpu.c +5 -9
@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "mmu.h"
@@ -103,27 +104,22 @@ static gint cris_cpu_list_compare(gconstpointer a, gconstpointer b)static void cris_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename =object_class_get_name (oc);char *name; name =g_strndup (typename,strlen (typename) -strlen (CRIS_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file," %s\n" , name); +qemu_printf (" %s\n" , name);g_free (name); } -void cris_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void cris_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_CRIS_CPU , false); list =g_slist_sort (list, cris_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, cris_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, cris_cpu_list_entry,NULL );g_slist_free (list); }
target/cris/cpu.h +1 -1
@@ -308,6 +308,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc, }#define cpu_list cris_cpu_list -void cris_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void cris_cpu_list (void );#endif
target/hppa/cpu.c +5 -9
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h"
@@ -113,22 +114,17 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)static void hppa_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data; - (*s->cpu_fprintf)(s->file," %s\n" ,object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); } -void hppa_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void hppa_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_HPPA_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, hppa_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, hppa_cpu_list_entry,NULL );g_slist_free (list); }
target/hppa/cpu.h +1 -1
@@ -272,7 +272,7 @@ void hppa_translate_init(void);#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU -void hppa_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void hppa_cpu_list (void );static inline target_ulong hppa_form_gva_psw (target_ureg psw,uint64_t spc,target_ureg off)
target/i386/cpu.c +12 -17
@@ -21,6 +21,7 @@#include "qemu/units.h" #include "qemu/cutils.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h"
@@ -3671,7 +3672,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,/* Print all cpuid feature names in featureset */ -static void listflags (FILE *f,fprintf_function print,GList *features) +static void listflags (GList *features) {size_t len =0 ;GList *tmp;
@@ -3679,13 +3680,13 @@ static void listflags(FILE *f, fprintf_function print, GList *features)for (tmp = features; tmp; tmp = tmp->next) {const char *name = tmp->data;if ((len +strlen (name) +1 ) >=75 ) { -"\n" ); +qemu_printf ("\n" ); len =0 ; } -"%s%s" , len ==0 ?" " :" " , name); +qemu_printf ("%s%s" , len ==0 ?" " :" " , name); len +=strlen (name) +1 ; } -"\n" ); +qemu_printf ("\n" ); }/* Sort alphabetically by type name, respecting X86CPUClass::ordering. */
@@ -3721,32 +3722,26 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data) {ObjectClass *oc = data;X86CPUClass *cc =X86_CPU_CLASS (oc); -CPUListState *s = user_data;char *name =x86_cpu_class_get_model_name (cc);const char *desc = cc->model_description;if (!desc && cc->cpu_def) { desc = cc->cpu_def->model_id; } - (*s->cpu_fprintf)(s->file,"x86 %-20s %-48s\n" , - name, desc); +qemu_printf ("x86 %-20s %-48s\n" , name, desc);g_free (name); }/* list available CPU models and flags */ -void x86_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void x86_cpu_list (void ) {int i, j; -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list;GList *names =NULL ; - (*cpu_fprintf)(f,"Available CPUs:\n" ); +qemu_printf ("Available CPUs:\n" ); list =get_sorted_cpu_model_list (); -g_slist_foreach (list, x86_cpu_list_entry, &s); +g_slist_foreach (list, x86_cpu_list_entry,NULL );g_slist_free (list); names =NULL ;
@@ -3761,9 +3756,9 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) names =g_list_sort (names, (GCompareFunc )strcmp); - (*cpu_fprintf)(f,"\nRecognized CPUID flags:\n" ); -listflags (f, cpu_fprintf, names); - (*cpu_fprintf)(f,"\n" ); +qemu_printf ("\nRecognized CPUID flags:\n" ); +listflags (names); +qemu_printf ("\n" );g_list_free (names); }
target/i386/cpu.h +1 -1
@@ -1532,7 +1532,7 @@ int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void x86_cpu_exec_enter (CPUState *cpu);void x86_cpu_exec_exit (CPUState *cpu); -void x86_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void x86_cpu_list (void );int cpu_x86_support_mca_broadcast (CPUX86State *env);int cpu_get_pic_interrupt (CPUX86State *s);
target/lm32/cpu.c +5 -9
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h"
@@ -34,27 +35,22 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value)static void lm32_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename =object_class_get_name (oc);char *name; name =g_strndup (typename,strlen (typename) -strlen (LM32_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file," %s\n" , name); +qemu_printf (" %s\n" , name);g_free (name); } -void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void lm32_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_LM32_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, lm32_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, lm32_cpu_list_entry,NULL );g_slist_free (list); }
target/lm32/cpu.h +1 -1
@@ -243,7 +243,7 @@ static inline lm32_wp_t lm32_wp_type(uint32_t dc, int idx)is returned if the signal was handled by the virtual CPU. */ int cpu_lm32_signal_handler (int host_signum,void *pinfo,void *puc); -void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void lm32_cpu_list (void );void lm32_translate_init (void );void cpu_lm32_set_phys_msb_ignore (CPULM32State *env,int value); void QEMU_NORETURN raise_exception(CPULM32State *env, int index);
target/m68k/cpu.h +1 -1
@@ -499,7 +499,7 @@ static inline int m68k_feature(CPUM68KState *env, int feature)return (env->features & (1u << feature)) !=0 ; } -void m68k_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void m68k_cpu_list (void );void register_m68k_insns (CPUM68KState *env);
target/m68k/helper.c +4 -10
@@ -22,9 +22,9 @@#include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "exec/helper-proto.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" #define SIGNBIT (1u << 31)
@@ -49,28 +49,22 @@ static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)static void m68k_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *c = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (c); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_M68K_CPU )); - (*s->cpu_fprintf)(s->file,"%s\n" , - name); +qemu_printf ("%s\n" , name);g_free (name); } -void m68k_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void m68k_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_M68K_CPU , false); list =g_slist_sort (list, m68k_cpu_list_compare); -g_slist_foreach (list, m68k_cpu_list_entry, &s); +g_slist_foreach (list, m68k_cpu_list_entry,NULL );g_slist_free (list); }
target/mips/cpu.h +1 -1
@@ -1065,7 +1065,7 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)#define ENV_OFFSET offsetof(MIPSCPU, env) -void mips_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void mips_cpu_list (void );#define cpu_signal_handler cpu_mips_signal_handler#define cpu_list mips_cpu_list
target/mips/translate.c +1 -0
@@ -38,6 +38,7 @@#include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/qemu-print.h" #define MIPS_DEBUG_DISAS 0
target/mips/translate_init.inc.c +2 -3
@@ -835,13 +835,12 @@ const mips_def_t mips_defs[] = };const int mips_defs_number =ARRAY_SIZE (mips_defs); -void mips_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void mips_cpu_list (void ) {int i;for (i =0 ; i <ARRAY_SIZE (mips_defs); i++) { - (*cpu_fprintf)(f,"MIPS '%s'\n" , - mips_defs[i].name); +qemu_printf ("MIPS '%s'\n" , mips_defs[i].name); } }
target/openrisc/cpu.c +5 -10
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h"
@@ -180,30 +181,24 @@ static gint openrisc_cpu_list_compare(gconstpointer a, gconstpointer b)static void openrisc_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_OPENRISC_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf) +void cpu_openrisc_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_OPENRISC_CPU , false); list =g_slist_sort (list, openrisc_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, openrisc_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, openrisc_cpu_list_entry,NULL );g_slist_free (list); }
target/openrisc/cpu.h +1 -1
@@ -336,7 +336,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)#define ENV_OFFSET offsetof(OpenRISCCPU, env) -void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf); +void cpu_openrisc_list (void );void openrisc_cpu_do_interrupt (CPUState *cpu);bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f,
target/ppc/cpu.h +1 -1
@@ -1308,7 +1308,7 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong value);#endif /* !defined(CONFIG_USER_ONLY) */ void ppc_store_msr (CPUPPCState *env,target_ulong value); -void ppc_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void ppc_cpu_list (void );/* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS
target/ppc/translate_init.inc.c +10 -16
@@ -28,6 +28,7 @@#include "mmu-hash32.h" #include "mmu-hash64.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/error.h" #include "qapi/qmp/qnull.h" #include "qapi/visitor.h"
@@ -10215,7 +10216,6 @@ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b)static void ppc_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc);DeviceClass *family =DEVICE_CLASS (ppc_cpu_get_family_class (pcc));const char *typename =object_class_get_name (oc);
@@ -10228,8 +10228,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data) name =g_strndup (typename,strlen (typename) -strlen (POWERPC_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file,"PowerPC %-16s PVR %08x\n" , - name, pcc->pvr); +qemu_printf ("PowerPC %-16s PVR %08x\n" , name, pcc->pvr);for (i =0 ; ppc_cpu_aliases[i].alias !=NULL ; i++) {PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];ObjectClass *alias_oc =ppc_cpu_class_by_name (alias->model);
@@ -10242,33 +10241,28 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)* avoid printing the wrong alias here and use "preferred" instead */ if (strcmp (alias->alias, family->desc) ==0 ) { - (*s->cpu_fprintf)(s->file, -"PowerPC %-16s (alias for preferred %s CPU)\n" , - alias->alias, family->desc); +qemu_printf ("PowerPC %-16s (alias for preferred %s CPU)\n" , + alias->alias, family->desc); }else { - (*s->cpu_fprintf)(s->file,"PowerPC %-16s (alias for %s)\n" , - alias->alias, name); +qemu_printf ("PowerPC %-16s (alias for %s)\n" , + alias->alias, name); } }g_free (name); } -void ppc_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void ppc_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_POWERPC_CPU , false); list =g_slist_sort (list, ppc_cpu_list_compare); -g_slist_foreach (list, ppc_cpu_list_entry, &s); +g_slist_foreach (list, ppc_cpu_list_entry,NULL );g_slist_free (list);#ifdef CONFIG_KVM -cpu_fprintf (f,"\n" ); -cpu_fprintf (f,"PowerPC %-16s\n" ,"host" ); +qemu_printf ("\n" ); +qemu_printf ("PowerPC %-16s\n" ,"host" );#endif }
target/riscv/cpu.c +4 -13
@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h"
@@ -383,11 +384,6 @@ char *riscv_isa_string(RISCVCPU *cpu)return isa_str; } -typedef struct RISCVCPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}RISCVCPUListState ; -static gint riscv_cpu_list_compare (gconstpointer a,gconstpointer b) {ObjectClass *class_a = (ObjectClass *)a;
@@ -401,24 +397,19 @@ static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)static void riscv_cpu_list_entry (gpointer data,gpointer user_data) { -RISCVCPUListState *s = user_data;const char *typename =object_class_get_name (OBJECT_CLASS (data));int len =strlen (typename) -strlen (RISCV_CPU_TYPE_SUFFIX ); - (*s->cpu_fprintf)(s->file,"%.*s\n" , len, typename); +qemu_printf ("%.*s\n" , len, typename); } -void riscv_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void riscv_cpu_list (void ) { -RISCVCPUListState s = { - .cpu_fprintf = cpu_fprintf, - .file = f, - };GSList *list; list =object_class_get_list (TYPE_RISCV_CPU , false); list =g_slist_sort (list, riscv_cpu_list_compare); -g_slist_foreach (list, riscv_cpu_list_entry, &s); +g_slist_foreach (list, riscv_cpu_list_entry,NULL );g_slist_free (list); }
target/riscv/cpu.h +1 -1
@@ -264,7 +264,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,int riscv_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);char *riscv_isa_string (RISCVCPU *cpu); -void riscv_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void riscv_cpu_list (void );#define cpu_signal_handler riscv_cpu_signal_handler#define cpu_list riscv_cpu_list
target/s390x/cpu.h +1 -1
@@ -753,7 +753,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)/* cpu_models.c */ -void s390_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void s390_cpu_list (void );#define cpu_list s390_cpu_listvoid s390_set_qemu_cpu_model (uint16_t type,uint8_t gen,uint8_t ec_ga,const S390FeatInit feat_init);
target/s390x/cpu_models.c +8 -13
@@ -18,6 +18,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qmp/qdict.h"
@@ -308,7 +309,6 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,static void s390_print_cpu_model_list_entry (gpointer data,gpointer user_data) { -CPUListState *s = user_data;const S390CPUClass *scc =S390_CPU_CLASS ((ObjectClass *)data);char *name =g_strdup (object_class_get_name ((ObjectClass *)data));const char *details ="" ;
@@ -321,8 +321,7 @@ static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data)/* strip off the -s390x-cpu */ g_strrstr (name,"-" TYPE_S390_CPU )[0 ] =0 ; - (*s->cpu_fprintf)(s->file,"s390 %-15s %-35s %s\n" , name, scc->desc, - details); +qemu_printf ("s390 %-15s %-35s %s\n" , name, scc->desc, details);g_free (name); }
@@ -360,33 +359,29 @@ static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)return cc_a->is_static ?-1 :1 ; } -void s390_cpu_list (FILE *f,fprintf_function print) +void s390_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = print, - };S390FeatGroup group;S390Feat feat;GSList *list; list =object_class_get_list (TYPE_S390_CPU , false); list =g_slist_sort (list, s390_cpu_list_compare); -g_slist_foreach (list, s390_print_cpu_model_list_entry, &s); +g_slist_foreach (list, s390_print_cpu_model_list_entry,NULL );g_slist_free (list); - (*print)(f,"\nRecognized feature flags:\n" ); +qemu_printf ("\nRecognized feature flags:\n" );for (feat =0 ; feat <S390_FEAT_MAX ; feat++) {const S390FeatDef *def =s390_feat_def (feat); - (*print)(f,"%-20s %-50s\n" , def->name, def->desc); +qemu_printf ("%-20s %-50s\n" , def->name, def->desc); } - (*print)(f,"\nRecognized feature groups:\n" ); +qemu_printf ("\nRecognized feature groups:\n" );for (group =0 ; group <S390_FEAT_GROUP_MAX ; group++) {const S390FeatGroupDef *def =s390_feat_group_def (group); - (*print)(f,"%-20s %-50s\n" , def->name, def->desc); +qemu_printf ("%-20s %-50s\n" , def->name, def->desc); } }
target/sh4/cpu.c +4 -13
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "migration/vmstate.h"
@@ -79,30 +80,20 @@ static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) info->print_insn = print_insn_sh; } -typedef struct SuperHCPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}SuperHCPUListState ; -static void superh_cpu_list_entry (gpointer data,gpointer user_data) { -SuperHCPUListState *s = user_data;const char *typename =object_class_get_name (OBJECT_CLASS (data));int len =strlen (typename) -strlen (SUPERH_CPU_TYPE_SUFFIX ); - (*s->cpu_fprintf)(s->file,"%.*s\n" , len, typename); +qemu_printf ("%.*s\n" , len, typename); } -void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void sh4_cpu_list (void ) { -SuperHCPUListState s = { - .cpu_fprintf = cpu_fprintf, - .file = f, - };GSList *list; list =object_class_get_list_sorted (TYPE_SUPERH_CPU , false); -g_slist_foreach (list, superh_cpu_list_entry, &s); +g_slist_foreach (list, superh_cpu_list_entry,NULL );g_slist_free (list); }
target/sh4/cpu.h +1 -1
@@ -247,7 +247,7 @@ int cpu_sh4_signal_handler(int host_signum, void *pinfo,int superh_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx); -void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void sh4_cpu_list (void );#if !defined(CONFIG_USER_ONLY )void cpu_sh4_invalidate_tlb (CPUSH4State *s); uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
target/sparc/cpu.c +23 -26
77 lines not on this page · raw message
target/sparc/cpu.h +1 -1
@@ -578,7 +578,7 @@ void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;#ifndef NO_CPU_IO_DEFS /* cpu_init.c */ void cpu_sparc_set_id (CPUSPARCState *env,unsigned int cpu); -void sparc_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void sparc_cpu_list (void );/* mmu_helper.c */ int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);
target/tricore/cpu.h +1 -1
@@ -375,7 +375,7 @@ void fpu_set_state(CPUTriCoreState *env);#define MMU_USER_IDX 2 -void tricore_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void tricore_cpu_list (void );#define cpu_signal_handler cpu_tricore_signal_handler#define cpu_list tricore_cpu_list
target/tricore/helper.c +5 -10
@@ -20,6 +20,7 @@#include "cpu.h" #include "exec/exec-all.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" enum {TLBRET_DIRTY =-4 ,
@@ -82,28 +83,22 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,static void tricore_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_TRICORE_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void tricore_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void tricore_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_TRICORE_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, tricore_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, tricore_cpu_list_entry,NULL );g_slist_free (list); }
target/xtensa/cpu.h +1 -1
@@ -600,7 +600,7 @@ void xtensa_irq_init(CPUXtensaState *env);qemu_irq *xtensa_get_extints (CPUXtensaState *env);qemu_irq xtensa_get_runstall (CPUXtensaState *env);int cpu_xtensa_signal_handler (int host_signum,void *pinfo,void *puc); -void xtensa_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void xtensa_cpu_list (void );void xtensa_sync_window_from_phys (CPUXtensaState *env);void xtensa_sync_phys_from_window (CPUXtensaState *env);void xtensa_rotate_window (CPUXtensaState *env,uint32_t delta);
target/xtensa/helper.c +4 -3
@@ -31,6 +31,7 @@#include "exec/gdbstub.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/host-utils.h" static struct XtensaConfigList *xtensa_cores;
@@ -228,12 +229,12 @@ void xtensa_breakpoint_handler(CPUState *cs) } } -void xtensa_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void xtensa_cpu_list (void ) {XtensaConfigList *core = xtensa_cores; -cpu_fprintf (f,"Available CPUs:\n" ); +qemu_printf ("Available CPUs:\n" );for (; core; core = core->next) { -cpu_fprintf (f," %s\n" , core->config->name); +qemu_printf (" %s\n" , core->config->name); } }
vl.c +1 -1
@@ -4051,7 +4051,7 @@ int main(int argc, char **argv, char **envp) }if (cpu_model &&is_help_option (cpu_model)) { -list_cpus (stdout, &fprintf, cpu_model); +list_cpus (cpu_model);exit (0 ); }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 09/17] target: Simplify how the TARGET_cpu_list() print
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
The various
TARGET_cpu_list()take an fprintf()-like callback and a FILE * to pass to it. Their callers (vl.c'smain()vialist_cpus(), bsd-user/main.c'smain(), linux-user/main.c'smain()) all passfprintf()and stdout. Thus, the flexibility provided by the (rather tiresome) indirection isn't actually used.Drop the callback, and call
qemu_fprintf()instead.
Actually calling qemu_printf
Quoted 2 lines
Calling
printf()would also work, but would make the code unsuitable for monitor context without making it simpler.
Gernally OK; but just checking - are there any flag combos that will mean this ends up with the result going down a monitor rather than stdout, and will that upset something like libvirt that might be using this to enumerate a cpu list?
Dave
Quoted 1,191 lines
Signed-off-by Markus Armbruster <[email protected]>--- bsd-user/main.c | 2 +- cpus.c | 4 +-- include/exec/cpu-common.h | 13 --------- include/sysemu/cpus.h | 3 +- linux-user/main.c | 2 +- target/alpha/cpu.c | 15 ++++------ target/alpha/cpu.h | 2 +- target/arm/cpu.c | 1 - target/arm/cpu.h | 2 +- target/arm/helper.c | 15 ++++------ target/cris/cpu.c | 14 ++++----- target/cris/cpu.h | 2 +- target/hppa/cpu.c | 14 ++++----- target/hppa/cpu.h | 2 +- target/i386/cpu.c | 29 ++++++++----------- target/i386/cpu.h | 2 +- target/lm32/cpu.c | 14 ++++----- target/lm32/cpu.h | 2 +- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 14 +++------ target/mips/cpu.h | 2 +- target/mips/translate.c | 1 + target/mips/translate_init.inc.c | 5 ++-- target/openrisc/cpu.c | 15 ++++------ target/openrisc/cpu.h | 2 +- target/ppc/cpu.h | 2 +- target/ppc/translate_init.inc.c | 26 +++++++---------- target/riscv/cpu.c | 17 +++-------- target/riscv/cpu.h | 2 +- target/s390x/cpu.h | 2 +- target/s390x/cpu_models.c | 21 ++++++-------- target/sh4/cpu.c | 17 +++-------- target/sh4/cpu.h | 2 +- target/sparc/cpu.c | 49 +++++++++++++++----------------- target/sparc/cpu.h | 2 +- target/tricore/cpu.h | 2 +- target/tricore/helper.c | 15 ++++------ target/xtensa/cpu.h | 2 +- target/xtensa/helper.c | 7 +++-- vl.c | 2 +- 40 files changed, 129 insertions(+), 218 deletions(-)bsd-user/main.c +1
-1@@ -817,7 +817,7 @@ int main(int argc, char **argv)if (is_help_option (cpu_model)) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (stdout, &fprintf); +cpu_list ();#endif exit (1 ); }cpus.c +2
-2@@ -2181,11 +2181,11 @@ int vm_stop_force_state(RunState state) } } -void list_cpus (FILE *f,fprintf_function cpu_fprintf,const char *optarg) +void list_cpus (const char *optarg) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (f, cpu_fprintf); +cpu_list ();#endif }include/exec/cpu-common.h +0
-13@@ -9,19 +9,6 @@#include "qemu/bswap.h" #include "qemu/queue.h" -#include "qemu/fprintf-fn.h" - -/** -* CPUListState: -* @cpu_fprintf: Print function. -* @file: File to print to using @cpu_fprint. -* -* State commonly used for iterating over CPU models. -*/ -typedef struct CPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}CPUListState ;/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ void qemu_init_cpu_list (void );include/sysemu/cpus.h +1
-2@@ -1,7 +1,6 @@#ifndef QEMU_CPUS_H #define QEMU_CPUS_H -#include "qemu/fprintf-fn.h" #include "qemu/timer.h" /* cpus.c */ @@ -39,7 +38,7 @@ extern int smp_cores;extern int smp_threads;#endif -void list_cpus (FILE *f,fprintf_function cpu_fprintf,const char *optarg); +void list_cpus (const char *optarg);void qemu_tcg_configure (QemuOpts *opts,Error **errp);linux-user/main.c +1
-1@@ -316,7 +316,7 @@ static void handle_arg_cpu(const char *arg)if (cpu_model ==NULL ||is_help_option (cpu_model)) {/* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) -cpu_list (stdout, &fprintf); +cpu_list ();#endif exit (EXIT_FAILURE ); }target/alpha/cpu.c +5
-10@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h" @@ -74,23 +75,17 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)static void alpha_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data; - (*s->cpu_fprintf)(s->file," %s\n" , -object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); } -void alpha_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void alpha_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_ALPHA_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, alpha_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, alpha_cpu_list_entry,NULL );g_slist_free (list); }target/alpha/cpu.h +1
-1@@ -470,7 +470,7 @@ void alpha_translate_init(void);#define ALPHA_CPU_TYPE_NAME (model) model ALPHA_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU -void alpha_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void alpha_cpu_list (void );/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ target/arm/cpu.c +0
-1@@ -20,7 +20,6 @@#include "qemu/osdep.h" #include "target/arm/idau.h" -#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "cpu.h" target/arm/cpu.h +1
-1@@ -1936,7 +1936,7 @@ static inline bool access_secure_reg(CPUARMState *env) (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \ (_val)) -void arm_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void arm_cpu_list (void );uint32_t arm_phys_excp_target_el (CPUState *cs,uint32_t excp_idx,uint32_t cur_el,bool secure);target/arm/helper.c +5
-10@@ -10,6 +10,7 @@#include "sysemu/sysemu.h" #include "qemu/bitops.h" #include "qemu/crc32c.h" +#include "qemu/qemu-print.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "arm_ldst.h" @@ -6724,29 +6725,23 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b)static void arm_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_ARM_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void arm_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void arm_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_ARM_CPU , false); list =g_slist_sort (list, arm_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, arm_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, arm_cpu_list_entry,NULL );g_slist_free (list); }target/cris/cpu.c +5
-9@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "mmu.h" @@ -103,27 +104,22 @@ static gint cris_cpu_list_compare(gconstpointer a, gconstpointer b)static void cris_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename =object_class_get_name (oc);char *name; name =g_strndup (typename,strlen (typename) -strlen (CRIS_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file," %s\n" , name); +qemu_printf (" %s\n" , name);g_free (name); } -void cris_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void cris_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_CRIS_CPU , false); list =g_slist_sort (list, cris_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, cris_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, cris_cpu_list_entry,NULL );g_slist_free (list); }target/cris/cpu.h +1
-1@@ -308,6 +308,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc, }#define cpu_list cris_cpu_list -void cris_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void cris_cpu_list (void );#endif target/hppa/cpu.c +5
-9@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h" @@ -113,22 +114,17 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)static void hppa_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data; - (*s->cpu_fprintf)(s->file," %s\n" ,object_class_get_name (oc)); +qemu_printf (" %s\n" ,object_class_get_name (oc)); } -void hppa_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void hppa_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_HPPA_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, hppa_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, hppa_cpu_list_entry,NULL );g_slist_free (list); }target/hppa/cpu.h +1
-1@@ -272,7 +272,7 @@ void hppa_translate_init(void);#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU -void hppa_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void hppa_cpu_list (void );static inline target_ulong hppa_form_gva_psw (target_ureg psw,uint64_t spc,target_ureg off)target/i386/cpu.c +12
-17@@ -21,6 +21,7 @@#include "qemu/units.h" #include "qemu/cutils.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" @@ -3671,7 +3672,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,/* Print all cpuid feature names in featureset */ -static void listflags (FILE *f,fprintf_function print,GList *features) +static void listflags (GList *features) {size_t len =0 ;GList *tmp;@@ -3679,13 +3680,13 @@ static void listflags(FILE *f, fprintf_function print, GList *features)for (tmp = features; tmp; tmp = tmp->next) {const char *name = tmp->data;if ((len +strlen (name) +1 ) >=75 ) { -"\n" ); +qemu_printf ("\n" ); len =0 ; } -"%s%s" , len ==0 ?" " :" " , name); +qemu_printf ("%s%s" , len ==0 ?" " :" " , name); len +=strlen (name) +1 ; } -"\n" ); +qemu_printf ("\n" ); }/* Sort alphabetically by type name, respecting X86CPUClass::ordering. */ @@ -3721,32 +3722,26 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data) {ObjectClass *oc = data;X86CPUClass *cc =X86_CPU_CLASS (oc); -CPUListState *s = user_data;char *name =x86_cpu_class_get_model_name (cc);const char *desc = cc->model_description;if (!desc && cc->cpu_def) { desc = cc->cpu_def->model_id; } - (*s->cpu_fprintf)(s->file,"x86 %-20s %-48s\n" , - name, desc); +qemu_printf ("x86 %-20s %-48s\n" , name, desc);g_free (name); }/* list available CPU models and flags */ -void x86_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void x86_cpu_list (void ) {int i, j; -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list;GList *names =NULL ; - (*cpu_fprintf)(f,"Available CPUs:\n" ); +qemu_printf ("Available CPUs:\n" ); list =get_sorted_cpu_model_list (); -g_slist_foreach (list, x86_cpu_list_entry, &s); +g_slist_foreach (list, x86_cpu_list_entry,NULL );g_slist_free (list); names =NULL ;@@ -3761,9 +3756,9 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) names =g_list_sort (names, (GCompareFunc )strcmp); - (*cpu_fprintf)(f,"\nRecognized CPUID flags:\n" ); -listflags (f, cpu_fprintf, names); - (*cpu_fprintf)(f,"\n" ); +qemu_printf ("\nRecognized CPUID flags:\n" ); +listflags (names); +qemu_printf ("\n" );g_list_free (names); }target/i386/cpu.h +1
-1@@ -1532,7 +1532,7 @@ int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void x86_cpu_exec_enter (CPUState *cpu);void x86_cpu_exec_exit (CPUState *cpu); -void x86_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void x86_cpu_list (void );int cpu_x86_support_mca_broadcast (CPUX86State *env);int cpu_get_pic_interrupt (CPUX86State *s);target/lm32/cpu.c +5
-9@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" @@ -34,27 +35,22 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value)static void lm32_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename =object_class_get_name (oc);char *name; name =g_strndup (typename,strlen (typename) -strlen (LM32_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file," %s\n" , name); +qemu_printf (" %s\n" , name);g_free (name); } -void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void lm32_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_LM32_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, lm32_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, lm32_cpu_list_entry,NULL );g_slist_free (list); }target/lm32/cpu.h +1
-1@@ -243,7 +243,7 @@ static inline lm32_wp_t lm32_wp_type(uint32_t dc, int idx)is returned if the signal was handled by the virtual CPU. */ int cpu_lm32_signal_handler (int host_signum,void *pinfo,void *puc); -void lm32_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void lm32_cpu_list (void );void lm32_translate_init (void );void cpu_lm32_set_phys_msb_ignore (CPULM32State *env,int value); void QEMU_NORETURN raise_exception(CPULM32State *env, int index);target/m68k/cpu.h +1
-1@@ -499,7 +499,7 @@ static inline int m68k_feature(CPUM68KState *env, int feature)return (env->features & (1u << feature)) !=0 ; } -void m68k_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void m68k_cpu_list (void );void register_m68k_insns (CPUM68KState *env);target/m68k/helper.c +4
-10@@ -22,9 +22,9 @@#include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "exec/helper-proto.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" #define SIGNBIT (1u << 31)@@ -49,28 +49,22 @@ static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b)static void m68k_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *c = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (c); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_M68K_CPU )); - (*s->cpu_fprintf)(s->file,"%s\n" , - name); +qemu_printf ("%s\n" , name);g_free (name); } -void m68k_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void m68k_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_M68K_CPU , false); list =g_slist_sort (list, m68k_cpu_list_compare); -g_slist_foreach (list, m68k_cpu_list_entry, &s); +g_slist_foreach (list, m68k_cpu_list_entry,NULL );g_slist_free (list); }target/mips/cpu.h +1
-1@@ -1065,7 +1065,7 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)#define ENV_OFFSET offsetof(MIPSCPU, env) -void mips_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void mips_cpu_list (void );#define cpu_signal_handler cpu_mips_signal_handler#define cpu_list mips_cpu_listtarget/mips/translate.c +1
-0@@ -38,6 +38,7 @@#include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/qemu-print.h" #define MIPS_DEBUG_DISAS 0target/mips/translate_init.inc.c +2
-3@@ -835,13 +835,12 @@ const mips_def_t mips_defs[] = };const int mips_defs_number =ARRAY_SIZE (mips_defs); -void mips_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void mips_cpu_list (void ) {int i;for (i =0 ; i <ARRAY_SIZE (mips_defs); i++) { - (*cpu_fprintf)(f,"MIPS '%s'\n" , - mips_defs[i].name); +qemu_printf ("MIPS '%s'\n" , mips_defs[i].name); } }target/openrisc/cpu.c +5
-10@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" @@ -180,30 +181,24 @@ static gint openrisc_cpu_list_compare(gconstpointer a, gconstpointer b)static void openrisc_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_OPENRISC_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf) +void cpu_openrisc_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_OPENRISC_CPU , false); list =g_slist_sort (list, openrisc_cpu_list_compare); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, openrisc_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, openrisc_cpu_list_entry,NULL );g_slist_free (list); }target/openrisc/cpu.h +1
-1@@ -336,7 +336,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)#define ENV_OFFSET offsetof(OpenRISCCPU, env) -void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf); +void cpu_openrisc_list (void );void openrisc_cpu_do_interrupt (CPUState *cpu);bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f,target/ppc/cpu.h +1
-1@@ -1308,7 +1308,7 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong value);#endif /* !defined(CONFIG_USER_ONLY) */ void ppc_store_msr (CPUPPCState *env,target_ulong value); -void ppc_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void ppc_cpu_list (void );/* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS target/ppc/translate_init.inc.c +10
-16@@ -28,6 +28,7 @@#include "mmu-hash32.h" #include "mmu-hash64.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/error.h" #include "qapi/qmp/qnull.h" #include "qapi/visitor.h" @@ -10215,7 +10216,6 @@ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b)static void ppc_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc);DeviceClass *family =DEVICE_CLASS (ppc_cpu_get_family_class (pcc));const char *typename =object_class_get_name (oc);@@ -10228,8 +10228,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data) name =g_strndup (typename,strlen (typename) -strlen (POWERPC_CPU_TYPE_SUFFIX )); - (*s->cpu_fprintf)(s->file,"PowerPC %-16s PVR %08x\n" , - name, pcc->pvr); +qemu_printf ("PowerPC %-16s PVR %08x\n" , name, pcc->pvr);for (i =0 ; ppc_cpu_aliases[i].alias !=NULL ; i++) {PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];ObjectClass *alias_oc =ppc_cpu_class_by_name (alias->model);@@ -10242,33 +10241,28 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)* avoid printing the wrong alias here and use "preferred" instead */ if (strcmp (alias->alias, family->desc) ==0 ) { - (*s->cpu_fprintf)(s->file, -"PowerPC %-16s (alias for preferred %s CPU)\n" , - alias->alias, family->desc); +qemu_printf ("PowerPC %-16s (alias for preferred %s CPU)\n" , + alias->alias, family->desc); }else { - (*s->cpu_fprintf)(s->file,"PowerPC %-16s (alias for %s)\n" , - alias->alias, name); +qemu_printf ("PowerPC %-16s (alias for %s)\n" , + alias->alias, name); } }g_free (name); } -void ppc_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void ppc_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list (TYPE_POWERPC_CPU , false); list =g_slist_sort (list, ppc_cpu_list_compare); -g_slist_foreach (list, ppc_cpu_list_entry, &s); +g_slist_foreach (list, ppc_cpu_list_entry,NULL );g_slist_free (list);#ifdef CONFIG_KVM -cpu_fprintf (f,"\n" ); -cpu_fprintf (f,"PowerPC %-16s\n" ,"host" ); +qemu_printf ("\n" ); +qemu_printf ("PowerPC %-16s\n" ,"host" );#endif }target/riscv/cpu.c +4
-13@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" @@ -383,11 +384,6 @@ char *riscv_isa_string(RISCVCPU *cpu)return isa_str; } -typedef struct RISCVCPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}RISCVCPUListState ; -static gint riscv_cpu_list_compare (gconstpointer a,gconstpointer b) {ObjectClass *class_a = (ObjectClass *)a;@@ -401,24 +397,19 @@ static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)static void riscv_cpu_list_entry (gpointer data,gpointer user_data) { -RISCVCPUListState *s = user_data;const char *typename =object_class_get_name (OBJECT_CLASS (data));int len =strlen (typename) -strlen (RISCV_CPU_TYPE_SUFFIX ); - (*s->cpu_fprintf)(s->file,"%.*s\n" , len, typename); +qemu_printf ("%.*s\n" , len, typename); } -void riscv_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void riscv_cpu_list (void ) { -RISCVCPUListState s = { - .cpu_fprintf = cpu_fprintf, - .file = f, - };GSList *list; list =object_class_get_list (TYPE_RISCV_CPU , false); list =g_slist_sort (list, riscv_cpu_list_compare); -g_slist_foreach (list, riscv_cpu_list_entry, &s); +g_slist_foreach (list, riscv_cpu_list_entry,NULL );g_slist_free (list); }target/riscv/cpu.h +1
-1@@ -264,7 +264,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,int riscv_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);char *riscv_isa_string (RISCVCPU *cpu); -void riscv_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void riscv_cpu_list (void );#define cpu_signal_handler riscv_cpu_signal_handler#define cpu_list riscv_cpu_listtarget/s390x/cpu.h +1
-1@@ -753,7 +753,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)/* cpu_models.c */ -void s390_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void s390_cpu_list (void );#define cpu_list s390_cpu_listvoid s390_set_qemu_cpu_model (uint16_t type,uint8_t gen,uint8_t ec_ga,const S390FeatInit feat_init);target/s390x/cpu_models.c +8
-13@@ -18,6 +18,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qmp/qdict.h" @@ -308,7 +309,6 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,static void s390_print_cpu_model_list_entry (gpointer data,gpointer user_data) { -CPUListState *s = user_data;const S390CPUClass *scc =S390_CPU_CLASS ((ObjectClass *)data);char *name =g_strdup (object_class_get_name ((ObjectClass *)data));const char *details ="" ;@@ -321,8 +321,7 @@ static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_data)/* strip off the -s390x-cpu */ g_strrstr (name,"-" TYPE_S390_CPU )[0 ] =0 ; - (*s->cpu_fprintf)(s->file,"s390 %-15s %-35s %s\n" , name, scc->desc, - details); +qemu_printf ("s390 %-15s %-35s %s\n" , name, scc->desc, details);g_free (name); }@@ -360,33 +359,29 @@ static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)return cc_a->is_static ?-1 :1 ; } -void s390_cpu_list (FILE *f,fprintf_function print) +void s390_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = print, - };S390FeatGroup group;S390Feat feat;GSList *list; list =object_class_get_list (TYPE_S390_CPU , false); list =g_slist_sort (list, s390_cpu_list_compare); -g_slist_foreach (list, s390_print_cpu_model_list_entry, &s); +g_slist_foreach (list, s390_print_cpu_model_list_entry,NULL );g_slist_free (list); - (*print)(f,"\nRecognized feature flags:\n" ); +qemu_printf ("\nRecognized feature flags:\n" );for (feat =0 ; feat <S390_FEAT_MAX ; feat++) {const S390FeatDef *def =s390_feat_def (feat); - (*print)(f,"%-20s %-50s\n" , def->name, def->desc); +qemu_printf ("%-20s %-50s\n" , def->name, def->desc); } - (*print)(f,"\nRecognized feature groups:\n" ); +qemu_printf ("\nRecognized feature groups:\n" );for (group =0 ; group <S390_FEAT_GROUP_MAX ; group++) {const S390FeatGroupDef *def =s390_feat_group_def (group); - (*print)(f,"%-20s %-50s\n" , def->name, def->desc); +qemu_printf ("%-20s %-50s\n" , def->name, def->desc); } }target/sh4/cpu.c +4
-13@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "migration/vmstate.h" @@ -79,30 +80,20 @@ static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) info->print_insn = print_insn_sh; } -typedef struct SuperHCPUListState { -fprintf_function cpu_fprintf; -FILE *file; -}SuperHCPUListState ; -static void superh_cpu_list_entry (gpointer data,gpointer user_data) { -SuperHCPUListState *s = user_data;const char *typename =object_class_get_name (OBJECT_CLASS (data));int len =strlen (typename) -strlen (SUPERH_CPU_TYPE_SUFFIX ); - (*s->cpu_fprintf)(s->file,"%.*s\n" , len, typename); +qemu_printf ("%.*s\n" , len, typename); } -void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void sh4_cpu_list (void ) { -SuperHCPUListState s = { - .cpu_fprintf = cpu_fprintf, - .file = f, - };GSList *list; list =object_class_get_list_sorted (TYPE_SUPERH_CPU , false); -g_slist_foreach (list, superh_cpu_list_entry, &s); +g_slist_foreach (list, superh_cpu_list_entry,NULL );g_slist_free (list); }target/sh4/cpu.h +1
-1@@ -247,7 +247,7 @@ int cpu_sh4_signal_handler(int host_signum, void *pinfo,int superh_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx); -void sh4_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void sh4_cpu_list (void );#if !defined(CONFIG_USER_ONLY )void cpu_sh4_invalidate_tlb (CPUSH4State *s); uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,target/sparc/cpu.c +23
-26@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" -#include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #include "qapi/visitor.h" @@ -556,47 +556,44 @@ static const char * const feature_name[] = { "gl", }; -static void print_features (FILE *f,fprintf_function cpu_fprintf, -uint32_t features,const char *prefix) +static void print_features (uint32_t features,const char *prefix) {unsigned int i;for (i =0 ; i <ARRAY_SIZE (feature_name); i++) {if (feature_name[i] && (features & (1 << i))) {if (prefix) { - (*cpu_fprintf)(f,"%s" , prefix); +qemu_printf ("%s" , prefix); } - (*cpu_fprintf)(f,"%s " , feature_name[i]); +qemu_printf ("%s " , feature_name[i]); } } } -void sparc_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void sparc_cpu_list (void ) {unsigned int i;for (i =0 ; i <ARRAY_SIZE (sparc_defs); i++) { - (*cpu_fprintf)(f,"Sparc %16s IU " TARGET_FMT_lx -" FPU %08x MMU %08x NWINS %d " , - sparc_defs[i].name, - sparc_defs[i].iu_version, - sparc_defs[i].fpu_version, - sparc_defs[i].mmu_version, - sparc_defs[i].nwindows); -print_features (f, cpu_fprintf,CPU_DEFAULT_FEATURES & - ~sparc_defs[i].features,"-" ); -print_features (f, cpu_fprintf, ~CPU_DEFAULT_FEATURES & - sparc_defs[i].features,"+" ); - (*cpu_fprintf)(f,"\n" ); +qemu_printf ("Sparc %16s IU " TARGET_FMT_lx +" FPU %08x MMU %08x NWINS %d " , + sparc_defs[i].name, + sparc_defs[i].iu_version, + sparc_defs[i].fpu_version, + sparc_defs[i].mmu_version, + sparc_defs[i].nwindows); +print_features (CPU_DEFAULT_FEATURES & ~sparc_defs[i].features,"-" ); +print_features (~CPU_DEFAULT_FEATURES & sparc_defs[i].features,"+" ); +qemu_printf ("\n" ); } - (*cpu_fprintf)(f,"Default CPU feature flags (use '-' to remove): " ); -print_features (f, cpu_fprintf,CPU_DEFAULT_FEATURES ,NULL ); - (*cpu_fprintf)(f,"\n" ); - (*cpu_fprintf)(f,"Available CPU feature flags (use '+' to add): " ); -print_features (f, cpu_fprintf, ~CPU_DEFAULT_FEATURES ,NULL ); - (*cpu_fprintf)(f,"\n" ); - (*cpu_fprintf)(f,"Numerical features (use '=' to set): iu_version " -"fpu_version mmu_version nwindows\n" ); +qemu_printf ("Default CPU feature flags (use '-' to remove): " ); +print_features (CPU_DEFAULT_FEATURES ,NULL ); +qemu_printf ("\n" ); +qemu_printf ("Available CPU feature flags (use '+' to add): " ); +print_features (~CPU_DEFAULT_FEATURES ,NULL ); +qemu_printf ("\n" ); +qemu_printf ("Numerical features (use '=' to set): iu_version " +"fpu_version mmu_version nwindows\n" ); } static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf,target/sparc/cpu.h +1
-1@@ -578,7 +578,7 @@ void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;#ifndef NO_CPU_IO_DEFS /* cpu_init.c */ void cpu_sparc_set_id (CPUSPARCState *env,unsigned int cpu); -void sparc_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void sparc_cpu_list (void );/* mmu_helper.c */ int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);target/tricore/cpu.h +1
-1@@ -375,7 +375,7 @@ void fpu_set_state(CPUTriCoreState *env);#define MMU_USER_IDX 2 -void tricore_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void tricore_cpu_list (void );#define cpu_signal_handler cpu_tricore_signal_handler#define cpu_list tricore_cpu_listtarget/tricore/helper.c +5
-10@@ -20,6 +20,7 @@#include "cpu.h" #include "exec/exec-all.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" enum {TLBRET_DIRTY =-4 ,@@ -82,28 +83,22 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,static void tricore_cpu_list_entry (gpointer data,gpointer user_data) {ObjectClass *oc = data; -CPUListState *s = user_data;const char *typename;char *name; typename =object_class_get_name (oc); name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_TRICORE_CPU )); - (*s->cpu_fprintf)(s->file," %s\n" , - name); +qemu_printf (" %s\n" , name);g_free (name); } -void tricore_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void tricore_cpu_list (void ) { -CPUListState s = { - .file = f, - .cpu_fprintf = cpu_fprintf, - };GSList *list; list =object_class_get_list_sorted (TYPE_TRICORE_CPU , false); - (*cpu_fprintf)(f,"Available CPUs:\n" ); -g_slist_foreach (list, tricore_cpu_list_entry, &s); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, tricore_cpu_list_entry,NULL );g_slist_free (list); }target/xtensa/cpu.h +1
-1@@ -600,7 +600,7 @@ void xtensa_irq_init(CPUXtensaState *env);qemu_irq *xtensa_get_extints (CPUXtensaState *env);qemu_irq xtensa_get_runstall (CPUXtensaState *env);int cpu_xtensa_signal_handler (int host_signum,void *pinfo,void *puc); -void xtensa_cpu_list (FILE *f,fprintf_function cpu_fprintf); +void xtensa_cpu_list (void );void xtensa_sync_window_from_phys (CPUXtensaState *env);void xtensa_sync_phys_from_window (CPUXtensaState *env);void xtensa_rotate_window (CPUXtensaState *env,uint32_t delta);target/xtensa/helper.c +4
-3@@ -31,6 +31,7 @@#include "exec/gdbstub.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/host-utils.h" static struct XtensaConfigList *xtensa_cores;@@ -228,12 +229,12 @@ void xtensa_breakpoint_handler(CPUState *cs) } } -void xtensa_cpu_list (FILE *f,fprintf_function cpu_fprintf) +void xtensa_cpu_list (void ) {XtensaConfigList *core = xtensa_cores; -cpu_fprintf (f,"Available CPUs:\n" ); +qemu_printf ("Available CPUs:\n" );for (; core; core = core->next) { -cpu_fprintf (f," %s\n" , core->config->name); +qemu_printf (" %s\n" , core->config->name); } }vl.c +1
-1@@ -4051,7 +4051,7 @@ int main(int argc, char **argv, char **envp) }if (cpu_model &&is_help_option (cpu_model)) { -list_cpus (stdout, &fprintf, cpu_model); +list_cpus (cpu_model);exit (0 ); }Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 09/17] target: Simplify how the TARGET_cpu_list() print
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
The various
TARGET_cpu_list()take an fprintf()-like callback and a FILE * to pass to it. Their callers (vl.c'smain()vialist_cpus(), bsd-user/main.c'smain(), linux-user/main.c'smain()) all passfprintf()and stdout. Thus, the flexibility provided by the (rather tiresome) indirection isn't actually used.Drop the callback, and call
qemu_fprintf()instead.Actually calling
qemu_printf
Typo, will fix. Thanks!
Quoted 7 lines
Quoted 2 lines
Calling
printf()would also work, but would make the code unsuitable for monitor context without making it simpler.Gernally OK; but just checking - are there any flag combos that will mean this ends up with the result going down a monitor rather than stdout, and will that upset something like libvirt that might be using this to enumerate a cpu list?
No.
qemu_printf() prints to current monitor if we have one, else to stdout. Thus, it prints to stdout as long as !cur_mon.
cur_mon is thread-local, and always set like this:
Monitor *old_mon = cur_mon;
cur_mon = ... non-null value ...
... do something ...
cur-mon = old_mon;It's set and restored
* in monitor_qmp_dispatch() around executing a QMP command
* in monitor_read() around handling HMP input (this includes executing a command)
* in qmp_human_monitor_command() around executing the HMP command (this is where monitors become nested)
Therefore, cur_mon is null unless we're executing a QMP command, an HMP command, or are processing HMP input.
Clearer now?
Re: [Qemu-devel] [PATCH 09/17] target: Simplify how the TARGET_cpu_list() print
Quoted 42 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
The various
TARGET_cpu_list()take an fprintf()-like callback and a FILE * to pass to it. Their callers (vl.c'smain()vialist_cpus(), bsd-user/main.c'smain(), linux-user/main.c'smain()) all passfprintf()and stdout. Thus, the flexibility provided by the (rather tiresome) indirection isn't actually used.Drop the callback, and call
qemu_fprintf()instead.Actually calling
qemu_printfTypo, will fix. Thanks!
Quoted 7 lines
Quoted 2 lines
Calling
printf()would also work, but would make the code unsuitable for monitor context without making it simpler.Gernally OK; but just checking - are there any flag combos that will mean this ends up with the result going down a monitor rather than stdout, and will that upset something like libvirt that might be using this to enumerate a cpu list?
No.
qemu_printf()prints to current monitor if we have one, else to stdout. Thus, it prints to stdout as long as !cur_mon.
cur_monis thread-local, and always set like this:Monitor *old_mon = cur_mon; cur_mon = ... non-null value ... ... do something ... cur-mon = old_mon;It's set and restored
* in
monitor_qmp_dispatch()around executing a QMP command* in
monitor_read()around handling HMP input (this includes executing a command)
Quoted 7 lines
* in
qmp_human_monitor_command()around executing the HMP command (this is where monitors become nested)Therefore,
cur_monis null unless we're executing a QMP command, an HMP command, or are processing HMP input.Clearer now?
Yes, thanks!
Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 10/17 target: Clean up how the dump_mmu() print
In reply to Markus ArmbrusterThe various dump_mmu() take an fprintf()-like callback and a FILE * to pass to it, and so do their helper functions. Passing around callback and argument is rather tiresome.
Most dump_mmu() are called only by the target's hmp_info_tlb(). These all pass monitor_printf() cast to fprintf_function and the current monitor cast to FILE *.
SPARC's dump_mmu() gets also called from target/sparc/ldst_helper.c a few times #ifdef DEBUG_MMU. These calls pass fprintf() and stdout.
The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead.
--- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 115 ++++++++++++++++++------------------- target/m68k/monitor.c | 2 +- target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 7 ++- target/nios2/monitor.c | 2 +- target/ppc/cpu.h | 2 +- target/ppc/mmu-hash64.c | 7 ++- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_helper.c | 70 +++++++++++----------- target/ppc/monitor.c | 2 +- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++--- target/sparc/mmu_helper.c | 97 +++++++++++++++---------------- target/sparc/monitor.c | 2 +- target/xtensa/cpu.h | 2 +- target/xtensa/mmu_helper.c | 24 ++++---- target/xtensa/monitor.c | 2 +- 18 files changed, 178 insertions(+), 183 deletions(-)
target/m68k/cpu.h +2 -1
@@ -573,5 +573,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, } } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUM68KState *env); +void dump_mmu (CPUM68KState *env); +#endif
target/m68k/helper.c +56 -59
219 lines not on this page · raw message
target/m68k/monitor.c +1 -1
@@ -19,7 +19,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }static const MonitorDef monitor_defs[] = {
target/nios2/cpu.h +1 -1
@@ -212,7 +212,7 @@ static inline Nios2CPU *nios2_env_get_cpu(CPUNios2State *env)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 (FILE *f,fprintf_function cpu_fprintf,CPUNios2State *env); +void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);
target/nios2/mmu.c +4 -3
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" #include "mmu.h"
@@ -264,18 +265,18 @@ void mmu_init(CPUNios2State *env) mmu->tlb =g_new0 (Nios2TLBEntry, cpu->tlb_num_entries); } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUNios2State *env) +void dump_mmu (CPUNios2State *env) {Nios2CPU *cpu =nios2_env_get_cpu (env);int i; -cpu_fprintf (f,"MMU: ways %d, entries %d, pid bits %d\n" , +qemu_printf ("MMU: ways %d, entries %d, pid bits %d\n" , cpu->tlb_num_ways, cpu->tlb_num_entries, cpu->pid_num_bits);for (i =0 ; i < cpu->tlb_num_entries; i++) {Nios2TLBEntry *entry = &env->mmu.tlb[i]; - cpu_fprintf(f, "TLB[%d] = %08X %08X %c VPN %05X " + qemu_printf("TLB[%d] = %08X %08X %c VPN %05X " "PID %02X %c PFN %05X %c%c%c%c\n", i, entry->tag, entry->data, (entry->tag & (1 << 10)) ? 'V' : '-',
target/nios2/monitor.c +1 -1
@@ -31,5 +31,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) {CPUArchState *env1 =mon_get_cpu_env (); -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }
target/ppc/cpu.h +1 -1
@@ -2629,7 +2629,7 @@ static inline ppc_avr_t *cpu_avr_ptr(CPUPPCState *env, int i) return (ppc_avr_t *)((uintptr_t)env + avr_full_offset(i)); } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env); +void dump_mmu (CPUPPCState *env);void ppc_maybe_bswap_register (CPUPPCState *env,uint8_t *mem_buf,int len);#endif /* PPC_CPU_H */
target/ppc/mmu-hash64.c +4 -3
@@ -22,6 +22,7 @@#include "exec/exec-all.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/hw_accel.h" #include "kvm_ppc.h" #include "mmu-hash64.h"
@@ -71,7 +72,7 @@ static ppc_slb_t *slb_lookup(PowerPCCPU *cpu, target_ulong eaddr)return NULL ; } -void dump_slb (FILE *f,fprintf_function cpu_fprintf,PowerPCCPU *cpu) +void dump_slb (PowerPCCPU *cpu) {CPUPPCState *env = &cpu->env;int i;
@@ -79,14 +80,14 @@ void dump_slb(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu)cpu_synchronize_state (CPU (cpu)); -cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +qemu_printf ("SLB\tESID\t\t\tVSID\n" );for (i =0 ; i < cpu->hash64_opts->slb_size; i++) { slbe = env->slb[i].esid; slbv = env->slb[i].vsid;if (slbe ==0 && slbv ==0 ) {continue ; } -cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , +qemu_printf ("%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , i, slbe, slbv); } }
target/ppc/mmu-hash64.h +1 -1
@@ -4,7 +4,7 @@#ifndef CONFIG_USER_ONLY #ifdef TARGET_PPC64 -void dump_slb (FILE *f,fprintf_function cpu_fprintf,PowerPCCPU *cpu); +void dump_slb (PowerPCCPU *cpu);int ppc_store_slb (PowerPCCPU *cpu,target_ulong slot,target_ulong esid,target_ulong vsid);hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr);
target/ppc/mmu_helper.c +33 -37
203 lines not on this page · raw message
target/ppc/monitor.c +1 -1
@@ -66,7 +66,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }const MonitorDef monitor_defs[] = {
target/sparc/cpu.h +1 -1
@@ -583,7 +583,7 @@ void sparc_cpu_list(void);int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev); -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env); +void dump_mmu (CPUSPARCState *env);#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
target/sparc/ldst_helper.c +9 -9
@@ -198,7 +198,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,replace_tlb_entry (&tlb[i],0 ,0 , env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s demap invalidated entry [%02u]\n" , strmmu, i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif } }
@@ -260,7 +260,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,replace_tlb_entry (&tlb[i], tlb_tag, tlb_tte, env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced invalid entry [%i]\n" , strmmu, i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif return ; }
@@ -279,7 +279,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced unlocked %s entry [%i]\n" , strmmu, (replace_used ?"used" :"unused" ), i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif return ; }
@@ -886,7 +886,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,break ; }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif }break ;
@@ -941,7 +941,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, reg, oldreg, env->mmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif }break ;
@@ -1634,7 +1634,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->immuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }
@@ -1658,7 +1658,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("immu data access replaced entry [%i]\n" , i); -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }
@@ -1718,7 +1718,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }
@@ -1740,7 +1740,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("dmmu data access replaced entry [%i]\n" , i); -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }
target/sparc/mmu_helper.c +49 -48
156 lines not on this page · raw message
target/sparc/monitor.c +1 -1
@@ -36,7 +36,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }#ifndef TARGET_SPARC64
target/xtensa/cpu.h +1 -1
@@ -673,7 +673,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access);void reset_mmu (CPUXtensaState *env); -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUXtensaState *env); +void dump_mmu (CPUXtensaState *env);static inline MemoryRegion *xtensa_get_er_region (CPUXtensaState *env) {
target/xtensa/mmu_helper.c +11 -13
@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" +#include "qemu/qemu-print.h" #include "qemu/units.h" #include "cpu.h" #include "exec/helper-proto.h"
@@ -740,8 +741,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, } } -static void dump_tlb (FILE *f,fprintf_function cpu_fprintf, -CPUXtensaState *env,bool dtlb) +static void dump_tlb (CPUXtensaState *env,bool dtlb) {unsigned wi, ei; const xtensa_tlb *conf =
@@ -780,13 +780,11 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fprintf,if (print_header) { print_header = false; -cpu_fprintf (f,"Way %u (%d %s)\n" , wi, sz, sz_text); -cpu_fprintf (f, -"\tVaddr Paddr ASID Attr RWX Cache\n" +qemu_printf ("Way %u (%d %s)\n" , wi, sz, sz_text); +qemu_printf ("\tVaddr Paddr ASID Attr RWX Cache\n" "\t---------- ---------- ---- ---- --- -------\n" ); } - cpu_fprintf(f, - "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\n", + qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\n", entry->vaddr, entry->paddr, entry->asid,
@@ -801,18 +799,18 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fprintf, } } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUXtensaState *env) +void dump_mmu (CPUXtensaState *env) {if (xtensa_option_bits_enabled (env->config,XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_PROTECTION ) |XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_TRANSLATION ) |XTENSA_OPTION_BIT (XTENSA_OPTION_MMU ))) { -cpu_fprintf (f,"ITLB:\n" ); -dump_tlb (f, cpu_fprintf, env, false); -cpu_fprintf (f,"\nDTLB:\n" ); -dump_tlb (f, cpu_fprintf, env, true); +qemu_printf ("ITLB:\n" ); +dump_tlb (env, false); +qemu_printf ("\nDTLB:\n" ); +dump_tlb (env, true); }else { -cpu_fprintf (f,"No TLB for this CPU core\n" ); +qemu_printf ("No TLB for this CPU core\n" ); } }
target/xtensa/monitor.c +1 -1
@@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 10/17] target: Clean up how the dump_mmu() print
Quoted 10 lines · * Markus Armbruster ([email protected]) wrote:
The various
dump_mmu()take an fprintf()-like callback and a FILE * to pass to it, and so do their helper functions. Passing around callback and argument is rather tiresome.Most
dump_mmu()are called only by the target'shmp_info_tlb(). These all passmonitor_printf()cast tofprintf_functionand the current monitor cast to FILE *.SPARC's
dump_mmu()gets also called fromtarget/sparc/ldst_helper.ca few times #ifdefDEBUG_MMU. These calls passfprintf()and stdout.
You might want to fixup the DPRINTF_MMU in ldst_helper.c to also use qemu_printf.
Quoted 5 lines
The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 992 lines
--- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 115 ++++++++++++++++++------------------- target/m68k/monitor.c | 2 +- target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 7 ++- target/nios2/monitor.c | 2 +- target/ppc/cpu.h | 2 +- target/ppc/mmu-hash64.c | 7 ++- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_helper.c | 70 +++++++++++----------- target/ppc/monitor.c | 2 +- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++--- target/sparc/mmu_helper.c | 97 +++++++++++++++---------------- target/sparc/monitor.c | 2 +- target/xtensa/cpu.h | 2 +- target/xtensa/mmu_helper.c | 24 ++++---- target/xtensa/monitor.c | 2 +- 18 files changed, 178 insertions(+), 183 deletions(-)target/m68k/cpu.h +2
-1@@ -573,5 +573,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, } } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUM68KState *env); +void dump_mmu (CPUM68KState *env); +#endif target/m68k/helper.c +56
-59@@ -369,30 +369,28 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,/* MMU: 68040 only */ -static void print_address_zone (FILE *f,fprintf_function cpu_fprintf, -uint32_t logical,uint32_t physical, +static void print_address_zone (uint32_t logical,uint32_t physical,uint32_t size,int attr) { -cpu_fprintf (f,"%08x - %08x -> %08x - %08x %c " , +qemu_printf ("%08x - %08x -> %08x - %08x %c " , logical, logical + size -1 , physical, physical + size -1 , attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -cpu_fprintf (f,"(%d KiB)\n" , size); +qemu_printf ("(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -cpu_fprintf (f,"(%d MiB)\n" , size); +qemu_printf ("(%d MiB)\n" , size); }else { size >>=10 ; -cpu_fprintf (f,"(%d GiB)\n" , size); +qemu_printf ("(%d GiB)\n" , size); } } } -static void dump_address_map (FILE *f,fprintf_function cpu_fprintf, -CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -454,7 +452,7 @@ static void dump_address_map(FILE *f, fprintf_function cpu_fprintf,if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (f, cpu_fprintf, first_logical, +print_address_zone (first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -465,126 +463,125 @@ static void dump_address_map(FILE *f, fprintf_function cpu_fprintf, }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical; -print_address_zone (f, cpu_fprintf, first_logical, first_physical, size, - last_attr); +print_address_zone (first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cachable, write-through */ \ -cpu_fprintf (f,"T" ); \ +qemu_printf ("T" ); \break ; \case M68K_DESC_CM_COPYBK :/* cachable, copyback */ \ -cpu_fprintf (f,"C" ); \ +qemu_printf ("C" ); \break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -cpu_fprintf (f,"S" ); \ +qemu_printf ("S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -cpu_fprintf (f,"N" ); \ +qemu_printf ("N" ); \break ; \ } -static void dump_ttr (FILE *f,fprintf_function cpu_fprintf,uint32_t ttr) +static void dump_ttr (uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -cpu_fprintf (f,"disabled\n" ); +qemu_printf ("disabled\n" );return ; } -cpu_fprintf (f,"Base: 0x%08x Mask: 0x%08x Control: " , +qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , ttr &M68K_TTR_ADDR_BASE , (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -cpu_fprintf (f,"U" ); +qemu_printf ("U" );break ;case M68K_TTR_SFIELD_SUPER : -cpu_fprintf (f,"S" ); +qemu_printf ("S" );break ;default : -cpu_fprintf (f,"*" ); +qemu_printf ("*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -cpu_fprintf (f,"R" ); +qemu_printf ("R" ); }else { -cpu_fprintf (f,"W" ); +qemu_printf ("W" ); } -cpu_fprintf (f," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUM68KState *env) +void dump_mmu (CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -cpu_fprintf (f,"Translation disabled\n" ); +qemu_printf ("Translation disabled\n" );return ; } -cpu_fprintf (f,"Page Size: " ); +qemu_printf ("Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -cpu_fprintf (f,"8kB\n" ); +qemu_printf ("8kB\n" ); }else { -cpu_fprintf (f,"4kB\n" ); +qemu_printf ("4kB\n" ); } -cpu_fprintf (f,"MMUSR: " ); +qemu_printf ("MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -cpu_fprintf (f,"BUS ERROR\n" ); +qemu_printf ("BUS ERROR\n" ); }else { -cpu_fprintf (f,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -cpu_fprintf (f,"G" );/* Global */ +qemu_printf ("G" );/* Global */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -cpu_fprintf (f,"S" );/* Supervisor */ +qemu_printf ("S" );/* Supervisor */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -cpu_fprintf (f,"M" );/* Modified */ +qemu_printf ("M" );/* Modified */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -cpu_fprintf (f,"W" );/* Write protect */ +qemu_printf ("W" );/* Write protect */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -cpu_fprintf (f,"T" );/* Transparent */ +qemu_printf ("T" );/* Transparent */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -cpu_fprintf (f,"R" );/* Resident */ +qemu_printf ("R" );/* Resident */ }else { -cpu_fprintf (f,"." ); +qemu_printf ("." ); } -cpu_fprintf (f," Cache: " ); +qemu_printf (" Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -cpu_fprintf (f," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -cpu_fprintf (f,"\n" ); +qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +qemu_printf ("\n" ); } -cpu_fprintf (f,"ITTR0: " ); -dump_ttr (f, cpu_fprintf, env->mmu.ttr[M68K_ITTR0 ]); -cpu_fprintf (f,"ITTR1: " ); -dump_ttr (f, cpu_fprintf, env->mmu.ttr[M68K_ITTR1 ]); -cpu_fprintf (f,"DTTR0: " ); -dump_ttr (f, cpu_fprintf, env->mmu.ttr[M68K_DTTR0 ]); -cpu_fprintf (f,"DTTR1: " ); -dump_ttr (f, cpu_fprintf, env->mmu.ttr[M68K_DTTR1 ]); +qemu_printf ("ITTR0: " ); +dump_ttr (env->mmu.ttr[M68K_ITTR0 ]); +qemu_printf ("ITTR1: " ); +dump_ttr (env->mmu.ttr[M68K_ITTR1 ]); +qemu_printf ("DTTR0: " ); +dump_ttr (env->mmu.ttr[M68K_DTTR0 ]); +qemu_printf ("DTTR1: " ); +dump_ttr (env->mmu.ttr[M68K_DTTR1 ]); -cpu_fprintf (f,"SRP: 0x%08x\n" , env->mmu.srp); -dump_address_map (f, cpu_fprintf, env, env->mmu.srp); +qemu_printf ("SRP: 0x%08x\n" , env->mmu.srp); +dump_address_map (env, env->mmu.srp); -cpu_fprintf (f,"URP: 0x%08x\n" , env->mmu.urp); -dump_address_map (f, cpu_fprintf, env, env->mmu.urp); +qemu_printf ("URP: 0x%08x\n" , env->mmu.urp); +dump_address_map (env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr,target/m68k/monitor.c +1
-1@@ -19,7 +19,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }static const MonitorDef monitor_defs[] = {target/nios2/cpu.h +1
-1@@ -212,7 +212,7 @@ static inline Nios2CPU *nios2_env_get_cpu(CPUNios2State *env)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 (FILE *f,fprintf_function cpu_fprintf,CPUNios2State *env); +void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);target/nios2/mmu.c +4
-3@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" #include "mmu.h" @@ -264,18 +265,18 @@ void mmu_init(CPUNios2State *env) mmu->tlb =g_new0 (Nios2TLBEntry, cpu->tlb_num_entries); } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUNios2State *env) +void dump_mmu (CPUNios2State *env) {Nios2CPU *cpu =nios2_env_get_cpu (env);int i; -cpu_fprintf (f,"MMU: ways %d, entries %d, pid bits %d\n" , +qemu_printf ("MMU: ways %d, entries %d, pid bits %d\n" , cpu->tlb_num_ways, cpu->tlb_num_entries, cpu->pid_num_bits);for (i =0 ; i < cpu->tlb_num_entries; i++) {Nios2TLBEntry *entry = &env->mmu.tlb[i]; - cpu_fprintf(f, "TLB[%d] = %08X %08X %c VPN %05X " + qemu_printf("TLB[%d] = %08X %08X %c VPN %05X " "PID %02X %c PFN %05X %c%c%c%c\n", i, entry->tag, entry->data, (entry->tag & (1 << 10)) ? 'V' : '-',target/nios2/monitor.c +1
-1@@ -31,5 +31,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) {CPUArchState *env1 =mon_get_cpu_env (); -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }target/ppc/cpu.h +1
-1@@ -2629,7 +2629,7 @@ static inline ppc_avr_t *cpu_avr_ptr(CPUPPCState *env, int i) return (ppc_avr_t *)((uintptr_t)env + avr_full_offset(i)); } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env); +void dump_mmu (CPUPPCState *env);void ppc_maybe_bswap_register (CPUPPCState *env,uint8_t *mem_buf,int len);#endif /* PPC_CPU_H */ target/ppc/mmu-hash64.c +4
-3@@ -22,6 +22,7 @@#include "exec/exec-all.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/hw_accel.h" #include "kvm_ppc.h" #include "mmu-hash64.h" @@ -71,7 +72,7 @@ static ppc_slb_t *slb_lookup(PowerPCCPU *cpu, target_ulong eaddr)return NULL ; } -void dump_slb (FILE *f,fprintf_function cpu_fprintf,PowerPCCPU *cpu) +void dump_slb (PowerPCCPU *cpu) {CPUPPCState *env = &cpu->env;int i;@@ -79,14 +80,14 @@ void dump_slb(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu)cpu_synchronize_state (CPU (cpu)); -cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +qemu_printf ("SLB\tESID\t\t\tVSID\n" );for (i =0 ; i < cpu->hash64_opts->slb_size; i++) { slbe = env->slb[i].esid; slbv = env->slb[i].vsid;if (slbe ==0 && slbv ==0 ) {continue ; } -cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , +qemu_printf ("%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , i, slbe, slbv); } }target/ppc/mmu-hash64.h +1
-1@@ -4,7 +4,7 @@#ifndef CONFIG_USER_ONLY #ifdef TARGET_PPC64 -void dump_slb (FILE *f,fprintf_function cpu_fprintf,PowerPCCPU *cpu); +void dump_slb (PowerPCCPU *cpu);int ppc_store_slb (PowerPCCPU *cpu,target_ulong slot,target_ulong esid,target_ulong vsid);hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr);target/ppc/mmu_helper.c +33
-37@@ -29,6 +29,7 @@#include "exec/log.h" #include "helper_regs.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "mmu-book3s-v3.h" #include "mmu-radix64.h" @@ -1116,19 +1117,18 @@ static const char *book3e_tsize_to_str[32] = { "1T", "2T" }; -static void mmubooke_dump_mmu (FILE *f,fprintf_function cpu_fprintf, -CPUPPCState *env) +static void mmubooke_dump_mmu (CPUPPCState *env) {ppcemb_tlb_t *entry;int i;if (kvm_enabled () && !env->kvm_sw_tlb) { -cpu_fprintf (f,"Cannot access KVM TLB\n" ); +qemu_printf ("Cannot access KVM TLB\n" );return ; } -cpu_fprintf (f,"\nTLB:\n" ); -cpu_fprintf (f,"Effective Physical Size PID Prot " +qemu_printf ("\nTLB:\n" ); +qemu_printf ("Effective Physical Size PID Prot " "Attr\n" ); entry = &env->tlb.tlbe[0 ];@@ -1153,22 +1153,21 @@ static void mmubooke_dump_mmu(FILE *f, fprintf_function cpu_fprintf, }else {snprintf (size_buf,sizeof (size_buf),"%3" PRId64"k" , size / KiB); } -cpu_fprintf (f,"0x%016" PRIx64" 0x%016" PRIx64" %s %-5u %08x %08x\n" , +qemu_printf ("0x%016" PRIx64" 0x%016" PRIx64" %s %-5u %08x %08x\n" , (uint64_t )ea, (uint64_t )pa, size_buf, (uint32_t )entry->PID, entry->prot, entry->attr); } } -static void mmubooke206_dump_one_tlb (FILE *f,fprintf_function cpu_fprintf, -CPUPPCState *env,int tlbn,int offset, +static void mmubooke206_dump_one_tlb (CPUPPCState *env,int tlbn,int offset,int tlbsize) {ppcmas_tlb_t *entry;int i; -cpu_fprintf (f,"\nTLB%d:\n" , tlbn); -cpu_fprintf (f,"Effective Physical Size TID TS SRWX" +qemu_printf ("\nTLB%d:\n" , tlbn); +qemu_printf ("Effective Physical Size TID TS SRWX" " URWX WIMGE U0123\n" ); entry = &env->tlb.tlbm[offset];@@ -1185,7 +1184,7 @@ static void mmubooke206_dump_one_tlb(FILE *f, fprintf_function cpu_fprintf, ea = entry->mas2 & ~(size -1 ); pa = entry->mas7_3 & ~(size -1 ); - cpu_fprintf(f, "0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c%c" + qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c%c" "U%c%c%c %c%c%c%c%c U%c%c%c%c\n", (uint64_t)ea, (uint64_t)pa, book3e_tsize_to_str[tsize],@@ -1209,14 +1208,13 @@ static void mmubooke206_dump_one_tlb(FILE *f, fprintf_function cpu_fprintf, } } -static void mmubooke206_dump_mmu (FILE *f,fprintf_function cpu_fprintf, -CPUPPCState *env) +static void mmubooke206_dump_mmu (CPUPPCState *env) {int offset =0 ;int i;if (kvm_enabled () && !env->kvm_sw_tlb) { -cpu_fprintf (f,"Cannot access KVM TLB\n" ); +qemu_printf ("Cannot access KVM TLB\n" );return ; }@@ -1227,13 +1225,12 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf,continue ; } -mmubooke206_dump_one_tlb (f, cpu_fprintf, env, i, offset, size); +mmubooke206_dump_one_tlb (env, i, offset, size); offset += size; } } -static void mmu6xx_dump_BATs (FILE *f,fprintf_function cpu_fprintf, -CPUPPCState *env,int type) +static void mmu6xx_dump_BATs (CPUPPCState *env,int type) {target_ulong *BATlt, *BATut, *BATu, *BATl;target_ulong BEPIl, BEPIu, bl;@@ -1256,7 +1253,7 @@ static void mmu6xx_dump_BATs(FILE *f, fprintf_function cpu_fprintf, BEPIu = *BATu &0xF0000000 ; BEPIl = *BATu &0x0FFE0000 ; bl = (*BATu &0x00001FFC ) <<15 ; - cpu_fprintf(f, "%s BAT%d BATu " TARGET_FMT_lx + qemu_printf("%s BAT%d BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " TARGET_FMT_lx " " TARGET_FMT_lx "\n", type == ACCESS_CODE ? "code" : "data", i,@@ -1264,44 +1261,43 @@ static void mmu6xx_dump_BATs(FILE *f, fprintf_function cpu_fprintf, } } -static void mmu6xx_dump_mmu (FILE *f,fprintf_function cpu_fprintf, -CPUPPCState *env) +static void mmu6xx_dump_mmu (CPUPPCState *env) {PowerPCCPU *cpu =ppc_env_get_cpu (env);ppc6xx_tlb_t *tlb;target_ulong sr;int type, way, entry, i; -cpu_fprintf (f,"HTAB base = 0x%" HWADDR_PRIx"\n" ,ppc_hash32_hpt_base (cpu)); -cpu_fprintf (f,"HTAB mask = 0x%" HWADDR_PRIx"\n" ,ppc_hash32_hpt_mask (cpu)); +qemu_printf ("HTAB base = 0x%" HWADDR_PRIx"\n" ,ppc_hash32_hpt_base (cpu)); +qemu_printf ("HTAB mask = 0x%" HWADDR_PRIx"\n" ,ppc_hash32_hpt_mask (cpu)); -cpu_fprintf (f,"\nSegment registers:\n" ); +qemu_printf ("\nSegment registers:\n" );for (i =0 ; i <32 ; i++) { sr = env->sr[i];if (sr &0x80000000 ) { -cpu_fprintf (f,"%02d T=%d Ks=%d Kp=%d BUID=0x%03x " +qemu_printf ("%02d T=%d Ks=%d Kp=%d BUID=0x%03x " "CNTLR_SPEC=0x%05x\n" , i, sr &0x80000000 ?1 :0 , sr &0x40000000 ?1 :0 , sr &0x20000000 ?1 :0 , (uint32_t )((sr >>20 ) &0x1FF ), (uint32_t )(sr &0xFFFFF )); }else { -cpu_fprintf (f,"%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n" , i, +qemu_printf ("%02d T=%d Ks=%d Kp=%d N=%d VSID=0x%06x\n" , i, sr &0x80000000 ?1 :0 , sr &0x40000000 ?1 :0 , sr &0x20000000 ?1 :0 , sr &0x10000000 ?1 :0 , (uint32_t )(sr &0x00FFFFFF )); } } -cpu_fprintf (f,"\nBATs:\n" ); -mmu6xx_dump_BATs (f, cpu_fprintf, env,ACCESS_INT ); -mmu6xx_dump_BATs (f, cpu_fprintf, env,ACCESS_CODE ); +qemu_printf ("\nBATs:\n" ); +mmu6xx_dump_BATs (env,ACCESS_INT ); +mmu6xx_dump_BATs (env,ACCESS_CODE );if (env->id_tlbs !=1 ) { -cpu_fprintf (f,"ERROR: 6xx MMU should have separated TLB" +qemu_printf ("ERROR: 6xx MMU should have separated TLB" " for code and data\n" ); } -cpu_fprintf (f,"\nTLBs [EPN EPN + SIZE]\n" ); +qemu_printf ("\nTLBs [EPN EPN + SIZE]\n" );for (type =0 ; type <2 ; type++) {for (way =0 ; way < env->nb_ways; way++) {@@ -1310,7 +1306,7 @@ static void mmu6xx_dump_mmu(FILE *f, fprintf_function cpu_fprintf, entry++) { tlb = &env->tlb.tlb6[entry]; - cpu_fprintf(f, "%s TLB %02d/%02d way:%d %s [" + qemu_printf("%s TLB %02d/%02d way:%d %s [" TARGET_FMT_lx " " TARGET_FMT_lx "]\n", type ? "code" : "data", entry % env->nb_tlb, env->nb_tlb, way,@@ -1321,31 +1317,31 @@ static void mmu6xx_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env) +void dump_mmu (CPUPPCState *env) {switch (env->mmu_model) {case POWERPC_MMU_BOOKE : -mmubooke_dump_mmu (f, cpu_fprintf, env); +mmubooke_dump_mmu (env);break ;case POWERPC_MMU_BOOKE206 : -mmubooke206_dump_mmu (f, cpu_fprintf, env); +mmubooke206_dump_mmu (env);break ;case POWERPC_MMU_SOFT_6xx:case POWERPC_MMU_SOFT_74xx: -mmu6xx_dump_mmu (f, cpu_fprintf, env); +mmu6xx_dump_mmu (env);break ;#if defined(TARGET_PPC64 )case POWERPC_MMU_64B :case POWERPC_MMU_2_03 :case POWERPC_MMU_2_06 :case POWERPC_MMU_2_07 : -dump_slb (f, cpu_fprintf,ppc_env_get_cpu (env)); +dump_slb (ppc_env_get_cpu (env));break ;case POWERPC_MMU_3_00 :if (ppc64_v3_radix (ppc_env_get_cpu (env))) {/* TODO - Unsupported */ }else { -dump_slb (f, cpu_fprintf,ppc_env_get_cpu (env)); +dump_slb (ppc_env_get_cpu (env));break ; }#endif target/ppc/monitor.c +1
-1@@ -66,7 +66,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }const MonitorDef monitor_defs[] = {target/sparc/cpu.h +1
-1@@ -583,7 +583,7 @@ void sparc_cpu_list(void);int sparc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int mmu_idx);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev); -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env); +void dump_mmu (CPUSPARCState *env);#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,target/sparc/ldst_helper.c +9
-9@@ -198,7 +198,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,replace_tlb_entry (&tlb[i],0 ,0 , env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s demap invalidated entry [%02u]\n" , strmmu, i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif } }@@ -260,7 +260,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,replace_tlb_entry (&tlb[i], tlb_tag, tlb_tte, env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced invalid entry [%i]\n" , strmmu, i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif return ; }@@ -279,7 +279,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced unlocked %s entry [%i]\n" , strmmu, (replace_used ?"used" :"unused" ), i); -dump_mmu (stdout, fprintf, env1); +dump_mmu (env1);#endif return ; }@@ -886,7 +886,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,break ; }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif }break ;@@ -941,7 +941,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, reg, oldreg, env->mmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif }break ;@@ -1634,7 +1634,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->immuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }@@ -1658,7 +1658,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("immu data access replaced entry [%i]\n" , i); -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }@@ -1718,7 +1718,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }@@ -1740,7 +1740,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("dmmu data access replaced entry [%i]\n" , i); -dump_mmu (stdout, fprintf, env); +dump_mmu (env);#endif return ; }target/sparc/mmu_helper.c +49
-48@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "qemu/qemu-print.h" #include "trace.h" /* Sparc MMU emulation */ @@ -320,7 +321,7 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return 0 ; } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env) +void dump_mmu (CPUSPARCState *env) {CPUState *cs =CPU (sparc_env_get_cpu (env));target_ulong va, va1, va2;@@ -330,29 +331,29 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env) pde_ptr = (env->mmuregs[1 ] <<4 ) + (env->mmuregs[2 ] <<2 ); pde =ldl_phys (cs->as, pde_ptr); - (*cpu_fprintf)(f,"Root ptr: " TARGET_FMT_plx", ctx: %d\n" , - (hwaddr )env->mmuregs[1 ] <<4 , env->mmuregs[2 ]); +qemu_printf ("Root ptr: " TARGET_FMT_plx", ctx: %d\n" , + (hwaddr )env->mmuregs[1 ] <<4 , env->mmuregs[2 ]);for (n =0 , va =0 ; n <256 ; n++, va +=16 *1024 *1024 ) { pde =mmu_probe (env, va,2 );if (pde) { pa =cpu_get_phys_page_debug (cs, va); - (*cpu_fprintf)(f,"VA: " TARGET_FMT_lx", PA: " TARGET_FMT_plx -" PDE: " TARGET_FMT_lx"\n" , va, pa, pde); +qemu_printf ("VA: " TARGET_FMT_lx", PA: " TARGET_FMT_plx +" PDE: " TARGET_FMT_lx"\n" , va, pa, pde);for (m =0 , va1 = va; m <64 ; m++, va1 +=256 *1024 ) { pde =mmu_probe (env, va1,1 );if (pde) { pa =cpu_get_phys_page_debug (cs, va1); - (*cpu_fprintf)(f," VA: " TARGET_FMT_lx", PA: " - TARGET_FMT_plx" PDE: " TARGET_FMT_lx"\n" , - va1, pa, pde); +qemu_printf (" VA: " TARGET_FMT_lx", PA: " + TARGET_FMT_plx" PDE: " TARGET_FMT_lx"\n" , + va1, pa, pde);for (o =0 , va2 = va1; o <64 ; o++, va2 +=4 *1024 ) { pde =mmu_probe (env, va2,0 );if (pde) { pa =cpu_get_phys_page_debug (cs, va2); - (*cpu_fprintf)(f," VA: " TARGET_FMT_lx", PA: " - TARGET_FMT_plx" PTE: " - TARGET_FMT_lx"\n" , - va2, pa, pde); +qemu_printf (" VA: " TARGET_FMT_lx", PA: " + TARGET_FMT_plx" PTE: " + TARGET_FMT_lx"\n" , + va2, pa, pde); } } }@@ -739,21 +740,21 @@ int sparc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,return 1 ; } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env) +void dump_mmu (CPUSPARCState *env) {unsigned int i;const char *mask; - (*cpu_fprintf)(f,"MMU contexts: Primary: %" PRId64", Secondary: %" - PRId64"\n" , - env->dmmu.mmu_primary_context, - env->dmmu.mmu_secondary_context); - (*cpu_fprintf)(f,"DMMU Tag Access: %" PRIx64", TSB Tag Target: %" PRIx64 -"\n" , env->dmmu.tag_access, env->dmmu.tsb_tag_target); +qemu_printf ("MMU contexts: Primary: %" PRId64", Secondary: %" + PRId64"\n" , + env->dmmu.mmu_primary_context, + env->dmmu.mmu_secondary_context); +qemu_printf ("DMMU Tag Access: %" PRIx64", TSB Tag Target: %" PRIx64 +"\n" , env->dmmu.tag_access, env->dmmu.tsb_tag_target);if ((env->lsu &DMMU_E ) ==0 ) { - (*cpu_fprintf)(f,"DMMU disabled\n" ); +qemu_printf ("DMMU disabled\n" ); }else { - (*cpu_fprintf)(f,"DMMU dump\n" ); +qemu_printf ("DMMU dump\n" );for (i =0 ; i <64 ; i++) {switch (TTE_PGSIZE (env->dtlb[i].tte)) {default :@@ -771,26 +772,26 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env)break ; }if (TTE_IS_VALID (env->dtlb[i].tte)) { - (*cpu_fprintf)(f,"[%02u] VA: %" PRIx64", PA: %llx" -", %s, %s, %s, %s, ctx %" PRId64" %s\n" , - i, - env->dtlb[i].tag & (uint64_t )~0x1fffULL , -TTE_PA (env->dtlb[i].tte), - mask, -TTE_IS_PRIV (env->dtlb[i].tte) ?"priv" :"user" , -TTE_IS_W_OK (env->dtlb[i].tte) ?"RW" :"RO" , -TTE_IS_LOCKED (env->dtlb[i].tte) ? -"locked" :"unlocked" , - env->dtlb[i].tag & (uint64_t )0x1fffULL , -TTE_IS_GLOBAL (env->dtlb[i].tte) ? -"global" :"local" ); +qemu_printf ("[%02u] VA: %" PRIx64", PA: %llx" +", %s, %s, %s, %s, ctx %" PRId64" %s\n" , + i, + env->dtlb[i].tag & (uint64_t )~0x1fffULL , +TTE_PA (env->dtlb[i].tte), + mask, +TTE_IS_PRIV (env->dtlb[i].tte) ?"priv" :"user" , +TTE_IS_W_OK (env->dtlb[i].tte) ?"RW" :"RO" , +TTE_IS_LOCKED (env->dtlb[i].tte) ? +"locked" :"unlocked" , + env->dtlb[i].tag & (uint64_t )0x1fffULL , +TTE_IS_GLOBAL (env->dtlb[i].tte) ? +"global" :"local" ); } } }if ((env->lsu &IMMU_E ) ==0 ) { - (*cpu_fprintf)(f,"IMMU disabled\n" ); +qemu_printf ("IMMU disabled\n" ); }else { - (*cpu_fprintf)(f,"IMMU dump\n" ); +qemu_printf ("IMMU dump\n" );for (i =0 ; i <64 ; i++) {switch (TTE_PGSIZE (env->itlb[i].tte)) {default :@@ -808,18 +809,18 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env)break ; }if (TTE_IS_VALID (env->itlb[i].tte)) { - (*cpu_fprintf)(f,"[%02u] VA: %" PRIx64", PA: %llx" -", %s, %s, %s, ctx %" PRId64" %s\n" , - i, - env->itlb[i].tag & (uint64_t )~0x1fffULL , -TTE_PA (env->itlb[i].tte), - mask, -TTE_IS_PRIV (env->itlb[i].tte) ?"priv" :"user" , -TTE_IS_LOCKED (env->itlb[i].tte) ? -"locked" :"unlocked" , - env->itlb[i].tag & (uint64_t )0x1fffULL , -TTE_IS_GLOBAL (env->itlb[i].tte) ? -"global" :"local" ); +qemu_printf ("[%02u] VA: %" PRIx64", PA: %llx" +", %s, %s, %s, ctx %" PRId64" %s\n" , + i, + env->itlb[i].tag & (uint64_t )~0x1fffULL , +TTE_PA (env->itlb[i].tte), + mask, +TTE_IS_PRIV (env->itlb[i].tte) ?"priv" :"user" , +TTE_IS_LOCKED (env->itlb[i].tte) ? +"locked" :"unlocked" , + env->itlb[i].tag & (uint64_t )0x1fffULL , +TTE_IS_GLOBAL (env->itlb[i].tte) ? +"global" :"local" ); } } }target/sparc/monitor.c +1
-1@@ -36,7 +36,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }#ifndef TARGET_SPARC64 target/xtensa/cpu.h +1
-1@@ -673,7 +673,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access);void reset_mmu (CPUXtensaState *env); -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUXtensaState *env); +void dump_mmu (CPUXtensaState *env);static inline MemoryRegion *xtensa_get_er_region (CPUXtensaState *env) {target/xtensa/mmu_helper.c +11
-13@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" +#include "qemu/qemu-print.h" #include "qemu/units.h" #include "cpu.h" #include "exec/helper-proto.h" @@ -740,8 +741,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, } } -static void dump_tlb (FILE *f,fprintf_function cpu_fprintf, -CPUXtensaState *env,bool dtlb) +static void dump_tlb (CPUXtensaState *env,bool dtlb) {unsigned wi, ei; const xtensa_tlb *conf =@@ -780,13 +780,11 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fprintf,if (print_header) { print_header = false; -cpu_fprintf (f,"Way %u (%d %s)\n" , wi, sz, sz_text); -cpu_fprintf (f, -"\tVaddr Paddr ASID Attr RWX Cache\n" +qemu_printf ("Way %u (%d %s)\n" , wi, sz, sz_text); +qemu_printf ("\tVaddr Paddr ASID Attr RWX Cache\n" "\t---------- ---------- ---- ---- --- -------\n" ); } - cpu_fprintf(f, - "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\n", + qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\n", entry->vaddr, entry->paddr, entry->asid,@@ -801,18 +799,18 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fprintf, } } -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUXtensaState *env) +void dump_mmu (CPUXtensaState *env) {if (xtensa_option_bits_enabled (env->config,XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_PROTECTION ) |XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_TRANSLATION ) |XTENSA_OPTION_BIT (XTENSA_OPTION_MMU ))) { -cpu_fprintf (f,"ITLB:\n" ); -dump_tlb (f, cpu_fprintf, env, false); -cpu_fprintf (f,"\nDTLB:\n" ); -dump_tlb (f, cpu_fprintf, env, true); +qemu_printf ("ITLB:\n" ); +dump_tlb (env, false); +qemu_printf ("\nDTLB:\n" ); +dump_tlb (env, true); }else { -cpu_fprintf (f,"No TLB for this CPU core\n" ); +qemu_printf ("No TLB for this CPU core\n" ); } }target/xtensa/monitor.c +1
-1@@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +dump_mmu (env1); }Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 10/17] target: Clean up how the dump_mmu() print
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Markus Armbruster ([email protected]) wrote:
The various
dump_mmu()take an fprintf()-like callback and a FILE * to pass to it, and so do their helper functions. Passing around callback and argument is rather tiresome.Most
dump_mmu()are called only by the target'shmp_info_tlb(). These all passmonitor_printf()cast tofprintf_functionand the current monitor cast to FILE *.
Quoted 5 lines
Quoted 2 lines
SPARC's
dump_mmu()gets also called fromtarget/sparc/ldst_helper.ca few times #ifdefDEBUG_MMU. These calls passfprintf()and stdout.You might want to fixup the
DPRINTF_MMUinldst_helper.cto also useqemu_printf.
Hmm. Makes DPRINTF_MMU() consistent with how dump_mmu() prints, but inconsistent with how the other DPRINTF_*() print. Dunno...
All that debug code should really be tracepoints of course.
I'll leave DPRINTF_MMU() alone unless a maintainer (cc'ed) wants me to update it.
Quoted 7 lines
Quoted 5 lines
The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks!
PATCH 11/17 target/i386: Simplify how x86_cpu_dump_local_apic_state() prints
In reply to Markus Armbrusterx86_cpu_dump_local_apic_state() takes an fprintf()-like callback and a FILE * to pass to it, and so do its helper functions.
Its only caller hmp_info_local_apic() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- target/i386/cpu.h | 3 +- target/i386/helper.c | 79 ++++++++++++++++++++----------------------- target/i386/monitor.c | 3 +- 3 files changed, 39 insertions(+), 46 deletions(-)
target/i386/cpu.h +1 -2
@@ -1924,8 +1924,7 @@ void enable_compat_apic_id_mode(void);#define APIC_DEFAULT_ADDRESS 0xfee00000#define APIC_SPACE_SIZE 0x100000 -void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags); +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags);/* cpu.c */ bool cpu_is_bsp (X86CPU *cpu);
target/i386/helper.c +37 -42
184 lines not on this page · raw message
target/i386/monitor.c +1 -2
@@ -664,8 +664,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -x86_cpu_dump_local_apic_state (cs, (FILE *)mon, monitor_fprintf, -CPU_DUMP_FPU ); +x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); }void hmp_info_io_apic (Monitor *mon,const QDict *qdict)
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 11/17] target/i386: Simplify how x86_cpu_dump_local_apic_state() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
x86_cpu_dump_local_apic_state()takes an fprintf()-like callback and a FILE * to pass to it, and so do its helper functions.Its only caller
hmp_info_local_apic()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 232 lines
--- target/i386/cpu.h | 3 +- target/i386/helper.c | 79 ++++++++++++++++++++----------------------- target/i386/monitor.c | 3 +- 3 files changed, 39 insertions(+), 46 deletions(-)target/i386/cpu.h +1
-2@@ -1924,8 +1924,7 @@ void enable_compat_apic_id_mode(void);#define APIC_DEFAULT_ADDRESS 0xfee00000#define APIC_SPACE_SIZE 0x100000 -void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags); +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags);/* cpu.c */ bool cpu_is_bsp (X86CPU *cpu);target/i386/helper.c +37
-42@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "qemu/qemu-print.h" #include "sysemu/kvm.h" #include "kvm_i386.h" #ifndef CONFIG_USER_ONLY @@ -231,12 +232,10 @@ static inline const char *dm2str(uint32_t dm)return str[dm]; } -static void dump_apic_lvt (FILE *f,fprintf_function cpu_fprintf, -const char *name,uint32_t lvt,bool is_timer) +static void dump_apic_lvt (const char *name,uint32_t lvt,bool is_timer) {uint32_t dm = (lvt &APIC_LVT_DELIV_MOD ) >>APIC_LVT_DELIV_MOD_SHIFT ; - cpu_fprintf(f, - "%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", + qemu_printf("%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", name, lvt, lvt & APIC_LVT_INT_POLARITY ? "active-lo" : "active-hi", lvt & APIC_LVT_LEVEL_TRIGGER ? "level" : "edge",@@ -248,9 +247,9 @@ static void dump_apic_lvt(FILE *f, fprintf_function cpu_fprintf, "tsc-deadline" : "one-shot", dm2str(dm));if (dm !=APIC_DM_NMI ) { -cpu_fprintf (f," (vec %u)\n" , lvt &APIC_VECTOR_MASK ); +qemu_printf (" (vec %u)\n" , lvt &APIC_VECTOR_MASK ); }else { -cpu_fprintf (f,"\n" ); +qemu_printf ("\n" ); } }@@ -282,8 +281,7 @@ static inline void mask2str(char *str, uint32_t val, uint8_t size)#define MAX_LOGICAL_APIC_ID_MASK_SIZE 16 -static void dump_apic_icr (FILE *f,fprintf_function cpu_fprintf, -APICCommonState *s,CPUX86State *env) +static void dump_apic_icr (APICCommonState *s,CPUX86State *env) {uint32_t icr = s->icr[0 ], icr2 = s->icr[1 ]; uint8_t dest_shorthand = \@@ -293,16 +291,16 @@ static void dump_apic_icr(FILE *f, fprintf_function cpu_fprintf,uint32_t dest_field;bool x2apic; -cpu_fprintf (f,"ICR\t 0x%08x %s %s %s %s\n" , +qemu_printf ("ICR\t 0x%08x %s %s %s %s\n" , icr, logical_mod ?"logical" :"physical" , icr &APIC_ICR_TRIGGER_MOD ?"level" :"edge" , icr &APIC_ICR_LEVEL ?"assert" :"de-assert" ,shorthand2str (dest_shorthand)); -cpu_fprintf (f,"ICR2\t 0x%08x" , icr2); +qemu_printf ("ICR2\t 0x%08x" , icr2);if (dest_shorthand !=0 ) { -cpu_fprintf (f,"\n" ); +qemu_printf ("\n" );return ; } x2apic = env->features[FEAT_1_ECX ] &CPUID_EXT_X2APIC ;@@ -310,9 +308,9 @@ static void dump_apic_icr(FILE *f, fprintf_function cpu_fprintf,if (!logical_mod) {if (x2apic) { -cpu_fprintf (f," cpu %u (X2APIC ID)\n" , dest_field); +qemu_printf (" cpu %u (X2APIC ID)\n" , dest_field); }else { -cpu_fprintf (f," cpu %u (APIC ID)\n" , +qemu_printf (" cpu %u (APIC ID)\n" , dest_field &APIC_LOGDEST_XAPIC_ID ); }return ;@@ -320,87 +318,84 @@ static void dump_apic_icr(FILE *f, fprintf_function cpu_fprintf,if (s->dest_mode ==0xf ) {/* flat mode */ mask2str (apic_id_str, icr2 >>APIC_ICR_DEST_SHIFT ,8 ); -cpu_fprintf (f," mask %s (APIC ID)\n" , apic_id_str); +qemu_printf (" mask %s (APIC ID)\n" , apic_id_str); }else if (s->dest_mode ==0 ) {/* cluster mode */ if (x2apic) {mask2str (apic_id_str, dest_field &APIC_LOGDEST_X2APIC_ID ,16 ); -cpu_fprintf (f," cluster %u mask %s (X2APIC ID)\n" , +qemu_printf (" cluster %u mask %s (X2APIC ID)\n" , dest_field >>APIC_LOGDEST_X2APIC_SHIFT , apic_id_str); }else {mask2str (apic_id_str, dest_field &APIC_LOGDEST_XAPIC_ID ,4 ); -cpu_fprintf (f," cluster %u mask %s (APIC ID)\n" , +qemu_printf (" cluster %u mask %s (APIC ID)\n" , dest_field >>APIC_LOGDEST_XAPIC_SHIFT , apic_id_str); } } } -static void dump_apic_interrupt (FILE *f,fprintf_function cpu_fprintf, -const char *name,uint32_t *ireg_tab, +static void dump_apic_interrupt (const char *name,uint32_t *ireg_tab,uint32_t *tmr_tab) {int i, empty = true; -cpu_fprintf (f,"%s\t " , name); +qemu_printf ("%s\t " , name);for (i =0 ; i <256 ; i++) {if (apic_get_bit (ireg_tab, i)) { -cpu_fprintf (f,"%u%s " , i, +qemu_printf ("%u%s " , i,apic_get_bit (tmr_tab, i) ?"(level)" :"" ); empty = false; } } -cpu_fprintf (f,"%s\n" , empty ?"(none)" :"" ); +qemu_printf ("%s\n" , empty ?"(none)" :"" ); } -void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) {X86CPU *cpu =X86_CPU (cs);APICCommonState *s =APIC_COMMON (cpu->apic_state);if (!s) { -cpu_fprintf (f,"local apic state not available\n" ); +qemu_printf ("local apic state not available\n" );return ; }uint32_t *lvt = s->lvt; -cpu_fprintf (f,"dumping local APIC state for CPU %-2u\n\n" , +qemu_printf ("dumping local APIC state for CPU %-2u\n\n" ,CPU (cpu)->cpu_index); -dump_apic_lvt (f, cpu_fprintf,"LVT0" , lvt[APIC_LVT_LINT0 ], false); -dump_apic_lvt (f, cpu_fprintf,"LVT1" , lvt[APIC_LVT_LINT1 ], false); -dump_apic_lvt (f, cpu_fprintf,"LVTPC" , lvt[APIC_LVT_PERFORM ], false); -dump_apic_lvt (f, cpu_fprintf,"LVTERR" , lvt[APIC_LVT_ERROR ], false); -dump_apic_lvt (f, cpu_fprintf,"LVTTHMR" , lvt[APIC_LVT_THERMAL ], false); -dump_apic_lvt (f, cpu_fprintf,"LVTT" , lvt[APIC_LVT_TIMER ], true); +dump_apic_lvt ("LVT0" , lvt[APIC_LVT_LINT0 ], false); +dump_apic_lvt ("LVT1" , lvt[APIC_LVT_LINT1 ], false); +dump_apic_lvt ("LVTPC" , lvt[APIC_LVT_PERFORM ], false); +dump_apic_lvt ("LVTERR" , lvt[APIC_LVT_ERROR ], false); +dump_apic_lvt ("LVTTHMR" , lvt[APIC_LVT_THERMAL ], false); +dump_apic_lvt ("LVTT" , lvt[APIC_LVT_TIMER ], true); -cpu_fprintf (f,"Timer\t DCR=0x%x (divide by %u) initial_count = %u\n" , +qemu_printf ("Timer\t DCR=0x%x (divide by %u) initial_count = %u\n" , s->divide_conf &APIC_DCR_MASK ,divider_conf (s->divide_conf), s->initial_count); -cpu_fprintf (f,"SPIV\t 0x%08x APIC %s, focus=%s, spurious vec %u\n" , +qemu_printf ("SPIV\t 0x%08x APIC %s, focus=%s, spurious vec %u\n" , s->spurious_vec, s->spurious_vec &APIC_SPURIO_ENABLED ?"enabled" :"disabled" , s->spurious_vec &APIC_SPURIO_FOCUS ?"on" :"off" , s->spurious_vec &APIC_VECTOR_MASK ); -dump_apic_icr (f, cpu_fprintf, s, &cpu->env); +dump_apic_icr (s, &cpu->env); -cpu_fprintf (f,"ESR\t 0x%08x\n" , s->esr); +qemu_printf ("ESR\t 0x%08x\n" , s->esr); -dump_apic_interrupt (f, cpu_fprintf,"ISR" , s->isr, s->tmr); -dump_apic_interrupt (f, cpu_fprintf,"IRR" , s->irr, s->tmr); +dump_apic_interrupt ("ISR" , s->isr, s->tmr); +dump_apic_interrupt ("IRR" , s->irr, s->tmr); -cpu_fprintf (f,"\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x" , +qemu_printf ("\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x" , s->arb_id, s->tpr, s->dest_mode, s->log_dest);if (s->dest_mode ==0 ) { -cpu_fprintf (f,"(cluster %u: id %u)" , +qemu_printf ("(cluster %u: id %u)" , s->log_dest >>APIC_LOGDEST_XAPIC_SHIFT , s->log_dest &APIC_LOGDEST_XAPIC_ID ); } -cpu_fprintf (f," PPR 0x%02x\n" ,apic_get_ppr (s)); +qemu_printf (" PPR 0x%02x\n" ,apic_get_ppr (s)); }#else -void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) { }#endif /* !CONFIG_USER_ONLY */ target/i386/monitor.c +1
-2@@ -664,8 +664,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -x86_cpu_dump_local_apic_state (cs, (FILE *)mon, monitor_fprintf, -CPU_DUMP_FPU ); +x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); }void hmp_info_io_apic (Monitor *mon,const QDict *qdict)Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 12/17 qom/cpu: Simplify how CPUClass::dump_statistics() prints
In reply to Markus ArmbrusterCPUClass method dump_statistics() takes an fprintf()-like callback and a FILE * to pass to it.
Its only caller hmp_info_cpustats() (via cpu_dump_statistics()) passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
Drop the callback, and call qemu_printf() instead.
--- include/qom/cpu.h | 11 ++++------- monitor.c | 2 +- qom/cpu.c | 5 ++--- target/ppc/cpu.h | 3 +-- target/ppc/translate.c | 9 ++++----- 5 files changed, 12 insertions(+), 18 deletions(-)
include/qom/cpu.h +4 -7
@@ -184,8 +184,7 @@ typedef struct CPUClass {void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu); -void (*dump_statistics)(CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu); void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
@@ -576,14 +575,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,/** * cpu_dump_statistics: * @cpu: The CPU whose state is to be dumped. -* @f: File to dump to. -* @cpu_fprintf: Function to dump with. * @flags: Flags what to dump. * -* Dumps CPU statistics. +* Dump CPU statistics to the current monitor if we have one, else to +* stdout. */ -void cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cpu_dump_statistics (CPUState *cpu,int flags);#ifndef CONFIG_USER_ONLY /**
monitor.c +1 -1
@@ -1364,7 +1364,7 @@ static void hmp_info_cpustats(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -cpu_dump_statistics (cs, (FILE *)mon, &monitor_fprintf,0 ); +cpu_dump_statistics (cs,0 ); }static void hmp_info_trace_events (Monitor *mon,const QDict *qdict)
qom/cpu.c +2 -3
@@ -230,13 +230,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, } } -void cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cpu_dump_statistics (CPUState *cpu,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->dump_statistics) { - cc->dump_statistics (cpu, f, cpu_fprintf, flags); + cc->dump_statistics (cpu, flags); } }
target/ppc/cpu.h +1 -2
@@ -1270,8 +1270,7 @@ void ppc_cpu_do_interrupt(CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req);void ppc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); -void ppc_cpu_dump_statistics (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void ppc_cpu_dump_statistics (CPUState *cpu,int flags);hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int ppc_cpu_gdb_read_register_apple (CPUState *cpu,uint8_t *buf,int reg);
target/ppc/translate.c +4 -5
@@ -7593,8 +7593,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,#undef RFPL } -void ppc_cpu_dump_statistics (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void ppc_cpu_dump_statistics (CPUState *cs,int flags) {#if defined(DO_PPC_STATISTICS )PowerPCCPU *cpu =POWERPC_CPU (cs);
@@ -7614,7 +7613,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, handler = t3[op3];if (handler->count ==0 )continue ; - cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: " + qemu_printf("%02x %02x %02x (%02x %04d) %16s: " "%016" PRIx64 " %" PRId64 "\n", op1, op2, op3, op1, (op3 << 5) | op2, handler->oname,
@@ -7623,7 +7622,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, }else {if (handler->count ==0 )continue ; -cpu_fprintf (f,"%02x %02x (%02x %04d) %16s: " +qemu_printf ("%02x %02x (%02x %04d) %16s: " "%016" PRIx64" %" PRId64"\n" , op1, op2, op1, op2, handler->oname, handler->count, handler->count);
@@ -7632,7 +7631,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, }else {if (handler->count ==0 )continue ; -cpu_fprintf (f,"%02x (%02x ) %16s: %016" PRIx64 +qemu_printf ("%02x (%02x ) %16s: %016" PRIx64" %" PRId64"\n" , op1, op1, handler->oname, handler->count, handler->count);
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 12/17] qom/cpu: Simplify how CPUClass::dump_statistics() prints
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
CPUClass method
dump_statistics()takes an fprintf()-like callback and a FILE * to pass to it.Its only caller
hmp_info_cpustats()(viacpu_dump_statistics()) passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.Drop the callback, and call
qemu_printf()instead.Signed-off-by Markus Armbruster <[email protected]>
Quoted 131 lines
--- include/qom/cpu.h | 11 ++++------- monitor.c | 2 +- qom/cpu.c | 5 ++--- target/ppc/cpu.h | 3 +-- target/ppc/translate.c | 9 ++++----- 5 files changed, 12 insertions(+), 18 deletions(-)include/qom/cpu.h +4
-7@@ -184,8 +184,7 @@ typedef struct CPUClass {void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu); -void (*dump_statistics)(CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu); void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,@@ -576,14 +575,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,/** * cpu_dump_statistics: * @cpu: The CPU whose state is to be dumped. -* @f: File to dump to. -* @cpu_fprintf: Function to dump with. * @flags: Flags what to dump. * -* Dumps CPU statistics. +* Dump CPU statistics to the current monitor if we have one, else to +* stdout. */ -void cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cpu_dump_statistics (CPUState *cpu,int flags);#ifndef CONFIG_USER_ONLY /** monitor.c +1
-1@@ -1364,7 +1364,7 @@ static void hmp_info_cpustats(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -cpu_dump_statistics (cs, (FILE *)mon, &monitor_fprintf,0 ); +cpu_dump_statistics (cs,0 ); }static void hmp_info_trace_events (Monitor *mon,const QDict *qdict)qom/cpu.c +2
-3@@ -230,13 +230,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, } } -void cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cpu_dump_statistics (CPUState *cpu,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->dump_statistics) { - cc->dump_statistics (cpu, f, cpu_fprintf, flags); + cc->dump_statistics (cpu, flags); } }target/ppc/cpu.h +1
-2@@ -1270,8 +1270,7 @@ void ppc_cpu_do_interrupt(CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req);void ppc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); -void ppc_cpu_dump_statistics (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void ppc_cpu_dump_statistics (CPUState *cpu,int flags);hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int ppc_cpu_gdb_read_register_apple (CPUState *cpu,uint8_t *buf,int reg);target/ppc/translate.c +4
-5@@ -7593,8 +7593,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,#undef RFPL } -void ppc_cpu_dump_statistics (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void ppc_cpu_dump_statistics (CPUState *cs,int flags) {#if defined(DO_PPC_STATISTICS )PowerPCCPU *cpu =POWERPC_CPU (cs);@@ -7614,7 +7613,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, handler = t3[op3];if (handler->count ==0 )continue ; - cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: " + qemu_printf("%02x %02x %02x (%02x %04d) %16s: " "%016" PRIx64 " %" PRId64 "\n", op1, op2, op3, op1, (op3 << 5) | op2, handler->oname,@@ -7623,7 +7622,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, }else {if (handler->count ==0 )continue ; -cpu_fprintf (f,"%02x %02x (%02x %04d) %16s: " +qemu_printf ("%02x %02x (%02x %04d) %16s: " "%016" PRIx64" %" PRId64"\n" , op1, op2, op1, op2, handler->oname, handler->count, handler->count);@@ -7632,7 +7631,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, }else {if (handler->count ==0 )continue ; -cpu_fprintf (f,"%02x (%02x ) %16s: %016" PRIx64 +qemu_printf ("%02x (%02x ) %16s: %016" PRIx64" %" PRId64"\n" , op1, op1, handler->oname, handler->count, handler->count);Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 13/17 qemu-print: New qemu_fprintf(), qemu_vfprintf()
In reply to Markus ArmbrusterCode that doesn't want to know about current monitor vs. stdout vs. stderr takes an fprintf_function callback and a FILE * argument to pass to it. Actual arguments are either fprintf() and stdout or stderr, or monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly.
New qemu_fprintf() and qemu_vprintf() address this need without type
punning: they are like fprintf() and vfprintf(), except they print to the current monitor when passed a null FILE *. The next commits will put them to use.
--- include/qemu/qemu-print.h | 4 ++++ util/qemu-print.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/qemu/qemu-print.h +4 -0
@@ -16,4 +16,8 @@ int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +int qemu_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +#endif
util/qemu-print.c +27 -0
@@ -40,3 +40,30 @@ int qemu_printf(const char *fmt, ...)va_end (ap);return ret; } + +/* +* Print like vfprintf() +* Print to @stream if non-null, else to current monitor. +*/ +int qemu_vfprintf (FILE *stream,const char *fmt,va_list ap) +{ +if (!stream) { +return monitor_vprintf (cur_mon, fmt, ap); + } +return vfprintf (stream, fmt, ap); +} + +/* +* Print like fprintf(). +* Print to @stream if non-null, else to current monitor. +*/ +int qemu_fprintf (FILE *stream,const char *fmt, ...) +{ +va_list ap; +int ret; + +va_start (ap, fmt); + ret =qemu_vfprintf (stream, fmt, ap); +va_end (ap); +return ret; +}
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 13/17] qemu-print: New qemu_fprintf(), qemu_vfprintf()
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
Code that doesn't want to know about current monitor vs. stdout vs. stderr takes an
fprintf_functioncallback and a FILE * argument to pass to it. Actual arguments are eitherfprintf()and stdout or stderr, ormonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-punning is ugly.
Quoted 6 lines
New
qemu_fprintf()andqemu_vprintf()address this need without type
punning: they are likefprintf()andvfprintf(), except they print to the current monitor when passed a null FILE *. The next commits will put them to use.Signed-off-by Markus Armbruster <[email protected]>
Quoted 56 lines
--- include/qemu/qemu-print.h | 4 ++++ util/qemu-print.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)include/qemu/qemu-print.h +4
-0@@ -16,4 +16,8 @@ int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +int qemu_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +#endif util/qemu-print.c +27
-0@@ -40,3 +40,30 @@ int qemu_printf(const char *fmt, ...)va_end (ap);return ret; } + +/* +* Print like vfprintf() +* Print to @stream if non-null, else to current monitor. +*/ +int qemu_vfprintf (FILE *stream,const char *fmt,va_list ap) +{ +if (!stream) { +return monitor_vprintf (cur_mon, fmt, ap); + } +return vfprintf (stream, fmt, ap); +} + +/* +* Print like fprintf(). +* Print to @stream if non-null, else to current monitor. +*/ +int qemu_fprintf (FILE *stream,const char *fmt, ...) +{ +va_list ap; +int ret; + +va_start (ap, fmt); + ret =qemu_vfprintf (stream, fmt, ap); +va_end (ap); +return ret; +}Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 14/17 qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
In reply to Markus ArmbrusterCPUClass 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 *.
--- accel/kvm/kvm-all.c | 4 +- bsd-user/main.c | 2 +- cpus.c | 2 +- exec.c | 2 +- include/exec/log.h | 2 +- include/qom/cpu.h | 11 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/cpu_loop-common.h | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 4 +- linux-user/s390x/cpu_loop.c | 4 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- monitor.c | 4 +- qom/cpu.c | 6 +- target/alpha/cpu.h | 3 +- target/alpha/helper.c | 24 +-- target/arm/arm-semi.c | 2 +- target/arm/cpu.h | 3 +- target/arm/translate-a64.c | 82 ++++----- target/arm/translate.c | 58 +++---- target/arm/translate.h | 7 +- target/cris/cpu.h | 3 +- target/cris/helper.c | 2 +- target/cris/translate.c | 36 ++-- target/hppa/cpu.h | 2 +- target/hppa/helper.c | 24 +-- target/i386/cpu.h | 5 +- target/i386/hax-all.c | 4 +- target/i386/helper.c | 281 +++++++++++++++---------------- target/i386/monitor.c | 2 +- target/lm32/cpu.h | 3 +- target/lm32/translate.c | 36 ++-- target/m68k/cpu.h | 3 +- target/m68k/translate.c | 86 +++++----- target/microblaze/cpu.h | 3 +- target/microblaze/helper.c | 2 +- target/microblaze/translate.c | 39 ++--- target/mips/internal.h | 3 +- target/mips/translate.c | 76 ++++----- target/moxie/cpu.h | 3 +- target/moxie/helper.c | 2 +- target/moxie/translate.c | 22 +-- target/nios2/cpu.h | 3 +- target/nios2/helper.c | 2 +- target/nios2/translate.c | 24 +-- target/openrisc/cpu.h | 3 +- target/openrisc/translate.c | 11 +- target/ppc/cpu.h | 3 +- target/ppc/translate.c | 161 +++++++++--------- target/riscv/cpu.c | 37 ++-- target/s390x/helper.c | 42 ++--- target/s390x/internal.h | 3 +- target/sh4/cpu.h | 3 +- target/sh4/translate.c | 27 +-- target/sparc/cpu.c | 84 +++++---- target/sparc/cpu.h | 3 +- target/tilegx/cpu.c | 14 +- target/tricore/cpu.h | 3 +- target/tricore/translate.c | 26 +-- target/unicore32/cpu.h | 3 +- target/unicore32/translate.c | 39 +++-- target/xtensa/cpu.h | 3 +- target/xtensa/translate.c | 40 ++--- 64 files changed, 686 insertions(+), 715 deletions(-)
accel/kvm/kvm-all.c +2 -2
@@ -1798,7 +1798,7 @@ static int kvm_handle_internal_error(CPUState *cpu, struct kvm_run *run)if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION ) {fprintf (stderr,"emulation failure\n" );if (!kvm_arch_stop_on_emulation_error (cpu)) { -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_CODE ); +cpu_dump_state (cpu, stderr,CPU_DUMP_CODE );return EXCP_INTERRUPT ; } }
@@ -2089,7 +2089,7 @@ int kvm_cpu_exec(CPUState *cpu)qemu_mutex_lock_iothread ();if (ret <0 ) { -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_CODE ); +cpu_dump_state (cpu, stderr,CPU_DUMP_CODE );vm_stop (RUN_STATE_INTERNAL_ERROR ); }
bsd-user/main.c +1 -1
@@ -639,7 +639,7 @@ void cpu_loop(CPUSPARCState *env) badtrap:#endif printf ("Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (1 ); }process_pending_signals (env);
cpus.c +1 -1
@@ -1010,7 +1010,7 @@ void hw_error(const char *fmt, ...)fprintf (stderr,"\n" );CPU_FOREACH (cpu) {fprintf (stderr,"CPU #%d:\n" , cpu->cpu_index); -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cpu, stderr,CPU_DUMP_FPU ); }va_end (ap);abort ();
exec.c +1 -1
@@ -1256,7 +1256,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)fprintf (stderr,"qemu: fatal: " );vfprintf (stderr, fmt, ap);fprintf (stderr,"\n" ); -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_FPU |CPU_DUMP_CCOP ); +cpu_dump_state (cpu, stderr,CPU_DUMP_FPU |CPU_DUMP_CCOP );if (qemu_log_separate ()) {qemu_log_lock ();qemu_log ("qemu: fatal: " );
include/exec/log.h +1 -1
@@ -16,7 +16,7 @@static inline void log_cpu_state (CPUState *cpu,int flags) {if (qemu_log_enabled ()) { -cpu_dump_state (cpu, qemu_logfile, fprintf, flags); +cpu_dump_state (cpu, qemu_logfile, flags); } }
include/qom/cpu.h +3 -8
@@ -26,7 +26,6 @@#include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" -#include "qemu/fprintf-fn.h" #include "qemu/rcu_queue.h" #include "qemu/queue.h" #include "qemu/thread.h"
@@ -181,8 +180,7 @@ typedef struct CPUClass {bool (*virtio_is_big_endian)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write); -void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void (*dump_state)(CPUState *cpu,FILE *,int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu);void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);
@@ -563,14 +561,11 @@ enum CPUDumpFlags {/** * cpu_dump_state: * @cpu: The CPU whose state is to be dumped. -* @f: File to dump to. -* @cpu_fprintf: Function to dump with. -* @flags: Flags what to dump. +* @f: If non-null, dump to this stream, else to current print sink. * * Dumps CPU state. */ -void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cpu_dump_state (CPUState *cpu,FILE *f,int flags);/** * cpu_dump_statistics:
linux-user/alpha/cpu_loop.c +1 -1
@@ -193,7 +193,7 @@ void cpu_loop(CPUAlphaState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
linux-user/cpu_loop-common.h +1 -1
@@ -26,7 +26,7 @@ do { \ CPUState *cs = ENV_GET_CPU(env); \ fprintf(stderr, fmt , ## __VA_ARGS__); \ - cpu_dump_state(cs, stderr, fprintf, 0); \ + cpu_dump_state(cs, stderr, 0); \ if (qemu_log_separate()) { \ qemu_log(fmt, ## __VA_ARGS__); \ log_cpu_state(cs, 0); \
linux-user/cris/cpu_loop.c +1 -1
@@ -74,7 +74,7 @@ void cpu_loop(CPUCRISState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
linux-user/microblaze/cpu_loop.c +2 -2
@@ -107,7 +107,7 @@ void cpu_loop(CPUMBState *env)default :fprintf (stderr,"Unhandled hw-exception: 0x%" PRIx64"\n" , env->sregs[SR_ESR ] &ESR_EC_MASK ); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE );break ; }
@@ -123,7 +123,7 @@ void cpu_loop(CPUMBState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
linux-user/s390x/cpu_loop.c +2 -2
@@ -124,7 +124,7 @@ void cpu_loop(CPUS390XState *env)default :fprintf (stderr,"Unhandled program exception: %#x\n" , n); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }break ;
@@ -144,7 +144,7 @@ void cpu_loop(CPUS390XState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
linux-user/sh4/cpu_loop.c +1 -1
@@ -76,7 +76,7 @@ void cpu_loop(CPUSH4State *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
linux-user/sparc/cpu_loop.c +1 -1
@@ -278,7 +278,7 @@ void cpu_loop (CPUSPARCState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);
monitor.c +2 -2
@@ -1296,7 +1296,7 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)if (all_cpus) {CPU_FOREACH (cs) {monitor_printf (mon,"\nCPU#%d\n" , cs->cpu_index); -cpu_dump_state (cs, (FILE *)mon, monitor_fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cs,NULL ,CPU_DUMP_FPU ); } }else { cs =mon_get_cpu ();
@@ -1306,7 +1306,7 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)return ; } -cpu_dump_state (cs, (FILE *)mon, monitor_fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cs,NULL ,CPU_DUMP_FPU ); } }
qom/cpu.c +3 -3
@@ -28,6 +28,7 @@#include "exec/log.h" #include "exec/cpu-common.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/qdev-properties.h"
@@ -219,14 +220,13 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)return res; } -void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cpu_dump_state (CPUState *cpu,FILE *f,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->dump_state) {cpu_synchronize_state (cpu); - cc->dump_state (cpu, f, cpu_fprintf, flags); + cc->dump_state (cpu, f, flags); } }
target/alpha/cpu.h +1 -2
@@ -311,8 +311,7 @@ extern const struct VMStateDescription vmstate_alpha_cpu;void alpha_cpu_do_interrupt (CPUState *cpu);bool alpha_cpu_exec_interrupt (CPUState *cpu,int int_req); -void alpha_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int alpha_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int alpha_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/alpha/helper.c +12 -12
@@ -23,6 +23,7 @@#include "exec/exec-all.h" #include "fpu/softfloat.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" #define CONVERT_BIT (X ,SRC ,DST ) \
@@ -426,8 +427,7 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request)return false; } -void alpha_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags) {static const char *linux_reg_names[] = {"v0 " ,"t0 " ,"t1 " ,"t2 " ,"t3 " ,"t4 " ,"t5 " ,"t6 " ,
@@ -439,24 +439,24 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,CPUAlphaState *env = &cpu->env;int i; -cpu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , - env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 )); +qemu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , + env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 ));for (i =0 ; i <31 ; i++) { -cpu_fprintf (f,"IR%02d %s " TARGET_FMT_lx"%c" , i, - linux_reg_names[i],cpu_alpha_load_gr (env, i), - (i %3 ) ==2 ?'\n' :' ' ); +qemu_fprintf (f,"IR%02d %s " TARGET_FMT_lx"%c" , i, + linux_reg_names[i],cpu_alpha_load_gr (env, i), + (i %3 ) ==2 ?'\n' :' ' ); } -cpu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , - env->lock_addr, env->lock_value); +qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , + env->lock_addr, env->lock_value);if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <31 ; i++) { -cpu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], - (i %3 ) ==2 ?'\n' :' ' ); +qemu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], + (i %3 ) ==2 ?'\n' :' ' ); } } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }/* This should only be called from translate, via gen_excp.
target/arm/arm-semi.c +1 -1
@@ -650,7 +650,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)/* fall through -- invalid for A32/T32 */ default :fprintf (stderr,"qemu: Unsupported SemiHosting SWI 0x%02x\n" , nr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );abort (); } }
target/arm/cpu.h +1 -2
@@ -935,8 +935,7 @@ void arm_cpu_do_interrupt(CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu);bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req); -void arm_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr,MemTxAttrs *attrs);
target/arm/translate-a64.c +41 -41
154 lines not on this page · raw message
target/arm/translate.c +29 -29
101 lines not on this page · raw message
target/arm/translate.h +2 -5
@@ -166,8 +166,7 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)#ifdef TARGET_AARCH64 void a64_translate_init (void );void gen_a64_set_pc_im (uint64_t val); -void aarch64_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags); +void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags);extern const TranslatorOps aarch64_translator_ops;#else static inline void a64_translate_init (void )
@@ -178,9 +177,7 @@ static inline void gen_a64_set_pc_im(uint64_t val) { } -static inline void aarch64_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf, -int flags) +static inline void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags) { }#endif
target/cris/cpu.h +1 -2
@@ -207,8 +207,7 @@ void cris_cpu_do_interrupt(CPUState *cpu);void crisv10_cpu_do_interrupt (CPUState *cpu);bool cris_cpu_exec_interrupt (CPUState *cpu,int int_req); -void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cris_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr cris_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);
target/cris/helper.c +1 -1
@@ -60,7 +60,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, cs->exception_index =0xaa ; cpu->env.pregs[PR_EDA ] = address; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }
target/cris/translate.c +18 -18
@@ -33,6 +33,7 @@#include "exec/cpu_ldst.h" #include "exec/translator.h" #include "crisv32-decode.h" +#include "qemu/qemu-print.h" #include "exec/helper-gen.h"
@@ -3299,8 +3300,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)#endif } -void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cris_cpu_dump_state (CPUState *cs,FILE *f,int flags) {CRISCPU *cpu =CRIS_CPU (cs);CPUCRISState *env = &cpu->env;
@@ -3308,7 +3308,7 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,const char **pregnames;int i; -if (!env || !f) { +if (!env) {return ; }if (env->pregs[PR_VR ] <32 ) {
@@ -3319,40 +3319,40 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, regnames = regnames_v32; } -cpu_fprintf (f,"PC=%x CCS=%x btaken=%d btarget=%x\n" -"cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n" , - env->pc, env->pregs[PR_CCS ], env->btaken, env->btarget, - env->cc_op, - env->cc_src, env->cc_dest, env->cc_result, env->cc_mask); +qemu_fprintf (f,"PC=%x CCS=%x btaken=%d btarget=%x\n" +"cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n" , + env->pc, env->pregs[PR_CCS ], env->btaken, env->btarget, + env->cc_op, + env->cc_src, env->cc_dest, env->cc_result, env->cc_mask);for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"%s=%8.8x " , regnames[i], env->regs[i]); +qemu_fprintf (f,"%s=%8.8x " , regnames[i], env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } -cpu_fprintf (f,"\nspecial regs:\n" ); +qemu_fprintf (f,"\nspecial regs:\n" );for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"%s=%8.8x " , pregnames[i], env->pregs[i]); +qemu_fprintf (f,"%s=%8.8x " , pregnames[i], env->pregs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }if (env->pregs[PR_VR ] >=32 ) {uint32_t srs = env->pregs[PR_SRS ]; -cpu_fprintf (f,"\nsupport function regs bank %x:\n" , srs); +qemu_fprintf (f,"\nsupport function regs bank %x:\n" , srs);if (srs <ARRAY_SIZE (env->sregs)) {for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"s%2.2d=%8.8x " , - i, env->sregs[srs][i]); +qemu_fprintf (f,"s%2.2d=%8.8x " , + i, env->sregs[srs][i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } } } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }
target/hppa/cpu.h +1 -1
@@ -359,7 +359,7 @@ int hppa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);int hppa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void hppa_cpu_do_interrupt (CPUState *cpu);bool hppa_cpu_exec_interrupt (CPUState *cpu,int int_req); -void hppa_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function ,int ); +void hppa_cpu_dump_state (CPUState *cs,FILE *f,int );#ifdef CONFIG_USER_ONLY int hppa_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int midx);
target/hppa/helper.c +12 -12
@@ -23,6 +23,7 @@#include "fpu/softfloat.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" target_ureg cpu_hppa_get_psw (CPUHPPAState *env) {
@@ -76,8 +77,7 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw) } } -void hppa_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void hppa_cpu_dump_state (CPUState *cs,FILE *f,int flags) {HPPACPU *cpu =HPPA_CPU (cs);CPUHPPAState *env = &cpu->env;
@@ -86,9 +86,9 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f,char psw_c[20 ];int i; -cpu_fprintf (f,"IA_F " TARGET_FMT_lx" IA_B " TARGET_FMT_lx"\n" , -hppa_form_gva_psw (psw, env->iasq_f, env->iaoq_f), -hppa_form_gva_psw (psw, env->iasq_b, env->iaoq_b)); +qemu_fprintf (f,"IA_F " TARGET_FMT_lx" IA_B " TARGET_FMT_lx"\n" , +hppa_form_gva_psw (psw, env->iasq_f, env->iaoq_f), +hppa_form_gva_psw (psw, env->iasq_b, env->iaoq_b)); psw_c[0 ] = (psw &PSW_W ?'W' :'-' ); psw_c[1 ] = (psw &PSW_E ?'E' :'-' );
@@ -111,20 +111,20 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, psw_c[18 ] ='\0' ; psw_cb = ((env->psw_cb >>4 ) &0x01111111 ) | (env->psw_cb_msb <<28 ); -cpu_fprintf (f,"PSW " TREG_FMT_lx" CB " TREG_FMT_lx" %s\n" , - psw, psw_cb, psw_c); +qemu_fprintf (f,"PSW " TREG_FMT_lx" CB " TREG_FMT_lx" %s\n" , + psw, psw_cb, psw_c);for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"GR%02d " TREG_FMT_lx"%c" , i, env->gr[i], - (i &3 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"GR%02d " TREG_FMT_lx"%c" , i, env->gr[i], + (i &3 ) ==3 ?'\n' :' ' ); }#ifndef CONFIG_USER_ONLY for (i =0 ; i <8 ; i++) { -cpu_fprintf (f,"SR%02d %08x%c" , i, (uint32_t )(env->sr[i] >>32 ), - (i &3 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"SR%02d %08x%c" , i, (uint32_t )(env->sr[i] >>32 ), + (i &3 ) ==3 ?'\n' :' ' ); }#endif -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );/* ??? FR */ }
target/i386/cpu.h +2 -3
@@ -1521,8 +1521,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,void x86_cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list,Error **errp); -void x86_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void x86_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr x86_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);
@@ -1924,7 +1923,7 @@ void enable_compat_apic_id_mode(void);#define APIC_DEFAULT_ADDRESS 0xfee00000#define APIC_SPACE_SIZE 0x100000 -void x86_cpu_dump_local_apic_state (CPUState *cs,int flags); +void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f,int flags);/* cpu.c */ bool cpu_is_bsp (X86CPU *cpu);
target/i386/hax-all.c +2 -2
@@ -540,7 +540,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env) ht->_exit_reason);qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_RESET );hax_vcpu_sync_state (env,0 ); -cpu_dump_state (cpu, stderr, fprintf,0 ); +cpu_dump_state (cpu, stderr,0 ); ret =-1 ;break ;case HAX_EXIT_HLT :
@@ -571,7 +571,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env)fprintf (stderr,"Unknown exit %x from HAX\n" , ht->_exit_status);qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_RESET );hax_vcpu_sync_state (env,0 ); -cpu_dump_state (cpu, stderr, fprintf,0 ); +cpu_dump_state (cpu, stderr,0 ); ret =1 ;break ; }
target/i386/helper.c +140 -141
394 lines not on this page · raw message
target/i386/monitor.c +1 -1
@@ -664,7 +664,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); +x86_cpu_dump_local_apic_state (cs,NULL ,CPU_DUMP_FPU ); }void hmp_info_io_apic (Monitor *mon,const QDict *qdict)
target/lm32/cpu.h +1 -2
@@ -219,8 +219,7 @@ extern const struct VMStateDescription vmstate_lm32_cpu;void lm32_cpu_do_interrupt (CPUState *cpu);bool lm32_cpu_exec_interrupt (CPUState *cs,int int_req); -void lm32_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void lm32_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr lm32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int lm32_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int lm32_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/lm32/translate.c +18 -18
@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "exec/translator.h" #include "tcg-op.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "hw/lm32/lm32_pic.h"
@@ -1161,38 +1162,37 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)#endif } -void lm32_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void lm32_cpu_dump_state (CPUState *cs,FILE *f,int flags) {LM32CPU *cpu =LM32_CPU (cs);CPULM32State *env = &cpu->env;int i; -if (!env || !f) { +if (!env) {return ; } -cpu_fprintf (f,"IN: PC=%x %s\n" , - env->pc,lookup_symbol (env->pc)); +qemu_fprintf (f,"IN: PC=%x %s\n" , + env->pc,lookup_symbol (env->pc)); -cpu_fprintf (f,"ie=%8.8x (IE=%x EIE=%x BIE=%x) im=%8.8x ip=%8.8x\n" , - env->ie, - (env->ie &IE_IE ) ?1 :0 , - (env->ie &IE_EIE ) ?1 :0 , - (env->ie &IE_BIE ) ?1 :0 , -lm32_pic_get_im (env->pic_state), -lm32_pic_get_ip (env->pic_state)); -cpu_fprintf (f,"eba=%8.8x deba=%8.8x\n" , - env->eba, - env->deba); +qemu_fprintf (f,"ie=%8.8x (IE=%x EIE=%x BIE=%x) im=%8.8x ip=%8.8x\n" , + env->ie, + (env->ie &IE_IE ) ?1 :0 , + (env->ie &IE_EIE ) ?1 :0 , + (env->ie &IE_BIE ) ?1 :0 , +lm32_pic_get_im (env->pic_state), +lm32_pic_get_ip (env->pic_state)); +qemu_fprintf (f,"eba=%8.8x deba=%8.8x\n" , + env->eba, + env->deba);for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]); +qemu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); } void restore_state_to_opc(CPULM32State *env, TranslationBlock *tb,
target/m68k/cpu.h +1 -2
@@ -179,8 +179,7 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)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,fprintf_function cpu_fprintf, -int flags); +void m68k_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr m68k_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int m68k_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int m68k_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/m68k/translate.c +43 -43
125 lines not on this page · raw message
target/microblaze/cpu.h +1 -2
@@ -328,8 +328,7 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)void mb_cpu_do_interrupt (CPUState *cs);bool mb_cpu_exec_interrupt (CPUState *cs,int int_req); -void mb_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void mb_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr mb_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int mb_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int mb_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/microblaze/helper.c +1 -1
@@ -42,7 +42,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, int mmu_idx) { cs->exception_index =0xaa ; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }
target/microblaze/translate.c +20 -19
@@ -28,6 +28,7 @@#include "exec/cpu_ldst.h" #include "exec/helper-gen.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" #include "trace-tcg.h" #include "exec/log.h"
@@ -1785,36 +1786,36 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)assert (!dc->abort_at_next_insn); } -void mb_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void mb_cpu_dump_state (CPUState *cs,FILE *f,int flags) {MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs);CPUMBState *env = &cpu->env;int i; -if (!env || !f) +if (!env) {return ; + } -cpu_fprintf (f,"IN: PC=%" PRIx64" %s\n" , - env->sregs[SR_PC ],lookup_symbol (env->sregs[SR_PC ])); -cpu_fprintf (f,"rmsr=%" PRIx64" resr=%" PRIx64" rear=%" PRIx64" " -"debug=%x imm=%x iflags=%x fsr=%" PRIx64"\n" , - env->sregs[SR_MSR ], env->sregs[SR_ESR ], env->sregs[SR_EAR ], - env->debug, env->imm, env->iflags, env->sregs[SR_FSR ]); -cpu_fprintf (f,"btaken=%d btarget=%" PRIx64" mode=%s(saved=%s) " -"eip=%d ie=%d\n" , - env->btaken, env->btarget, - (env->sregs[SR_MSR ] &MSR_UM ) ?"user" :"kernel" , - (env->sregs[SR_MSR ] &MSR_UMS ) ?"user" :"kernel" , - (bool )(env->sregs[SR_MSR ] &MSR_EIP ), - (bool )(env->sregs[SR_MSR ] &MSR_IE )); +qemu_fprintf (f,"IN: PC=%" PRIx64" %s\n" , + env->sregs[SR_PC ],lookup_symbol (env->sregs[SR_PC ])); +qemu_fprintf (f,"rmsr=%" PRIx64" resr=%" PRIx64" rear=%" PRIx64" " +"debug=%x imm=%x iflags=%x fsr=%" PRIx64"\n" , + env->sregs[SR_MSR ], env->sregs[SR_ESR ], env->sregs[SR_EAR ], + env->debug, env->imm, env->iflags, env->sregs[SR_FSR ]); +qemu_fprintf (f,"btaken=%d btarget=%" PRIx64" mode=%s(saved=%s) " +"eip=%d ie=%d\n" , + env->btaken, env->btarget, + (env->sregs[SR_MSR ] &MSR_UM ) ?"user" :"kernel" , + (env->sregs[SR_MSR ] &MSR_UMS ) ?"user" :"kernel" , + (bool )(env->sregs[SR_MSR ] &MSR_EIP ), + (bool )(env->sregs[SR_MSR ] &MSR_IE ));for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]); +qemu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]);if ((i +1 ) %4 ==0 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }void mb_tcg_init (void )
target/mips/internal.h +1 -2
@@ -76,8 +76,7 @@ enum CPUMIPSMSADataFormat {void mips_cpu_do_interrupt (CPUState *cpu);bool mips_cpu_exec_interrupt (CPUState *cpu,int int_req); -void mips_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void mips_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr mips_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int mips_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int mips_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/mips/translate.c +38 -38
114 lines not on this page · raw message
target/moxie/cpu.h +1 -2
@@ -112,8 +112,7 @@ static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)#define ENV_OFFSET offsetof(MoxieCPU, env)void moxie_cpu_do_interrupt (CPUState *cs); -void moxie_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void moxie_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr moxie_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void moxie_translate_init (void ); int cpu_moxie_signal_handler(int host_signum, void *pinfo,
target/moxie/helper.c +1 -1
@@ -101,7 +101,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cs->exception_index =0xaa ; cpu->env.debug1 = address; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }
target/moxie/translate.c +11 -11
@@ -28,6 +28,7 @@#include "disas/disas.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h"
@@ -69,24 +70,23 @@ static int extract_branch_offset(int opcode)return (((signed short )((opcode & ((1 <<10 ) -1 )) <<6 )) >>6 ) <<1 ; } -void moxie_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void moxie_cpu_dump_state (CPUState *cs,FILE *f,int flags) {MoxieCPU *cpu =MOXIE_CPU (cs);CPUMoxieState *env = &cpu->env;int i; -cpu_fprintf (f,"pc=0x%08x\n" , env->pc); -cpu_fprintf (f,"$fp=0x%08x $sp=0x%08x $r0=0x%08x $r1=0x%08x\n" , - env->gregs[0 ], env->gregs[1 ], env->gregs[2 ], env->gregs[3 ]); +qemu_fprintf (f,"pc=0x%08x\n" , env->pc); +qemu_fprintf (f,"$fp=0x%08x $sp=0x%08x $r0=0x%08x $r1=0x%08x\n" , + env->gregs[0 ], env->gregs[1 ], env->gregs[2 ], env->gregs[3 ]);for (i =4 ; i <16 ; i +=4 ) { -cpu_fprintf (f,"$r%d=0x%08x $r%d=0x%08x $r%d=0x%08x $r%d=0x%08x\n" , - i-2 , env->gregs[i], i-1 , env->gregs[i +1 ], - i, env->gregs[i +2 ], i+1 , env->gregs[i +3 ]); +qemu_fprintf (f,"$r%d=0x%08x $r%d=0x%08x $r%d=0x%08x $r%d=0x%08x\n" , + i -2 , env->gregs[i], i -1 , env->gregs[i +1 ], + i, env->gregs[i +2 ], i +1 , env->gregs[i +3 ]); }for (i =4 ; i <16 ; i +=4 ) { -cpu_fprintf (f,"sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x\n" , - i-2 , env->sregs[i], i-1 , env->sregs[i +1 ], - i, env->sregs[i +2 ], i+1 , env->sregs[i +3 ]); +qemu_fprintf (f,"sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x\n" , + i -2 , env->sregs[i], i -1 , env->sregs[i +1 ], + i, env->sregs[i +2 ], i +1 , env->sregs[i +3 ]); } }
target/nios2/cpu.h +1 -2
@@ -213,8 +213,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,fprintf_function cpu_fprintf, -int flags); +void nios2_cpu_dump_state (CPUState *cpu,FILE *f,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,
target/nios2/helper.c +1 -1
@@ -42,7 +42,7 @@ int nios2_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cs->exception_index =0xaa ;/* Page 0x1000 is kuser helper */ if (address <0x1000 || address >=0x2000 ) { -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 ); }return 1 ; }
target/nios2/translate.c +12 -12
@@ -31,6 +31,7 @@#include "exec/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0/* only pc was modified dynamically */
@@ -914,33 +915,32 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)#endif } -void nios2_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void nios2_cpu_dump_state (CPUState *cs,FILE *f,int flags) {Nios2CPU *cpu =NIOS2_CPU (cs);CPUNios2State *env = &cpu->env;int i; -if (!env || !f) { +if (!env) {return ; } -cpu_fprintf (f,"IN: PC=%x %s\n" , - env->regs[R_PC ],lookup_symbol (env->regs[R_PC ])); +qemu_fprintf (f,"IN: PC=%x %s\n" , + env->regs[R_PC ],lookup_symbol (env->regs[R_PC ]));for (i =0 ; i <NUM_CORE_REGS ; i++) { -cpu_fprintf (f,"%9s=%8.8x " , regnames[i], env->regs[i]); +qemu_fprintf (f,"%9s=%8.8x " , regnames[i], env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }#if !defined(CONFIG_USER_ONLY ) -cpu_fprintf (f," mmu write: VPN=%05X PID %02X TLBACC %08X\n" , - env->mmu.pteaddr_wr &CR_PTEADDR_VPN_MASK , - (env->mmu.tlbmisc_wr &CR_TLBMISC_PID_MASK ) >>4 , - env->mmu.tlbacc_wr); +qemu_fprintf (f," mmu write: VPN=%05X PID %02X TLBACC %08X\n" , + env->mmu.pteaddr_wr &CR_PTEADDR_VPN_MASK , + (env->mmu.tlbmisc_wr &CR_TLBMISC_PID_MASK ) >>4 , + env->mmu.tlbacc_wr);#endif -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }void nios2_tcg_init (void )
target/openrisc/cpu.h +1 -2
@@ -339,8 +339,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)void cpu_openrisc_list (void );void openrisc_cpu_do_interrupt (CPUState *cpu);bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req); -void openrisc_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void openrisc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/openrisc/translate.c +5 -6
@@ -26,6 +26,7 @@#include "qemu-common.h" #include "qemu/log.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "exec/translator.h"
@@ -1415,18 +1416,16 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)translator_loop (&openrisc_tr_ops, &ctx.base, cs, tb); } -void openrisc_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf, -int flags) +void openrisc_cpu_dump_state (CPUState *cs,FILE *f,int flags) {OpenRISCCPU *cpu =OPENRISC_CPU (cs);CPUOpenRISCState *env = &cpu->env;int i; -cpu_fprintf (f,"PC=%08x\n" , env->pc); +qemu_fprintf (f,"PC=%08x\n" , env->pc);for (i =0 ; i <32 ; ++i) { -cpu_fprintf (f,"R%02d=%08x%c" , i,cpu_get_gpr (env, i), - (i %4 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"R%02d=%08x%c" , i,cpu_get_gpr (env, i), + (i %4 ) ==3 ?'\n' :' ' ); } }
target/ppc/cpu.h +1 -2
@@ -1268,8 +1268,7 @@ struct PPCVirtualHypervisorClass {void ppc_cpu_do_interrupt (CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req); -void ppc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void ppc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);void ppc_cpu_dump_statistics (CPUState *cpu,int flags);hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);
target/ppc/translate.c +80 -81
240 lines not on this page · raw message
target/riscv/cpu.c +18 -19
@@ -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" ); } } }
target/s390x/helper.c +21 -21
92 lines not on this page · raw message
target/s390x/internal.h +1 -2
@@ -292,8 +292,7 @@ void s390_cpu_gdb_init(CPUState *cs);/* helper.c */ -void s390_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void s390_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr s390_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);hwaddr s390_cpu_get_phys_addr_debug (CPUState *cpu,vaddr addr);uint64_t get_psw_mask (CPUS390XState *env);
target/sh4/cpu.h +1 -2
@@ -232,8 +232,7 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)void superh_cpu_do_interrupt (CPUState *cpu);bool superh_cpu_exec_interrupt (CPUState *cpu,int int_req); -void superh_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void superh_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int superh_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int superh_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/sh4/translate.c +14 -13
@@ -30,6 +30,7 @@#include "exec/translator.h" #include "trace-tcg.h" #include "exec/log.h" +#include "qemu/qemu-print.h" typedef struct DisasContext {
@@ -156,32 +157,32 @@ void sh4_translate_init(void) fregnames[i]); } -void superh_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void superh_cpu_dump_state (CPUState *cs,FILE *f,int flags) {SuperHCPU *cpu =SUPERH_CPU (cs);CPUSH4State *env = &cpu->env;int i; -cpu_fprintf (f,"pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n" , - env->pc,cpu_read_sr (env), env->pr, env->fpscr); -cpu_fprintf (f,"spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n" , - env->spc, env->ssr, env->gbr, env->vbr); -cpu_fprintf (f,"sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n" , - env->sgr, env->dbr, env->delayed_pc, env->fpul); + +qemu_fprintf (f,"pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n" , + env->pc,cpu_read_sr (env), env->pr, env->fpscr); +qemu_fprintf (f,"spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n" , + env->spc, env->ssr, env->gbr, env->vbr); +qemu_fprintf (f,"sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n" , + env->sgr, env->dbr, env->delayed_pc, env->fpul);for (i =0 ; i <24 ; i +=4 ) { -cpu_fprintf (f,"r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n" , +qemu_printf ("r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n" , i, env->gregs[i], i +1 , env->gregs[i +1 ], i +2 , env->gregs[i +2 ], i +3 , env->gregs[i +3 ]); }if (env->flags &DELAY_SLOT ) { -cpu_fprintf (f,"in delay slot (delayed_pc=0x%08x)\n" , +qemu_printf ("in delay slot (delayed_pc=0x%08x)\n" , env->delayed_pc); }else if (env->flags &DELAY_SLOT_CONDITIONAL ) { -cpu_fprintf (f,"in conditional delay slot (delayed_pc=0x%08x)\n" , +qemu_printf ("in conditional delay slot (delayed_pc=0x%08x)\n" , env->delayed_pc); }else if (env->flags &DELAY_SLOT_RTE ) { -cpu_fprintf (f,"in rte delay slot (delayed_pc=0x%08x)\n" , - env->delayed_pc); +qemu_fprintf (f,"in rte delay slot (delayed_pc=0x%08x)\n" , + env->delayed_pc); } }
target/sparc/cpu.c +41 -43
130 lines not on this page · raw message
target/sparc/cpu.h +1 -2
@@ -564,8 +564,7 @@ extern const struct VMStateDescription vmstate_sparc_cpu;#endif void sparc_cpu_do_interrupt (CPUState *cpu); -void sparc_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void sparc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int sparc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int sparc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/tilegx/cpu.c +7 -7
@@ -24,9 +24,9 @@#include "qemu-common.h" #include "hw/qdev-properties.h" #include "linux-user/syscall_defs.h" +#include "qemu/qemu-print.h" -static void tilegx_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +static void tilegx_cpu_dump_state (CPUState *cs,FILE *f,int flags) {static const char *const reg_names[TILEGX_R_COUNT ] = {"r0" ,"r1" ,"r2" ,"r3" ,"r4" ,"r5" ,"r6" ,"r7" ,
@@ -43,12 +43,12 @@ static void tilegx_cpu_dump_state(CPUState *cs, FILE *f,int i;for (i =0 ; i <TILEGX_R_COUNT ; i++) { -cpu_fprintf (f,"%-4s" TARGET_FMT_lx"%s" , - reg_names[i], env->regs[i], - (i %4 ) ==3 ?"\n" :" " ); +qemu_fprintf (f,"%-4s" TARGET_FMT_lx"%s" , + reg_names[i], env->regs[i], + (i %4 ) ==3 ?"\n" :" " ); } -cpu_fprintf (f,"PC " TARGET_FMT_lx" CEX " TARGET_FMT_lx"\n\n" , - env->pc, env->spregs[TILEGX_SPR_CMPEXCH ]); +qemu_fprintf (f,"PC " TARGET_FMT_lx" CEX " TARGET_FMT_lx"\n\n" , + env->pc, env->spregs[TILEGX_SPR_CMPEXCH ]); }static ObjectClass *tilegx_cpu_class_by_name (const char *cpu_model)
target/tricore/cpu.h +1 -2
@@ -224,8 +224,7 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)#define ENV_OFFSET offsetof(TriCoreCPU, env)hwaddr tricore_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -void tricore_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void tricore_cpu_dump_state (CPUState *cpu,FILE *f,int flags);#define MASK_PCXI_PCPN 0xff000000
target/tricore/translate.c +13 -13
@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h"
@@ -88,8 +89,7 @@ enum { MODE_UU = 3, }; -void tricore_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void tricore_cpu_dump_state (CPUState *cs,FILE *f,int flags) {TriCoreCPU *cpu =TRICORE_CPU (cs);CPUTriCoreState *env = &cpu->env;
@@ -98,26 +98,26 @@ void tricore_cpu_dump_state(CPUState *cs, FILE *f, psw =psw_read (env); -cpu_fprintf (f,"PC: " TARGET_FMT_lx, env->PC); -cpu_fprintf (f," PSW: " TARGET_FMT_lx, psw); -cpu_fprintf (f," ICR: " TARGET_FMT_lx, env->ICR); -cpu_fprintf (f,"\nPCXI: " TARGET_FMT_lx, env->PCXI); -cpu_fprintf (f," FCX: " TARGET_FMT_lx, env->FCX); -cpu_fprintf (f," LCX: " TARGET_FMT_lx, env->LCX); +qemu_fprintf (f,"PC: " TARGET_FMT_lx, env->PC); +qemu_fprintf (f," PSW: " TARGET_FMT_lx, psw); +qemu_fprintf (f," ICR: " TARGET_FMT_lx, env->ICR); +qemu_fprintf (f,"\nPCXI: " TARGET_FMT_lx, env->PCXI); +qemu_fprintf (f," FCX: " TARGET_FMT_lx, env->FCX); +qemu_fprintf (f," LCX: " TARGET_FMT_lx, env->LCX);for (i =0 ; i <16 ; ++i) {if ((i &3 ) ==0 ) { -cpu_fprintf (f,"\nGPR A%02d:" , i); +qemu_fprintf (f,"\nGPR A%02d:" , i); } -cpu_fprintf (f," " TARGET_FMT_lx, env->gpr_a[i]); +qemu_fprintf (f," " TARGET_FMT_lx, env->gpr_a[i]); }for (i =0 ; i <16 ; ++i) {if ((i &3 ) ==0 ) { -cpu_fprintf (f,"\nGPR D%02d:" , i); +qemu_fprintf (f,"\nGPR D%02d:" , i); } -cpu_fprintf (f," " TARGET_FMT_lx, env->gpr_d[i]); +qemu_fprintf (f," " TARGET_FMT_lx, env->gpr_d[i]); } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }/*
target/unicore32/cpu.h +1 -2
@@ -97,8 +97,7 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)void uc32_cpu_do_interrupt (CPUState *cpu);bool uc32_cpu_exec_interrupt (CPUState *cpu,int int_req); -void uc32_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void uc32_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr uc32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#define ASR_M (0x1f)
target/unicore32/translate.c +19 -20
@@ -17,6 +17,7 @@#include "qemu/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h"
@@ -2043,8 +2044,7 @@ static const char *cpu_mode_names[16] = {#undef UCF64_DUMP_STATE#ifdef UCF64_DUMP_STATE -static void cpu_dump_state_ucf64 (CPUUniCore32State *env,FILE *f, -fprintf_function cpu_fprintf,int flags) +static void cpu_dump_state_ucf64 (CPUUniCore32State *env,int flags) {int i; union {
@@ -2064,20 +2064,19 @@ static void cpu_dump_state_ucf64(CPUUniCore32State *env, FILE *f, s0.i = d.l.lower; s1.i = d.l.upper; d0.f64 = d.d; -cpu_fprintf (f,"s%02d=%08x(%8g) s%02d=%08x(%8g)" , - i *2 , (int )s0.i, s0.s, - i *2 +1 , (int )s1.i, s1.s); -cpu_fprintf (f," d%02d=%" PRIx64"(%8g)\n" , - i, (uint64_t)d0.f64, d0.d); +qemu_fprintf (f,"s%02d=%08x(%8g) s%02d=%08x(%8g)" , + i *2 , (int )s0.i, s0.s, + i *2 +1 , (int )s1.i, s1.s); +qemu_fprintf (f," d%02d=%" PRIx64"(%8g)\n" , + i, (uint64_t)d0.f64, d0.d); } -cpu_fprintf (f,"FPSCR: %08x\n" , (int )env->ucf64.xregs[UC32_UCF64_FPSCR ]); +qemu_fprintf (f,"FPSCR: %08x\n" , (int )env->ucf64.xregs[UC32_UCF64_FPSCR ]); }#else #define cpu_dump_state_ucf64 (env, file, pr, flags) do { } while (0)#endif -void uc32_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void uc32_cpu_dump_state (CPUState *cs,FILE *f,int flags) {UniCore32CPU *cpu =UNICORE32_CPU (cs);CPUUniCore32State *env = &cpu->env;
@@ -2085,21 +2084,21 @@ void uc32_cpu_dump_state(CPUState *cs, FILE *f,uint32_t psr;for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"R%02d=%08x" , i, env->regs[i]); +qemu_fprintf (f,"R%02d=%08x" , i, env->regs[i]);if ((i %4 ) ==3 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }else { -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); } } psr =cpu_asr_read (env); -cpu_fprintf (f,"PSR=%08x %c%c%c%c %s\n" , - psr, - psr & (1 <<31 ) ?'N' :'-' , - psr & (1 <<30 ) ?'Z' :'-' , - psr & (1 <<29 ) ?'C' :'-' , - psr & (1 <<28 ) ?'V' :'-' , - cpu_mode_names[psr &0xf ]); +qemu_fprintf (f,"PSR=%08x %c%c%c%c %s\n" , + psr, + psr & (1 <<31 ) ?'N' :'-' , + psr & (1 <<30 ) ?'Z' :'-' , + psr & (1 <<29 ) ?'C' :'-' , + psr & (1 <<28 ) ?'V' :'-' , + cpu_mode_names[psr &0xf ]);if (flags &CPU_DUMP_FPU ) {cpu_dump_state_ucf64 (env, f, cpu_fprintf, flags);
target/xtensa/cpu.h +1 -2
@@ -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);
target/xtensa/translate.c +21 -19
@@ -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' :' ' ); } } }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 14/17] qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
Quoted 7 lines · * Markus Armbruster ([email protected]) wrote:
CPUClass method
dump_statistics()takes an fprintf()-like callback and a FILE * to pass to it. Most callers passfprintf()and stderr.log_cpu_state()passesfprintf()andqemu_log_file.hmp_info_registers()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf().
Quoted 8 lines
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, sinceqemu_fprintf()takes NULL instead of the current monitor cast to FILE *.Signed-off-by Markus Armbruster <[email protected]>
<phew long patch>
Yes, I think so.
There seems to be a place which changes hmp_info_local_apic in a plce that was changed in an earlier patch which seems a shame, but OK.
Quoted 3,029 lines
--- accel/kvm/kvm-all.c | 4 +- bsd-user/main.c | 2 +- cpus.c | 2 +- exec.c | 2 +- include/exec/log.h | 2 +- include/qom/cpu.h | 11 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/cpu_loop-common.h | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 4 +- linux-user/s390x/cpu_loop.c | 4 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- monitor.c | 4 +- qom/cpu.c | 6 +- target/alpha/cpu.h | 3 +- target/alpha/helper.c | 24 +-- target/arm/arm-semi.c | 2 +- target/arm/cpu.h | 3 +- target/arm/translate-a64.c | 82 ++++----- target/arm/translate.c | 58 +++---- target/arm/translate.h | 7 +- target/cris/cpu.h | 3 +- target/cris/helper.c | 2 +- target/cris/translate.c | 36 ++-- target/hppa/cpu.h | 2 +- target/hppa/helper.c | 24 +-- target/i386/cpu.h | 5 +- target/i386/hax-all.c | 4 +- target/i386/helper.c | 281 +++++++++++++++---------------- target/i386/monitor.c | 2 +- target/lm32/cpu.h | 3 +- target/lm32/translate.c | 36 ++-- target/m68k/cpu.h | 3 +- target/m68k/translate.c | 86 +++++----- target/microblaze/cpu.h | 3 +- target/microblaze/helper.c | 2 +- target/microblaze/translate.c | 39 ++--- target/mips/internal.h | 3 +- target/mips/translate.c | 76 ++++----- target/moxie/cpu.h | 3 +- target/moxie/helper.c | 2 +- target/moxie/translate.c | 22 +-- target/nios2/cpu.h | 3 +- target/nios2/helper.c | 2 +- target/nios2/translate.c | 24 +-- target/openrisc/cpu.h | 3 +- target/openrisc/translate.c | 11 +- target/ppc/cpu.h | 3 +- target/ppc/translate.c | 161 +++++++++--------- target/riscv/cpu.c | 37 ++-- target/s390x/helper.c | 42 ++--- target/s390x/internal.h | 3 +- target/sh4/cpu.h | 3 +- target/sh4/translate.c | 27 +-- target/sparc/cpu.c | 84 +++++---- target/sparc/cpu.h | 3 +- target/tilegx/cpu.c | 14 +- target/tricore/cpu.h | 3 +- target/tricore/translate.c | 26 +-- target/unicore32/cpu.h | 3 +- target/unicore32/translate.c | 39 +++-- target/xtensa/cpu.h | 3 +- target/xtensa/translate.c | 40 ++--- 64 files changed, 686 insertions(+), 715 deletions(-)accel/kvm/kvm-all.c +2
-2@@ -1798,7 +1798,7 @@ static int kvm_handle_internal_error(CPUState *cpu, struct kvm_run *run)if (run->internal.suberror ==KVM_INTERNAL_ERROR_EMULATION ) {fprintf (stderr,"emulation failure\n" );if (!kvm_arch_stop_on_emulation_error (cpu)) { -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_CODE ); +cpu_dump_state (cpu, stderr,CPU_DUMP_CODE );return EXCP_INTERRUPT ; } }@@ -2089,7 +2089,7 @@ int kvm_cpu_exec(CPUState *cpu)qemu_mutex_lock_iothread ();if (ret <0 ) { -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_CODE ); +cpu_dump_state (cpu, stderr,CPU_DUMP_CODE );vm_stop (RUN_STATE_INTERNAL_ERROR ); }bsd-user/main.c +1
-1@@ -639,7 +639,7 @@ void cpu_loop(CPUSPARCState *env) badtrap:#endif printf ("Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (1 ); }process_pending_signals (env);cpus.c +1
-1@@ -1010,7 +1010,7 @@ void hw_error(const char *fmt, ...)fprintf (stderr,"\n" );CPU_FOREACH (cpu) {fprintf (stderr,"CPU #%d:\n" , cpu->cpu_index); -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cpu, stderr,CPU_DUMP_FPU ); }va_end (ap);abort ();exec.c +1
-1@@ -1256,7 +1256,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)fprintf (stderr,"qemu: fatal: " );vfprintf (stderr, fmt, ap);fprintf (stderr,"\n" ); -cpu_dump_state (cpu, stderr, fprintf,CPU_DUMP_FPU |CPU_DUMP_CCOP ); +cpu_dump_state (cpu, stderr,CPU_DUMP_FPU |CPU_DUMP_CCOP );if (qemu_log_separate ()) {qemu_log_lock ();qemu_log ("qemu: fatal: " );include/exec/log.h +1
-1@@ -16,7 +16,7 @@static inline void log_cpu_state (CPUState *cpu,int flags) {if (qemu_log_enabled ()) { -cpu_dump_state (cpu, qemu_logfile, fprintf, flags); +cpu_dump_state (cpu, qemu_logfile, flags); } }include/qom/cpu.h +3
-8@@ -26,7 +26,6 @@#include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" -#include "qemu/fprintf-fn.h" #include "qemu/rcu_queue.h" #include "qemu/queue.h" #include "qemu/thread.h" @@ -181,8 +180,7 @@ typedef struct CPUClass {bool (*virtio_is_big_endian)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write); -void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void (*dump_state)(CPUState *cpu,FILE *,int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu);void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);@@ -563,14 +561,11 @@ enum CPUDumpFlags {/** * cpu_dump_state: * @cpu: The CPU whose state is to be dumped. -* @f: File to dump to. -* @cpu_fprintf: Function to dump with. -* @flags: Flags what to dump. +* @f: If non-null, dump to this stream, else to current print sink. * * Dumps CPU state. */ -void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cpu_dump_state (CPUState *cpu,FILE *f,int flags);/** * cpu_dump_statistics: linux-user/alpha/cpu_loop.c +1
-1@@ -193,7 +193,7 @@ void cpu_loop(CPUAlphaState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);linux-user/cpu_loop-common.h +1
-1@@ -26,7 +26,7 @@ do { \ CPUState *cs = ENV_GET_CPU(env); \ fprintf(stderr, fmt , ## __VA_ARGS__); \ - cpu_dump_state(cs, stderr, fprintf, 0); \ + cpu_dump_state(cs, stderr, 0); \ if (qemu_log_separate()) { \ qemu_log(fmt, ## __VA_ARGS__); \ log_cpu_state(cs, 0); \linux-user/cris/cpu_loop.c +1
-1@@ -74,7 +74,7 @@ void cpu_loop(CPUCRISState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);linux-user/microblaze/cpu_loop.c +2
-2@@ -107,7 +107,7 @@ void cpu_loop(CPUMBState *env)default :fprintf (stderr,"Unhandled hw-exception: 0x%" PRIx64"\n" , env->sregs[SR_ESR ] &ESR_EC_MASK ); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE );break ; }@@ -123,7 +123,7 @@ void cpu_loop(CPUMBState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);linux-user/s390x/cpu_loop.c +2
-2@@ -124,7 +124,7 @@ void cpu_loop(CPUS390XState *env)default :fprintf (stderr,"Unhandled program exception: %#x\n" , n); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }break ;@@ -144,7 +144,7 @@ void cpu_loop(CPUS390XState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);linux-user/sh4/cpu_loop.c +1
-1@@ -76,7 +76,7 @@ void cpu_loop(CPUSH4State *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);linux-user/sparc/cpu_loop.c +1
-1@@ -278,7 +278,7 @@ void cpu_loop (CPUSPARCState *env)break ;default :fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );exit (EXIT_FAILURE ); }process_pending_signals (env);monitor.c +2
-2@@ -1296,7 +1296,7 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)if (all_cpus) {CPU_FOREACH (cs) {monitor_printf (mon,"\nCPU#%d\n" , cs->cpu_index); -cpu_dump_state (cs, (FILE *)mon, monitor_fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cs,NULL ,CPU_DUMP_FPU ); } }else { cs =mon_get_cpu ();@@ -1306,7 +1306,7 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)return ; } -cpu_dump_state (cs, (FILE *)mon, monitor_fprintf,CPU_DUMP_FPU ); +cpu_dump_state (cs,NULL ,CPU_DUMP_FPU ); } }qom/cpu.c +3
-3@@ -28,6 +28,7 @@#include "exec/log.h" #include "exec/cpu-common.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -219,14 +220,13 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)return res; } -void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cpu_dump_state (CPUState *cpu,FILE *f,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->dump_state) {cpu_synchronize_state (cpu); - cc->dump_state (cpu, f, cpu_fprintf, flags); + cc->dump_state (cpu, f, flags); } }target/alpha/cpu.h +1
-2@@ -311,8 +311,7 @@ extern const struct VMStateDescription vmstate_alpha_cpu;void alpha_cpu_do_interrupt (CPUState *cpu);bool alpha_cpu_exec_interrupt (CPUState *cpu,int int_req); -void alpha_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int alpha_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int alpha_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/alpha/helper.c +12
-12@@ -23,6 +23,7 @@#include "exec/exec-all.h" #include "fpu/softfloat.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" #define CONVERT_BIT (X ,SRC ,DST ) \@@ -426,8 +427,7 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request)return false; } -void alpha_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags) {static const char *linux_reg_names[] = {"v0 " ,"t0 " ,"t1 " ,"t2 " ,"t3 " ,"t4 " ,"t5 " ,"t6 " ,@@ -439,24 +439,24 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,CPUAlphaState *env = &cpu->env;int i; -cpu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , - env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 )); +qemu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , + env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 ));for (i =0 ; i <31 ; i++) { -cpu_fprintf (f,"IR%02d %s " TARGET_FMT_lx"%c" , i, - linux_reg_names[i],cpu_alpha_load_gr (env, i), - (i %3 ) ==2 ?'\n' :' ' ); +qemu_fprintf (f,"IR%02d %s " TARGET_FMT_lx"%c" , i, + linux_reg_names[i],cpu_alpha_load_gr (env, i), + (i %3 ) ==2 ?'\n' :' ' ); } -cpu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , - env->lock_addr, env->lock_value); +qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , + env->lock_addr, env->lock_value);if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <31 ; i++) { -cpu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], - (i %3 ) ==2 ?'\n' :' ' ); +qemu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], + (i %3 ) ==2 ?'\n' :' ' ); } } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }/* This should only be called from translate, via gen_excp. target/arm/arm-semi.c +1
-1@@ -650,7 +650,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)/* fall through -- invalid for A32/T32 */ default :fprintf (stderr,"qemu: Unsupported SemiHosting SWI 0x%02x\n" , nr); -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );abort (); } }target/arm/cpu.h +1
-2@@ -935,8 +935,7 @@ void arm_cpu_do_interrupt(CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu);bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req); -void arm_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr,MemTxAttrs *attrs);target/arm/translate-a64.c +41
-41@@ -27,6 +27,7 @@#include "translate.h" #include "internals.h" #include "qemu/host-utils.h" +#include "qemu/qemu-print.h" #include "exec/semihost.h" #include "exec/gen-icount.h" @@ -151,8 +152,7 @@ static void set_btype(DisasContext *s, int val) s->btype =-1 ; } -void aarch64_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;@@ -161,13 +161,13 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,int el =arm_current_el (env);const char *ns_status; -cpu_fprintf (f," PC=%016" PRIx64" " , env->pc); +qemu_fprintf (f," PC=%016" PRIx64" " , env->pc);for (i =0 ; i <32 ; i++) {if (i ==31 ) { -cpu_fprintf (f," SP=%016" PRIx64"\n" , env->xregs[i]); +qemu_fprintf (f," SP=%016" PRIx64"\n" , env->xregs[i]); }else { -cpu_fprintf (f,"X%02d=%016" PRIx64"%s" , i, env->xregs[i], - (i +2 ) %3 ?" " :"\n" ); +qemu_fprintf (f,"X%02d=%016" PRIx64"%s" , i, env->xregs[i], + (i +2 ) %3 ?" " :"\n" ); } }@@ -176,29 +176,29 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, }else { ns_status ="" ; } -cpu_fprintf (f,"PSTATE=%08x %c%c%c%c %sEL%d%c" , - psr, - psr &PSTATE_N ?'N' :'-' , - psr &PSTATE_Z ?'Z' :'-' , - psr &PSTATE_C ?'C' :'-' , - psr &PSTATE_V ?'V' :'-' , - ns_status, - el, - psr &PSTATE_SP ?'h' :'t' ); +qemu_fprintf (f,"PSTATE=%08x %c%c%c%c %sEL%d%c" , + psr, + psr &PSTATE_N ?'N' :'-' , + psr &PSTATE_Z ?'Z' :'-' , + psr &PSTATE_C ?'C' :'-' , + psr &PSTATE_V ?'V' :'-' , + ns_status, + el, + psr &PSTATE_SP ?'h' :'t' );if (cpu_isar_feature (aa64_bti, cpu)) { -cpu_fprintf (f," BTYPE=%d" , (psr &PSTATE_BTYPE ) >>10 ); +qemu_fprintf (f," BTYPE=%d" , (psr &PSTATE_BTYPE ) >>10 ); }if (!(flags &CPU_DUMP_FPU )) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );return ; }if (fp_exception_el (env, el) !=0 ) { -cpu_fprintf (f," FPU disabled\n" ); +qemu_fprintf (f," FPU disabled\n" );return ; } -cpu_fprintf (f," FPCR=%08x FPSR=%08x\n" , -vfp_get_fpcr (env),vfp_get_fpsr (env)); +qemu_fprintf (f," FPCR=%08x FPSR=%08x\n" , +vfp_get_fpcr (env),vfp_get_fpsr (env));if (cpu_isar_feature (aa64_sve, cpu) &&sve_exception_el (env, el) ==0 ) {int j, zcr_len =sve_zcr_len_for_el (env, el);@@ -206,11 +206,11 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,for (i =0 ; i <=FFR_PRED_NUM ; i++) {bool eol;if (i ==FFR_PRED_NUM ) { -cpu_fprintf (f,"FFR=" ); +qemu_fprintf (f,"FFR=" );/* It's last, so end the line. */ eol = true; }else { -cpu_fprintf (f,"P%02d=" , i); +qemu_fprintf (f,"P%02d=" , i);switch (zcr_len) {case 0 : eol = i %8 ==7 ;@@ -235,46 +235,46 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, }else { digits = (zcr_len %4 +1 ) *4 ; } -cpu_fprintf (f,"%0*" PRIx64"%s" , digits, - env->vfp.pregs[i].p[j], - j ?":" : eol ?"\n" :" " ); +qemu_fprintf (f,"%0*" PRIx64"%s" , digits, + env->vfp.pregs[i].p[j], + j ?":" : eol ?"\n" :" " ); } }for (i =0 ; i <32 ; i++) {if (zcr_len ==0 ) { -cpu_fprintf (f,"Z%02d=%016" PRIx64":%016" PRIx64"%s" , - i, env->vfp.zregs[i].d[1 ], - env->vfp.zregs[i].d[0 ], i &1 ?"\n" :" " ); +qemu_fprintf (f,"Z%02d=%016" PRIx64":%016" PRIx64"%s" , + i, env->vfp.zregs[i].d[1 ], + env->vfp.zregs[i].d[0 ], i &1 ?"\n" :" " ); }else if (zcr_len ==1 ) { -cpu_fprintf (f,"Z%02d=%016" PRIx64":%016" PRIx64 -":%016" PRIx64":%016" PRIx64"\n" , - i, env->vfp.zregs[i].d[3 ], env->vfp.zregs[i].d[2 ], - env->vfp.zregs[i].d[1 ], env->vfp.zregs[i].d[0 ]); +qemu_fprintf (f,"Z%02d=%016" PRIx64":%016" PRIx64 +":%016" PRIx64":%016" PRIx64"\n" , + i, env->vfp.zregs[i].d[3 ], env->vfp.zregs[i].d[2 ], + env->vfp.zregs[i].d[1 ], env->vfp.zregs[i].d[0 ]); }else {for (j = zcr_len; j >=0 ; j--) {bool odd = (zcr_len - j) %2 !=0 ;if (j == zcr_len) { -cpu_fprintf (f,"Z%02d[%x-%x]=" , i, j, j -1 ); +qemu_fprintf (f,"Z%02d[%x-%x]=" , i, j, j -1 ); }else if (!odd) {if (j >0 ) { -cpu_fprintf (f," [%x-%x]=" , j, j -1 ); +qemu_fprintf (f," [%x-%x]=" , j, j -1 ); }else { -cpu_fprintf (f," [%x]=" , j); +qemu_fprintf (f," [%x]=" , j); } } -cpu_fprintf (f,"%016" PRIx64":%016" PRIx64"%s" , - env->vfp.zregs[i].d[j *2 +1 ], - env->vfp.zregs[i].d[j *2 ], - odd || j ==0 ?"\n" :":" ); +qemu_fprintf (f,"%016" PRIx64":%016" PRIx64"%s" , + env->vfp.zregs[i].d[j *2 +1 ], + env->vfp.zregs[i].d[j *2 ], + odd || j ==0 ?"\n" :":" ); } } } }else {for (i =0 ; i <32 ; i++) {uint64_t *q =aa64_vfp_qreg (env, i); -cpu_fprintf (f,"Q%02d=%016" PRIx64":%016" PRIx64"%s" , - i, q[1 ], q[0 ], (i &1 ?"\n" :" " )); +qemu_fprintf (f,"Q%02d=%016" PRIx64":%016" PRIx64"%s" , + i, q[1 ], q[0 ], (i &1 ?"\n" :" " )); } } }target/arm/translate.c +29
-29@@ -28,6 +28,7 @@#include "tcg-op-gvec.h" #include "qemu/log.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "arm_ldst.h" #include "exec/semihost.h" @@ -13772,24 +13773,23 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)translator_loop (ops, &dc.base, cpu, tb); } -void arm_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;int i;if (is_a64 (env)) { -aarch64_cpu_dump_state (cs, f, cpu_fprintf, flags); +aarch64_cpu_dump_state (cs, f, flags);return ; }for (i=0 ;i<16 ;i++) { -cpu_fprintf (f,"R%02d=%08x" , i, env->regs[i]); +qemu_fprintf (f,"R%02d=%08x" , i, env->regs[i]);if ((i %4 ) ==3 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );else -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); }if (arm_feature (env,ARM_FEATURE_M )) {@@ -13811,15 +13811,15 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, } } -cpu_fprintf (f,"XPSR=%08x %c%c%c%c %c %s%s\n" , - xpsr, - xpsr &XPSR_N ?'N' :'-' , - xpsr &XPSR_Z ?'Z' :'-' , - xpsr &XPSR_C ?'C' :'-' , - xpsr &XPSR_V ?'V' :'-' , - xpsr &XPSR_T ?'T' :'A' , - ns_status, - mode); +qemu_fprintf (f,"XPSR=%08x %c%c%c%c %c %s%s\n" , + xpsr, + xpsr &XPSR_N ?'N' :'-' , + xpsr &XPSR_Z ?'Z' :'-' , + xpsr &XPSR_C ?'C' :'-' , + xpsr &XPSR_V ?'V' :'-' , + xpsr &XPSR_T ?'T' :'A' , + ns_status, + mode); }else {uint32_t psr =cpsr_read (env);const char *ns_status ="" ;@@ -13829,15 +13829,15 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, ns_status = env->cp15.scr_el3 &SCR_NS ?"NS " :"S " ; } -cpu_fprintf (f,"PSR=%08x %c%c%c%c %c %s%s%d\n" , - psr, - psr &CPSR_N ?'N' :'-' , - psr &CPSR_Z ?'Z' :'-' , - psr &CPSR_C ?'C' :'-' , - psr &CPSR_V ?'V' :'-' , - psr &CPSR_T ?'T' :'A' , - ns_status, -aarch32_mode_name (psr), (psr &0x10 ) ?32 :26 ); +qemu_fprintf (f,"PSR=%08x %c%c%c%c %c %s%s%d\n" , + psr, + psr &CPSR_N ?'N' :'-' , + psr &CPSR_Z ?'Z' :'-' , + psr &CPSR_C ?'C' :'-' , + psr &CPSR_V ?'V' :'-' , + psr &CPSR_T ?'T' :'A' , + ns_status, +aarch32_mode_name (psr), (psr &0x10 ) ?32 :26 ); }if (flags &CPU_DUMP_FPU ) {@@ -13850,12 +13850,12 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, }for (i =0 ; i < numvfpregs; i++) {uint64_t v = *aa32_vfp_dreg (env, i); -cpu_fprintf (f,"s%02d=%08x s%02d=%08x d%02d=%016" PRIx64"\n" , - i *2 , (uint32_t )v, - i *2 +1 , (uint32_t )(v >>32 ), - i, v); +qemu_fprintf (f,"s%02d=%08x s%02d=%08x d%02d=%016" PRIx64"\n" , + i *2 , (uint32_t )v, + i *2 +1 , (uint32_t )(v >>32 ), + i, v); } -cpu_fprintf (f,"FPSCR: %08x\n" ,vfp_get_fpscr (env)); +qemu_fprintf (f,"FPSCR: %08x\n" ,vfp_get_fpscr (env)); } }target/arm/translate.h +2
-5@@ -166,8 +166,7 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)#ifdef TARGET_AARCH64 void a64_translate_init (void );void gen_a64_set_pc_im (uint64_t val); -void aarch64_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags); +void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags);extern const TranslatorOps aarch64_translator_ops;#else static inline void a64_translate_init (void )@@ -178,9 +177,7 @@ static inline void gen_a64_set_pc_im(uint64_t val) { } -static inline void aarch64_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf, -int flags) +static inline void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags) { }#endif target/cris/cpu.h +1
-2@@ -207,8 +207,7 @@ void cris_cpu_do_interrupt(CPUState *cpu);void crisv10_cpu_do_interrupt (CPUState *cpu);bool cris_cpu_exec_interrupt (CPUState *cpu,int int_req); -void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void cris_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr cris_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);target/cris/helper.c +1
-1@@ -60,7 +60,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, cs->exception_index =0xaa ; cpu->env.pregs[PR_EDA ] = address; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }target/cris/translate.c +18
-18@@ -33,6 +33,7 @@#include "exec/cpu_ldst.h" #include "exec/translator.h" #include "crisv32-decode.h" +#include "qemu/qemu-print.h" #include "exec/helper-gen.h" @@ -3299,8 +3300,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)#endif } -void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void cris_cpu_dump_state (CPUState *cs,FILE *f,int flags) {CRISCPU *cpu =CRIS_CPU (cs);CPUCRISState *env = &cpu->env;@@ -3308,7 +3308,7 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,const char **pregnames;int i; -if (!env || !f) { +if (!env) {return ; }if (env->pregs[PR_VR ] <32 ) {@@ -3319,40 +3319,40 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, regnames = regnames_v32; } -cpu_fprintf (f,"PC=%x CCS=%x btaken=%d btarget=%x\n" -"cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n" , - env->pc, env->pregs[PR_CCS ], env->btaken, env->btarget, - env->cc_op, - env->cc_src, env->cc_dest, env->cc_result, env->cc_mask); +qemu_fprintf (f,"PC=%x CCS=%x btaken=%d btarget=%x\n" +"cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n" , + env->pc, env->pregs[PR_CCS ], env->btaken, env->btarget, + env->cc_op, + env->cc_src, env->cc_dest, env->cc_result, env->cc_mask);for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"%s=%8.8x " , regnames[i], env->regs[i]); +qemu_fprintf (f,"%s=%8.8x " , regnames[i], env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } -cpu_fprintf (f,"\nspecial regs:\n" ); +qemu_fprintf (f,"\nspecial regs:\n" );for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"%s=%8.8x " , pregnames[i], env->pregs[i]); +qemu_fprintf (f,"%s=%8.8x " , pregnames[i], env->pregs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }if (env->pregs[PR_VR ] >=32 ) {uint32_t srs = env->pregs[PR_SRS ]; -cpu_fprintf (f,"\nsupport function regs bank %x:\n" , srs); +qemu_fprintf (f,"\nsupport function regs bank %x:\n" , srs);if (srs <ARRAY_SIZE (env->sregs)) {for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"s%2.2d=%8.8x " , - i, env->sregs[srs][i]); +qemu_fprintf (f,"s%2.2d=%8.8x " , + i, env->sregs[srs][i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } } } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }target/hppa/cpu.h +1
-1@@ -359,7 +359,7 @@ int hppa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);int hppa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void hppa_cpu_do_interrupt (CPUState *cpu);bool hppa_cpu_exec_interrupt (CPUState *cpu,int int_req); -void hppa_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function ,int ); +void hppa_cpu_dump_state (CPUState *cs,FILE *f,int );#ifdef CONFIG_USER_ONLY int hppa_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int size,int rw,int midx);target/hppa/helper.c +12
-12@@ -23,6 +23,7 @@#include "fpu/softfloat.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" target_ureg cpu_hppa_get_psw (CPUHPPAState *env) {@@ -76,8 +77,7 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw) } } -void hppa_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void hppa_cpu_dump_state (CPUState *cs,FILE *f,int flags) {HPPACPU *cpu =HPPA_CPU (cs);CPUHPPAState *env = &cpu->env;@@ -86,9 +86,9 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f,char psw_c[20 ];int i; -cpu_fprintf (f,"IA_F " TARGET_FMT_lx" IA_B " TARGET_FMT_lx"\n" , -hppa_form_gva_psw (psw, env->iasq_f, env->iaoq_f), -hppa_form_gva_psw (psw, env->iasq_b, env->iaoq_b)); +qemu_fprintf (f,"IA_F " TARGET_FMT_lx" IA_B " TARGET_FMT_lx"\n" , +hppa_form_gva_psw (psw, env->iasq_f, env->iaoq_f), +hppa_form_gva_psw (psw, env->iasq_b, env->iaoq_b)); psw_c[0 ] = (psw &PSW_W ?'W' :'-' ); psw_c[1 ] = (psw &PSW_E ?'E' :'-' );@@ -111,20 +111,20 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, psw_c[18 ] ='\0' ; psw_cb = ((env->psw_cb >>4 ) &0x01111111 ) | (env->psw_cb_msb <<28 ); -cpu_fprintf (f,"PSW " TREG_FMT_lx" CB " TREG_FMT_lx" %s\n" , - psw, psw_cb, psw_c); +qemu_fprintf (f,"PSW " TREG_FMT_lx" CB " TREG_FMT_lx" %s\n" , + psw, psw_cb, psw_c);for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"GR%02d " TREG_FMT_lx"%c" , i, env->gr[i], - (i &3 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"GR%02d " TREG_FMT_lx"%c" , i, env->gr[i], + (i &3 ) ==3 ?'\n' :' ' ); }#ifndef CONFIG_USER_ONLY for (i =0 ; i <8 ; i++) { -cpu_fprintf (f,"SR%02d %08x%c" , i, (uint32_t )(env->sr[i] >>32 ), - (i &3 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"SR%02d %08x%c" , i, (uint32_t )(env->sr[i] >>32 ), + (i &3 ) ==3 ?'\n' :' ' ); }#endif -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );/* ??? FR */ }target/i386/cpu.h +2
-3@@ -1521,8 +1521,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,void x86_cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list,Error **errp); -void x86_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags); +void x86_cpu_dump_state (CPUState *cs,FILE *f,int flags);hwaddr x86_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);@@ -1924,7 +1923,7 @@ void enable_compat_apic_id_mode(void);#define APIC_DEFAULT_ADDRESS 0xfee00000#define APIC_SPACE_SIZE 0x100000 -void x86_cpu_dump_local_apic_state (CPUState *cs,int flags); +void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f,int flags);/* cpu.c */ bool cpu_is_bsp (X86CPU *cpu);target/i386/hax-all.c +2
-2@@ -540,7 +540,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env) ht->_exit_reason);qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_RESET );hax_vcpu_sync_state (env,0 ); -cpu_dump_state (cpu, stderr, fprintf,0 ); +cpu_dump_state (cpu, stderr,0 ); ret =-1 ;break ;case HAX_EXIT_HLT :@@ -571,7 +571,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env)fprintf (stderr,"Unknown exit %x from HAX\n" , ht->_exit_status);qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_RESET );hax_vcpu_sync_state (env,0 ); -cpu_dump_state (cpu, stderr, fprintf,0 ); +cpu_dump_state (cpu, stderr,0 ); ret =1 ;break ; }target/i386/helper.c +140
-141@@ -156,38 +156,41 @@ static const char *cc_op_str[CC_OP_NB] = { };static void -cpu_x86_dump_seg_cache (CPUX86State *env,FILE *f,fprintf_function cpu_fprintf, +cpu_x86_dump_seg_cache (CPUX86State *env,FILE *f,const char *name,struct SegmentCache *sc) {#ifdef TARGET_X86_64 if (env->hflags &HF_CS64_MASK ) { -cpu_fprintf (f,"%-3s=%04x %016" PRIx64" %08x %08x" , name, - sc->selector, sc->base, sc->limit, sc->flags &0x00ffff00 ); +qemu_fprintf (f,"%-3s=%04x %016" PRIx64" %08x %08x" , name, + sc->selector, sc->base, sc->limit, + sc->flags &0x00ffff00 ); } else#endif { -cpu_fprintf (f,"%-3s=%04x %08x %08x %08x" , name, sc->selector, - (uint32_t )sc->base, sc->limit, sc->flags &0x00ffff00 ); +qemu_fprintf (f,"%-3s=%04x %08x %08x %08x" , name, sc->selector, + (uint32_t )sc->base, sc->limit, + sc->flags &0x00ffff00 ); }if (!(env->hflags &HF_PE_MASK ) || !(sc->flags &DESC_P_MASK )) goto done; -cpu_fprintf (f," DPL=%d " , (sc->flags &DESC_DPL_MASK ) >>DESC_DPL_SHIFT ); +qemu_fprintf (f," DPL=%d " , + (sc->flags &DESC_DPL_MASK ) >>DESC_DPL_SHIFT );if (sc->flags &DESC_S_MASK ) {if (sc->flags &DESC_CS_MASK ) { -cpu_fprintf (f, (sc->flags &DESC_L_MASK ) ?"CS64" : - ((sc->flags &DESC_B_MASK ) ?"CS32" :"CS16" )); -cpu_fprintf (f," [%c%c" , (sc->flags &DESC_C_MASK ) ?'C' :'-' , - (sc->flags &DESC_R_MASK ) ?'R' :'-' ); +qemu_fprintf (f, (sc->flags &DESC_L_MASK ) ?"CS64" : + ((sc->flags &DESC_B_MASK ) ?"CS32" :"CS16" )); +qemu_fprintf (f," [%c%c" , (sc->flags &DESC_C_MASK ) ?'C' :'-' , + (sc->flags &DESC_R_MASK ) ?'R' :'-' ); }else { -cpu_fprintf (f, - (sc->flags &DESC_B_MASK || env->hflags &HF_LMA_MASK ) - ?"DS " :"DS16" ); -cpu_fprintf (f," [%c%c" , (sc->flags &DESC_E_MASK ) ?'E' :'-' , - (sc->flags &DESC_W_MASK ) ?'W' :'-' ); +qemu_fprintf (f, (sc->flags &DESC_B_MASK + || env->hflags &HF_LMA_MASK ) + ?"DS " :"DS16" ); +qemu_fprintf (f," [%c%c" , (sc->flags &DESC_E_MASK ) ?'E' :'-' , + (sc->flags &DESC_W_MASK ) ?'W' :'-' ); } -cpu_fprintf (f,"%c]" , (sc->flags &DESC_A_MASK ) ?'A' :'-' ); +qemu_fprintf (f,"%c]" , (sc->flags &DESC_A_MASK ) ?'A' :'-' ); }else {static const char *sys_type_name[2 ][16 ] = { {/* 32 bit mode */ @@ -203,13 +206,12 @@ cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, fprintf_function cpu_fprintf, "Reserved", "IntGate64", "TrapGate64" } }; -cpu_fprintf (f,"%s" , - sys_type_name[(env->hflags &HF_LMA_MASK ) ?1 :0 ] - [(sc->flags &DESC_TYPE_MASK ) - >>DESC_TYPE_SHIFT ]); +qemu_fprintf (f,"%s" , + sys_type_name[(env->hflags &HF_LMA_MASK ) ?1 :0 ] + [(sc->flags &DESC_TYPE_MASK ) >>DESC_TYPE_SHIFT ]); } done: -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }#ifndef CONFIG_USER_ONLY @@ -348,7 +350,7 @@ static void dump_apic_interrupt(const char *name, uint32_t *ireg_tab,qemu_printf ("%s\n" , empty ?"(none)" :"" ); } -void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) +void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f,int flags) {X86CPU *cpu =X86_CPU (cs);APICCommonState *s =APIC_COMMON (cpu->apic_state);@@ -395,7 +397,7 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) qemu_printf(" PPR 0x%02x\n", apic_get_ppr(s)); }#else -void x86_cpu_dump_local_apic_state (CPUState *cs,int flags) +void x86_cpu_dump_local_apic_state (CPUState *cs,FILE *f,int flags) { }#endif /* !CONFIG_USER_ONLY */ @@ -403,8 +405,7 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, int flags)#define DUMP_CODE_BYTES_TOTAL 50#define DUMP_CODE_BYTES_BACKWARD 20 -void x86_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void x86_cpu_dump_state (CPUState *cs,FILE *f,int flags) {X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;@@ -415,109 +416,107 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, eflags =cpu_compute_eflags (env);#ifdef TARGET_X86_64 if (env->hflags &HF_CS64_MASK ) { -cpu_fprintf (f, -"RAX=%016" PRIx64" RBX=%016" PRIx64" RCX=%016" PRIx64" RDX=%016" PRIx64"\n" -"RSI=%016" PRIx64" RDI=%016" PRIx64" RBP=%016" PRIx64" RSP=%016" PRIx64"\n" -"R8 =%016" PRIx64" R9 =%016" PRIx64" R10=%016" PRIx64" R11=%016" PRIx64"\n" -"R12=%016" PRIx64" R13=%016" PRIx64" R14=%016" PRIx64" R15=%016" PRIx64"\n" -"RIP=%016" PRIx64" RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , - env->regs[R_EAX ], - env->regs[R_EBX ], - env->regs[R_ECX ], - env->regs[R_EDX ], - env->regs[R_ESI ], - env->regs[R_EDI ], - env->regs[R_EBP ], - env->regs[R_ESP ], - env->regs[8 ], - env->regs[9 ], - env->regs[10 ], - env->regs[11 ], - env->regs[12 ], - env->regs[13 ], - env->regs[14 ], - env->regs[15 ], - env->eip, eflags, - eflags &DF_MASK ?'D' :'-' , - eflags &CC_O ?'O' :'-' , - eflags &CC_S ?'S' :'-' , - eflags &CC_Z ?'Z' :'-' , - eflags &CC_A ?'A' :'-' , - eflags &CC_P ?'P' :'-' , - eflags &CC_C ?'C' :'-' , - env->hflags &HF_CPL_MASK , - (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , - (env->a20_mask >>20 ) &1 , - (env->hflags >>HF_SMM_SHIFT ) &1 , - cs->halted); +qemu_fprintf (f,"RAX=%016" PRIx64" RBX=%016" PRIx64" RCX=%016" PRIx64" RDX=%016" PRIx64"\n" +"RSI=%016" PRIx64" RDI=%016" PRIx64" RBP=%016" PRIx64" RSP=%016" PRIx64"\n" +"R8 =%016" PRIx64" R9 =%016" PRIx64" R10=%016" PRIx64" R11=%016" PRIx64"\n" +"R12=%016" PRIx64" R13=%016" PRIx64" R14=%016" PRIx64" R15=%016" PRIx64"\n" +"RIP=%016" PRIx64" RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , + env->regs[R_EAX ], + env->regs[R_EBX ], + env->regs[R_ECX ], + env->regs[R_EDX ], + env->regs[R_ESI ], + env->regs[R_EDI ], + env->regs[R_EBP ], + env->regs[R_ESP ], + env->regs[8 ], + env->regs[9 ], + env->regs[10 ], + env->regs[11 ], + env->regs[12 ], + env->regs[13 ], + env->regs[14 ], + env->regs[15 ], + env->eip, eflags, + eflags &DF_MASK ?'D' :'-' , + eflags &CC_O ?'O' :'-' , + eflags &CC_S ?'S' :'-' , + eflags &CC_Z ?'Z' :'-' , + eflags &CC_A ?'A' :'-' , + eflags &CC_P ?'P' :'-' , + eflags &CC_C ?'C' :'-' , + env->hflags &HF_CPL_MASK , + (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , + (env->a20_mask >>20 ) &1 , + (env->hflags >>HF_SMM_SHIFT ) &1 , + cs->halted); } else#endif { -cpu_fprintf (f,"EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" -"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" -"EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , - (uint32_t )env->regs[R_EAX ], - (uint32_t )env->regs[R_EBX ], - (uint32_t )env->regs[R_ECX ], - (uint32_t )env->regs[R_EDX ], - (uint32_t )env->regs[R_ESI ], - (uint32_t )env->regs[R_EDI ], - (uint32_t )env->regs[R_EBP ], - (uint32_t )env->regs[R_ESP ], - (uint32_t )env->eip, eflags, - eflags &DF_MASK ?'D' :'-' , - eflags &CC_O ?'O' :'-' , - eflags &CC_S ?'S' :'-' , - eflags &CC_Z ?'Z' :'-' , - eflags &CC_A ?'A' :'-' , - eflags &CC_P ?'P' :'-' , - eflags &CC_C ?'C' :'-' , - env->hflags &HF_CPL_MASK , - (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , - (env->a20_mask >>20 ) &1 , - (env->hflags >>HF_SMM_SHIFT ) &1 , - cs->halted); +qemu_fprintf (f,"EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" +"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" +"EIP=%08x EFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n" , + (uint32_t )env->regs[R_EAX ], + (uint32_t )env->regs[R_EBX ], + (uint32_t )env->regs[R_ECX ], + (uint32_t )env->regs[R_EDX ], + (uint32_t )env->regs[R_ESI ], + (uint32_t )env->regs[R_EDI ], + (uint32_t )env->regs[R_EBP ], + (uint32_t )env->regs[R_ESP ], + (uint32_t )env->eip, eflags, + eflags &DF_MASK ?'D' :'-' , + eflags &CC_O ?'O' :'-' , + eflags &CC_S ?'S' :'-' , + eflags &CC_Z ?'Z' :'-' , + eflags &CC_A ?'A' :'-' , + eflags &CC_P ?'P' :'-' , + eflags &CC_C ?'C' :'-' , + env->hflags &HF_CPL_MASK , + (env->hflags >>HF_INHIBIT_IRQ_SHIFT ) &1 , + (env->a20_mask >>20 ) &1 , + (env->hflags >>HF_SMM_SHIFT ) &1 , + cs->halted); }for (i =0 ; i <6 ; i++) { -cpu_x86_dump_seg_cache (env, f, cpu_fprintf, seg_name[i], - &env->segs[i]); +cpu_x86_dump_seg_cache (env, f, seg_name[i], &env->segs[i]); } -cpu_x86_dump_seg_cache (env, f, cpu_fprintf,"LDT" , &env->ldt); -cpu_x86_dump_seg_cache (env, f, cpu_fprintf,"TR" , &env->tr); +cpu_x86_dump_seg_cache (env, f,"LDT" , &env->ldt); +cpu_x86_dump_seg_cache (env, f,"TR" , &env->tr);#ifdef TARGET_X86_64 if (env->hflags &HF_LMA_MASK ) { -cpu_fprintf (f,"GDT= %016" PRIx64" %08x\n" , - env->gdt.base, env->gdt.limit); -cpu_fprintf (f,"IDT= %016" PRIx64" %08x\n" , - env->idt.base, env->idt.limit); -cpu_fprintf (f,"CR0=%08x CR2=%016" PRIx64" CR3=%016" PRIx64" CR4=%08x\n" , - (uint32_t )env->cr[0 ], - env->cr[2 ], - env->cr[3 ], - (uint32_t )env->cr[4 ]); +qemu_fprintf (f,"GDT= %016" PRIx64" %08x\n" , + env->gdt.base, env->gdt.limit); +qemu_fprintf (f,"IDT= %016" PRIx64" %08x\n" , + env->idt.base, env->idt.limit); +qemu_fprintf (f,"CR0=%08x CR2=%016" PRIx64" CR3=%016" PRIx64" CR4=%08x\n" , + (uint32_t )env->cr[0 ], + env->cr[2 ], + env->cr[3 ], + (uint32_t )env->cr[4 ]);for (i =0 ; i <4 ; i++) -cpu_fprintf (f,"DR%d=%016" PRIx64" " , i, env->dr[i]); -cpu_fprintf (f,"\nDR6=%016" PRIx64" DR7=%016" PRIx64"\n" , - env->dr[6 ], env->dr[7 ]); +qemu_fprintf (f,"DR%d=%016" PRIx64" " , i, env->dr[i]); +qemu_fprintf (f,"\nDR6=%016" PRIx64" DR7=%016" PRIx64"\n" , + env->dr[6 ], env->dr[7 ]); } else#endif { -cpu_fprintf (f,"GDT= %08x %08x\n" , - (uint32_t )env->gdt.base, env->gdt.limit); -cpu_fprintf (f,"IDT= %08x %08x\n" , - (uint32_t )env->idt.base, env->idt.limit); -cpu_fprintf (f,"CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n" , - (uint32_t )env->cr[0 ], - (uint32_t )env->cr[2 ], - (uint32_t )env->cr[3 ], - (uint32_t )env->cr[4 ]); +qemu_fprintf (f,"GDT= %08x %08x\n" , + (uint32_t )env->gdt.base, env->gdt.limit); +qemu_fprintf (f,"IDT= %08x %08x\n" , + (uint32_t )env->idt.base, env->idt.limit); +qemu_fprintf (f,"CR0=%08x CR2=%08x CR3=%08x CR4=%08x\n" , + (uint32_t )env->cr[0 ], + (uint32_t )env->cr[2 ], + (uint32_t )env->cr[3 ], + (uint32_t )env->cr[4 ]);for (i =0 ; i <4 ; i++) { -cpu_fprintf (f,"DR%d=" TARGET_FMT_lx" " , i, env->dr[i]); +qemu_fprintf (f,"DR%d=" TARGET_FMT_lx" " , i, env->dr[i]); } -cpu_fprintf (f,"\nDR6=" TARGET_FMT_lx" DR7=" TARGET_FMT_lx"\n" , - env->dr[6 ], env->dr[7 ]); +qemu_fprintf (f,"\nDR6=" TARGET_FMT_lx" DR7=" TARGET_FMT_lx"\n" , + env->dr[6 ], env->dr[7 ]); }if (flags &CPU_DUMP_CCOP ) {if ((unsigned )env->cc_op <CC_OP_NB )@@ -526,55 +525,55 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,snprintf (cc_op_name,sizeof (cc_op_name),"[%d]" , env->cc_op);#ifdef TARGET_X86_64 if (env->hflags &HF_CS64_MASK ) { -cpu_fprintf (f,"CCS=%016" PRIx64" CCD=%016" PRIx64" CCO=%-8s\n" , - env->cc_src, env->cc_dst, - cc_op_name); +qemu_fprintf (f,"CCS=%016" PRIx64" CCD=%016" PRIx64" CCO=%-8s\n" , + env->cc_src, env->cc_dst, + cc_op_name); } else#endif { -cpu_fprintf (f,"CCS=%08x CCD=%08x CCO=%-8s\n" , - (uint32_t )env->cc_src, (uint32_t )env->cc_dst, - cc_op_name); +qemu_fprintf (f,"CCS=%08x CCD=%08x CCO=%-8s\n" , + (uint32_t )env->cc_src, (uint32_t )env->cc_dst, + cc_op_name); } } -cpu_fprintf (f,"EFER=%016" PRIx64"\n" , env->efer); +qemu_fprintf (f,"EFER=%016" PRIx64"\n" , env->efer);if (flags &CPU_DUMP_FPU ) {int fptag; fptag =0 ;for (i =0 ; i <8 ; i++) { fptag |= ((!env->fptags[i]) << i); } -cpu_fprintf (f,"FCW=%04x FSW=%04x [ST=%d] FTW=%02x MXCSR=%08x\n" , - env->fpuc, - (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 , - env->fpstt, - fptag, - env->mxcsr); +qemu_fprintf (f,"FCW=%04x FSW=%04x [ST=%d] FTW=%02x MXCSR=%08x\n" , + env->fpuc, + (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 , + env->fpstt, + fptag, + env->mxcsr);for (i=0 ;i<8 ;i++) {CPU_LDoubleU u; u.d = env->fpregs[i].d; -cpu_fprintf (f,"FPR%d=%016" PRIx64" %04x" , - i, u.l.lower, u.l.upper); +qemu_fprintf (f,"FPR%d=%016" PRIx64" %04x" , + i, u.l.lower, u.l.upper);if ((i &1 ) ==1 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );else -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); }if (env->hflags &HF_CS64_MASK ) nb =16 ;else nb =8 ;for (i=0 ;i<nb;i++) { -cpu_fprintf (f,"XMM%02d=%08x%08x%08x%08x" , - i, - env->xmm_regs[i].ZMM_L (3 ), - env->xmm_regs[i].ZMM_L (2 ), - env->xmm_regs[i].ZMM_L (1 ), - env->xmm_regs[i].ZMM_L (0 )); +qemu_fprintf (f,"XMM%02d=%08x%08x%08x%08x" , + i, + env->xmm_regs[i].ZMM_L (3 ), + env->xmm_regs[i].ZMM_L (2 ), + env->xmm_regs[i].ZMM_L (1 ), + env->xmm_regs[i].ZMM_L (0 ));if ((i &1 ) ==1 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );else -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); } }if (flags &CPU_DUMP_CODE ) {@@ -583,17 +582,17 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,uint8_t code;char codestr[3 ]; -cpu_fprintf (f,"Code=" ); +qemu_fprintf (f,"Code=" );for (i =0 ; i <DUMP_CODE_BYTES_TOTAL ; i++) {if (cpu_memory_rw_debug (cs, base - offs + i, &code,1 ,0 ) ==0 ) {snprintf (codestr,sizeof (codestr),"%02x" , code); }else {snprintf (codestr,sizeof (codestr),"??" ); } -cpu_fprintf (f,"%s%s%s%s" , i >0 ?" " :"" , - i == offs ?"<" :"" , codestr, i == offs ?">" :"" ); +qemu_fprintf (f,"%s%s%s%s" , i >0 ?" " :"" , + i == offs ?"<" :"" , codestr, i == offs ?">" :"" ); } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }target/i386/monitor.c +1
-1@@ -664,7 +664,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); +x86_cpu_dump_local_apic_state (cs,NULL ,CPU_DUMP_FPU ); }void hmp_info_io_apic (Monitor *mon,const QDict *qdict)target/lm32/cpu.h +1
-2@@ -219,8 +219,7 @@ extern const struct VMStateDescription vmstate_lm32_cpu;void lm32_cpu_do_interrupt (CPUState *cpu);bool lm32_cpu_exec_interrupt (CPUState *cs,int int_req); -void lm32_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void lm32_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr lm32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int lm32_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int lm32_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/lm32/translate.c +18
-18@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "exec/translator.h" #include "tcg-op.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "hw/lm32/lm32_pic.h" @@ -1161,38 +1162,37 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)#endif } -void lm32_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void lm32_cpu_dump_state (CPUState *cs,FILE *f,int flags) {LM32CPU *cpu =LM32_CPU (cs);CPULM32State *env = &cpu->env;int i; -if (!env || !f) { +if (!env) {return ; } -cpu_fprintf (f,"IN: PC=%x %s\n" , - env->pc,lookup_symbol (env->pc)); +qemu_fprintf (f,"IN: PC=%x %s\n" , + env->pc,lookup_symbol (env->pc)); -cpu_fprintf (f,"ie=%8.8x (IE=%x EIE=%x BIE=%x) im=%8.8x ip=%8.8x\n" , - env->ie, - (env->ie &IE_IE ) ?1 :0 , - (env->ie &IE_EIE ) ?1 :0 , - (env->ie &IE_BIE ) ?1 :0 , -lm32_pic_get_im (env->pic_state), -lm32_pic_get_ip (env->pic_state)); -cpu_fprintf (f,"eba=%8.8x deba=%8.8x\n" , - env->eba, - env->deba); +qemu_fprintf (f,"ie=%8.8x (IE=%x EIE=%x BIE=%x) im=%8.8x ip=%8.8x\n" , + env->ie, + (env->ie &IE_IE ) ?1 :0 , + (env->ie &IE_EIE ) ?1 :0 , + (env->ie &IE_BIE ) ?1 :0 , +lm32_pic_get_im (env->pic_state), +lm32_pic_get_ip (env->pic_state)); +qemu_fprintf (f,"eba=%8.8x deba=%8.8x\n" , + env->eba, + env->deba);for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]); +qemu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); } void restore_state_to_opc(CPULM32State *env, TranslationBlock *tb,target/m68k/cpu.h +1
-2@@ -179,8 +179,7 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)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,fprintf_function cpu_fprintf, -int flags); +void m68k_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr m68k_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int m68k_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int m68k_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/m68k/translate.c +43
-43@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "tcg-op.h" #include "qemu/log.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" @@ -6187,76 +6188,75 @@ 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,fprintf_function cpu_fprintf, -int flags) +void m68k_cpu_dump_state (CPUState *cs,FILE *f,int flags) {M68kCPU *cpu =M68K_CPU (cs);CPUM68KState *env = &cpu->env;int i;uint16_t sr;for (i =0 ; i <8 ; i++) { -cpu_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,"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)); } -cpu_fprintf (f,"PC = %08x " , env->pc); +qemu_fprintf (f,"PC = %08x " , env->pc); sr = env->sr |cpu_m68k_get_ccr (env); -cpu_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' :'-' ); -cpu_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' :'-' ); -cpu_fprintf (f,"\n " -"FPCR = %04x " , env->fpcr); +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);switch (env->fpcr &FPCR_PREC_MASK ) {case FPCR_PREC_X : -cpu_fprintf (f,"X " ); +qemu_fprintf (f,"X " );break ;case FPCR_PREC_S : -cpu_fprintf (f,"S " ); +qemu_fprintf (f,"S " );break ;case FPCR_PREC_D : -cpu_fprintf (f,"D " ); +qemu_fprintf (f,"D " );break ; }switch (env->fpcr &FPCR_RND_MASK ) {case FPCR_RND_N : -cpu_fprintf (f,"RN " ); +qemu_fprintf (f,"RN " );break ;case FPCR_RND_Z : -cpu_fprintf (f,"RZ " ); +qemu_fprintf (f,"RZ " );break ;case FPCR_RND_M : -cpu_fprintf (f,"RM " ); +qemu_fprintf (f,"RM " );break ;case FPCR_RND_P : -cpu_fprintf (f,"RP " ); +qemu_fprintf (f,"RP " );break ; } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" );#ifdef CONFIG_SOFTMMU -cpu_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 ]); -cpu_fprintf (f,"VBR = 0x%08x\n" , env->vbr); -cpu_fprintf (f,"SFC = %x DFC %x\n" , env->sfc, env->dfc); -cpu_fprintf (f,"SSW %08x TCR %08x URP %08x SRP %08x\n" , - env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp); -cpu_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 ]); -cpu_fprintf (f,"MMUSR %08x, fault at %08x\n" , - env->mmu.mmusr, env->mmu.ar); +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);#endif }target/microblaze/cpu.h +1
-2@@ -328,8 +328,7 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)void mb_cpu_do_interrupt (CPUState *cs);bool mb_cpu_exec_interrupt (CPUState *cs,int int_req); -void mb_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void mb_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr mb_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int mb_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int mb_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/microblaze/helper.c +1
-1@@ -42,7 +42,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, int mmu_idx) { cs->exception_index =0xaa ; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }target/microblaze/translate.c +20
-19@@ -28,6 +28,7 @@#include "exec/cpu_ldst.h" #include "exec/helper-gen.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" #include "trace-tcg.h" #include "exec/log.h" @@ -1785,36 +1786,36 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)assert (!dc->abort_at_next_insn); } -void mb_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void mb_cpu_dump_state (CPUState *cs,FILE *f,int flags) {MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs);CPUMBState *env = &cpu->env;int i; -if (!env || !f) +if (!env) {return ; + } -cpu_fprintf (f,"IN: PC=%" PRIx64" %s\n" , - env->sregs[SR_PC ],lookup_symbol (env->sregs[SR_PC ])); -cpu_fprintf (f,"rmsr=%" PRIx64" resr=%" PRIx64" rear=%" PRIx64" " -"debug=%x imm=%x iflags=%x fsr=%" PRIx64"\n" , - env->sregs[SR_MSR ], env->sregs[SR_ESR ], env->sregs[SR_EAR ], - env->debug, env->imm, env->iflags, env->sregs[SR_FSR ]); -cpu_fprintf (f,"btaken=%d btarget=%" PRIx64" mode=%s(saved=%s) " -"eip=%d ie=%d\n" , - env->btaken, env->btarget, - (env->sregs[SR_MSR ] &MSR_UM ) ?"user" :"kernel" , - (env->sregs[SR_MSR ] &MSR_UMS ) ?"user" :"kernel" , - (bool )(env->sregs[SR_MSR ] &MSR_EIP ), - (bool )(env->sregs[SR_MSR ] &MSR_IE )); +qemu_fprintf (f,"IN: PC=%" PRIx64" %s\n" , + env->sregs[SR_PC ],lookup_symbol (env->sregs[SR_PC ])); +qemu_fprintf (f,"rmsr=%" PRIx64" resr=%" PRIx64" rear=%" PRIx64" " +"debug=%x imm=%x iflags=%x fsr=%" PRIx64"\n" , + env->sregs[SR_MSR ], env->sregs[SR_ESR ], env->sregs[SR_EAR ], + env->debug, env->imm, env->iflags, env->sregs[SR_FSR ]); +qemu_fprintf (f,"btaken=%d btarget=%" PRIx64" mode=%s(saved=%s) " +"eip=%d ie=%d\n" , + env->btaken, env->btarget, + (env->sregs[SR_MSR ] &MSR_UM ) ?"user" :"kernel" , + (env->sregs[SR_MSR ] &MSR_UMS ) ?"user" :"kernel" , + (bool )(env->sregs[SR_MSR ] &MSR_EIP ), + (bool )(env->sregs[SR_MSR ] &MSR_IE ));for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]); +qemu_fprintf (f,"r%2.2d=%8.8x " , i, env->regs[i]);if ((i +1 ) %4 ==0 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }void mb_tcg_init (void )target/mips/internal.h +1
-2@@ -76,8 +76,7 @@ enum CPUMIPSMSADataFormat {void mips_cpu_do_interrupt (CPUState *cpu);bool mips_cpu_exec_interrupt (CPUState *cpu,int int_req); -void mips_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void mips_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr mips_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int mips_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int mips_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/mips/translate.c +38
-38@@ -29728,8 +29728,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)translator_loop (&mips_tr_ops, &ctx.base, cs, tb); } -static void fpu_dump_state (CPUMIPSState *env,FILE *f,fprintf_function fpu_fprintf, -int flags) +static void fpu_dump_state (CPUMIPSState *env,FILE *f,int flags) {int i;int is_fpu64 = !!(env->hflags &MIPS_HFLAG_F64 );@@ -29737,68 +29736,69 @@ static void fpu_dump_state(CPUMIPSState *env, FILE *f, fprintf_function fpu_fpri#define printfpr (fp) \ do { \ if (is_fpu64) \ - fpu_fprintf(f, "w:%08x d:%016" PRIx64 \ - " fd:%13g fs:%13g psu: %13g\n", \ - (fp)->w[FP_ENDIAN_IDX], (fp)->d, \ - (double)(fp)->fd, \ - (double)(fp)->fs[FP_ENDIAN_IDX], \ - (double)(fp)->fs[!FP_ENDIAN_IDX]); \ + qemu_fprintf(f, "w:%08x d:%016" PRIx64 \ + " fd:%13g fs:%13g psu: %13g\n", \ + (fp)->w[FP_ENDIAN_IDX], (fp)->d, \ + (double)(fp)->fd, \ + (double)(fp)->fs[FP_ENDIAN_IDX], \ + (double)(fp)->fs[!FP_ENDIAN_IDX]); \ else { \ fpr_t tmp; \ tmp.w[FP_ENDIAN_IDX] = (fp)->w[FP_ENDIAN_IDX]; \ tmp.w[!FP_ENDIAN_IDX] = ((fp) + 1)->w[FP_ENDIAN_IDX]; \ - fpu_fprintf(f, "w:%08x d:%016" PRIx64 \ - " fd:%13g fs:%13g psu:%13g\n", \ - tmp.w[FP_ENDIAN_IDX], tmp.d, \ - (double)tmp.fd, \ - (double)tmp.fs[FP_ENDIAN_IDX], \ - (double)tmp.fs[!FP_ENDIAN_IDX]); \ + qemu_fprintf(f, "w:%08x d:%016" PRIx64 \ + " fd:%13g fs:%13g psu:%13g\n", \ + tmp.w[FP_ENDIAN_IDX], tmp.d, \ + (double)tmp.fd, \ + (double)tmp.fs[FP_ENDIAN_IDX], \ + (double)tmp.fs[!FP_ENDIAN_IDX]); \ } \ } while(0) -fpu_fprintf (f,"CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%02x\n" , - env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, -get_float_exception_flags (&env->active_fpu.fp_status)); +qemu_fprintf (f, +"CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%02x\n" , + env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, +get_float_exception_flags (&env->active_fpu.fp_status));for (i =0 ; i <32 ; (is_fpu64) ? i++ : (i +=2 )) { -fpu_fprintf (f,"%3s: " , fregnames[i]); +qemu_fprintf (f,"%3s: " , fregnames[i]);printfpr (&env->active_fpu.fpr[i]); }#undef printfpr } -void mips_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void mips_cpu_dump_state (CPUState *cs,FILE *f,int flags) {MIPSCPU *cpu =MIPS_CPU (cs);CPUMIPSState *env = &cpu->env;int i; -cpu_fprintf (f,"pc=0x" TARGET_FMT_lx" HI=0x" TARGET_FMT_lx -" LO=0x" TARGET_FMT_lx" ds %04x " - TARGET_FMT_lx" " TARGET_FMT_ld"\n" , - env->active_tc.PC, env->active_tc.HI[0 ], env->active_tc.LO[0 ], - env->hflags, env->btarget, env->bcond); +qemu_fprintf (f,"pc=0x" TARGET_FMT_lx" HI=0x" TARGET_FMT_lx +" LO=0x" TARGET_FMT_lx" ds %04x " + TARGET_FMT_lx" " TARGET_FMT_ld"\n" , + env->active_tc.PC, env->active_tc.HI[0 ], env->active_tc.LO[0 ], + env->hflags, env->btarget, env->bcond);for (i =0 ; i <32 ; i++) {if ((i &3 ) ==0 ) -cpu_fprintf (f,"GPR%02d:" , i); -cpu_fprintf (f," %s " TARGET_FMT_lx, regnames[i], env->active_tc.gpr[i]); +qemu_fprintf (f,"GPR%02d:" , i); +qemu_fprintf (f," %s " TARGET_FMT_lx, + regnames[i], env->active_tc.gpr[i]);if ((i &3 ) ==3 ) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } -cpu_fprintf (f,"CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx"\n" , - env->CP0_Status, env->CP0_Cause, env->CP0_EPC); -cpu_fprintf (f," Config0 0x%08x Config1 0x%08x LLAddr 0x%016" - PRIx64"\n" , - env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); -cpu_fprintf (f," Config2 0x%08x Config3 0x%08x\n" , - env->CP0_Config2, env->CP0_Config3); -cpu_fprintf (f," Config4 0x%08x Config5 0x%08x\n" , - env->CP0_Config4, env->CP0_Config5); +qemu_fprintf (f,"CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx"\n" , + env->CP0_Status, env->CP0_Cause, env->CP0_EPC); +qemu_fprintf (f," Config0 0x%08x Config1 0x%08x LLAddr 0x%016" + PRIx64"\n" , + env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); +qemu_fprintf (f," Config2 0x%08x Config3 0x%08x\n" , + env->CP0_Config2, env->CP0_Config3); +qemu_fprintf (f," Config4 0x%08x Config5 0x%08x\n" , + env->CP0_Config4, env->CP0_Config5);if ((flags &CPU_DUMP_FPU ) && (env->hflags &MIPS_HFLAG_FPU )) { -fpu_dump_state (env, f, cpu_fprintf, flags); +fpu_dump_state (env, f, flags); } }target/moxie/cpu.h +1
-2@@ -112,8 +112,7 @@ static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)#define ENV_OFFSET offsetof(MoxieCPU, env)void moxie_cpu_do_interrupt (CPUState *cs); -void moxie_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void moxie_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr moxie_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void moxie_translate_init (void ); int cpu_moxie_signal_handler(int host_signum, void *pinfo,target/moxie/helper.c +1
-1@@ -101,7 +101,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cs->exception_index =0xaa ; cpu->env.debug1 = address; -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 );return 1 ; }target/moxie/translate.c +11
-11@@ -28,6 +28,7 @@#include "disas/disas.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -69,24 +70,23 @@ static int extract_branch_offset(int opcode)return (((signed short )((opcode & ((1 <<10 ) -1 )) <<6 )) >>6 ) <<1 ; } -void moxie_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void moxie_cpu_dump_state (CPUState *cs,FILE *f,int flags) {MoxieCPU *cpu =MOXIE_CPU (cs);CPUMoxieState *env = &cpu->env;int i; -cpu_fprintf (f,"pc=0x%08x\n" , env->pc); -cpu_fprintf (f,"$fp=0x%08x $sp=0x%08x $r0=0x%08x $r1=0x%08x\n" , - env->gregs[0 ], env->gregs[1 ], env->gregs[2 ], env->gregs[3 ]); +qemu_fprintf (f,"pc=0x%08x\n" , env->pc); +qemu_fprintf (f,"$fp=0x%08x $sp=0x%08x $r0=0x%08x $r1=0x%08x\n" , + env->gregs[0 ], env->gregs[1 ], env->gregs[2 ], env->gregs[3 ]);for (i =4 ; i <16 ; i +=4 ) { -cpu_fprintf (f,"$r%d=0x%08x $r%d=0x%08x $r%d=0x%08x $r%d=0x%08x\n" , - i-2 , env->gregs[i], i-1 , env->gregs[i +1 ], - i, env->gregs[i +2 ], i+1 , env->gregs[i +3 ]); +qemu_fprintf (f,"$r%d=0x%08x $r%d=0x%08x $r%d=0x%08x $r%d=0x%08x\n" , + i -2 , env->gregs[i], i -1 , env->gregs[i +1 ], + i, env->gregs[i +2 ], i +1 , env->gregs[i +3 ]); }for (i =4 ; i <16 ; i +=4 ) { -cpu_fprintf (f,"sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x\n" , - i-2 , env->sregs[i], i-1 , env->sregs[i +1 ], - i, env->sregs[i +2 ], i+1 , env->sregs[i +3 ]); +qemu_fprintf (f,"sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x sr%d=0x%08x\n" , + i -2 , env->sregs[i], i -1 , env->sregs[i +1 ], + i, env->sregs[i +2 ], i +1 , env->sregs[i +3 ]); } }target/nios2/cpu.h +1
-2@@ -213,8 +213,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,fprintf_function cpu_fprintf, -int flags); +void nios2_cpu_dump_state (CPUState *cpu,FILE *f,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,target/nios2/helper.c +1
-1@@ -42,7 +42,7 @@ int nios2_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cs->exception_index =0xaa ;/* Page 0x1000 is kuser helper */ if (address <0x1000 || address >=0x2000 ) { -cpu_dump_state (cs, stderr, fprintf,0 ); +cpu_dump_state (cs, stderr,0 ); }return 1 ; }target/nios2/translate.c +12
-12@@ -31,6 +31,7 @@#include "exec/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0/* only pc was modified dynamically */ @@ -914,33 +915,32 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)#endif } -void nios2_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void nios2_cpu_dump_state (CPUState *cs,FILE *f,int flags) {Nios2CPU *cpu =NIOS2_CPU (cs);CPUNios2State *env = &cpu->env;int i; -if (!env || !f) { +if (!env) {return ; } -cpu_fprintf (f,"IN: PC=%x %s\n" , - env->regs[R_PC ],lookup_symbol (env->regs[R_PC ])); +qemu_fprintf (f,"IN: PC=%x %s\n" , + env->regs[R_PC ],lookup_symbol (env->regs[R_PC ]));for (i =0 ; i <NUM_CORE_REGS ; i++) { -cpu_fprintf (f,"%9s=%8.8x " , regnames[i], env->regs[i]); +qemu_fprintf (f,"%9s=%8.8x " , regnames[i], env->regs[i]);if ((i +1 ) %4 ==0 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }#if !defined(CONFIG_USER_ONLY ) -cpu_fprintf (f," mmu write: VPN=%05X PID %02X TLBACC %08X\n" , - env->mmu.pteaddr_wr &CR_PTEADDR_VPN_MASK , - (env->mmu.tlbmisc_wr &CR_TLBMISC_PID_MASK ) >>4 , - env->mmu.tlbacc_wr); +qemu_fprintf (f," mmu write: VPN=%05X PID %02X TLBACC %08X\n" , + env->mmu.pteaddr_wr &CR_PTEADDR_VPN_MASK , + (env->mmu.tlbmisc_wr &CR_TLBMISC_PID_MASK ) >>4 , + env->mmu.tlbacc_wr);#endif -cpu_fprintf (f,"\n\n" ); +qemu_fprintf (f,"\n\n" ); }void nios2_tcg_init (void )target/openrisc/cpu.h +1
-2@@ -339,8 +339,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env)void cpu_openrisc_list (void );void openrisc_cpu_do_interrupt (CPUState *cpu);bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req); -void openrisc_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void openrisc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/openrisc/translate.c +5
-6@@ -26,6 +26,7 @@#include "qemu-common.h" #include "qemu/log.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" @@ -1415,18 +1416,16 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)translator_loop (&openrisc_tr_ops, &ctx.base, cs, tb); } -void openrisc_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf, -int flags) +void openrisc_cpu_dump_state (CPUState *cs,FILE *f,int flags) {OpenRISCCPU *cpu =OPENRISC_CPU (cs);CPUOpenRISCState *env = &cpu->env;int i; -cpu_fprintf (f,"PC=%08x\n" , env->pc); +qemu_fprintf (f,"PC=%08x\n" , env->pc);for (i =0 ; i <32 ; ++i) { -cpu_fprintf (f,"R%02d=%08x%c" , i,cpu_get_gpr (env, i), - (i %4 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"R%02d=%08x%c" , i,cpu_get_gpr (env, i), + (i %4 ) ==3 ?'\n' :' ' ); } }target/ppc/cpu.h +1
-2@@ -1268,8 +1268,7 @@ struct PPCVirtualHypervisorClass {void ppc_cpu_do_interrupt (CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req); -void ppc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void ppc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);void ppc_cpu_dump_statistics (CPUState *cpu,int flags);hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);target/ppc/translate.c +80
-81@@ -7414,8 +7414,7 @@ GEN_HANDLER2_E(trechkpt, "trechkpt", 0x1F, 0x0E, 0x1F, 0x03FFF800, \/*****************************************************************************/ /* Misc PowerPC helpers */ -void ppc_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void ppc_cpu_dump_state (CPUState *cs,FILE *f,int flags) {#define RGPL 4#define RFPL 4@@ -7424,37 +7423,37 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,CPUPPCState *env = &cpu->env;int i; -cpu_fprintf (f,"NIP " TARGET_FMT_lx" LR " TARGET_FMT_lx" CTR " - TARGET_FMT_lx" XER " TARGET_FMT_lx" CPU#%d\n" , - env->nip, env->lr, env->ctr,cpu_read_xer (env), - cs->cpu_index); -cpu_fprintf (f,"MSR " TARGET_FMT_lx" HID0 " TARGET_FMT_lx" HF " - TARGET_FMT_lx" iidx %d didx %d\n" , - env->msr, env->spr[SPR_HID0 ], - env->hflags, env->immu_idx, env->dmmu_idx); +qemu_fprintf (f,"NIP " TARGET_FMT_lx" LR " TARGET_FMT_lx" CTR " + TARGET_FMT_lx" XER " TARGET_FMT_lx" CPU#%d\n" , + env->nip, env->lr, env->ctr,cpu_read_xer (env), + cs->cpu_index); +qemu_fprintf (f,"MSR " TARGET_FMT_lx" HID0 " TARGET_FMT_lx" HF " + TARGET_FMT_lx" iidx %d didx %d\n" , + env->msr, env->spr[SPR_HID0 ], + env->hflags, env->immu_idx, env->dmmu_idx);#if !defined(NO_TIMER_DUMP ) - cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 + qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 #if !defined(CONFIG_USER_ONLY) - " DECR " TARGET_FMT_lu + " DECR " TARGET_FMT_lu #endif -"\n" , - cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) +"\n" , + cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) - ,cpu_ppc_load_decr (env) + ,cpu_ppc_load_decr (env) #endif - ); + );#endif for (i =0 ; i <32 ; i++) {if ((i & (RGPL -1 )) ==0 ) -cpu_fprintf (f,"GPR%02d" , i); -cpu_fprintf (f," %016" PRIx64,ppc_dump_gpr (env, i)); +qemu_fprintf (f,"GPR%02d" , i); +qemu_fprintf (f," %016" PRIx64,ppc_dump_gpr (env, i));if ((i & (RGPL -1 )) == (RGPL -1 )) -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } -cpu_fprintf (f,"CR " ); +qemu_fprintf (f,"CR " );for (i =0 ; i <8 ; i++) -cpu_fprintf (f,"%01x" , env->crf[i]); -cpu_fprintf (f," [" ); +qemu_fprintf (f,"%01x" , env->crf[i]); +qemu_fprintf (f," [" );for (i =0 ; i <8 ; i++) {char a ='-' ;if (env->crf[i] &0x08 )@@ -7463,74 +7462,74 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, a ='G' ; else if (env->crf[i] & 0x02) a ='E' ; -cpu_fprintf (f," %c%c" , a, env->crf[i] &0x01 ?'O' :' ' ); +qemu_fprintf (f," %c%c" , a, env->crf[i] &0x01 ?'O' :' ' ); } -cpu_fprintf (f," ] RES " TARGET_FMT_lx"\n" , - env->reserve_addr); +qemu_fprintf (f," ] RES " TARGET_FMT_lx"\n" , + env->reserve_addr);if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <32 ; i++) {if ((i & (RFPL -1 )) ==0 ) { -cpu_fprintf (f,"FPR%02d" , i); +qemu_fprintf (f,"FPR%02d" , i); } -cpu_fprintf (f," %016" PRIx64, *cpu_fpr_ptr (env, i)); +qemu_fprintf (f," %016" PRIx64, *cpu_fpr_ptr (env, i));if ((i & (RFPL -1 )) == (RFPL -1 )) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } -cpu_fprintf (f,"FPSCR " TARGET_FMT_lx"\n" , env->fpscr); +qemu_fprintf (f,"FPSCR " TARGET_FMT_lx"\n" , env->fpscr); }#if !defined(CONFIG_USER_ONLY ) -cpu_fprintf (f," SRR0 " TARGET_FMT_lx" SRR1 " TARGET_FMT_lx -" PVR " TARGET_FMT_lx" VRSAVE " TARGET_FMT_lx"\n" , - env->spr[SPR_SRR0 ], env->spr[SPR_SRR1 ], - env->spr[SPR_PVR ], env->spr[SPR_VRSAVE ]); +qemu_fprintf (f," SRR0 " TARGET_FMT_lx" SRR1 " TARGET_FMT_lx +" PVR " TARGET_FMT_lx" VRSAVE " TARGET_FMT_lx"\n" , + env->spr[SPR_SRR0 ], env->spr[SPR_SRR1 ], + env->spr[SPR_PVR ], env->spr[SPR_VRSAVE ]); -cpu_fprintf (f,"SPRG0 " TARGET_FMT_lx" SPRG1 " TARGET_FMT_lx -" SPRG2 " TARGET_FMT_lx" SPRG3 " TARGET_FMT_lx"\n" , - env->spr[SPR_SPRG0 ], env->spr[SPR_SPRG1 ], - env->spr[SPR_SPRG2 ], env->spr[SPR_SPRG3 ]); +qemu_fprintf (f,"SPRG0 " TARGET_FMT_lx" SPRG1 " TARGET_FMT_lx +" SPRG2 " TARGET_FMT_lx" SPRG3 " TARGET_FMT_lx"\n" , + env->spr[SPR_SPRG0 ], env->spr[SPR_SPRG1 ], + env->spr[SPR_SPRG2 ], env->spr[SPR_SPRG3 ]); -cpu_fprintf (f,"SPRG4 " TARGET_FMT_lx" SPRG5 " TARGET_FMT_lx -" SPRG6 " TARGET_FMT_lx" SPRG7 " TARGET_FMT_lx"\n" , - env->spr[SPR_SPRG4 ], env->spr[SPR_SPRG5 ], - env->spr[SPR_SPRG6 ], env->spr[SPR_SPRG7 ]); +qemu_fprintf (f,"SPRG4 " TARGET_FMT_lx" SPRG5 " TARGET_FMT_lx +" SPRG6 " TARGET_FMT_lx" SPRG7 " TARGET_FMT_lx"\n" , + env->spr[SPR_SPRG4 ], env->spr[SPR_SPRG5 ], + env->spr[SPR_SPRG6 ], env->spr[SPR_SPRG7 ]);#if defined(TARGET_PPC64 )if (env->excp_model ==POWERPC_EXCP_POWER7 || env->excp_model ==POWERPC_EXCP_POWER8 || env->excp_model ==POWERPC_EXCP_POWER9 ) { -cpu_fprintf (f,"HSRR0 " TARGET_FMT_lx" HSRR1 " TARGET_FMT_lx"\n" , - env->spr[SPR_HSRR0 ], env->spr[SPR_HSRR1 ]); +qemu_fprintf (f,"HSRR0 " TARGET_FMT_lx" HSRR1 " TARGET_FMT_lx"\n" , + env->spr[SPR_HSRR0 ], env->spr[SPR_HSRR1 ]); }#endif if (env->excp_model ==POWERPC_EXCP_BOOKE ) { -cpu_fprintf (f,"CSRR0 " TARGET_FMT_lx" CSRR1 " TARGET_FMT_lx -" MCSRR0 " TARGET_FMT_lx" MCSRR1 " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_CSRR0 ], env->spr[SPR_BOOKE_CSRR1 ], - env->spr[SPR_BOOKE_MCSRR0 ], env->spr[SPR_BOOKE_MCSRR1 ]); +qemu_fprintf (f,"CSRR0 " TARGET_FMT_lx" CSRR1 " TARGET_FMT_lx +" MCSRR0 " TARGET_FMT_lx" MCSRR1 " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_CSRR0 ], env->spr[SPR_BOOKE_CSRR1 ], + env->spr[SPR_BOOKE_MCSRR0 ], env->spr[SPR_BOOKE_MCSRR1 ]); -cpu_fprintf (f," TCR " TARGET_FMT_lx" TSR " TARGET_FMT_lx -" ESR " TARGET_FMT_lx" DEAR " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_TCR ], env->spr[SPR_BOOKE_TSR ], - env->spr[SPR_BOOKE_ESR ], env->spr[SPR_BOOKE_DEAR ]); +qemu_fprintf (f," TCR " TARGET_FMT_lx" TSR " TARGET_FMT_lx +" ESR " TARGET_FMT_lx" DEAR " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_TCR ], env->spr[SPR_BOOKE_TSR ], + env->spr[SPR_BOOKE_ESR ], env->spr[SPR_BOOKE_DEAR ]); -cpu_fprintf (f," PIR " TARGET_FMT_lx" DECAR " TARGET_FMT_lx -" IVPR " TARGET_FMT_lx" EPCR " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_PIR ], env->spr[SPR_BOOKE_DECAR ], - env->spr[SPR_BOOKE_IVPR ], env->spr[SPR_BOOKE_EPCR ]); +qemu_fprintf (f," PIR " TARGET_FMT_lx" DECAR " TARGET_FMT_lx +" IVPR " TARGET_FMT_lx" EPCR " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_PIR ], env->spr[SPR_BOOKE_DECAR ], + env->spr[SPR_BOOKE_IVPR ], env->spr[SPR_BOOKE_EPCR ]); -cpu_fprintf (f," MCSR " TARGET_FMT_lx" SPRG8 " TARGET_FMT_lx -" EPR " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_MCSR ], env->spr[SPR_BOOKE_SPRG8 ], - env->spr[SPR_BOOKE_EPR ]); +qemu_fprintf (f," MCSR " TARGET_FMT_lx" SPRG8 " TARGET_FMT_lx +" EPR " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_MCSR ], env->spr[SPR_BOOKE_SPRG8 ], + env->spr[SPR_BOOKE_EPR ]);/* FSL-specific */ -cpu_fprintf (f," MCAR " TARGET_FMT_lx" PID1 " TARGET_FMT_lx -" PID2 " TARGET_FMT_lx" SVR " TARGET_FMT_lx"\n" , - env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1 ], - env->spr[SPR_BOOKE_PID2 ], env->spr[SPR_E500_SVR ]); +qemu_fprintf (f," MCAR " TARGET_FMT_lx" PID1 " TARGET_FMT_lx +" PID2 " TARGET_FMT_lx" SVR " TARGET_FMT_lx"\n" , + env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1 ], + env->spr[SPR_BOOKE_PID2 ], env->spr[SPR_E500_SVR ]);/* * IVORs are left out as they are large and do not change often -- @@ -7540,12 +7539,12 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,#if defined(TARGET_PPC64 )if (env->flags &POWERPC_FLAG_CFAR ) { -cpu_fprintf (f," CFAR " TARGET_FMT_lx"\n" , env->cfar); +qemu_fprintf (f," CFAR " TARGET_FMT_lx"\n" , env->cfar); }#endif if (env->spr_cb[SPR_LPCR ].name) -cpu_fprintf (f," LPCR " TARGET_FMT_lx"\n" , env->spr[SPR_LPCR ]); +qemu_fprintf (f," LPCR " TARGET_FMT_lx"\n" , env->spr[SPR_LPCR ]);switch (env->mmu_model) {case POWERPC_MMU_32B :@@ -7560,29 +7559,29 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,case POWERPC_MMU_3_00 :#endif if (env->spr_cb[SPR_SDR1 ].name) {/* SDR1 Exists */ -cpu_fprintf (f," SDR1 " TARGET_FMT_lx" " , env->spr[SPR_SDR1 ]); +qemu_fprintf (f," SDR1 " TARGET_FMT_lx" " , env->spr[SPR_SDR1 ]); }if (env->spr_cb[SPR_PTCR ].name) {/* PTCR Exists */ -cpu_fprintf (f," PTCR " TARGET_FMT_lx" " , env->spr[SPR_PTCR ]); +qemu_fprintf (f," PTCR " TARGET_FMT_lx" " , env->spr[SPR_PTCR ]); } -cpu_fprintf (f," DAR " TARGET_FMT_lx" DSISR " TARGET_FMT_lx"\n" , - env->spr[SPR_DAR ], env->spr[SPR_DSISR ]); +qemu_fprintf (f," DAR " TARGET_FMT_lx" DSISR " TARGET_FMT_lx"\n" , + env->spr[SPR_DAR ], env->spr[SPR_DSISR ]);break ;case POWERPC_MMU_BOOKE206 : -cpu_fprintf (f," MAS0 " TARGET_FMT_lx" MAS1 " TARGET_FMT_lx -" MAS2 " TARGET_FMT_lx" MAS3 " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_MAS0 ], env->spr[SPR_BOOKE_MAS1 ], - env->spr[SPR_BOOKE_MAS2 ], env->spr[SPR_BOOKE_MAS3 ]); +qemu_fprintf (f," MAS0 " TARGET_FMT_lx" MAS1 " TARGET_FMT_lx +" MAS2 " TARGET_FMT_lx" MAS3 " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_MAS0 ], env->spr[SPR_BOOKE_MAS1 ], + env->spr[SPR_BOOKE_MAS2 ], env->spr[SPR_BOOKE_MAS3 ]); -cpu_fprintf (f," MAS4 " TARGET_FMT_lx" MAS6 " TARGET_FMT_lx -" MAS7 " TARGET_FMT_lx" PID " TARGET_FMT_lx"\n" , - env->spr[SPR_BOOKE_MAS4 ], env->spr[SPR_BOOKE_MAS6 ], - env->spr[SPR_BOOKE_MAS7 ], env->spr[SPR_BOOKE_PID ]); +qemu_fprintf (f," MAS4 " TARGET_FMT_lx" MAS6 " TARGET_FMT_lx +" MAS7 " TARGET_FMT_lx" PID " TARGET_FMT_lx"\n" , + env->spr[SPR_BOOKE_MAS4 ], env->spr[SPR_BOOKE_MAS6 ], + env->spr[SPR_BOOKE_MAS7 ], env->spr[SPR_BOOKE_PID ]); -cpu_fprintf (f,"MMUCFG " TARGET_FMT_lx" TLB0CFG " TARGET_FMT_lx -" TLB1CFG " TARGET_FMT_lx"\n" , - env->spr[SPR_MMUCFG ], env->spr[SPR_BOOKE_TLB0CFG ], - env->spr[SPR_BOOKE_TLB1CFG ]); +qemu_fprintf (f,"MMUCFG " TARGET_FMT_lx" TLB0CFG " TARGET_FMT_lx +" TLB1CFG " TARGET_FMT_lx"\n" , + env->spr[SPR_MMUCFG ], env->spr[SPR_BOOKE_TLB0CFG ], + env->spr[SPR_BOOKE_TLB1CFG ]);break ;default :break ;target/riscv/cpu.c +18
-19@@ -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" ); } } }target/s390x/helper.c +21
-21@@ -23,6 +23,7 @@#include "internal.h" #include "exec/gdbstub.h" #include "qemu/timer.h" +#include "qemu/qemu-print.h" #include "hw/s390x/ioinst.h" #include "sysemu/hw_accel.h" #ifndef CONFIG_USER_ONLY @@ -313,65 +314,64 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) }#endif /* CONFIG_USER_ONLY */ -void s390_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void s390_cpu_dump_state (CPUState *cs,FILE *f,int flags) {S390CPU *cpu =S390_CPU (cs);CPUS390XState *env = &cpu->env;int i;if (env->cc_op >3 ) { -cpu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %15s\n" , - env->psw.mask, env->psw.addr,cc_name (env->cc_op)); +qemu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %15s\n" , + env->psw.mask, env->psw.addr,cc_name (env->cc_op)); }else { -cpu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %02x\n" , - env->psw.mask, env->psw.addr, env->cc_op); +qemu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %02x\n" , + env->psw.mask, env->psw.addr, env->cc_op); }for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"R%02d=%016" PRIx64, i, env->regs[i]); +qemu_fprintf (f,"R%02d=%016" PRIx64, i, env->regs[i]);if ((i %4 ) ==3 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }else { -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); } }if (flags &CPU_DUMP_FPU ) {if (s390_has_feat (S390_FEAT_VECTOR )) {for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"V%02d=%016" PRIx64"%016" PRIx64"%c" , - i, env->vregs[i][0 ].ll, env->vregs[i][1 ].ll, - i %2 ?'\n' :' ' ); +qemu_fprintf (f,"V%02d=%016" PRIx64"%016" PRIx64"%c" , + i, env->vregs[i][0 ].ll, env->vregs[i][1 ].ll, + i %2 ?'\n' :' ' ); } }else {for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"F%02d=%016" PRIx64"%c" , - i,get_freg (env, i)->ll, - (i %4 ) ==3 ?'\n' :' ' ); +qemu_fprintf (f,"F%02d=%016" PRIx64"%c" , + i,get_freg (env, i)->ll, + (i %4 ) ==3 ?'\n' :' ' ); } } }#ifndef CONFIG_USER_ONLY for (i =0 ; i <16 ; i++) { -cpu_fprintf (f,"C%02d=%016" PRIx64, i, env->cregs[i]); +qemu_fprintf (f,"C%02d=%016" PRIx64, i, env->cregs[i]);if ((i %4 ) ==3 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }else { -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); } }#endif #ifdef DEBUG_INLINE_BRANCHES for (i =0 ; i <CC_OP_MAX ; i++) { -cpu_fprintf (f," %15s = %10ld\t%10ld\n" ,cc_name (i), - inline_branch_miss[i], inline_branch_hit[i]); +qemu_fprintf (f," %15s = %10ld\t%10ld\n" ,cc_name (i), + inline_branch_miss[i], inline_branch_hit[i]); }#endif -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }const char *cc_name (enum cc_op cc_op)target/s390x/internal.h +1
-2@@ -292,8 +292,7 @@ void s390_cpu_gdb_init(CPUState *cs);/* helper.c */ -void s390_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf, -int flags); +void s390_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr s390_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);hwaddr s390_cpu_get_phys_addr_debug (CPUState *cpu,vaddr addr);uint64_t get_psw_mask (CPUS390XState *env);target/sh4/cpu.h +1
-2@@ -232,8 +232,7 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)void superh_cpu_do_interrupt (CPUState *cpu);bool superh_cpu_exec_interrupt (CPUState *cpu,int int_req); -void superh_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void superh_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int superh_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int superh_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/sh4/translate.c +14
-13@@ -30,6 +30,7 @@#include "exec/translator.h" #include "trace-tcg.h" #include "exec/log.h" +#include "qemu/qemu-print.h" typedef struct DisasContext {@@ -156,32 +157,32 @@ void sh4_translate_init(void) fregnames[i]); } -void superh_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void superh_cpu_dump_state (CPUState *cs,FILE *f,int flags) {SuperHCPU *cpu =SUPERH_CPU (cs);CPUSH4State *env = &cpu->env;int i; -cpu_fprintf (f,"pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n" , - env->pc,cpu_read_sr (env), env->pr, env->fpscr); -cpu_fprintf (f,"spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n" , - env->spc, env->ssr, env->gbr, env->vbr); -cpu_fprintf (f,"sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n" , - env->sgr, env->dbr, env->delayed_pc, env->fpul); + +qemu_fprintf (f,"pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n" , + env->pc,cpu_read_sr (env), env->pr, env->fpscr); +qemu_fprintf (f,"spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n" , + env->spc, env->ssr, env->gbr, env->vbr); +qemu_fprintf (f,"sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n" , + env->sgr, env->dbr, env->delayed_pc, env->fpul);for (i =0 ; i <24 ; i +=4 ) { -cpu_fprintf (f,"r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n" , +qemu_printf ("r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n" , i, env->gregs[i], i +1 , env->gregs[i +1 ], i +2 , env->gregs[i +2 ], i +3 , env->gregs[i +3 ]); }if (env->flags &DELAY_SLOT ) { -cpu_fprintf (f,"in delay slot (delayed_pc=0x%08x)\n" , +qemu_printf ("in delay slot (delayed_pc=0x%08x)\n" , env->delayed_pc); }else if (env->flags &DELAY_SLOT_CONDITIONAL ) { -cpu_fprintf (f,"in conditional delay slot (delayed_pc=0x%08x)\n" , +qemu_printf ("in conditional delay slot (delayed_pc=0x%08x)\n" , env->delayed_pc); }else if (env->flags &DELAY_SLOT_RTE ) { -cpu_fprintf (f,"in rte delay slot (delayed_pc=0x%08x)\n" , - env->delayed_pc); +qemu_fprintf (f,"in rte delay slot (delayed_pc=0x%08x)\n" , + env->delayed_pc); } }target/sparc/cpu.c +41
-43@@ -596,12 +596,11 @@ void sparc_cpu_list(void) "fpu_version mmu_version nwindows\n"); } -static void cpu_print_cc (FILE *f,fprintf_function cpu_fprintf, -uint32_t cc) +static void cpu_print_cc (FILE *f,uint32_t cc) { -cpu_fprintf (f,"%c%c%c%c" , cc &PSR_NEG ?'N' :'-' , - cc &PSR_ZERO ?'Z' :'-' , cc &PSR_OVF ?'V' :'-' , - cc &PSR_CARRY ?'C' :'-' ); +qemu_fprintf (f,"%c%c%c%c" , cc &PSR_NEG ?'N' :'-' , + cc &PSR_ZERO ?'Z' :'-' , cc &PSR_OVF ?'V' :'-' , + cc &PSR_CARRY ?'C' :'-' ); }#ifdef TARGET_SPARC64 @@ -610,35 +609,34 @@ static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf,#define REGS_PER_LINE 8#endif -void sparc_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, -int flags) +void sparc_cpu_dump_state (CPUState *cs,FILE *f,int flags) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env;int i, x; -cpu_fprintf (f,"pc: " TARGET_FMT_lx" npc: " TARGET_FMT_lx"\n" , env->pc, - env->npc); +qemu_fprintf (f,"pc: " TARGET_FMT_lx" npc: " TARGET_FMT_lx"\n" , env->pc, + env->npc);for (i =0 ; i <8 ; i++) {if (i %REGS_PER_LINE ==0 ) { -cpu_fprintf (f,"%%g%d-%d:" , i, i +REGS_PER_LINE -1 ); +qemu_fprintf (f,"%%g%d-%d:" , i, i +REGS_PER_LINE -1 ); } -cpu_fprintf (f," " TARGET_FMT_lx, env->gregs[i]); +qemu_fprintf (f," " TARGET_FMT_lx, env->gregs[i]);if (i %REGS_PER_LINE ==REGS_PER_LINE -1 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } }for (x =0 ; x <3 ; x++) {for (i =0 ; i <8 ; i++) {if (i %REGS_PER_LINE ==0 ) { -cpu_fprintf (f,"%%%c%d-%d: " , - x ==0 ?'o' : (x ==1 ?'l' :'i' ), - i, i +REGS_PER_LINE -1 ); +qemu_fprintf (f,"%%%c%d-%d: " , + x ==0 ?'o' : (x ==1 ?'l' :'i' ), + i, i +REGS_PER_LINE -1 ); } -cpu_fprintf (f, TARGET_FMT_lx" " , env->regwptr[i + x *8 ]); +qemu_fprintf (f, TARGET_FMT_lx" " , env->regwptr[i + x *8 ]);if (i %REGS_PER_LINE ==REGS_PER_LINE -1 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } }@@ -646,42 +644,42 @@ void sparc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <TARGET_DPREGS ; i++) {if ((i &3 ) ==0 ) { -cpu_fprintf (f,"%%f%02d: " , i *2 ); +qemu_fprintf (f,"%%f%02d: " , i *2 ); } -cpu_fprintf (f," %016" PRIx64, env->fpr[i].ll); +qemu_fprintf (f," %016" PRIx64, env->fpr[i].ll);if ((i &3 ) ==3 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); } } }#ifdef TARGET_SPARC64 -cpu_fprintf (f,"pstate: %08x ccr: %02x (icc: " , env->pstate, - (unsigned )cpu_get_ccr (env)); -cpu_print_cc (f, cpu_fprintf,cpu_get_ccr (env) <<PSR_CARRY_SHIFT ); -cpu_fprintf (f," xcc: " ); -cpu_print_cc (f, cpu_fprintf,cpu_get_ccr (env) << (PSR_CARRY_SHIFT -4 )); -cpu_fprintf (f,") asi: %02x tl: %d pil: %x gl: %d\n" , env->asi, env->tl, - env->psrpil, env->gl); -cpu_fprintf (f,"tbr: " TARGET_FMT_lx" hpstate: " TARGET_FMT_lx" htba: " - TARGET_FMT_lx"\n" , env->tbr, env->hpstate, env->htba); -cpu_fprintf (f,"cansave: %d canrestore: %d otherwin: %d wstate: %d " -"cleanwin: %d cwp: %d\n" , - env->cansave, env->canrestore, env->otherwin, env->wstate, - env->cleanwin, env->nwindows -1 - env->cwp); -cpu_fprintf (f,"fsr: " TARGET_FMT_lx" y: " TARGET_FMT_lx" fprs: " - TARGET_FMT_lx"\n" , env->fsr, env->y, env->fprs); +qemu_fprintf (f,"pstate: %08x ccr: %02x (icc: " , env->pstate, + (unsigned )cpu_get_ccr (env)); +cpu_print_cc (f,cpu_get_ccr (env) <<PSR_CARRY_SHIFT ); +qemu_fprintf (f," xcc: " ); +cpu_print_cc (f,cpu_get_ccr (env) << (PSR_CARRY_SHIFT -4 )); +qemu_fprintf (f,") asi: %02x tl: %d pil: %x gl: %d\n" , env->asi, env->tl, + env->psrpil, env->gl); +qemu_fprintf (f,"tbr: " TARGET_FMT_lx" hpstate: " TARGET_FMT_lx" htba: " + TARGET_FMT_lx"\n" , env->tbr, env->hpstate, env->htba); +qemu_fprintf (f,"cansave: %d canrestore: %d otherwin: %d wstate: %d " +"cleanwin: %d cwp: %d\n" , + env->cansave, env->canrestore, env->otherwin, env->wstate, + env->cleanwin, env->nwindows -1 - env->cwp); +qemu_fprintf (f,"fsr: " TARGET_FMT_lx" y: " TARGET_FMT_lx" fprs: " + TARGET_FMT_lx"\n" , env->fsr, env->y, env->fprs);#else -cpu_fprintf (f,"psr: %08x (icc: " ,cpu_get_psr (env)); -cpu_print_cc (f, cpu_fprintf,cpu_get_psr (env)); -cpu_fprintf (f," SPE: %c%c%c) wim: %08x\n" , env->psrs ?'S' :'-' , - env->psrps ?'P' :'-' , env->psret ?'E' :'-' , - env->wim); -cpu_fprintf (f,"fsr: " TARGET_FMT_lx" y: " TARGET_FMT_lx"\n" , - env->fsr, env->y); +qemu_fprintf (f,"psr: %08x (icc: " ,cpu_get_psr (env)); +cpu_print_cc (f,cpu_get_psr (env)); +qemu_fprintf (f," SPE: %c%c%c) wim: %08x\n" , env->psrs ?'S' :'-' , + env->psrps ?'P' :'-' , env->psret ?'E' :'-' , + env->wim); +qemu_fprintf (f,"fsr: " TARGET_FMT_lx" y: " TARGET_FMT_lx"\n" , + env->fsr, env->y);#endif -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }static void sparc_cpu_set_pc (CPUState *cs,vaddr value)target/sparc/cpu.h +1
-2@@ -564,8 +564,7 @@ extern const struct VMStateDescription vmstate_sparc_cpu;#endif void sparc_cpu_do_interrupt (CPUState *cpu); -void sparc_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void sparc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int sparc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int sparc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/tilegx/cpu.c +7
-7@@ -24,9 +24,9 @@#include "qemu-common.h" #include "hw/qdev-properties.h" #include "linux-user/syscall_defs.h" +#include "qemu/qemu-print.h" -static void tilegx_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +static void tilegx_cpu_dump_state (CPUState *cs,FILE *f,int flags) {static const char *const reg_names[TILEGX_R_COUNT ] = {"r0" ,"r1" ,"r2" ,"r3" ,"r4" ,"r5" ,"r6" ,"r7" ,@@ -43,12 +43,12 @@ static void tilegx_cpu_dump_state(CPUState *cs, FILE *f,int i;for (i =0 ; i <TILEGX_R_COUNT ; i++) { -cpu_fprintf (f,"%-4s" TARGET_FMT_lx"%s" , - reg_names[i], env->regs[i], - (i %4 ) ==3 ?"\n" :" " ); +qemu_fprintf (f,"%-4s" TARGET_FMT_lx"%s" , + reg_names[i], env->regs[i], + (i %4 ) ==3 ?"\n" :" " ); } -cpu_fprintf (f,"PC " TARGET_FMT_lx" CEX " TARGET_FMT_lx"\n\n" , - env->pc, env->spregs[TILEGX_SPR_CMPEXCH ]); +qemu_fprintf (f,"PC " TARGET_FMT_lx" CEX " TARGET_FMT_lx"\n\n" , + env->pc, env->spregs[TILEGX_SPR_CMPEXCH ]); }static ObjectClass *tilegx_cpu_class_by_name (const char *cpu_model)target/tricore/cpu.h +1
-2@@ -224,8 +224,7 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)#define ENV_OFFSET offsetof(TriCoreCPU, env)hwaddr tricore_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -void tricore_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void tricore_cpu_dump_state (CPUState *cpu,FILE *f,int flags);#define MASK_PCXI_PCPN 0xff000000target/tricore/translate.c +13
-13@@ -24,6 +24,7 @@#include "exec/exec-all.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -88,8 +89,7 @@ enum { MODE_UU = 3, }; -void tricore_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void tricore_cpu_dump_state (CPUState *cs,FILE *f,int flags) {TriCoreCPU *cpu =TRICORE_CPU (cs);CPUTriCoreState *env = &cpu->env;@@ -98,26 +98,26 @@ void tricore_cpu_dump_state(CPUState *cs, FILE *f, psw =psw_read (env); -cpu_fprintf (f,"PC: " TARGET_FMT_lx, env->PC); -cpu_fprintf (f," PSW: " TARGET_FMT_lx, psw); -cpu_fprintf (f," ICR: " TARGET_FMT_lx, env->ICR); -cpu_fprintf (f,"\nPCXI: " TARGET_FMT_lx, env->PCXI); -cpu_fprintf (f," FCX: " TARGET_FMT_lx, env->FCX); -cpu_fprintf (f," LCX: " TARGET_FMT_lx, env->LCX); +qemu_fprintf (f,"PC: " TARGET_FMT_lx, env->PC); +qemu_fprintf (f," PSW: " TARGET_FMT_lx, psw); +qemu_fprintf (f," ICR: " TARGET_FMT_lx, env->ICR); +qemu_fprintf (f,"\nPCXI: " TARGET_FMT_lx, env->PCXI); +qemu_fprintf (f," FCX: " TARGET_FMT_lx, env->FCX); +qemu_fprintf (f," LCX: " TARGET_FMT_lx, env->LCX);for (i =0 ; i <16 ; ++i) {if ((i &3 ) ==0 ) { -cpu_fprintf (f,"\nGPR A%02d:" , i); +qemu_fprintf (f,"\nGPR A%02d:" , i); } -cpu_fprintf (f," " TARGET_FMT_lx, env->gpr_a[i]); +qemu_fprintf (f," " TARGET_FMT_lx, env->gpr_a[i]); }for (i =0 ; i <16 ; ++i) {if ((i &3 ) ==0 ) { -cpu_fprintf (f,"\nGPR D%02d:" , i); +qemu_fprintf (f,"\nGPR D%02d:" , i); } -cpu_fprintf (f," " TARGET_FMT_lx, env->gpr_d[i]); +qemu_fprintf (f," " TARGET_FMT_lx, env->gpr_d[i]); } -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }/* target/unicore32/cpu.h +1
-2@@ -97,8 +97,7 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)void uc32_cpu_do_interrupt (CPUState *cpu);bool uc32_cpu_exec_interrupt (CPUState *cpu,int int_req); -void uc32_cpu_dump_state (CPUState *cpu,FILE *f, -fprintf_function cpu_fprintf,int flags); +void uc32_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr uc32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#define ASR_M (0x1f)target/unicore32/translate.c +19
-20@@ -17,6 +17,7 @@#include "qemu/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -2043,8 +2044,7 @@ static const char *cpu_mode_names[16] = {#undef UCF64_DUMP_STATE#ifdef UCF64_DUMP_STATE -static void cpu_dump_state_ucf64 (CPUUniCore32State *env,FILE *f, -fprintf_function cpu_fprintf,int flags) +static void cpu_dump_state_ucf64 (CPUUniCore32State *env,int flags) {int i; union {@@ -2064,20 +2064,19 @@ static void cpu_dump_state_ucf64(CPUUniCore32State *env, FILE *f, s0.i = d.l.lower; s1.i = d.l.upper; d0.f64 = d.d; -cpu_fprintf (f,"s%02d=%08x(%8g) s%02d=%08x(%8g)" , - i *2 , (int )s0.i, s0.s, - i *2 +1 , (int )s1.i, s1.s); -cpu_fprintf (f," d%02d=%" PRIx64"(%8g)\n" , - i, (uint64_t)d0.f64, d0.d); +qemu_fprintf (f,"s%02d=%08x(%8g) s%02d=%08x(%8g)" , + i *2 , (int )s0.i, s0.s, + i *2 +1 , (int )s1.i, s1.s); +qemu_fprintf (f," d%02d=%" PRIx64"(%8g)\n" , + i, (uint64_t)d0.f64, d0.d); } -cpu_fprintf (f,"FPSCR: %08x\n" , (int )env->ucf64.xregs[UC32_UCF64_FPSCR ]); +qemu_fprintf (f,"FPSCR: %08x\n" , (int )env->ucf64.xregs[UC32_UCF64_FPSCR ]); }#else #define cpu_dump_state_ucf64 (env, file, pr, flags) do { } while (0)#endif -void uc32_cpu_dump_state (CPUState *cs,FILE *f, -fprintf_function cpu_fprintf,int flags) +void uc32_cpu_dump_state (CPUState *cs,FILE *f,int flags) {UniCore32CPU *cpu =UNICORE32_CPU (cs);CPUUniCore32State *env = &cpu->env;@@ -2085,21 +2084,21 @@ void uc32_cpu_dump_state(CPUState *cs, FILE *f,uint32_t psr;for (i =0 ; i <32 ; i++) { -cpu_fprintf (f,"R%02d=%08x" , i, env->regs[i]); +qemu_fprintf (f,"R%02d=%08x" , i, env->regs[i]);if ((i %4 ) ==3 ) { -cpu_fprintf (f,"\n" ); +qemu_fprintf (f,"\n" ); }else { -cpu_fprintf (f," " ); +qemu_fprintf (f," " ); } } psr =cpu_asr_read (env); -cpu_fprintf (f,"PSR=%08x %c%c%c%c %s\n" , - psr, - psr & (1 <<31 ) ?'N' :'-' , - psr & (1 <<30 ) ?'Z' :'-' , - psr & (1 <<29 ) ?'C' :'-' , - psr & (1 <<28 ) ?'V' :'-' , - cpu_mode_names[psr &0xf ]); +qemu_fprintf (f,"PSR=%08x %c%c%c%c %s\n" , + psr, + psr & (1 <<31 ) ?'N' :'-' , + psr & (1 <<30 ) ?'Z' :'-' , + psr & (1 <<29 ) ?'C' :'-' , + psr & (1 <<28 ) ?'V' :'-' , + cpu_mode_names[psr &0xf ]);if (flags &CPU_DUMP_FPU ) {cpu_dump_state_ucf64 (env, f, cpu_fprintf, flags);target/xtensa/cpu.h +1
-2@@ -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);target/xtensa/translate.c +21
-19@@ -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' :' ' ); } } }Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 14/17] qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
Quoted 11 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Markus Armbruster ([email protected]) wrote:
CPUClass method
dump_statistics()takes an fprintf()-like callback and a FILE * to pass to it. Most callers passfprintf()and stderr.log_cpu_state()passesfprintf()andqemu_log_file.hmp_info_registers()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf().The callback gets passed around a lot, which is tiresome. The type-punning around
monitor_fprintf()is ugly.
Quoted 8 lines
Quoted 5 lines
Drop the callback, and call
qemu_fprintf()instead. Also gets rid of the type-punning, sinceqemu_fprintf()takes NULL instead of the current monitor cast to FILE *.Signed-off-by Markus Armbruster <[email protected]><phew long patch>
Yes, I think so.
Thanks for persevering!
Quoted 2 lines
There seems to be a place which changes
hmp_info_local_apicin a plce that was changed in an earlier patch which seems a shame, but OK.
Hmm. I think I can avoid that.
Quoted 1 line
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks!
PATCH 15/17 monitor: Clean up how monitor_disas() funnels output to monitor
In reply to Markus ArmbrusterINIT_DISASSEMBLE_INFO() takes an fprintf()-like callback and a FILE * to pass to it. monitor_disas() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-pinning is ugly.
Pass qemu_fprintf() and NULL instead.
monitor_fprintf() is now unused; delete it.
--- disas.c | 3 ++- include/monitor/monitor.h | 1 - monitor.c | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-)
disas.c +2 -1
@@ -3,6 +3,7 @@#include "qemu-common.h" #include "disas/bfd.h" #include "elf.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "disas/disas.h"
@@ -609,7 +610,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu,int count, i;CPUDebug s; -INIT_DISASSEMBLE_INFO (s.info, (FILE *)mon, monitor_fprintf); +INIT_DISASSEMBLE_INFO (s.info,NULL , qemu_fprintf); s.cpu = cpu; s.info.read_memory_func
include/monitor/monitor.h +0 -1
@@ -31,7 +31,6 @@ int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -int monitor_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_flush (Monitor *mon);int monitor_set_cpu (int cpu_index);int monitor_get_cpu_index (void );
monitor.c +0 -11
@@ -480,17 +480,6 @@ int monitor_printf(Monitor *mon, const char *fmt, ...)return ret; } -int monitor_fprintf (FILE *stream,const char *fmt, ...) -{ -int ret; - -va_list ap; -va_start (ap, fmt); - ret =monitor_vprintf ((Monitor *)stream, fmt, ap); -va_end (ap); -return ret; -} -static void qmp_send_response (Monitor *mon,const QDict *rsp) {const QObject *data =QOBJECT (rsp);
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 15/17] monitor: Clean up how monitor_disas() funnels output to monitor
Quoted 11 lines · * Markus Armbruster ([email protected]) wrote:
INIT_DISASSEMBLE_INFO()takes an fprintf()-like callback and a FILE * to pass to it.monitor_disas()passesmonitor_fprintf()and the current monitor cast to FILE *.monitor_fprintf()casts it right back, and is otherwise identical tomonitor_printf(). The type-pinning is ugly.Pass
qemu_fprintf()and NULL instead.
monitor_fprintf()is now unused; delete it.Signed-off-by Markus Armbruster <[email protected]>
Quoted 64 lines
--- disas.c | 3 ++- include/monitor/monitor.h | 1 - monitor.c | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-)disas.c +2
-1@@ -3,6 +3,7 @@#include "qemu-common.h" #include "disas/bfd.h" #include "elf.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "disas/disas.h" @@ -609,7 +610,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu,int count, i;CPUDebug s; -INIT_DISASSEMBLE_INFO (s.info, (FILE *)mon, monitor_fprintf); +INIT_DISASSEMBLE_INFO (s.info,NULL , qemu_fprintf); s.cpu = cpu; s.info.read_memory_funcinclude/monitor/monitor.h +0
-1@@ -31,7 +31,6 @@ int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -int monitor_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_flush (Monitor *mon);int monitor_set_cpu (int cpu_index);int monitor_get_cpu_index (void );monitor.c +0
-11@@ -480,17 +480,6 @@ int monitor_printf(Monitor *mon, const char *fmt, ...)return ret; } -int monitor_fprintf (FILE *stream,const char *fmt, ...) -{ -int ret; - -va_list ap; -va_start (ap, fmt); - ret =monitor_vprintf ((Monitor *)stream, fmt, ap); -va_end (ap); -return ret; -} -static void qmp_send_response (Monitor *mon,const QDict *rsp) {const QObject *data =QOBJECT (rsp);Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 16/17 disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h
In reply to Markus ArmbrusterCommit dc99065b5f9 (v0.1.0) added dis-asm.h from binutils.
Commit 43d4145a986 (v0.1.5) inlined bfd.h into dis-asm.h to remove the dependency on binutils.
Commit 76cad71136b (v1.4.0) moved dis-asm.h to include/disas/bfd.h. The new name is confusing when you try to match against (pre GPLv3+) binutils. Rename it back. Keep it in the same directory, of course.
---
disas.c | 2 +-
disas/alpha.c | 2 +-
disas/arm-a64.cc | 2 +-
disas/arm.c | 2 +-
disas/cris.c | 2 +-
disas/hppa.c | 2 +-
disas/i386.c | 2 +-
disas/lm32.c | 2 +-
disas/m68k.c | 2 +-
disas/microblaze.c | 2 +-
disas/mips.c | 2 +-
disas/moxie.c | 2 +-
disas/nanomips.cpp | 2 +-
disas/nios2.c | 2 +-
disas/ppc.c | 2 +-
disas/riscv.c | 2 +-
disas/s390.c | 2 +-
disas/sh4.c | 2 +-
disas/sparc.c | 2 +-
disas/tci.c | 2 +-
disas/xtensa.c | 2 +-
include/disas/{bfd.h => dis-asm.h} | 0
include/qom/cpu.h | 2 +-
target/openrisc/disas.c | 2 +-
target/ppc/translate_init.inc.c | 2 +-
25 files changed, 24 insertions(+), 24 deletions(-)
rename include/disas/{bfd.h => dis-asm.h} (100%)disas.c +1 -1
@@ -1,7 +1,7 @@/* General "disassemble this chunk" code. Used for debugging. */ #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "elf.h" #include "qemu/qemu-print.h"
disas/alpha.c +1 -1
@@ -20,7 +20,7 @@ along with this file; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* MAX is redefined below, so remove any previous definition. */ #undef MAX
disas/arm-a64.cc +1 -1
@@ -19,7 +19,7 @@ extern "C" { #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" } #include "vixl/a64/disasm-a64.h"
disas/arm.c +1 -1
@@ -23,7 +23,7 @@for things we don't care about. */ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #define ARM_EXT_V1 0#define ARM_EXT_V2 0
disas/cris.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "target/cris/opcode-cris.h" #define CONST_STRNEQ (STR1 ,STR2 ) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
disas/hppa.c +1 -1
@@ -19,7 +19,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* HP PA-RISC SOM object file format: definitions internal to BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
disas/i386.c +1 -1
@@ -32,7 +32,7 @@the Intel manual for details. */ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "qemu/cutils.h" /* include/opcode/i386.h r1.78 */
disas/lm32.c +1 -1
@@ -19,7 +19,7 @@*/ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" typedef enum { LM32_OP_SRUI = 0, LM32_OP_NORI, LM32_OP_MULI, LM32_OP_SH, LM32_OP_LB,
disas/m68k.c +1 -1
@@ -4,7 +4,7 @@#include "qemu/osdep.h" #include <math.h> -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* **** floatformat.h from sourceware.org CVS 2005-08-14. */ /* IEEE floating point support declarations, for GDB, the GNU Debugger.
disas/microblaze.c +1 -1
@@ -577,7 +577,7 @@ static const char pvr_register_prefix[] = "rpvr";#endif /* MICROBLAZE_OPC */ -#include "disas/bfd.h" +#include "disas/dis-asm.h" #define get_field_rd (instr) get_field(instr, RD_MASK, RD_LOW)#define get_field_r1 (instr) get_field(instr, RA_MASK, RA_LOW)
disas/mips.c +1 -1
@@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* mips.h. Mips opcode list for GDB, the GNU debugger. Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
disas/moxie.c +1 -1
@@ -18,7 +18,7 @@#define STATIC_TABLE #define DEFINE_TABLE -#include "disas/bfd.h" +#include "disas/dis-asm.h" static void *stream;
disas/nanomips.cpp +1 -1
@@ -29,7 +29,7 @@ extern "C" { #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" } #include <cstring>
disas/nios2.c +1 -1
@@ -36,7 +36,7 @@/*#include "bfd.h"*/ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /****************************************************************************
disas/ppc.c +1 -1
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this file; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #define BFD_DEFAULT_TARGET_SIZE 64/* ppc.h -- Header file for PowerPC opcode table
disas/riscv.c +1 -1
@@ -18,7 +18,7 @@*/ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* types */
disas/s390.c +1 -1
@@ -22,7 +22,7 @@#include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* include/opcode/s390.h revision 1.9 */ /* s390.h -- Header file for S390 opcode table
disas/sh4.c +1 -1
@@ -16,7 +16,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #define DEFINE_TABLE
disas/sparc.c +1 -1
@@ -27,7 +27,7 @@ see <http://www.gnu.org/licenses/>. */#include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" /* The SPARC opcode table (and other related data) is defined in the opcodes library in sparc-opc.c. If you change anything here, make
disas/tci.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "tcg/tcg.h" /* Disassemble TCI bytecode. */
disas/xtensa.c +1 -1
@@ -26,7 +26,7 @@*/ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "hw/xtensa/xtensa-isa.h" int print_insn_xtensa (bfd_vma memaddr,struct disassemble_info *info)
include/disas/dis-asm.h renamed from include/disas/bfd.h +0 -0
include/qom/cpu.h +1 -1
@@ -21,7 +21,7 @@#define QEMU_CPU_H #include "hw/qdev-core.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h"
target/openrisc/disas.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "qemu/bitops.h" #include "cpu.h"
target/ppc/translate_init.inc.c +1 -1
@@ -18,7 +18,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "exec/gdbstub.h" #include "kvm_ppc.h" #include "sysemu/arch_init.h"
Signature · 1 line
2.17.2
PATCH 17/17 include: Move fprintf_function to disas/
In reply to Markus ArmbrusterThe previous commits have eliminated fprintf_function outside disassemblers, simplifying code and cleaning up the ugly type-punning fprintf_function seems to attract. Move fprintf_function to include/disas/dis-asm.h to reduce the temptation to abuse it.
I considered renaming it to fprintf_ftype (reverting that part of commit 6e2d864edf5, v0.14.0) to get us closer to binutils, but I figure the fork is too distant to make this worthwhile.
--- include/disas/dis-asm.h | 5 +++-- include/qemu/fprintf-fn.h | 14 -------------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 include/qemu/fprintf-fn.h
include/disas/dis-asm.h +3 -2
@@ -9,8 +9,6 @@#ifndef DISAS_BFD_H #define DISAS_BFD_H -#include "qemu/fprintf-fn.h" -typedef void *PTR ;typedef uint64_t bfd_vma ;typedef int64_t bfd_signed_vma ;
@@ -243,6 +241,9 @@ typedef struct symbol_cache_entry } udata; } asymbol; +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) +GCC_FMT_ATTR (2 ,3 ); +enum dis_insn_type { dis_noninsn,/* Not a valid instruction */ dis_nonbranch,/* Not a branch instruction */
include/qemu/fprintf-fn.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* -* Typedef for fprintf-alike function pointers. -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef QEMU_FPRINTF_FN_H -#define QEMU_FPRINTF_FN_H - -typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) -GCC_FMT_ATTR (2 ,3 ); - -#endif
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH 17/17] include: Move fprintf_function to disas/
Quoted 10 lines · * Markus Armbruster ([email protected]) wrote:
The previous commits have eliminated
fprintf_functionoutside disassemblers, simplifying code and cleaning up the ugly type-punningfprintf_functionseems to attract. Movefprintf_functiontoinclude/disas/dis-asm.hto reduce the temptation to abuse it.I considered renaming it to
fprintf_ftype(reverting that part of commit6e2d864edf5, v0.14.0) to get us closer to binutils, but I figure the fork is too distant to make this worthwhile.Signed-off-by Markus Armbruster <[email protected]>
I'm OKish with this - although it's the only place we currently use it, it's a fairly common concept, so I'm not sure it's worth banishing.
Quoted 52 lines
--- include/disas/dis-asm.h | 5 +++-- include/qemu/fprintf-fn.h | 14 -------------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 include/qemu/fprintf-fn.hinclude/disas/dis-asm.h +3
-2@@ -9,8 +9,6 @@#ifndef DISAS_BFD_H #define DISAS_BFD_H -#include "qemu/fprintf-fn.h" -typedef void *PTR ;typedef uint64_t bfd_vma ;typedef int64_t bfd_signed_vma ;@@ -243,6 +241,9 @@ typedef struct symbol_cache_entry } udata; } asymbol; +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) +GCC_FMT_ATTR (2 ,3 ); +enum dis_insn_type { dis_noninsn,/* Not a valid instruction */ dis_nonbranch,/* Not a branch instruction */ include/qemu/fprintf-fn.h deleted +0
-14@@ -1,14 +0,0 @@ -/* -* Typedef for fprintf-alike function pointers. -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef QEMU_FPRINTF_FN_H -#define QEMU_FPRINTF_FN_H - -typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) -GCC_FMT_ATTR (2 ,3 ); - -#endif Signature · 1 line
2.17.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 17/17] include: Move fprintf_function to disas/
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Markus Armbruster ([email protected]) wrote:
The previous commits have eliminated
fprintf_functionoutside disassemblers, simplifying code and cleaning up the ugly type-punningfprintf_functionseems to attract. Movefprintf_functiontoinclude/disas/dis-asm.hto reduce the temptation to abuse it.I considered renaming it to
fprintf_ftype(reverting that part of commit6e2d864edf5, v0.14.0) to get us closer to binutils, but I figure the fork is too distant to make this worthwhile.
Quoted 5 lines
Quoted 1 line
Signed-off-by Markus Armbruster <[email protected]>I'm OKish with this - although it's the only place we currently use it, it's a fairly common concept, so I'm not sure it's worth banishing.
I found 15 uses, ranging from questionable to outright bad. I eliminated 14, and cleaned up one. I guess that has made me skeptical on the chances of this type getting used sanely.
Banishing the type to where it came from reduces the temptation.
Perhaps that's not actually necessary now we've gotten rid of the bad examples.
Should a sane use come up, we can simply revert this patch.
Quoted 1 line
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks!
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH 00/17] Clean up and simplify around fprintf_function
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'c57bf406e7 include: Move fprintf_function to disas/3f40e31e61 disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h fc467535fe monitor: Clean up how monitor_disas() funnels output to monitor 2fee322e6c qom/cpu: Simplify how CPUClass:cpu_dump_state() prints 9cb032aa41 qemu-print: New qemu_fprintf(), qemu_vfprintf() 6266a2acbd qom/cpu: Simplify how CPUClass::dump_statistics() prints 46444d62f8 target/i386: Simplify how x86_cpu_dump_local_apic_state() prints 97d83bc9d1 target: Clean up how the dump_mmu() printc218e3496f target: Simplify how the TARGET_cpu_list() print de4fa45d1e memory: Clean up how mtree_info() prints1776a3be10 block/qapi: Clean up how we print to monitor or stdout 7ab595d193 qsp: Simplify how qsp_report() printse21527b143 tcg: Simplify how dump_drift_info() prints866fc3c2b0 tcg: Simplify how dump_exec_info() prints2cb3665cd5 tcg: Simplify how dump_opcount_info() prints 251bcf57b3 trace: Simplify how st_print_trace_file_status() prints d81fd6300c include: Include fprintf-fn.h only where needed
=== OUTPUT BEGIN ===
1/17 Checking commit d81fd6300c43 (include: Include fprintf-fn.h only where needed) 2/17 Checking commit 251bcf57b37a (trace: Simplify how st_print_trace_file_status() prints) 3/17 Checking commit 2cb3665cd56c (tcg: Simplify how dump_opcount_info() prints) 4/17 Checking commit 866fc3c2b030 (tcg: Simplify how dump_exec_info() prints) 5/17 Checking commit e21527b143e1 (tcg: Simplify how dump_drift_info() prints) 6/17 Checking commit 7ab595d1932b (qsp: Simplify how qsp_report() prints) 7/17 Checking commit 1776a3be104f (block/qapi: Clean up how we print to monitor or stdout) 8/17 Checking commit de4fa45d1ebc (memory: Clean up how mtree_info() prints) 9/17 Checking commit c218e3496fc1 (target: Simplify how the TARGET_cpu_list() print) 10/17 Checking commit 97d83bc9d139 (target: Clean up how the dump_mmu() print)
WARNING: line over 80 characters
#949: FILE: target/xtensa/mmu_helper.c:784:
+ qemu_printf("\tVaddr Paddr ASID Attr RWX Cache\n"
total: 0 errors, 1 warnings, 848 lines checked
Patch 10/17 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/17 Checking commit 46444d62f83d (target/i386: Simplify how x86_cpu_dump_local_apic_state() prints) 12/17 Checking commit 6266a2acbdda (qom/cpu: Simplify how CPUClass::dump_statistics() prints) 13/17 Checking commit 9cb032aa41f9 (qemu-print: New qemu_fprintf(), qemu_vfprintf()) 14/17 Checking commit 2fee322e6cb8 (qom/cpu: Simplify how CPUClass:cpu_dump_state() prints)
ERROR: line over 90 characters
#1077: FILE: target/i386/helper.c:419:
+ qemu_fprintf(f, "RAX=%016" PRIx64 " RBX=%016" PRIx64 " RCX=%016" PRIx64 " RDX=%016" PRIx64 "\n"
ERROR: line over 90 characters
#1078: FILE: target/i386/helper.c:420:
+ "RSI=%016" PRIx64 " RDI=%016" PRIx64 " RBP=%016" PRIx64 " RSP=%016" PRIx64 "\n"
ERROR: line over 90 characters
#1079: FILE: target/i386/helper.c:421:
+ "R8 =%016" PRIx64 " R9 =%016" PRIx64 " R10=%016" PRIx64 " R11=%016" PRIx64 "\n"
ERROR: line over 90 characters
#1080: FILE: target/i386/helper.c:422:
+ "R12=%016" PRIx64 " R13=%016" PRIx64 " R14=%016" PRIx64 " R15=%016" PRIx64 "\n"
ERROR: line over 90 characters
#1081: FILE: target/i386/helper.c:423:
+ "RIP=%016" PRIx64 " RFL=%08x [%c%c%c%c%c%c%c] CPL=%d II=%d A20=%d SMM=%d HLT=%d\n",
WARNING: line over 80 characters
#1189: FILE: target/i386/helper.c:494:
+ qemu_fprintf(f, "CR0=%08x CR2=%016" PRIx64 " CR3=%016" PRIx64 " CR4=%08x\n",
WARNING: line over 80 characters
#1790: FILE: target/mips/translate.c:29791:
+ qemu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx "\n",
total: 5 errors, 2 warnings, 2583 lines checked
Patch 14/17 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
15/17 Checking commit fc467535fe7a (monitor: Clean up how monitor_disas() funnels output to monitor) 16/17 Checking commit 3f40e31e614a (disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#296:
rename from include/disas/bfd.h
total: 0 errors, 1 warnings, 192 lines checked
Patch 16/17 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
17/17 Checking commit c57bf406e725 (include: Move fprintf_function to disas/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #44:
deleted file mode 100644
total: 0 errors, 1 warnings, 17 lines checked
Patch 17/17 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]