Logging cleanup, take 3
PATCH 4/5 global s/fflush(logfile)/qemu_log_flush()/
In reply to Eduardo Habkost--- block-raw-posix.c | 2 +- exec.c | 2 +- translate-all.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
block-raw-posix.c +1 -1
@@ -68,7 +68,7 @@//#define DEBUG_BLOCK #if defined(DEBUG_BLOCK ) #define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (qemu_log_enabled()) \ - { qemu_log(formatCstr, ##args); fflush(logfile); } } while (0) + { qemu_log(formatCstr, ##args); qemu_log_flush(); } } while (0)#else #define DEBUG_BLOCK_PRINT(formatCstr, args...)#endif
exec.c +1 -1
@@ -1641,7 +1641,7 @@ void cpu_abort(CPUState *env, const char *fmt, ...)#else log_cpu_state (env,0 );#endif -fflush (logfile); +qemu_log_flush ();qemu_log_close (); }va_end (ap2);
translate-all.c +1 -1
@@ -131,7 +131,7 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)qemu_log ("OUT: [size=%d]\n" , *gen_code_size_ptr);log_disas (tb->tc_ptr, *gen_code_size_ptr);qemu_log ("\n" ); - fflush(logfile); + qemu_log_flush(); }#endif return 0 ;
Signature · 1 line
1.5.6.rc3.11.g5f54d
cover Logging cleanup, take 3
Hi, Anthony,
This is a rebase of the previous logging cleanup patches I've sent. There aren't many changes, except for some manually-solved on target-mips/helper.c.
This includes changes from two series I've sent before: the logging #ifdef cleanup and the one that killed references to the loglevel/logfile global variables.
There are two large patches on the series because I didn't want to send 94 messages at once to qemu-devel. They are available as series of smaller commits commits if you pull from my git tree, as shown on the pull request below.
---
The following changes since commit 291c6ff9bf8cec5f7aa3f0da8895bd65b7d9bf93:
aliguori (1):
Make virtio_net_init() return void (Mark McLoughlin)
are available in the git repository at:
git://github.com/ehabkost/qemu-hacks.git log-clean-for-anthony
Eduardo Habkost (94):
hw/ppc.c: LOG_IRQ macro
hw/ppc.c: use LOG_IRQ instead of #ifdefs
hw/ppc.c: LOG_TB macro
hw/ppc.c: use LOG_TB instead of #ifdefs
vl.c: LOG_IOPORT macro
vl.c: use LOG_IOPORT instead of #ifdefs
kqemu.c: LOG_INT macro
kqemu.c: use LOG_INT instead of #ifdefs
kqemu.c: LOG_INT_STATE macro
kqemu.c: use LOG_INT_STATE instead of #ifdefs
kqemu.c: kill remaining DEBUG #ifdefs
target-i386/op_helper.c: LOG_PCALL macro
target-i386/op_helper.c: LOG_PCALL_STATE macro
target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs target-i386/op_helper.c: use LOG_PCALL/LOG_PCALL_STATE target-cris/translate.c: LOG_DIS macro
target-cris: replace D(fprintf(logfile, ...)) macros with D_LOG(...) target-mips/translate.c: LOG_DISAS macro
target-ppc/helper.c: LOG_MMU macro
target-ppc/helper.c: LOG_SWTLB macro
target-ppc/helper.c: convert commented-out debug code to LOG_SWTLB target-ppc/helper.c: LOG_BATS macro
target-ppc/helper.c: LOG_SLB macro
target-ppc/helper.c: LOG_EXCP macro
target-ppc/helper.c: remaining LOG_BATS & LOG_MMU conversions target-ppc/helper.c: LOG_MMU_STATE macro
target-ppc/op_helper.c: LOG_SWTLB macro
target-ppc/translate.c: LOG_DISAS macro
hw/ppc4xx_devs.c: LOG_UIC macro
target-alpha/translate.c: LOG_DISAS macro
linux-user/vm86.c: LOG_VM86 macro
Define macros that will become the new logging API target-i386/op_helper.c: qemu_log_mask() replacements target-i386/op_helper.c: simultaneous qemu_log_mask()/log_cpu_state_mask() replacements target-i386/op_helper.c: qemu_log()/log_cpu_state() replacements target-i386/op_helper.c: debug macros: use qemu_log*() target-i386/translate.c: use log_cpu_state_mask() target-i386/translate.c: use qemu_log()/log_target_disas() target-mips/helper.c: use qemu_log()/log_cpu_state() target-mips/helper.c: remaining qemu_log() replacements target-mips/op_helper.c: move loglevel check into debug_pre_eret() target-mips/op_helper.c: move loglevel check into debug_post_eret() target-mips/op_helper.c: qemu_log() replacements target-mips/op_helper.c: remaining qemu_log() replacement target-mips/translate.c: debug macros: use qemu_log_mask() target-mips/translate.c: remaining qemu_log*() conversions hw/mips_timer.c: qemu_log() conversions
target-ppc/helper.c: qemu_log() conversions
target-ppc/helper.c: qemu_log_mask() conversions
target-ppc/helper.c: qemu_log_enabled()/qemu_log() conversions target-ppc/helper.c: move loglevel check into dump_syscall() target-ppc/helper.c: dump_syscall(): use qemu_log_mask() target-ppc/helper.c: debug macros: use qemu_log()
target-ppc/helper.c: cpu_dump_rfi(): use qemu_log() target-ppc/op_helper.c: qemu_log() conversions
target-ppc/op_helper.c: LOG_SWTLB: use qemu_log() target-ppc/translate.c: qemu_log() conversions
target-ppc/translate.c: qemu_log_enabled()/qemu_log() conversions target-ppc/translate.c: LOG_DISAS: use qemu_log_mask() target-ppc/translate.c: remaining qemu_log*() conversions
hw/ppc.c: debug macros: use qemu_log*()
hw/ppc4xx_devs.c: debug macros: use qemu_log*() target-sparc/op_helper.c: qemu_log*() conversions target-sparc/translate.c: qemu_log*() conversions target-cris/op_helper.c: helper_dump: use qemu_log() target-cris/translate.c: qemu_log*() conversions target-cris/translate.c: LOG_DIS: use qemu_log_mask() target-cris/translate.c: use qemu_log_try_set_file()
target-cris/*: D_LOG: use qemu_log()
hw/alpha_palcode.c: qemu_log() conversions
target-alpha/translate.c: qemu_log*() conversions target-alpha/translate.c: LOG_DISAS: use qemu_log()
target-sh4/helper.c: qemu_log*() conversions
target-sh4/translate.c: qemu_log_*() conversions target-m68k/translate.c: qemu_log*() conversions
target-arm/translate.c: qemu_log*() conversions
kqemu.c: LOG_INT: use qemu_log_mask()
kqemu.c: LOG_INT_STATE: use log_cpu_state_mask()
linux-user/main.c: qemu_log*() conversions
linux-user/vm86.c: LOG_VM86: use qemu_log()
linux-user/elfload.c: load_elf_binary(): use qemu_log_enabled() bsd-user/main.c: use log_page_dump()/qemu_log()
bsd-user/elfload.c: load_elf_binary(): use qemu_log_enabled() darwin-user/main.c: qemu_log*() conversions
darwin-user: DPRINTF: use qemu_log()
block-raw-posix.c: qemu_log*() conversions
translate-all.c: qemu_log*() conversions
cpu-exec.c: qemu_log*() conversions
exec.c: qemu_log*() conversions
exec.c: cpu_abort(): use qemu_log_close()
tcg.c: qemu_log() conversions
vl.c: LOG_IOPORT: use qemu_log_mask()
global s/fflush(logfile)/qemu_log_flush()/
global s/loglevel & X/qemu_loglevel_mask(X)/
block-raw-posix.c | 4 +- bsd-user/elfload.c | 2 +- bsd-user/main.c | 28 ++-- cpu-exec.c | 35 ++--- darwin-user/commpage.c | 4 +- darwin-user/machload.c | 4 +- darwin-user/main.c | 6 +- darwin-user/syscall.c | 4 +- exec.c | 26 ++-- hw/alpha_palcode.c | 15 +-- hw/mips_timer.c | 4 +- hw/ppc.c | 307 ++++++++------------------------------ hw/ppc4xx_devs.c | 55 ++----- hw/ppc_prep.c | 11 +- kqemu.c | 70 +++------ linux-user/elfload.c | 2 +- linux-user/main.c | 34 ++--- linux-user/vm86.c | 39 ++--- qemu-log.h | 86 +++++++++++ target-alpha/translate.c | 37 ++--- target-arm/translate.c | 10 +- target-cris/helper.c | 26 +++- target-cris/mmu.c | 12 +- target-cris/op_helper.c | 28 +++-- target-cris/translate.c | 309 +++++++++++++++++++------------------- target-i386/op_helper.c | 120 ++++++--------- target-i386/translate.c | 24 ++-- target-m68k/translate.c | 12 +- target-mips/helper.c | 40 ++--- target-mips/op_helper.c | 68 ++++---- target-mips/translate.c | 147 ++++-------------- target-ppc/helper.c | 378 ++++++++++++++-------------------------------- target-ppc/op_helper.c | 89 +++-------- target-ppc/translate.c | 73 ++++------ target-sh4/helper.c | 8 +- target-sh4/translate.c | 19 +-- target-sparc/op_helper.c | 24 ++-- target-sparc/translate.c | 19 +-- tcg/tcg.c | 12 +- translate-all.c | 10 +- vl.c | 37 ++--- 41 files changed, 857 insertions(+), 1381 deletions(-)
Signature · 1 line
Eduardo
PATCH 2/5 Define macros that will become the new logging API
These macros are NOT a proposal for a definitive new logging API. They are just a step for it: a way to mark all usage patterns of the logfile/loglevel variables on a single place.
--- qemu-log.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+), 0 deletions(-)
qemu-log.h +86 -0
@@ -1,7 +1,93 @@#ifndef QEMU_LOG_H #define QEMU_LOG_H +/* The deprecated global variables: */ extern FILE *logfile;extern int loglevel; + +/* +* The new API: +* +*/ + +/* Log settings checking macros: */ + +/* Returns true if qemu_log() will really write somewhere +*/ +#define qemu_log_enabled () (logfile != NULL) + +/* Returns true if a bit is set in the current loglevel mask +*/ +#define qemu_loglevel_mask (b) ((loglevel & (b)) != 0) + + +/* Logging functions: */ + +/* main logging function +*/ +#define qemu_log (...) do { \ + if (logfile) \ + fprintf(logfile, ## __VA_ARGS__); \ + } while (0) + +/* vfprintf-like logging function +*/ +#define qemu_log_vprintf (fmt, va) do { \ + if (logfile) \ + vfprintf(logfile, fmt, va); \ + } while (0) + +/* log only if a bit is set on the current loglevel mask +*/ +#define qemu_log_mask (b, ...) do { \ + if (loglevel & (b)) \ + fprintf(logfile, ## __VA_ARGS__); \ + } while (0) + + + + +/* Special cases: */ + +/* cpu_dump_state() logging functions: */ +#define log_cpu_state (env, f) cpu_dump_state((env), logfile, fprintf, (f)); +#define log_cpu_state_mask (b, env, f) do { \ + if (loglevel & (b)) log_cpu_state((env), (f)); \ + } while (0) + +/* disas() and target_disas() to logfile: */ +#define log_target_disas (start, len, flags) \ + target_disas(logfile, (start), (len), (flags)) +#define log_disas (start, len) \ + disas(logfile, (start), (len)) + +/* page_dump() output to the log file: */ +#define log_page_dump () page_dump(logfile) + + + +/* Maintenance: */ + +/* fflush() the log file */ +#define qemu_log_flush () fflush(logfile) + +/* Close the log file */ +#define qemu_log_close () do { \ + fclose(logfile); \ + logfile = NULL; \ + } while (0) + +/* Set up a new log file */ +#define qemu_log_set_file (f) do { \ + logfile = (f); \ + } while (0) + +/* Set up a new log file, only if none is set */ +#define qemu_log_try_set_file (f) do { \ + if (!logfile) \ + logfile = (f); \ + } while (0) + +#endif
Signature · 1 line
1.5.6.rc3.11.g5f54d
PATCH 5/5 global s/loglevel & X/qemu_loglevel_mask(X)/
In reply to Eduardo HabkostThese are references to 'loglevel' that aren't on a simple 'if (loglevel &
X) qemu_log()' statement.
--- cpu-exec.c | 2 +- hw/ppc_prep.c | 2 +- target-alpha/translate.c | 2 +- target-arm/translate.c | 2 +- target-cris/translate.c | 6 +++--- target-i386/op_helper.c | 2 +- target-i386/translate.c | 6 +++--- target-m68k/translate.c | 2 +- target-mips/op_helper.c | 6 +++--- target-mips/translate.c | 2 +- target-ppc/translate.c | 2 +- target-sh4/helper.c | 2 +- target-sh4/translate.c | 2 +- target-sparc/op_helper.c | 4 ++-- target-sparc/translate.c | 4 ++-- tcg/tcg.c | 4 ++-- translate-all.c | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-)
cpu-exec.c +1 -1
@@ -530,7 +530,7 @@ int cpu_exec(CPUState *env1) } }#ifdef DEBUG_EXEC -if ((loglevel &CPU_LOG_TB_CPU )) { +if (qemu_loglevel_mask (CPU_LOG_TB_CPU )) {/* restore flags in standard format */ regs_to_env ();#if defined(TARGET_I386 )
hw/ppc_prep.c +1 -1
@@ -52,7 +52,7 @@#if defined (HARD_DEBUG_PPC_IO ) #define PPC_IO_DPRINTF(fmt, args...) \ do { \ - if (loglevel & CPU_LOG_IOPORT) { \ + if (qemu_loglevel_mask(CPU_LOG_IOPORT)) { \ qemu_log("%s: " fmt, __func__ , ##args); \ } else { \ printf("%s : " fmt, __func__ , ##args); \
target-alpha/translate.c +1 -1
@@ -2442,7 +2442,7 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, }#if definedALPHA_DEBUG_DISAS log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 ); -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, ctx.pc - pc_start,1 );qemu_log ("\n" );
target-arm/translate.c +1 -1
@@ -8870,7 +8870,7 @@ done_generating: *gen_opc_ptr = INDEX_op_end;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("----------------\n" );qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, dc->pc - pc_start, env->thumb);
target-cris/translate.c +3 -3
@@ -3035,7 +3035,7 @@ cris_decoder(DisasContext *dc)unsigned int insn_len =2 ;int i; -if (unlikely (loglevel &CPU_LOG_TB_OP )) +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP )))tcg_gen_debug_insn_start (dc->pc);/* Load a halfword onto the instruction register. */
@@ -3179,7 +3179,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, dc->cpustate_changed =0 ; -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n" "pid=%x usp=%x\n"
@@ -3331,7 +3331,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, #ifdef DEBUG_DISAS #if !DISAS_CRIS - if (loglevel & CPU_LOG_TB_IN_ASM) { + if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { log_target_disas(pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%zd\n", dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
target-i386/op_helper.c +1 -1
@@ -1206,7 +1206,7 @@ void do_interrupt_user(int intno, int is_int, int error_code,void do_interrupt (int intno,int is_int,int error_code,target_ulong next_eip,int is_hw) { -if (loglevel &CPU_LOG_INT ) { +if (qemu_loglevel_mask (CPU_LOG_INT )) {if ((env->cr[0 ] &CR0_PE_MASK )) {static int count; qemu_log("%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx " pc=" TARGET_FMT_lx " SP=%04x:" TARGET_FMT_lx,
target-i386/translate.c +3 -3
@@ -3961,7 +3961,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)target_ulong next_eip, tval;int rex_w, rex_r; -if (unlikely (loglevel &CPU_LOG_TB_OP )) +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP )))tcg_gen_debug_insn_start (pc_start); s->pc = pc_start; prefixes =0 ;
@@ -7676,7 +7676,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,#ifdef DEBUG_DISAS log_cpu_state_mask (CPU_LOG_TB_CPU , env,X86_DUMP_CCOP ); -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {int disas_flags;qemu_log ("----------------\n" );qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));
@@ -7712,7 +7712,7 @@ void gen_pc_load(CPUState *env, TranslationBlock *tb, {int cc_op;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_OP ) { +if (qemu_loglevel_mask (CPU_LOG_TB_OP )) {int i;qemu_log ("RESTORE:\n" );for (i =0 ;i <= pc_pos; i++) {
target-m68k/translate.c +1 -1
@@ -3063,7 +3063,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, *gen_opc_ptr = INDEX_op_end;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("----------------\n" );qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, dc->pc - pc_start,0 );
target-mips/op_helper.c +3 -3
@@ -1194,7 +1194,7 @@ void do_mtc0_status (target_ulong t0) old = env->CP0_Status; env->CP0_Status = (env->CP0_Status & ~mask) | val;compute_hflags (env); -if (loglevel &CPU_LOG_EXEC ) +if (qemu_loglevel_mask (CPU_LOG_EXEC ))do_mtc0_status_debug (old, val);cpu_mips_update_irq (env); }
@@ -1705,7 +1705,7 @@ target_ulong do_ei (void)static void debug_pre_eret (void ) { -if (loglevel &CPU_LOG_EXEC ) { +if (qemu_loglevel_mask (CPU_LOG_EXEC )) {qemu_log ("ERET: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, env->active_tc.PC, env->CP0_EPC);if (env->CP0_Status & (1 << CP0St_ERL))
@@ -1718,7 +1718,7 @@ static void debug_pre_eret (void)static void debug_post_eret (void ) { -if (loglevel &CPU_LOG_EXEC ) { +if (qemu_loglevel_mask (CPU_LOG_EXEC )) {qemu_log (" => PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, env->active_tc.PC, env->CP0_EPC);if (env->CP0_Status & (1 << CP0St_ERL))
target-mips/translate.c +1 -1
@@ -8293,7 +8293,7 @@ done_generating: }#ifdef DEBUG_DISAS LOG_DISAS ("\n" ); -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, ctx.pc - pc_start,0 );qemu_log ("\n" );
target-ppc/translate.c +1 -1
@@ -8334,7 +8334,7 @@ static always_inline void gen_intermediate_code_internal (CPUState *env,#if defined(DEBUG_DISAS )qemu_log_mask (CPU_LOG_TB_CPU ,"---------------- excp: %04x\n" , ctx.exception);log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 ); -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {int flags; flags = env->bfd_mach; flags |= ctx.le_mode <<16 ;
target-sh4/helper.c +1 -1
@@ -105,7 +105,7 @@ void do_interrupt(CPUState * env) } } -if (loglevel &CPU_LOG_INT ) { +if (qemu_loglevel_mask (CPU_LOG_INT )) {const char *expname;switch (env->exception_index) {case 0x0e0 :
target-sh4/translate.c +1 -1
@@ -1926,7 +1926,7 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,#ifdef SH4_DEBUG_DISAS qemu_log_mask (CPU_LOG_TB_IN_ASM ,"\n" );#endif -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("IN:\n" );/* , lookup_symbol(pc_start)); */ log_target_disas (pc_start, ctx.pc - pc_start,0 );qemu_log ("\n" );
target-sparc/op_helper.c +2 -2
@@ -2811,7 +2811,7 @@ void do_interrupt(CPUState *env)int intno = env->exception_index;#ifdef DEBUG_PCALL -if (loglevel &CPU_LOG_INT ) { +if (qemu_loglevel_mask (CPU_LOG_INT )) {static int count;const char *name;
@@ -2942,7 +2942,7 @@ void do_interrupt(CPUState *env)int cwp, intno = env->exception_index;#ifdef DEBUG_PCALL -if (loglevel &CPU_LOG_INT ) { +if (qemu_loglevel_mask (CPU_LOG_INT )) {static int count;const char *name;
target-sparc/translate.c +2 -2
@@ -1933,7 +1933,7 @@ static void disas_sparc_insn(DisasContext * dc) {unsigned int insn, opc, rs1, rs2, rd; -if (unlikely (loglevel &CPU_LOG_TB_OP )) +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP )))tcg_gen_debug_insn_start (dc->pc); insn =ldl_code (dc->pc); opc =GET_FIELD (insn,0 ,1 );
@@ -4905,7 +4905,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, tb->icount = num_insns; }#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("--------------\n" );qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, last_pc +4 - pc_start,0 );
tcg/tcg.c +2 -2
@@ -1878,7 +1878,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,const TCGArg *args;#ifdef DEBUG_DISAS -if (unlikely (loglevel &CPU_LOG_TB_OP )) { +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP ))) {qemu_log ("OP:\n" );tcg_dump_ops (s, logfile);qemu_log ("\n" );
@@ -1894,7 +1894,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#endif #ifdef DEBUG_DISAS -if (unlikely (loglevel &CPU_LOG_TB_OP_OPT )) { +if (unlikely (qemu_loglevel_mask (CPU_LOG_TB_OP_OPT ))) {qemu_log ("OP after la:\n" );tcg_dump_ops (s, logfile);qemu_log ("\n" );
translate-all.c +1 -1
@@ -127,7 +127,7 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)#endif #ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_OUT_ASM ) { +if (qemu_loglevel_mask (CPU_LOG_TB_OUT_ASM )) {qemu_log ("OUT: [size=%d]\n" , *gen_code_size_ptr);log_disas (tb->tc_ptr, *gen_code_size_ptr);qemu_log ("\n" );
Signature · 1 line
1.5.6.rc3.11.g5f54d
PATCH 3/5 Convert references to logfile/loglevel to use qemu_log*() macros
In reply to Eduardo HabkostThis is a large patch that changes all occurrences of logfile/loglevel global variables to use the new qemu_log*() macros.
--- block-raw-posix.c | 4 +- bsd-user/elfload.c | 2 +- bsd-user/main.c | 28 ++++++------- cpu-exec.c | 33 +++++++--------- darwin-user/commpage.c | 4 +- darwin-user/machload.c | 4 +- darwin-user/main.c | 6 +-- darwin-user/syscall.c | 4 +- exec.c | 24 +++++------ hw/alpha_palcode.c | 15 ++----- hw/mips_timer.c | 4 +- hw/ppc.c | 10 +---- hw/ppc4xx_devs.c | 5 +-- hw/ppc_prep.c | 9 +--- kqemu.c | 11 +---- linux-user/elfload.c | 2 +- linux-user/main.c | 34 +++++++--------- linux-user/vm86.c | 2 +- target-alpha/translate.c | 15 ++----- target-arm/translate.c | 8 ++-- target-cris/helper.c | 2 +- target-cris/mmu.c | 2 +- target-cris/op_helper.c | 4 +- target-cris/translate.c | 22 ++++------ target-i386/op_helper.c | 77 +++++++++++++----------------------- target-i386/translate.c | 18 ++++----- target-m68k/translate.c | 10 ++-- target-mips/helper.c | 40 +++++++------------ target-mips/op_helper.c | 66 +++++++++++++++--------------- target-mips/translate.c | 39 +++++++------------ target-ppc/helper.c | 98 +++++++++++++-------------------------------- target-ppc/op_helper.c | 33 ++++------------ target-ppc/translate.c | 55 ++++++++++---------------- target-sh4/helper.c | 6 +- target-sh4/translate.c | 17 +++----- target-sparc/op_helper.c | 20 +++++----- target-sparc/translate.c | 15 +++---- tcg/tcg.c | 8 ++-- translate-all.c | 6 +- vl.c | 5 +-- 40 files changed, 295 insertions(+), 472 deletions(-)
block-raw-posix.c +2 -2
@@ -67,8 +67,8 @@//#define DEBUG_BLOCK #if defined(DEBUG_BLOCK ) -#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ - { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0) +#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (qemu_log_enabled()) \ + { qemu_log(formatCstr, ##args); fflush(logfile); } } while (0)#else #define DEBUG_BLOCK_PRINT(formatCstr, args...)#endif
bsd-user/elfload.c +1 -1
@@ -1456,7 +1456,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);
bsd-user/main.c +13 -15
@@ -533,21 +533,19 @@ int main(int argc, char **argv)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();
cpu-exec.c +14 -19
@@ -388,9 +388,7 @@ int cpu_exec(CPUState *env1)svm_check_intercept (SVM_EXIT_INTR ); env->interrupt_request &= ~(CPU_INTERRUPT_HARD |CPU_INTERRUPT_VIRQ ); intno =cpu_get_pic_interrupt (env); -if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"Servicing hardware INT=0x%02x\n" , intno); - } +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 );/* ensure that no TB jump will be modified as the program flow was changed */
@@ -403,8 +401,7 @@ int cpu_exec(CPUState *env1)/* FIXME: this should respect TPR */ svm_check_intercept (SVM_EXIT_VINTR ); intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector)); -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"Servicing virtual hardware INT=0x%02x\n" , intno); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing virtual hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 ); env->interrupt_request &= ~CPU_INTERRUPT_VIRQ ; next_tb =0 ;
@@ -538,28 +535,28 @@ int cpu_exec(CPUState *env1)regs_to_env ();#if defined(TARGET_I386 ) env->eflags = env->eflags |helper_cc_compute_all (CC_OP ) | (DF &DF_MASK ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_CCOP ); env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C );#elif defined(TARGET_ARM ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SPARC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_PPC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_MIPS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SH4 ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_ALPHA ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_CRIS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#else #error unsupported target CPU#endif
@@ -577,11 +574,9 @@ int cpu_exec(CPUState *env1) tb_invalidated_flag =0 ; }#ifdef DEBUG_EXEC -if ((loglevel &CPU_LOG_EXEC )) { -fprintf (logfile,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , - (long )tb->tc_ptr, tb->pc, -lookup_symbol (tb->pc)); - } +qemu_log_mask (CPU_LOG_EXEC ,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , + (long )tb->tc_ptr, tb->pc, +lookup_symbol (tb->pc));#endif /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct
darwin-user/commpage.c +2 -2
@@ -35,9 +35,9 @@//#define DEBUG_COMMPAGE #ifdef DEBUG_COMMPAGE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif /********************************************************************
darwin-user/machload.c +2 -2
@@ -39,9 +39,9 @@//#define DEBUG_MACHLOAD #ifdef DEBUG_MACHLOAD -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif # define check_mach_header (x) (x.magic == MH_CIGAM)
darwin-user/main.c +2 -4
@@ -160,10 +160,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)
darwin-user/syscall.c +2 -2
@@ -69,7 +69,7 @@# define DEBUG_ENABLE_ALL () static int __DEBUG_qemu_user_force_enable = 1DEBUG_ENABLE_ALL (); -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); \ +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); \ if(__DEBUG_qemu_user_force_enable) fprintf(stderr, __VA_ARGS__); \ } while(0)#else
@@ -77,7 +77,7 @@# define DEBUG_BEGIN_ENABLE # define DEBUG_END_ENABLE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif enum {
exec.c +11 -13
@@ -1004,12 +1004,10 @@ static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int leint offset, b;#if 0 if (1 ) { -if (loglevel) { -fprintf (logfile,"modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , - cpu_single_env->mem_io_vaddr, len, - cpu_single_env->eip, - cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); - } +qemu_log ("modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , + cpu_single_env->mem_io_vaddr, len, + cpu_single_env->eip, + cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); }#endif p =page_find (start >>TARGET_PAGE_BITS );
@@ -1634,17 +1632,17 @@ void cpu_abort(CPUState *env, const char *fmt, ...)#else cpu_dump_state (env, stderr, fprintf,0 );#endif -if (logfile) { -fprintf (logfile,"qemu: fatal: " ); -vfprintf (logfile, fmt, ap2); -fprintf (logfile,"\n" ); +if (qemu_log_enabled ()) { +qemu_log ("qemu: fatal: " ); +qemu_log_vprintf (fmt, ap2); +qemu_log ("\n" );#ifdef TARGET_I386 -cpu_dump_state (env, logfile, fprintf,X86_DUMP_FPU |X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_FPU |X86_DUMP_CCOP );#else -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif fflush (logfile); -fclose (logfile); +qemu_log_close (); }va_end (ap2);va_end (ap);
hw/alpha_palcode.c +5 -10
@@ -1061,13 +1061,11 @@ void call_pal (CPUState *env, int palcode) {target_long ret; -if (logfile !=NULL ) -fprintf (logfile,"%s: palcode %02x\n" , __func__, palcode); +qemu_log ("%s: palcode %02x\n" , __func__, palcode);switch (palcode) {case 0x83 :/* CALLSYS */ -if (logfile !=NULL ) -fprintf (logfile,"CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); +qemu_log ("CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); ret =do_syscall (env, env->ir[IR_V0 ], env->ir[IR_A0 ], env->ir[IR_A1 ], env->ir[IR_A2 ], env->ir[IR_A3 ], env->ir[IR_A4 ], env->ir[IR_A5 ]);
@@ -1082,18 +1080,15 @@ void call_pal (CPUState *env, int palcode)case 0x9E :/* RDUNIQUE */ env->ir[IR_V0 ] = env->unique; -if (logfile !=NULL ) -fprintf (logfile,"RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;case 0x9F :/* WRUNIQUE */ env->unique = env->ir[IR_A0 ]; -if (logfile !=NULL ) -fprintf (logfile,"WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;default : -if (logfile !=NULL ) -fprintf (logfile,"%s: unhandled palcode %02x\n" , +qemu_log ("%s: unhandled palcode %02x\n" , __func__, palcode);exit (1 ); }
hw/mips_timer.c +1 -3
@@ -84,9 +84,7 @@ static void mips_timer_cb (void *opaque) env = opaque;#if 0 -if (logfile) { -fprintf (logfile,"%s\n" , __func__); - } +qemu_log ("%s\n" , __func__);#endif if (env->CP0_Cause & (1 << CP0Ca_DC))
hw/ppc.c +2 -8
@@ -32,20 +32,14 @@//#define PPC_DEBUG_TB #ifdef PPC_DEBUG_IRQ -# define LOG_IRQ (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IRQ (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_IRQ (...) do { } while (0)#endif #ifdef PPC_DEBUG_TB -# define LOG_TB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_TB (...) qemu_log(__VA_ARGS__)#else # define LOG_TB (...) do { } while (0)#endif
hw/ppc4xx_devs.c +1 -4
@@ -33,10 +33,7 @@#ifdef DEBUG_UIC -# define LOG_UIC (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_UIC (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_UIC (...) do { } while (0)#endif
hw/ppc_prep.c +2 -7
@@ -53,18 +53,13 @@ #define PPC_IO_DPRINTF(fmt, args...) \ do { \ if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ + qemu_log("%s: " fmt, __func__ , ##args); \ } else { \ printf("%s : " fmt, __func__ , ##args); \ } \ } while (0)#elif defined (DEBUG_PPC_IO ) -#define PPC_IO_DPRINTF(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ - } \ -} while (0) +#define PPC_IO_DPRINTF(fmt, args...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else #define PPC_IO_DPRINTF(fmt, args...) do { } while (0)#endif
kqemu.c +2 -9
@@ -49,15 +49,8 @@#ifdef DEBUG -# define LOG_INT (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) -# define LOG_INT_STATE (env) \ - do { \ - if (loglevel & CPU_LOG_INT) \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } while (0) +# define LOG_INT (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__) +# define LOG_INT_STATE (env) log_cpu_state_mask(CPU_LOG_INT, (env), 0)#else # define LOG_INT (...) do { } while (0)# define LOG_INT_STATE (env) do { } while (0)
linux-user/elfload.c +1 -1
@@ -1454,7 +1454,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);
linux-user/main.c +15 -19
@@ -1057,10 +1057,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)
@@ -2396,21 +2394,19 @@ int main(int argc, char **argv, char **envp)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();
linux-user/vm86.c +1 -1
@@ -30,7 +30,7 @@//#define DEBUG_VM86 #ifdef DEBUG_VM86 -# define LOG_VM86 (...) fprintf(logfile, ## __VA_ARGS__); +# define LOG_VM86 (...) qemu_log(__VA_ARGS__);#else # define LOG_VM86 (...) do { } while (0)#endif
target-alpha/translate.c +5 -10
@@ -39,10 +39,7 @@#ifdef ALPHA_DEBUG_DISAS -# define LOG_DISAS (...) do { \ - if (logfile) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DISAS (...) qemu_log(__VA_ARGS__)#else # define LOG_DISAS (...) do { } while (0)#endif
@@ -2444,13 +2441,11 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, tb->icount = num_insns; }#if definedALPHA_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,0 ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,1 ); -fprintf (logfile,"\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,1 ); +qemu_log ("\n" ); }#endif }
target-arm/translate.c +4 -4
@@ -8871,10 +8871,10 @@ done_generating:#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start, env->thumb); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start, env->thumb); +qemu_log ("\n" ); }#endif if (search_pc) {
target-cris/helper.c +1 -1
@@ -34,7 +34,7 @@#ifdef CRIS_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
target-cris/mmu.c +1 -1
@@ -32,7 +32,7 @@#ifdef DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
target-cris/op_helper.c +2 -2
@@ -30,7 +30,7 @@#ifdef CRIS_OP_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
@@ -117,7 +117,7 @@ void helper_spc_write(uint32_t new_spc)void helper_dump (uint32_t a0,uint32_t a1,uint32_t a2) { - (fprintf (logfile,"%s: a0=%x a1=%x\n" , __func__, a0, a1)); +qemu_log ("%s: a0=%x a1=%x\n" , __func__, a0, a1); }/* Used by the tlb decoder. */
target-cris/translate.c +9 -13
@@ -44,10 +44,7 @@#define DISAS_CRIS 0#if DISAS_CRIS -# define LOG_DIS (...) do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else # define LOG_DIS (...) do { } while (0)#endif
@@ -131,7 +128,7 @@ typedef struct DisasContext {static void gen_BUG (DisasContext *dc,const char *file,int line) {printf ("BUG: pc=%x %s %d\n" , dc->pc, file, line); -fprintf (logfile,"BUG: pc=%x %s %d\n" , dc->pc, file, line); +qemu_log ("BUG: pc=%x %s %d\n" , dc->pc, file, line);cpu_abort (dc->env,"%s:%d\n" , file, line); }
@@ -798,7 +795,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,t_gen_subx_carry (dc, dst);break ;default : -fprintf (logfile,"illegal ALU op.\n" ); +qemu_log ("illegal ALU op.\n" );BUG ();break ; }
@@ -3147,8 +3144,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (!logfile) - logfile = stderr; +qemu_log_try_set_file (stderr);/* Odd PC indicates that branch is rexecuting due to exception in the * delayslot, like in real hw.
@@ -3184,7 +3180,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, dc->cpustate_changed =0 ;if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile, +qemu_log ("srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n" "pid=%x usp=%x\n" "%x.%x.%x.%x\n"
@@ -3202,8 +3198,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, env->regs[10 ], env->regs[11 ], env->regs[12 ], env->regs[13 ], env->regs[14], env->regs[15]); -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); } next_page_start = (pc_start &TARGET_PAGE_MASK ) +TARGET_PAGE_SIZE ;
@@ -3336,8 +3332,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS #if !DISAS_CRIS if (loglevel &CPU_LOG_TB_IN_ASM ) { -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\nisize=%d osize=%zd\n" , +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\nisize=%d osize=%zd\n" , dc->pc - pc_start, gen_opc_ptr - gen_opc_buf); }#endif
target-i386/op_helper.c +28 -49
191 lines not on this page · raw message
target-i386/translate.c +8 -10
@@ -7675,21 +7675,19 @@ static inline void gen_intermediate_code_internal(CPUState *env, }#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,X86_DUMP_CCOP );if (loglevel &CPU_LOG_TB_IN_ASM ) {int disas_flags; -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));#ifdef TARGET_X86_64 if (dc->code64) disas_flags =2 ; else#endif disas_flags = !dc->code32; -target_disas (logfile, pc_start, pc_ptr - pc_start, disas_flags); -fprintf (logfile,"\n" ); +log_target_disas (pc_start, pc_ptr - pc_start, disas_flags); +qemu_log ("\n" ); }#endif
@@ -7716,13 +7714,13 @@ void gen_pc_load(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OP ) {int i; -fprintf (logfile,"RESTORE:\n" ); +qemu_log ("RESTORE:\n" );for (i =0 ;i <= pc_pos; i++) {if (gen_opc_instr_start[i]) { -fprintf (logfile,"0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); +qemu_log ("0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); } } -fprintf (logfile,"spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , +qemu_log ("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base, (uint32_t )tb->cs_base); }
target-m68k/translate.c +5 -5
@@ -165,7 +165,7 @@ typedef void (*disas_proc)(DisasContext *, uint16_t);#define DISAS_INSN (name) \ static void real_disas_##name (DisasContext *s, uint16_t insn); \ static void disas_##name (DisasContext *s, uint16_t insn) { \ - if (logfile) fprintf(logfile, "Dispatch " #name "\n"); \ + qemu_log("Dispatch " #name "\n"); \ real_disas_##name(s, insn); } \ static void real_disas_##name (DisasContext *s, uint16_t insn)#else
@@ -3064,10 +3064,10 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\n" ); }#endif if (search_pc) {
target-mips/helper.c +14 -26
@@ -117,10 +117,7 @@ static int get_physical_address (CPUState *env, target_ulong *physical,int ret =TLBRET_MATCH ;#if 0 -if (logfile) { -fprintf (logfile,"user mode %d h %08x\n" , - user_mode, env->hflags); - } +qemu_log ("user mode %d h %08x\n" , user_mode, env->hflags);#endif if (address <= (int32_t )0x7FFFFFFFUL ) {
@@ -198,10 +195,8 @@ static int get_physical_address (CPUState *env, target_ulong *physical, } }#if 0 -if (logfile) { -fprintf (logfile, TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , - address, rw, access_type, *physical, *prot, ret); - } +qemu_log (TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , + address, rw, access_type, *physical, *prot, ret);#endif return ret;
@@ -233,13 +228,11 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,int access_type;int ret =0 ; -if (logfile) {#if 0 -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif -fprintf (logfile,"%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , - __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); - } +qemu_log ("%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , + __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); rw &=1 ;
@@ -252,10 +245,8 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,#else ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -if (logfile) { -fprintf (logfile,"%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , - __func__, address, ret, physical, prot); - } +qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , + __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot,
@@ -357,14 +348,14 @@ void do_interrupt (CPUState *env)int cause =-1 ;const char *name; -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) {if (env->exception_index <0 || env->exception_index >EXCP_LAST ) name ="unknown" ;else name = excp_names[env->exception_index]; -fprintf (logfile,"%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , - __func__, env->active_tc.PC, env->CP0_EPC, name); +qemu_log ("%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , + __func__, env->active_tc.PC, env->CP0_EPC, name); }if (env->exception_index ==EXCP_EXT_INTERRUPT && (env->hflags &MIPS_HFLAG_DM ))
@@ -558,15 +549,12 @@ void do_interrupt (CPUState *env) env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default : -if (logfile) { -fprintf (logfile,"Invalid MIPS exception %d. Exiting\n" , - env->exception_index); - } +qemu_log ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);printf ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);exit (1 ); } -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { - fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) { + qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
target-mips/op_helper.c +33 -33
117 lines not on this page · raw message
target-mips/translate.c +14 -25
@@ -514,18 +514,11 @@ static const char *fregnames_h[] = "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", };#ifdef MIPS_DEBUG_DISAS -#define MIPS_DEBUG(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) { \ - fprintf(logfile, TARGET_FMT_lx ": %08x " fmt "\n", \ - ctx->pc, ctx->opcode , ##args); \ - } \ -} while (0) -#define LOG_DISAS (...) \ - do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +#define MIPS_DEBUG(fmt, args...) \ + qemu_log_mask(CPU_LOG_TB_IN_ASM, \ + TARGET_FMT_lx ": %08x " fmt "\n", \ + ctx->pc, ctx->opcode , ##args) +#define LOG_DISAS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else #define MIPS_DEBUG(fmt, args...) do { } while(0)#define LOG_DISAS (...) do { } while (0)
@@ -8184,8 +8177,8 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (search_pc && loglevel) -fprintf (logfile,"search pc %d\n" , search_pc); +if (search_pc) +qemu_log ("search pc %d\n" , search_pc); pc_start = tb->pc;/* Leave some spare opc slots for branch handling. */
@@ -8207,11 +8200,9 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,if (max_insns ==0 ) max_insns =CF_COUNT_MASK ;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"------------------------------------------------\n" ); -/* FIXME: This may print out stale hflags from env... */ -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU ,"------------------------------------------------\n" ); +/* FIXME: This may print out stale hflags from env... */ +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif LOG_DISAS ("\ntb %p idx %d hflags %04x\n" , tb, ctx.mem_idx, ctx.hflags);gen_icount_start ();
@@ -8303,13 +8294,11 @@ done_generating:#ifdef DEBUG_DISAS LOG_DISAS ("\n" );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); - } -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); } +qemu_log_mask (CPU_LOG_TB_CPU ,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags);#endif }
target-ppc/helper.c +29 -69
233 lines not on this page · raw message
target-ppc/op_helper.c +8 -25
@@ -29,10 +29,7 @@//#define DEBUG_SOFTWARE_TLB #ifdef DEBUG_SOFTWARE_TLB -# define LOG_SWTLB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_SWTLB (...) qemu_log(__VA_ARGS__)#else # define LOG_SWTLB (...) do { } while (0)#endif
@@ -84,18 +81,14 @@ void helper_store_cr (target_ulong val, uint32_t mask)/* SPR accesses */ void helper_load_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Read SPR %d %03x => " ADDRX "\n" , +qemu_log ("Read SPR %d %03x => " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }void helper_store_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Write SPR %d %03x <= " ADDRX "\n" , +qemu_log ("Write SPR %d %03x <= " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }target_ulong helper_load_tbl (void )
@@ -192,10 +185,8 @@ void helper_store_hid0_601 (target_ulong val) env->hflags_nmsr &= ~(1 <<MSR_LE ); env->hflags_nmsr |= (1 <<MSR_LE ) & (((val >>3 ) &1 ) <<MSR_LE ); env->hflags |= env->hflags_nmsr; -if (loglevel !=0 ) { -fprintf (logfile,"%s: set endianness to %c => " ADDRX "\n" , +qemu_log ("%s: set endianness to %c => " ADDRX "\n" , __func__, val &0x8 ?'l' :'b' , env->hflags); - } } env->spr[SPR_HID0 ] = (uint32_t )val; }
@@ -1870,15 +1861,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)target_ulong val =0 ;if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_read (env->dcr_env, dcrn, &val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR read error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR read error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
@@ -1888,15 +1875,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)void helper_store_dcr (target_ulong dcrn,target_ulong val) {if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_write (env->dcr_env, dcrn, val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR write error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR write error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
target-ppc/translate.c +21 -34
111 lines not on this page · raw message
target-sh4/helper.c +3 -3
@@ -151,9 +151,9 @@ void do_interrupt(CPUState * env) expname = do_irq ?"interrupt" :"???" ;break ; } -fprintf (logfile,"exception 0x%03x [%s] raised\n" , - irq_vector, expname); -cpu_dump_state (env, logfile, fprintf,0 ); +qemu_log ("exception 0x%03x [%s] raised\n" , + irq_vector, expname); +log_cpu_state (env,0 ); } env->ssr = env->sr;
target-sh4/translate.c +7 -10
@@ -1829,11 +1829,9 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb, ctx.features = env->features;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile, -"------------------------------------------------\n" ); -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU , +"------------------------------------------------\n" ); +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif ii =-1 ;
@@ -1926,13 +1924,12 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,#ifdef DEBUG_DISAS #ifdef SH4_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"\n" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"\n" );#endif if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN:\n" );/* , lookup_symbol(pc_start)); */ -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("IN:\n" );/* , lookup_symbol(pc_start)); */ +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); }#endif }
target-sparc/op_helper.c +10 -10
@@ -2829,23 +2829,23 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64 +qemu_log ("%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64" SP=%016" PRIx64"\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;
@@ -2956,22 +2956,22 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , +qemu_log ("%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;
target-sparc/translate.c +6 -9
@@ -4829,8 +4829,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, } }if (spc) { -if (loglevel >0 ) -fprintf (logfile,"Search PC...\n" ); +qemu_log ("Search PC...\n" ); j = gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;
@@ -4897,9 +4896,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb,while (lj <= j) gen_opc_instr_start[lj++] =0 ;#if 0 -if (loglevel >0 ) { -page_dump (logfile); - } +log_page_dump ();#endif gen_opc_jump_pc[0 ] = dc->jump_pc[0 ]; gen_opc_jump_pc[1 ] = dc->jump_pc[1 ];
@@ -4909,10 +4906,10 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, }#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, last_pc +4 - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, last_pc +4 - pc_start,0 ); +qemu_log ("\n" ); }#endif }
tcg/tcg.c +4 -4
@@ -1879,9 +1879,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP )) { -fprintf (logfile,"OP:\n" ); +qemu_log ("OP:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif
@@ -1895,9 +1895,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP_OPT )) { -fprintf (logfile,"OP after la:\n" ); +qemu_log ("OP after la:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif
translate-all.c +3 -3
@@ -128,9 +128,9 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OUT_ASM ) { -fprintf (logfile,"OUT: [size=%d]\n" , *gen_code_size_ptr); -disas (logfile, tb->tc_ptr, *gen_code_size_ptr); -fprintf (logfile,"\n" ); +qemu_log ("OUT: [size=%d]\n" , *gen_code_size_ptr); +log_disas (tb->tc_ptr, *gen_code_size_ptr); +qemu_log ("\n" );fflush (logfile); }#endif
vl.c +1 -4
@@ -156,10 +156,7 @@#ifdef DEBUG_IOPORT -# define LOG_IOPORT (...) do { \ - if (loglevel & CPU_LOG_IOPORT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IOPORT (...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else # define LOG_IOPORT (...) do { } while (0)#endif
Signature · 1 line
1.5.6.rc3.11.g5f54d
PATCH 1/5 Clean up debugging code #ifdefs
In reply to Eduardo HabkostUse macros to avoid #ifdefs on debugging code.
This patch doesn't try to merge logging macros from different files, but just unify the debugging code #ifdefs onto a macro on each file. A further cleanup can unify the debugging macros on a common header, later
--- hw/ppc.c | 313 ++++++++++---------------------------------- hw/ppc4xx_devs.c | 58 +++------ kqemu.c | 77 ++++------- linux-user/vm86.c | 39 +++--- target-alpha/translate.c | 28 ++-- target-cris/helper.c | 26 +++- target-cris/mmu.c | 12 +- target-cris/op_helper.c | 26 +++-- target-cris/translate.c | 289 ++++++++++++++++++++-------------------- target-i386/op_helper.c | 57 ++++----- target-mips/translate.c | 116 +++------------- target-ppc/helper.c | 328 +++++++++++++++------------------------------- target-ppc/op_helper.c | 64 +++------- target-ppc/translate.c | 24 ++-- vl.c | 40 +++---- 15 files changed, 532 insertions(+), 965 deletions(-)
hw/ppc.c +68 -245
@@ -31,6 +31,25 @@//#define PPC_DEBUG_IRQ //#define PPC_DEBUG_TB +#ifdef PPC_DEBUG_IRQ +# define LOG_IRQ (...) do { \ + if (loglevel & CPU_LOG_INT) \ + fprintf(logfile, ## __VA_ARGS__); \ + } while (0) +#else +# define LOG_IRQ (...) do { } while (0) +#endif + + +#ifdef PPC_DEBUG_TB +# define LOG_TB (...) do { \ + if (loglevel) \ + fprintf(logfile, ## __VA_ARGS__); \ + } while (0) +#else +# define LOG_TB (...) do { } while (0) +#endif +static void cpu_ppc_tb_stop (CPUState *env);static void cpu_ppc_tb_start (CPUState *env);
@@ -44,13 +63,9 @@ static void ppc_set_irq (CPUState *env, int n_IRQ, int level)if (env->pending_interrupts ==0 )cpu_reset_interrupt (env,CPU_INTERRUPT_HARD ); } -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: %p n_IRQ %d level %d => pending %08" PRIx32 +LOG_IRQ ("%s: %p n_IRQ %d level %d => pending %08" PRIx32"req %08x\n" , __func__, env, n_IRQ, level, env->pending_interrupts, env->interrupt_request); - } -#endif }/* PowerPC 6xx / 7xx internal IRQ controller */
@@ -59,24 +74,16 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level)CPUState *env = opaque;int cur_level; -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: env %p pin %d level %d\n" , __func__, +LOG_IRQ ("%s: env %p pin %d level %d\n" , __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) &1 ;/* Don't generate spurious events */ if ((cur_level ==1 && level ==0 ) || (cur_level ==0 && level !=0 )) {switch (pin) {case PPC6xx_INPUT_TBEN:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: %s the time base\n" , +LOG_IRQ ("%s: %s the time base\n" , __func__, level ?"start" :"stop" ); - } -#endif if (level) {cpu_ppc_tb_start (env); }else {
@@ -84,22 +91,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) }case PPC6xx_INPUT_INT:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the external IRQ state to %d\n" , +LOG_IRQ ("%s: set the external IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_EXT , level);break ;case PPC6xx_INPUT_SMI:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the SMI IRQ state to %d\n" , +LOG_IRQ ("%s: set the SMI IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_SMI , level);break ;case PPC6xx_INPUT_MCP:
@@ -108,12 +107,8 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level)* 603/604/740/750: check HID0[EMCP] */ if (cur_level ==1 && level ==0 ) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: raise machine check state\n" , +LOG_IRQ ("%s: raise machine check state\n" , __func__); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_MCK ,1 ); }break ;
@@ -122,22 +117,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level)/* XXX: TODO: relay the signal to CKSTP_OUT pin */ /* XXX: Note that the only way to restart the CPU is to reset it */ if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: stop the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: stop the CPU\n" , __func__); env->halted =1 ; }break ;case PPC6xx_INPUT_HRESET:/* Level sensitive - active low */ if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: reset the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: reset the CPU\n" , __func__); env->interrupt_request |=CPU_INTERRUPT_EXITTB ;/* XXX: TOFIX */ #if 0
@@ -148,21 +135,13 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) }break ;case PPC6xx_INPUT_SRESET: -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the RESET IRQ state to %d\n" , +LOG_IRQ ("%s: set the RESET IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_RESET , level);break ;default :/* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: unknown IRQ pin %d\n" , __func__, pin); - } -#endif +LOG_IRQ ("%s: unknown IRQ pin %d\n" , __func__, pin);return ; }if (level)
@@ -185,34 +164,22 @@ static void ppc970_set_irq (void *opaque, int pin, int level)CPUState *env = opaque;int cur_level; -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: env %p pin %d level %d\n" , __func__, +LOG_IRQ ("%s: env %p pin %d level %d\n" , __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) &1 ;/* Don't generate spurious events */ if ((cur_level ==1 && level ==0 ) || (cur_level ==0 && level !=0 )) {switch (pin) {case PPC970_INPUT_INT :/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the external IRQ state to %d\n" , +LOG_IRQ ("%s: set the external IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_EXT , level);break ;case PPC970_INPUT_THINT :/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the SMI IRQ state to %d\n" , __func__, +LOG_IRQ ("%s: set the SMI IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_THERM , level);break ;case PPC970_INPUT_MCP :
@@ -221,12 +188,8 @@ static void ppc970_set_irq (void *opaque, int pin, int level)* 603/604/740/750: check HID0[EMCP] */ if (cur_level ==1 && level ==0 ) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: raise machine check state\n" , +LOG_IRQ ("%s: raise machine check state\n" , __func__); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_MCK ,1 ); }break ;
@@ -234,18 +197,10 @@ static void ppc970_set_irq (void *opaque, int pin, int level)/* Level sensitive - active low */ /* XXX: TODO: relay the signal to CKSTP_OUT pin */ if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: stop the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: stop the CPU\n" , __func__); env->halted =1 ; }else { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: restart the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: restart the CPU\n" , __func__); env->halted =0 ; }break ;
@@ -253,40 +208,24 @@ static void ppc970_set_irq (void *opaque, int pin, int level)/* Level sensitive - active low */ if (level) {#if 0 // XXX: TOFIX -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: reset the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: reset the CPU\n" , __func__);cpu_reset (env);#endif }break ;case PPC970_INPUT_SRESET : -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the RESET IRQ state to %d\n" , +LOG_IRQ ("%s: set the RESET IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_RESET , level);break ;case PPC970_INPUT_TBEN : -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the TBEN state to %d\n" , __func__, +LOG_IRQ ("%s: set the TBEN state to %d\n" , __func__, level); - } -#endif /* XXX: TODO */ break ;default :/* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: unknown IRQ pin %d\n" , __func__, pin); - } -#endif +LOG_IRQ ("%s: unknown IRQ pin %d\n" , __func__, pin);return ; }if (level)
@@ -309,103 +248,63 @@ static void ppc40x_set_irq (void *opaque, int pin, int level)CPUState *env = opaque;int cur_level; -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: env %p pin %d level %d\n" , __func__, +LOG_IRQ ("%s: env %p pin %d level %d\n" , __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) &1 ;/* Don't generate spurious events */ if ((cur_level ==1 && level ==0 ) || (cur_level ==0 && level !=0 )) {switch (pin) {case PPC40x_INPUT_RESET_SYS:if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: reset the PowerPC system\n" , +LOG_IRQ ("%s: reset the PowerPC system\n" , __func__); - } -#endif ppc40x_system_reset (env); }break ;case PPC40x_INPUT_RESET_CHIP:if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: reset the PowerPC chip\n" , __func__); - } -#endif +LOG_IRQ ("%s: reset the PowerPC chip\n" , __func__);ppc40x_chip_reset (env); }break ;case PPC40x_INPUT_RESET_CORE:/* XXX: TODO: update DBSR[MRR] */ if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: reset the PowerPC core\n" , __func__); - } -#endif +LOG_IRQ ("%s: reset the PowerPC core\n" , __func__);ppc40x_core_reset (env); }break ;case PPC40x_INPUT_CINT:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the critical IRQ state to %d\n" , +LOG_IRQ ("%s: set the critical IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_CEXT , level);break ;case PPC40x_INPUT_INT:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the external IRQ state to %d\n" , +LOG_IRQ ("%s: set the external IRQ state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_EXT , level);break ;case PPC40x_INPUT_HALT:/* Level sensitive - active low */ if (level) { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: stop the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: stop the CPU\n" , __func__); env->halted =1 ; }else { -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: restart the CPU\n" , __func__); - } -#endif +LOG_IRQ ("%s: restart the CPU\n" , __func__); env->halted =0 ; }break ;case PPC40x_INPUT_DEBUG:/* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: set the debug pin state to %d\n" , +LOG_IRQ ("%s: set the debug pin state to %d\n" , __func__, level); - } -#endif ppc_set_irq (env,PPC_INTERRUPT_DEBUG , level);break ;default :/* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ ) -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: unknown IRQ pin %d\n" , __func__, pin); - } -#endif +LOG_IRQ ("%s: unknown IRQ pin %d\n" , __func__, pin);return ; }if (level)
@@ -453,11 +352,7 @@ uint32_t cpu_ppc_load_tbl (CPUState *env)uint64_t tb; tb =cpu_ppc_get_tb (tb_env,qemu_get_clock (vm_clock), tb_env->tb_offset); -#if defined(PPC_DEBUG_TB ) -if (loglevel !=0 ) { -fprintf (logfile,"%s: tb %016" PRIx64"\n" , __func__, tb); - } -#endif +LOG_TB ("%s: tb %016" PRIx64"\n" , __func__, tb);return tb &0xFFFFFFFF ; }
@@ -468,11 +363,7 @@ static always_inline uint32_t _cpu_ppc_load_tbu (CPUState *env)uint64_t tb; tb =cpu_ppc_get_tb (tb_env,qemu_get_clock (vm_clock), tb_env->tb_offset); -#if defined(PPC_DEBUG_TB ) -if (loglevel !=0 ) { -fprintf (logfile,"%s: tb %016" PRIx64"\n" , __func__, tb); - } -#endif +LOG_TB ("%s: tb %016" PRIx64"\n" , __func__, tb);return tb >>32 ; }
@@ -487,12 +378,8 @@ static always_inline void cpu_ppc_store_tb (ppc_tb_t *tb_env, uint64_t vmclk, uint64_t value) { *tb_offsetp = value -muldiv64 (vmclk, tb_env->tb_freq, ticks_per_sec); -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: tb %016" PRIx64" offset %08" PRIx64"\n" , +LOG_TB ("%s: tb %016" PRIx64" offset %08" PRIx64"\n" , __func__, value, *tb_offsetp); - } -#endif }void cpu_ppc_store_tbl (CPUState *env,uint32_t value)
@@ -528,11 +415,7 @@ uint32_t cpu_ppc_load_atbl (CPUState *env)uint64_t tb; tb =cpu_ppc_get_tb (tb_env,qemu_get_clock (vm_clock), tb_env->atb_offset); -#if defined(PPC_DEBUG_TB ) -if (loglevel !=0 ) { -fprintf (logfile,"%s: tb %016" PRIx64"\n" , __func__, tb); - } -#endif +LOG_TB ("%s: tb %016" PRIx64"\n" , __func__, tb);return tb &0xFFFFFFFF ; }
@@ -543,11 +426,7 @@ uint32_t cpu_ppc_load_atbu (CPUState *env)uint64_t tb; tb =cpu_ppc_get_tb (tb_env,qemu_get_clock (vm_clock), tb_env->atb_offset); -#if defined(PPC_DEBUG_TB ) -if (loglevel !=0 ) { -fprintf (logfile,"%s: tb %016" PRIx64"\n" , __func__, tb); - } -#endif +LOG_TB ("%s: tb %016" PRIx64"\n" , __func__, tb);return tb >>32 ; }
@@ -629,11 +508,7 @@ static always_inline uint32_t _cpu_ppc_load_decr (CPUState *env, decr =muldiv64 (diff, tb_env->decr_freq, ticks_per_sec); else decr = -muldiv64 (-diff, tb_env->decr_freq, ticks_per_sec); -#if defined(PPC_DEBUG_TB ) -if (loglevel !=0 ) { -fprintf (logfile,"%s: %08" PRIx32"\n" , __func__, decr); - } -#endif +LOG_TB ("%s: %08" PRIx32"\n" , __func__, decr);return decr; }
@@ -668,22 +543,14 @@ uint64_t cpu_ppc_load_purr (CPUState *env) static always_inline void cpu_ppc_decr_excp (CPUState *env) {/* Raise it */ -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"raise decrementer exception\n" ); - } -#endif +LOG_TB ("raise decrementer exception\n" );ppc_set_irq (env,PPC_INTERRUPT_DECR ,1 ); } static always_inline void cpu_ppc_hdecr_excp (CPUState *env) {/* Raise it */ -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"raise decrementer exception\n" ); - } -#endif +LOG_TB ("raise decrementer exception\n" );ppc_set_irq (env,PPC_INTERRUPT_HDECR ,1 ); }
@@ -696,12 +563,8 @@ static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp,ppc_tb_t *tb_env = env->tb_env;uint64_t now, next; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: %08" PRIx32" => %08" PRIx32"\n" , __func__, +LOG_TB ("%s: %08" PRIx32" => %08" PRIx32"\n" , __func__, decr, value); - } -#endif now =qemu_get_clock (vm_clock); next = now +muldiv64 (value, ticks_per_sec, tb_env->decr_freq);if (is_excp)
@@ -882,13 +745,9 @@ static void cpu_4xx_fit_cb (void *opaque) env->spr[SPR_40x_TSR] |=1 <<26 ;if ((env->spr[SPR_40x_TCR] >>23 ) &0x1 )ppc_set_irq (env,PPC_INTERRUPT_FIT ,1 ); -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: ir %d TCR " ADDRX " TSR " ADDRX "\n" , __func__, +LOG_TB ("%s: ir %d TCR " ADDRX " TSR " ADDRX "\n" , __func__, (int )((env->spr[SPR_40x_TCR] >>23 ) &0x1 ), env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); - } -#endif }/* Programmable interval timer */
@@ -902,19 +761,11 @@ static void start_stop_pit (CPUState *env, ppc_tb_t *tb_env, int is_excp) !((env->spr[SPR_40x_TCR] >> 26) & 0x1) || (is_excp && !((env->spr[SPR_40x_TCR] >> 22) & 0x1))) { /* Stop PIT */ -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: stop PIT\n" , __func__); - } -#endif + LOG_TB("%s: stop PIT\n", __func__); qemu_del_timer(tb_env->decr_timer); } else { -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: start PIT %016" PRIx64"\n" , +LOG_TB ("%s: start PIT %016" PRIx64"\n" , __func__, ppcemb_timer->pit_reload); - } -#endif now =qemu_get_clock (vm_clock); next = now +muldiv64 (ppcemb_timer->pit_reload, ticks_per_sec, tb_env->decr_freq);
@@ -940,16 +791,12 @@ static void cpu_4xx_pit_cb (void *opaque)if ((env->spr[SPR_40x_TCR] >>26 ) &0x1 )ppc_set_irq (env,PPC_INTERRUPT_PIT ,1 );start_stop_pit (env, tb_env,1 ); -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " " +LOG_TB ("%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " " "%016" PRIx64"\n" , __func__, (int )((env->spr[SPR_40x_TCR] >>22 ) &0x1 ), (int )((env->spr[SPR_40x_TCR] >>26 ) &0x1 ), env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], ppcemb_timer->pit_reload); - } -#endif }/* Watchdog timer */
@@ -984,12 +831,8 @@ static void cpu_4xx_wdt_cb (void *opaque) next = now +muldiv64 (next, ticks_per_sec, tb_env->decr_freq);if (next == now) next++; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: TCR " ADDRX " TSR " ADDRX "\n" , __func__, +LOG_TB ("%s: TCR " ADDRX " TSR " ADDRX "\n" , __func__, env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); - } -#endif switch ((env->spr[SPR_40x_TSR] >>30 ) &0x3 ) {case 0x0 :case 0x1 :
@@ -1031,11 +874,7 @@ void store_40x_pit (CPUState *env, target_ulong val) tb_env = env->tb_env; ppcemb_timer = tb_env->opaque; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s val" ADDRX "\n" , __func__, val); - } -#endif +LOG_TB ("%s val" ADDRX "\n" , __func__, val); ppcemb_timer->pit_reload = val;start_stop_pit (env, tb_env,0 ); }
@@ -1047,11 +886,7 @@ target_ulong load_40x_pit (CPUState *env)void store_booke_tsr (CPUState *env,target_ulong val) { -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: val " ADDRX "\n" , __func__, val); - } -#endif +LOG_TB ("%s: val " ADDRX "\n" , __func__, val); env->spr[SPR_40x_TSR] &= ~(val &0xFC000000 );if (val &0x80000000 )ppc_set_irq (env,PPC_INTERRUPT_PIT ,0 );
@@ -1062,11 +897,7 @@ void store_booke_tcr (CPUState *env, target_ulong val)ppc_tb_t *tb_env; tb_env = env->tb_env; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s: val " ADDRX "\n" , __func__, val); - } -#endif +LOG_TB ("%s: val " ADDRX "\n" , __func__, val); env->spr[SPR_40x_TCR] = val &0xFFC00000 ;start_stop_pit (env, tb_env,1 );cpu_4xx_wdt_cb (env);
@@ -1077,12 +908,8 @@ static void ppc_emb_set_tb_clk (void *opaque, uint32_t freq)CPUState *env = opaque;ppc_tb_t *tb_env = env->tb_env; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s set new frequency to %" PRIu32"\n" , __func__, +LOG_TB ("%s set new frequency to %" PRIu32"\n" , __func__, freq); - } -#endif tb_env->tb_freq = freq; tb_env->decr_freq = freq;/* XXX: we should also update all timers */
@@ -1102,11 +929,7 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq) tb_env->tb_freq = freq; tb_env->decr_freq = freq; tb_env->opaque = ppcemb_timer; -#ifdef PPC_DEBUG_TB -if (loglevel !=0 ) { -fprintf (logfile,"%s freq %" PRIu32"\n" , __func__, freq); - } -#endif +LOG_TB ("%s freq %" PRIu32"\n" , __func__, freq);if (ppcemb_timer !=NULL ) {/* We use decr timer for PIT */ tb_env->decr_timer =qemu_new_timer (vm_clock, &cpu_4xx_pit_cb, env);
hw/ppc4xx_devs.c +18 -40
107 lines not on this page · raw message
kqemu.c +28 -49
137 lines not on this page · raw message
linux-user/vm86.c +17 -22
@@ -29,6 +29,13 @@//#define DEBUG_VM86 +#ifdef DEBUG_VM86 +# define LOG_VM86 (...) fprintf(logfile, ## __VA_ARGS__); +#else +# define LOG_VM86 (...) do { } while (0) +#endif + +#define set_flags (X ,new,mask) \ ((X) = ((X) & ~(mask)) | ((new) & (mask)))
@@ -92,10 +99,8 @@ void save_v86_state(CPUX86State *env)set_flags (env->eflags, ts->v86flags,VIF_MASK | ts->v86mask); target_v86->regs.eflags =tswap32 (env->eflags);unlock_user_struct (target_v86, ts->target_v86,1 ); -#ifdef DEBUG_VM86 -fprintf (logfile,"save_v86_state: eflags=%08x cs:ip=%04x:%04x\n" , - env->eflags, env->segs[R_CS ].selector, env->eip); -#endif +LOG_VM86 ("save_v86_state: eflags=%08x cs:ip=%04x:%04x\n" , + env->eflags, env->segs[R_CS ].selector, env->eip);/* restore 32 bit registers */ env->regs[R_EAX ] = ts->vm86_saved_regs.eax;
@@ -121,9 +126,7 @@ void save_v86_state(CPUX86State *env)'retval' */ static inline void return_to_32bit (CPUX86State *env,int retval) { -#ifdef DEBUG_VM86 -fprintf (logfile,"return_to_32bit: ret=0x%x\n" , retval); -#endif +LOG_VM86 ("return_to_32bit: ret=0x%x\n" , retval);save_v86_state (env); env->regs[R_EAX ] = retval; }
@@ -216,10 +219,8 @@ static void do_int(CPUX86State *env, int intno) segoffs =ldl (int_addr);if ((segoffs >>16 ) ==TARGET_BIOSSEG ) goto cannot_handle; -#if defined(DEBUG_VM86 ) -fprintf (logfile,"VM86: emulating int 0x%x. CS:IP=%04x:%04x\n" , - intno, segoffs >>16 , segoffs &0xffff ); -#endif +LOG_VM86 ("VM86: emulating int 0x%x. CS:IP=%04x:%04x\n" , + intno, segoffs >>16 , segoffs &0xffff );/* save old state */ ssp = env->segs[R_SS ].selector <<4 ; sp = env->regs[R_ESP ] &0xffff ;
@@ -235,9 +236,7 @@ static void do_int(CPUX86State *env, int intno)clear_AC (env);return ; cannot_handle: -#if defined(DEBUG_VM86 ) -fprintf (logfile,"VM86: return to 32 bits int 0x%x\n" , intno); -#endif +LOG_VM86 ("VM86: return to 32 bits int 0x%x\n" , intno);return_to_32bit (env, TARGET_VM86_INTx | (intno <<8 )); }
@@ -274,10 +273,8 @@ void handle_vm86_fault(CPUX86State *env) ssp = env->segs[R_SS ].selector <<4 ; sp = env->regs[R_ESP ] &0xffff ; -#if defined(DEBUG_VM86 ) -fprintf (logfile,"VM86 exception %04x:%08x\n" , - env->segs[R_CS ].selector, env->eip); -#endif +LOG_VM86 ("VM86 exception %04x:%08x\n" , + env->segs[R_CS ].selector, env->eip); data32 =0 ; pref_done =0 ;
@@ -478,10 +475,8 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) target_v86->vm86plus.vm86dbg_intxxtab, 32);unlock_user_struct (target_v86, vm86_addr,0 ); -#ifdef DEBUG_VM86 -fprintf (logfile,"do_vm86: cs:ip=%04x:%04x\n" , - env->segs[R_CS ].selector, env->eip); -#endif +LOG_VM86 ("do_vm86: cs:ip=%04x:%04x\n" , + env->segs[R_CS ].selector, env->eip);/* now the virtual CPU is ready for vm86 execution ! */ out:return ret;
target-alpha/translate.c +15 -13
@@ -37,6 +37,16 @@#define ALPHA_DEBUG_DISAS /* #define DO_TB_FLUSH */ + +#ifdef ALPHA_DEBUG_DISAS +# define LOG_DISAS (...) do { \ + if (logfile) \ + fprintf(logfile, ## __VA_ARGS__); \ + } while (0) +#else +# define LOG_DISAS (...) do { } while (0) +#endif +typedef struct DisasContext DisasContext ;struct DisasContext {uint64_t pc;
@@ -671,12 +681,8 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn) fn7 = (insn >>5 ) &0x0000007F ; fn2 = (insn >>5 ) &0x00000003 ; ret =0 ; -#if definedALPHA_DEBUG_DISAS -if (logfile !=NULL ) { -fprintf (logfile,"opc %02x ra %d rb %d rc %d disp16 %04x\n" , - opc, ra, rb, rc, disp16); - } -#endif +LOG_DISAS ("opc %02x ra %d rb %d rc %d disp16 %04x\n" , + opc, ra, rb, rc, disp16);switch (opc) {case 0x00 :/* CALL_PAL */
@@ -2386,17 +2392,13 @@ static always_inline void gen_intermediate_code_internal (CPUState *env,gen_io_start ();#if definedALPHA_DEBUG_DISAS insn_count++; -if (logfile !=NULL ) { -fprintf (logfile,"pc " TARGET_FMT_lx" mem_idx %d\n" , - ctx.pc, ctx.mem_idx); - } +LOG_DISAS ("pc " TARGET_FMT_lx" mem_idx %d\n" , + ctx.pc, ctx.mem_idx);#endif insn =ldl_code (ctx.pc);#if definedALPHA_DEBUG_DISAS insn_count++; -if (logfile !=NULL ) { -fprintf (logfile,"opcode %08x %d\n" , insn, insn_count); - } +LOG_DISAS ("opcode %08x %d\n" , insn, insn_count);#endif num_insns++; ctx.pc +=4 ;
target-cris/helper.c +18 -8
@@ -28,7 +28,17 @@#include "exec-all.h" #include "host-utils.h" + +//#define CRIS_HELPER_DEBUG + + +#ifdef CRIS_HELPER_DEBUG +#define D (x) x +#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#else #define D (x) +#define D_LOG (...) do { } while (0) +#endif #if defined(CONFIG_USER_ONLY )
@@ -98,10 +108,10 @@ int cpu_cris_handle_mmu_fault (CPUState *env, target_ulong address, int rw, r =tlb_set_page (env, address, phy, prot, mmu_idx, is_softmmu); }if (r >0 ) -D (fprintf (logfile,"%s returns %d irqreq=%x addr=%x" +D_LOG ("%s returns %d irqreq=%x addr=%x" " phy=%x ismmu=%d vec=%x pc=%x\n" , __func__, r, env->interrupt_request, - address, res.phy, is_softmmu, res.bf_vec, env->pc)); + address, res.phy, is_softmmu, res.bf_vec, env->pc);return r; }
@@ -109,9 +119,9 @@ void do_interrupt(CPUState *env) {int ex_vec =-1 ; -D (fprintf (logfile,"exception index=%d interrupt_req=%d\n" , +D_LOG ("exception index=%d interrupt_req=%d\n" , env->exception_index, - env->interrupt_request)); + env->interrupt_request);switch (env->exception_index) {
@@ -147,13 +157,13 @@ void do_interrupt(CPUState *env) env->pregs[PR_EXS ] = (ex_vec &0xff ) <<8 ;if (env->dslot) { -D (fprintf (logfile,"excp isr=%x PC=%x ds=%d SP=%x" +D_LOG ("excp isr=%x PC=%x ds=%d SP=%x" " ERP=%x pid=%x ccs=%x cc=%d %x\n" , ex_vec, env->pc, env->dslot, env->regs[R_SP ], env->pregs[PR_ERP ], env->pregs[PR_PID ], env->pregs[PR_CCS ], - env->cc_op, env->cc_mask)); + env->cc_op, env->cc_mask);/* We loose the btarget, btaken state here so rexec the branch. */ env->pregs[PR_ERP ] -= env->dslot;
@@ -171,11 +181,11 @@ void do_interrupt(CPUState *env)/* Apply the CRIS CCS shift. Clears U if set. */ cris_shift_ccs (env); -D (fprintf (logfile,"%s isr=%x vec=%x ccs=%x pid=%d erp=%x\n" , +D_LOG ("%s isr=%x vec=%x ccs=%x pid=%d erp=%x\n" , __func__, env->pc, ex_vec, env->pregs[PR_CCS ], env->pregs[PR_PID ], - env->pregs[PR_ERP ])); + env->pregs[PR_ERP ]); }target_phys_addr_t cpu_get_phys_page_debug (CPUState * env,target_ulong addr)
target-cris/mmu.c +6 -6
@@ -32,8 +32,10 @@#ifdef DEBUG #define D (x) x +#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__)#else #define D (x) +#define D_LOG (...) do { } while (0)#endif void cris_mmu_init (CPUState *env)
@@ -180,9 +182,8 @@ static int cris_mmu_translate_page(struct cris_mmu_result_t *res, tlb_pid =EXTRACT_FIELD (hi,0 ,7 ); tlb_g =EXTRACT_FIELD (lo,4 ,4 ); -D (fprintf (logfile, -"TLB[%d][%d][%d] v=%x vpage=%x lo=%x hi=%x\n" , - mmu, set, idx, tlb_vpn, vpage, lo, hi)); +D_LOG ("TLB[%d][%d][%d] v=%x vpage=%x lo=%x hi=%x\n" , + mmu, set, idx, tlb_vpn, vpage, lo, hi);if ((tlb_g || (tlb_pid == pid)) && tlb_vpn == vpage) { match =1 ;
@@ -314,9 +315,8 @@ void cris_mmu_flush_pid(CPUState *env, uint32_t pid)if (tlb_v && !tlb_g && (tlb_pid == pid)) { vaddr = tlb_vpn <<TARGET_PAGE_BITS ; -D (fprintf (logfile, -"flush pid=%x vaddr=%x\n" , - pid, vaddr)); +D_LOG ("flush pid=%x vaddr=%x\n" , + pid, vaddr);tlb_flush_page (env, vaddr); } }
target-cris/op_helper.c +17 -9
@@ -25,7 +25,16 @@#include "helper.h" #include "host-utils.h" +//#define CRIS_OP_HELPER_DEBUG + + +#ifdef CRIS_OP_HELPER_DEBUG +#define D (x) x +#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#else #define D (x) +#define D_LOG (...) do { } while (0) +#endif #if !defined(CONFIG_USER_ONLY )
@@ -59,8 +68,8 @@ void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr) saved_env = env; env = cpu_single_env; -D (fprintf (logfile,"%s pc=%x tpc=%x ra=%x\n" , __func__, - env->pc, env->debug1, retaddr)); +D_LOG ("%s pc=%x tpc=%x ra=%x\n" , __func__, + env->pc, env->debug1, retaddr); ret =cpu_cris_handle_mmu_fault (env, addr, is_write, mmu_idx,1 );if (unlikely (ret)) {if (retaddr) {
@@ -155,9 +164,8 @@ void helper_movl_sreg_reg (uint32_t sreg, uint32_t reg) env->tlbsets[srs -1 ][set][idx].lo = lo; env->tlbsets[srs -1 ][set][idx].hi = hi; -D (fprintf (logfile, -"tlb flush vaddr=%x v=%d pc=%x\n" , - vaddr, tlb_v, env->pc)); +D_LOG ("tlb flush vaddr=%x v=%d pc=%x\n" , + vaddr, tlb_v, env->pc);tlb_flush_page (env, vaddr); } }
@@ -213,10 +221,10 @@ void helper_rfe(void) {int rflag = env->pregs[PR_CCS ] &R_FLAG ; -D (fprintf (logfile,"rfe: erp=%x pid=%x ccs=%x btarget=%x\n" , +D_LOG ("rfe: erp=%x pid=%x ccs=%x btarget=%x\n" , env->pregs[PR_ERP ], env->pregs[PR_PID ], env->pregs[PR_CCS ], - env->btarget)); + env->btarget);cris_ccs_rshift (env);
@@ -229,10 +237,10 @@ void helper_rfn(void) {int rflag = env->pregs[PR_CCS ] &R_FLAG ; -D (fprintf (logfile,"rfn: erp=%x pid=%x ccs=%x btarget=%x\n" , +D_LOG ("rfn: erp=%x pid=%x ccs=%x btarget=%x\n" , env->pregs[PR_ERP ], env->pregs[PR_PID ], env->pregs[PR_CCS ], - env->btarget)); + env->btarget);cris_ccs_rshift (env);
target-cris/translate.c +146 -143
850 lines not on this page · raw message
target-i386/op_helper.c +25 -32
100 lines not on this page · raw message
target-mips/translate.c +22 -94
213 lines not on this page · raw message
target-ppc/helper.c +105 -223
645 lines not on this page · raw message
target-ppc/op_helper.c +19 -45
44 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.5.6.rc3.11.g5f54d
Part of the diff is not shown here. View the raw message.
[Qemu-devel] Re: [PATCH 3/5] Convert references to logfile/loglevel to use qemu_log*() macros
In reply to Eduardo HabkostQuoted 5 lines · Eduardo Habkost
This is a large patch that changes all occurrences of logfile/loglevel global variables to use the new qemu_log*() macros.
Signed-off-by Eduardo Habkost <[email protected]>
I applied the first two. The first one had a conflict but I repaired it. This one failed miserably:
Hunk #2 FAILED at 195.
1 out of 6 hunks FAILED -- saving rejects to file target-mips/helper.c.rej patching file target-mips/op_helper.c
Hunk #1 succeeded at 29 with fuzz 2.
missing header for unified diff at line 1142 of patch
can't find file to patch at input line 1142
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
| env->error_code = error_code;
--------------------------
File to patch: ^C
Can you fix this, send out again, and then ping me on IRC and I'll apply it immediately to avoid this happening again.
Thanks!
Regards,
Anthony Liguori
Quoted 1,966 lines
--- block-raw-posix.c | 4 +- bsd-user/elfload.c | 2 +- bsd-user/main.c | 28 ++++++------- cpu-exec.c | 33 +++++++--------- darwin-user/commpage.c | 4 +- darwin-user/machload.c | 4 +- darwin-user/main.c | 6 +-- darwin-user/syscall.c | 4 +- exec.c | 24 +++++------ hw/alpha_palcode.c | 15 ++----- hw/mips_timer.c | 4 +- hw/ppc.c | 10 +---- hw/ppc4xx_devs.c | 5 +-- hw/ppc_prep.c | 9 +--- kqemu.c | 11 +---- linux-user/elfload.c | 2 +- linux-user/main.c | 34 +++++++--------- linux-user/vm86.c | 2 +- target-alpha/translate.c | 15 ++----- target-arm/translate.c | 8 ++-- target-cris/helper.c | 2 +- target-cris/mmu.c | 2 +- target-cris/op_helper.c | 4 +- target-cris/translate.c | 22 ++++------ target-i386/op_helper.c | 77 +++++++++++++----------------------- target-i386/translate.c | 18 ++++----- target-m68k/translate.c | 10 ++-- target-mips/helper.c | 40 +++++++------------ target-mips/op_helper.c | 66 +++++++++++++++--------------- target-mips/translate.c | 39 +++++++------------ target-ppc/helper.c | 98 +++++++++++++-------------------------------- target-ppc/op_helper.c | 33 ++++------------ target-ppc/translate.c | 55 ++++++++++---------------- target-sh4/helper.c | 6 +- target-sh4/translate.c | 17 +++----- target-sparc/op_helper.c | 20 +++++----- target-sparc/translate.c | 15 +++---- tcg/tcg.c | 8 ++-- translate-all.c | 6 +- vl.c | 5 +-- 40 files changed, 295 insertions(+), 472 deletions(-)block-raw-posix.c +2
-2@@ -67,8 +67,8 @@//#define DEBUG_BLOCK #if defined(DEBUG_BLOCK ) -#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ - { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0) +#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (qemu_log_enabled()) \ + { qemu_log(formatCstr, ##args); fflush(logfile); } } while (0)#else #define DEBUG_BLOCK_PRINT(formatCstr, args...)#endif bsd-user/elfload.c +1
-1@@ -1456,7 +1456,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);bsd-user/main.c +13
-15@@ -533,21 +533,19 @@ int main(int argc, char **argv)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();cpu-exec.c +14
-19@@ -388,9 +388,7 @@ int cpu_exec(CPUState *env1)svm_check_intercept (SVM_EXIT_INTR ); env->interrupt_request &= ~(CPU_INTERRUPT_HARD |CPU_INTERRUPT_VIRQ ); intno =cpu_get_pic_interrupt (env); -if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"Servicing hardware INT=0x%02x\n" , intno); - } +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 );/* ensure that no TB jump will be modified as the program flow was changed */ @@ -403,8 +401,7 @@ int cpu_exec(CPUState *env1)/* FIXME: this should respect TPR */ svm_check_intercept (SVM_EXIT_VINTR ); intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector)); -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"Servicing virtual hardware INT=0x%02x\n" , intno); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing virtual hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 ); env->interrupt_request &= ~CPU_INTERRUPT_VIRQ ; next_tb =0 ;@@ -538,28 +535,28 @@ int cpu_exec(CPUState *env1)regs_to_env ();#if defined(TARGET_I386 ) env->eflags = env->eflags |helper_cc_compute_all (CC_OP ) | (DF &DF_MASK ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_CCOP ); env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C );#elif defined(TARGET_ARM ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SPARC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_PPC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_MIPS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SH4 ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_ALPHA ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_CRIS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#else #error unsupported target CPU#endif @@ -577,11 +574,9 @@ int cpu_exec(CPUState *env1) tb_invalidated_flag =0 ; }#ifdef DEBUG_EXEC -if ((loglevel &CPU_LOG_EXEC )) { -fprintf (logfile,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , - (long )tb->tc_ptr, tb->pc, -lookup_symbol (tb->pc)); - } +qemu_log_mask (CPU_LOG_EXEC ,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , + (long )tb->tc_ptr, tb->pc, +lookup_symbol (tb->pc));#endif /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct darwin-user/commpage.c +2
-2@@ -35,9 +35,9 @@//#define DEBUG_COMMPAGE #ifdef DEBUG_COMMPAGE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif /******************************************************************** darwin-user/machload.c +2
-2@@ -39,9 +39,9 @@//#define DEBUG_MACHLOAD #ifdef DEBUG_MACHLOAD -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif # define check_mach_header (x) (x.magic == MH_CIGAM)darwin-user/main.c +2
-4@@ -160,10 +160,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)darwin-user/syscall.c +2
-2@@ -69,7 +69,7 @@# define DEBUG_ENABLE_ALL () static int __DEBUG_qemu_user_force_enable = 1DEBUG_ENABLE_ALL (); -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); \ +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); \ if(__DEBUG_qemu_user_force_enable) fprintf(stderr, __VA_ARGS__); \ } while(0)#else @@ -77,7 +77,7 @@# define DEBUG_BEGIN_ENABLE # define DEBUG_END_ENABLE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif enum {exec.c +11
-13@@ -1004,12 +1004,10 @@ static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int leint offset, b;#if 0 if (1 ) { -if (loglevel) { -fprintf (logfile,"modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , - cpu_single_env->mem_io_vaddr, len, - cpu_single_env->eip, - cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); - } +qemu_log ("modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , + cpu_single_env->mem_io_vaddr, len, + cpu_single_env->eip, + cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); }#endif p =page_find (start >>TARGET_PAGE_BITS );@@ -1634,17 +1632,17 @@ void cpu_abort(CPUState *env, const char *fmt, ...)#else cpu_dump_state (env, stderr, fprintf,0 );#endif -if (logfile) { -fprintf (logfile,"qemu: fatal: " ); -vfprintf (logfile, fmt, ap2); -fprintf (logfile,"\n" ); +if (qemu_log_enabled ()) { +qemu_log ("qemu: fatal: " ); +qemu_log_vprintf (fmt, ap2); +qemu_log ("\n" );#ifdef TARGET_I386 -cpu_dump_state (env, logfile, fprintf,X86_DUMP_FPU |X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_FPU |X86_DUMP_CCOP );#else -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif fflush (logfile); -fclose (logfile); +qemu_log_close (); }va_end (ap2);va_end (ap);hw/alpha_palcode.c +5
-10@@ -1061,13 +1061,11 @@ void call_pal (CPUState *env, int palcode) {target_long ret; -if (logfile !=NULL ) -fprintf (logfile,"%s: palcode %02x\n" , __func__, palcode); +qemu_log ("%s: palcode %02x\n" , __func__, palcode);switch (palcode) {case 0x83 :/* CALLSYS */ -if (logfile !=NULL ) -fprintf (logfile,"CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); +qemu_log ("CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); ret =do_syscall (env, env->ir[IR_V0 ], env->ir[IR_A0 ], env->ir[IR_A1 ], env->ir[IR_A2 ], env->ir[IR_A3 ], env->ir[IR_A4 ], env->ir[IR_A5 ]);@@ -1082,18 +1080,15 @@ void call_pal (CPUState *env, int palcode)case 0x9E :/* RDUNIQUE */ env->ir[IR_V0 ] = env->unique; -if (logfile !=NULL ) -fprintf (logfile,"RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;case 0x9F :/* WRUNIQUE */ env->unique = env->ir[IR_A0 ]; -if (logfile !=NULL ) -fprintf (logfile,"WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;default : -if (logfile !=NULL ) -fprintf (logfile,"%s: unhandled palcode %02x\n" , +qemu_log ("%s: unhandled palcode %02x\n" , __func__, palcode);exit (1 ); }hw/mips_timer.c +1
-3@@ -84,9 +84,7 @@ static void mips_timer_cb (void *opaque) env = opaque;#if 0 -if (logfile) { -fprintf (logfile,"%s\n" , __func__); - } +qemu_log ("%s\n" , __func__);#endif if (env->CP0_Cause & (1 << CP0Ca_DC))hw/ppc.c +2
-8@@ -32,20 +32,14 @@//#define PPC_DEBUG_TB #ifdef PPC_DEBUG_IRQ -# define LOG_IRQ (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IRQ (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_IRQ (...) do { } while (0)#endif #ifdef PPC_DEBUG_TB -# define LOG_TB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_TB (...) qemu_log(__VA_ARGS__)#else # define LOG_TB (...) do { } while (0)#endif hw/ppc4xx_devs.c +1
-4@@ -33,10 +33,7 @@#ifdef DEBUG_UIC -# define LOG_UIC (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_UIC (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_UIC (...) do { } while (0)#endif hw/ppc_prep.c +2
-7@@ -53,18 +53,13 @@ #define PPC_IO_DPRINTF(fmt, args...) \ do { \ if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ + qemu_log("%s: " fmt, __func__ , ##args); \ } else { \ printf("%s : " fmt, __func__ , ##args); \ } \ } while (0)#elif defined (DEBUG_PPC_IO ) -#define PPC_IO_DPRINTF(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ - } \ -} while (0) +#define PPC_IO_DPRINTF(fmt, args...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else #define PPC_IO_DPRINTF(fmt, args...) do { } while (0)#endif kqemu.c +2
-9@@ -49,15 +49,8 @@#ifdef DEBUG -# define LOG_INT (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) -# define LOG_INT_STATE (env) \ - do { \ - if (loglevel & CPU_LOG_INT) \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } while (0) +# define LOG_INT (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__) +# define LOG_INT_STATE (env) log_cpu_state_mask(CPU_LOG_INT, (env), 0)#else # define LOG_INT (...) do { } while (0)# define LOG_INT_STATE (env) do { } while (0)linux-user/elfload.c +1
-1@@ -1454,7 +1454,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);linux-user/main.c +15
-19@@ -1057,10 +1057,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)@@ -2396,21 +2394,19 @@ int main(int argc, char **argv, char **envp)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();linux-user/vm86.c +1
-1@@ -30,7 +30,7 @@//#define DEBUG_VM86 #ifdef DEBUG_VM86 -# define LOG_VM86 (...) fprintf(logfile, ## __VA_ARGS__); +# define LOG_VM86 (...) qemu_log(__VA_ARGS__);#else # define LOG_VM86 (...) do { } while (0)#endif target-alpha/translate.c +5
-10@@ -39,10 +39,7 @@#ifdef ALPHA_DEBUG_DISAS -# define LOG_DISAS (...) do { \ - if (logfile) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DISAS (...) qemu_log(__VA_ARGS__)#else # define LOG_DISAS (...) do { } while (0)#endif @@ -2444,13 +2441,11 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, tb->icount = num_insns; }#if definedALPHA_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,0 ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,1 ); -fprintf (logfile,"\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,1 ); +qemu_log ("\n" ); }#endif }target-arm/translate.c +4
-4@@ -8871,10 +8871,10 @@ done_generating:#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start, env->thumb); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start, env->thumb); +qemu_log ("\n" ); }#endif if (search_pc) {target-cris/helper.c +1
-1@@ -34,7 +34,7 @@#ifdef CRIS_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)target-cris/mmu.c +1
-1@@ -32,7 +32,7 @@#ifdef DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)target-cris/op_helper.c +2
-2@@ -30,7 +30,7 @@#ifdef CRIS_OP_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)@@ -117,7 +117,7 @@ void helper_spc_write(uint32_t new_spc)void helper_dump (uint32_t a0,uint32_t a1,uint32_t a2) { - (fprintf (logfile,"%s: a0=%x a1=%x\n" , __func__, a0, a1)); +qemu_log ("%s: a0=%x a1=%x\n" , __func__, a0, a1); }/* Used by the tlb decoder. */ target-cris/translate.c +9
-13@@ -44,10 +44,7 @@#define DISAS_CRIS 0#if DISAS_CRIS -# define LOG_DIS (...) do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else # define LOG_DIS (...) do { } while (0)#endif @@ -131,7 +128,7 @@ typedef struct DisasContext {static void gen_BUG (DisasContext *dc,const char *file,int line) {printf ("BUG: pc=%x %s %d\n" , dc->pc, file, line); -fprintf (logfile,"BUG: pc=%x %s %d\n" , dc->pc, file, line); +qemu_log ("BUG: pc=%x %s %d\n" , dc->pc, file, line);cpu_abort (dc->env,"%s:%d\n" , file, line); }@@ -798,7 +795,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,t_gen_subx_carry (dc, dst);break ;default : -fprintf (logfile,"illegal ALU op.\n" ); +qemu_log ("illegal ALU op.\n" );BUG ();break ; }@@ -3147,8 +3144,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (!logfile) - logfile = stderr; +qemu_log_try_set_file (stderr);/* Odd PC indicates that branch is rexecuting due to exception in the * delayslot, like in real hw. @@ -3184,7 +3180,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, dc->cpustate_changed =0 ;if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile, +qemu_log ("srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n" "pid=%x usp=%x\n" "%x.%x.%x.%x\n"@@ -3202,8 +3198,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, env->regs[10 ], env->regs[11 ], env->regs[12 ], env->regs[13 ], env->regs[14], env->regs[15]); -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); } next_page_start = (pc_start &TARGET_PAGE_MASK ) +TARGET_PAGE_SIZE ;@@ -3336,8 +3332,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS #if !DISAS_CRIS if (loglevel &CPU_LOG_TB_IN_ASM ) { -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\nisize=%d osize=%zd\n" , +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\nisize=%d osize=%zd\n" , dc->pc - pc_start, gen_opc_ptr - gen_opc_buf); }#endif target-i386/op_helper.c +28
-49@@ -26,14 +26,9 @@#ifdef DEBUG_PCALL -# define LOG_PCALL (...) do { \ - if (loglevel & CPU_LOG_PCALL) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) -# define LOG_PCALL_STATE (env) do { \ - if (loglevel & CPU_LOG_PCALL) \ - cpu_dump_state((env), logfile, fprintf, X86_DUMP_CCOP); \ - } while (0) +# define LOG_PCALL (...) qemu_log_mask(CPU_LOG_PCALL, ## __VA_ARGS__) +# define LOG_PCALL_STATE (env) \ + log_cpu_state_mask(CPU_LOG_PCALL, (env), X86_DUMP_CCOP)#else # define LOG_PCALL (...) do { } while (0)# define LOG_PCALL_STATE (env) do { } while (0)@@ -43,8 +38,7 @@#if 0 #define raise_exception_err (a, b)\ do {\ - if (logfile)\ - fprintf(logfile, "raise_exception line=%d\n", __LINE__);\ + qemu_log("raise_exception line=%d\n", __LINE__);\ (raise_exception_err)(a, b);\ } while (0)#endif @@ -1215,29 +1209,29 @@ void do_interrupt(int intno, int is_int, int error_code,if (loglevel &CPU_LOG_INT ) {if ((env->cr[0 ] &CR0_PE_MASK )) {static int count; -fprintf (logfile,"%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx" pc=" TARGET_FMT_lx" SP=%04x:" TARGET_FMT_lx, +qemu_log ("%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx" pc=" TARGET_FMT_lx" SP=%04x:" TARGET_FMT_lx, count, intno, error_code, is_int, env->hflags &HF_CPL_MASK , env->segs[R_CS ].selector,EIP , (int )env->segs[R_CS ].base +EIP , env->segs[R_SS ].selector,ESP );if (intno ==0x0e ) { -fprintf (logfile," CR2=" TARGET_FMT_lx, env->cr[2 ]); +qemu_log (" CR2=" TARGET_FMT_lx, env->cr[2 ]); }else { -fprintf (logfile," EAX=" TARGET_FMT_lx,EAX ); +qemu_log (" EAX=" TARGET_FMT_lx,EAX ); } -fprintf (logfile,"\n" ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); +qemu_log ("\n" ); +log_cpu_state (env,X86_DUMP_CCOP );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = env->segs[R_CS ].base + env->eip;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;@@ -1270,8 +1264,7 @@ static int check_exception(int intno, int *error_code)int second_contributory = intno ==0 || (intno >=10 && intno <=13 ); -if (loglevel &CPU_LOG_INT ) -fprintf (logfile,"check_exception old: 0x%x new 0x%x\n" , +qemu_log_mask (CPU_LOG_INT ,"check_exception old: 0x%x new 0x%x\n" , env->old_exception, intno);if (env->old_exception ==EXCP08_DBLE )@@ -1352,10 +1345,8 @@ void do_smm_enter(void)SegmentCache *dt;int i, offset; -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"SMM: enter\n" ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); - } +qemu_log_mask (CPU_LOG_INT ,"SMM: enter\n" ); +log_cpu_state_mask (CPU_LOG_INT , env,X86_DUMP_CCOP ); env->hflags |=HF_SMM_MASK ;cpu_smm_update (env);@@ -1595,10 +1586,8 @@ void helper_rsm(void) env->hflags &= ~HF_SMM_MASK ;cpu_smm_update (env); -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"SMM: after RSM\n" ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); - } +qemu_log_mask (CPU_LOG_INT ,"SMM: after RSM\n" ); + log_cpu_state_mask(CPU_LOG_INT, env, X86_DUMP_CCOP); }#endif /* !CONFIG_USER_ONLY */ @@ -2156,7 +2145,7 @@ void helper_load_seg(int seg_reg, int selector)get_seg_limit (e1, e2), e2);#if 0 -fprintf (logfile,"load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n" , +qemu_log ("load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n" , selector, (unsigned long )sc->base, sc->limit, sc->flags);#endif }@@ -4774,8 +4763,7 @@ void helper_vmrun(int aflag, int next_eip_addend)else addr = (uint32_t )EAX ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"vmrun! " TARGET_FMT_lx"\n" , addr); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"vmrun! " TARGET_FMT_lx"\n" , addr); env->vm_vmcb = addr;@@ -4895,8 +4883,7 @@ void helper_vmrun(int aflag, int next_eip_addend) uint32_t event_inj_err = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj_err)); stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj), event_inj & ~SVM_EVTINJ_VALID); -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"Injecting(%#hx): " , valid_err); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Injecting(%#hx): " , valid_err);/* FIXME: need to implement valid_err */ switch (event_inj &SVM_EVTINJ_TYPE_MASK ) {case SVM_EVTINJ_TYPE_INTR :@@ -4904,8 +4891,7 @@ void helper_vmrun(int aflag, int next_eip_addend) env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip =-1 ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"INTR" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"INTR" );/* XXX: is it always correct ? */ do_interrupt (vector,0 ,0 ,0 ,1 );break ;@@ -4914,8 +4900,7 @@ void helper_vmrun(int aflag, int next_eip_addend) env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip =EIP ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"NMI" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"NMI" );cpu_loop_exit ();break ;case SVM_EVTINJ_TYPE_EXEPT :@@ -4923,8 +4908,7 @@ void helper_vmrun(int aflag, int next_eip_addend) env->error_code = event_inj_err; env->exception_is_int =0 ; env->exception_next_eip =-1 ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"EXEPT" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"EXEPT" );cpu_loop_exit ();break ;case SVM_EVTINJ_TYPE_SOFT :@@ -4932,13 +4916,11 @@ void helper_vmrun(int aflag, int next_eip_addend) env->error_code = event_inj_err; env->exception_is_int =1 ; env->exception_next_eip =EIP ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"SOFT" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"SOFT" );cpu_loop_exit ();break ; } -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile," %#x %#x\n" , env->exception_index, env->error_code); +qemu_log_mask (CPU_LOG_TB_IN_ASM ," %#x %#x\n" , env->exception_index, env->error_code); } }@@ -4958,8 +4940,7 @@ void helper_vmload(int aflag)else addr = (uint32_t )EAX ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"vmload! " TARGET_FMT_lx"\nFS: %016" PRIx64" | " TARGET_FMT_lx"\n" , +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"vmload! " TARGET_FMT_lx"\nFS: %016" PRIx64" | " TARGET_FMT_lx"\n" , addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)), env->segs[R_FS].base);@@ -4994,8 +4975,7 @@ void helper_vmsave(int aflag)else addr = (uint32_t )EAX ; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"vmsave! " TARGET_FMT_lx"\nFS: %016" PRIx64" | " TARGET_FMT_lx"\n" , +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"vmsave! " TARGET_FMT_lx"\nFS: %016" PRIx64" | " TARGET_FMT_lx"\n" , addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)), env->segs[R_FS].base);@@ -5143,8 +5123,7 @@ void helper_vmexit(uint32_t exit_code, uint64_t exit_info_1) {uint32_t int_ctl; -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"vmexit(%08x, %016" PRIx64", %016" PRIx64", " TARGET_FMT_lx")!\n" , +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"vmexit(%08x, %016" PRIx64", %016" PRIx64", " TARGET_FMT_lx")!\n" , exit_code, exit_info_1, ldq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2)),EIP );target-i386/translate.c +8
-10@@ -7675,21 +7675,19 @@ static inline void gen_intermediate_code_internal(CPUState *env, }#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,X86_DUMP_CCOP );if (loglevel &CPU_LOG_TB_IN_ASM ) {int disas_flags; -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));#ifdef TARGET_X86_64 if (dc->code64) disas_flags =2 ; else#endif disas_flags = !dc->code32; -target_disas (logfile, pc_start, pc_ptr - pc_start, disas_flags); -fprintf (logfile,"\n" ); +log_target_disas (pc_start, pc_ptr - pc_start, disas_flags); +qemu_log ("\n" ); }#endif @@ -7716,13 +7714,13 @@ void gen_pc_load(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OP ) {int i; -fprintf (logfile,"RESTORE:\n" ); +qemu_log ("RESTORE:\n" );for (i =0 ;i <= pc_pos; i++) {if (gen_opc_instr_start[i]) { -fprintf (logfile,"0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); +qemu_log ("0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); } } -fprintf (logfile,"spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , +qemu_log ("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base, (uint32_t )tb->cs_base); }target-m68k/translate.c +5
-5@@ -165,7 +165,7 @@ typedef void (*disas_proc)(DisasContext *, uint16_t);#define DISAS_INSN (name) \ static void real_disas_##name (DisasContext *s, uint16_t insn); \ static void disas_##name (DisasContext *s, uint16_t insn) { \ - if (logfile) fprintf(logfile, "Dispatch " #name "\n"); \ + qemu_log("Dispatch " #name "\n"); \ real_disas_##name(s, insn); } \ static void real_disas_##name (DisasContext *s, uint16_t insn)#else @@ -3064,10 +3064,10 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\n" ); }#endif if (search_pc) {target-mips/helper.c +14
-26@@ -117,10 +117,7 @@ static int get_physical_address (CPUState *env, target_ulong *physical,int ret =TLBRET_MATCH ;#if 0 -if (logfile) { -fprintf (logfile,"user mode %d h %08x\n" , - user_mode, env->hflags); - } +qemu_log ("user mode %d h %08x\n" , user_mode, env->hflags);#endif if (address <= (int32_t )0x7FFFFFFFUL ) {@@ -198,10 +195,8 @@ static int get_physical_address (CPUState *env, target_ulong *physical, } }#if 0 -if (logfile) { -fprintf (logfile, TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , - address, rw, access_type, *physical, *prot, ret); - } +qemu_log (TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , + address, rw, access_type, *physical, *prot, ret);#endif return ret;@@ -233,13 +228,11 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,int access_type;int ret =0 ; -if (logfile) {#if 0 -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif -fprintf (logfile,"%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , - __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); - } +qemu_log ("%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , + __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); rw &=1 ;@@ -252,10 +245,8 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,#else ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -if (logfile) { -fprintf (logfile,"%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , - __func__, address, ret, physical, prot); - } +qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , + __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot,@@ -357,14 +348,14 @@ void do_interrupt (CPUState *env)int cause =-1 ;const char *name; -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) {if (env->exception_index <0 || env->exception_index >EXCP_LAST ) name ="unknown" ;else name = excp_names[env->exception_index]; -fprintf (logfile,"%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , - __func__, env->active_tc.PC, env->CP0_EPC, name); +qemu_log ("%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , + __func__, env->active_tc.PC, env->CP0_EPC, name); }if (env->exception_index ==EXCP_EXT_INTERRUPT && (env->hflags &MIPS_HFLAG_DM ))@@ -558,15 +549,12 @@ void do_interrupt (CPUState *env) env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default : -if (logfile) { -fprintf (logfile,"Invalid MIPS exception %d. Exiting\n" , - env->exception_index); - } +qemu_log ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);printf ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);exit (1 ); } -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { - fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) { + qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,target-mips/op_helper.c +33
-33@@ -29,8 +29,8 @@void do_raise_exception_err (uint32_t exception,int error_code) {#if 1 -if (logfile && exception <0x100 ) -fprintf (logfile,"%s: %d %d\n" , __func__, exception, error_code); +if (exception <0x100 ) +qemu_log ("%s: %d %d\n" , __func__, exception, error_code);#endif env->exception_index = exception; env->error_code = error_code;@@ -1342,21 +1342,21 @@ void do_mtc0_datahi (target_ulong t0)void do_mtc0_status_debug (uint32_t old,uint32_t val) { -fprintf (logfile,"Status %08x (%08x) => %08x (%08x) Cause %08x" , +qemu_log ("Status %08x (%08x) => %08x (%08x) Cause %08x" , old, old & env->CP0_Cause & CP0Ca_IP_mask, val, val & env->CP0_Cause & CP0Ca_IP_mask, env->CP0_Cause);switch (env->hflags &MIPS_HFLAG_KSU ) { -case MIPS_HFLAG_UM :fputs (", UM\n" , logfile);break ; -case MIPS_HFLAG_SM :fputs (", SM\n" , logfile);break ; -case MIPS_HFLAG_KM :fputs ("\n" , logfile);break ; +case MIPS_HFLAG_UM :qemu_log (", UM\n" );break ; +case MIPS_HFLAG_SM :qemu_log (", SM\n" );break ; +case MIPS_HFLAG_KM :qemu_log ("\n" );break ;default :cpu_abort (env,"Invalid MMU mode!\n" );break ; } }void do_mtc0_status_irqraise_debug (void ) { -fprintf (logfile,"Raise pending IRQs\n" ); +qemu_log ("Raise pending IRQs\n" ); }/* MIPS MT functions */ @@ -1705,35 +1705,38 @@ target_ulong do_ei (void)static void debug_pre_eret (void ) { -fprintf (logfile,"ERET: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, - env->active_tc.PC, env->CP0_EPC); -if (env->CP0_Status & (1 << CP0St_ERL)) -fprintf (logfile," ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC); -if (env->hflags &MIPS_HFLAG_DM ) -fprintf (logfile," DEPC " TARGET_FMT_lx, env->CP0_DEPC); -fputs ("\n" , logfile); +if (loglevel &CPU_LOG_EXEC ) { +qemu_log ("ERET: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, + env->active_tc.PC, env->CP0_EPC); +if (env->CP0_Status & (1 << CP0St_ERL)) +qemu_log (" ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC); +if (env->hflags &MIPS_HFLAG_DM ) +qemu_log (" DEPC " TARGET_FMT_lx, env->CP0_DEPC); +qemu_log ("\n" ); + } }static void debug_post_eret (void ) { -fprintf (logfile," => PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, - env->active_tc.PC, env->CP0_EPC); -if (env->CP0_Status & (1 << CP0St_ERL)) -fprintf (logfile," ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC); -if (env->hflags &MIPS_HFLAG_DM ) -fprintf (logfile," DEPC " TARGET_FMT_lx, env->CP0_DEPC); -switch (env->hflags &MIPS_HFLAG_KSU ) { -case MIPS_HFLAG_UM :fputs (", UM\n" , logfile);break ; -case MIPS_HFLAG_SM :fputs (", SM\n" , logfile);break ; -case MIPS_HFLAG_KM :fputs ("\n" , logfile);break ; -default :cpu_abort (env,"Invalid MMU mode!\n" );break ; +if (loglevel &CPU_LOG_EXEC ) { +qemu_log (" => PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx, + env->active_tc.PC, env->CP0_EPC); +if (env->CP0_Status & (1 << CP0St_ERL)) +qemu_log (" ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC); +if (env->hflags &MIPS_HFLAG_DM ) +qemu_log (" DEPC " TARGET_FMT_lx, env->CP0_DEPC); +switch (env->hflags &MIPS_HFLAG_KSU ) { +case MIPS_HFLAG_UM :qemu_log (", UM\n" );break ; +case MIPS_HFLAG_SM :qemu_log (", SM\n" );break ; +case MIPS_HFLAG_KM :qemu_log ("\n" );break ; +default :cpu_abort (env,"Invalid MMU mode!\n" );break ; + } } }void do_eret (void ) { -if (loglevel &CPU_LOG_EXEC ) -debug_pre_eret (); +debug_pre_eret ();if (env->CP0_Status & (1 << CP0St_ERL)) { env->active_tc.PC = env->CP0_ErrorEPC; env->CP0_Status &= ~(1 << CP0St_ERL);@@ -1742,20 +1745,17 @@ void do_eret (void) env->CP0_Status &= ~(1 << CP0St_EXL); }compute_hflags (env); -if (loglevel &CPU_LOG_EXEC ) -debug_post_eret (); +debug_post_eret (); env->CP0_LLAddr =1 ; }void do_deret (void ) { -if (loglevel &CPU_LOG_EXEC ) -debug_pre_eret (); +debug_pre_eret (); env->active_tc.PC = env->CP0_DEPC; env->hflags &=MIPS_HFLAG_DM ;compute_hflags (env); -if (loglevel &CPU_LOG_EXEC ) -debug_post_eret (); +debug_post_eret (); env->CP0_LLAddr =1 ; }#endif /* !CONFIG_USER_ONLY */ target-mips/translate.c +14
-25@@ -514,18 +514,11 @@ static const char *fregnames_h[] = "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", };#ifdef MIPS_DEBUG_DISAS -#define MIPS_DEBUG(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) { \ - fprintf(logfile, TARGET_FMT_lx ": %08x " fmt "\n", \ - ctx->pc, ctx->opcode , ##args); \ - } \ -} while (0) -#define LOG_DISAS (...) \ - do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +#define MIPS_DEBUG(fmt, args...) \ + qemu_log_mask(CPU_LOG_TB_IN_ASM, \ + TARGET_FMT_lx ": %08x " fmt "\n", \ + ctx->pc, ctx->opcode , ##args) +#define LOG_DISAS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else #define MIPS_DEBUG(fmt, args...) do { } while(0)#define LOG_DISAS (...) do { } while (0)@@ -8184,8 +8177,8 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (search_pc && loglevel) -fprintf (logfile,"search pc %d\n" , search_pc); +if (search_pc) +qemu_log ("search pc %d\n" , search_pc); pc_start = tb->pc;/* Leave some spare opc slots for branch handling. */ @@ -8207,11 +8200,9 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,if (max_insns ==0 ) max_insns =CF_COUNT_MASK ;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"------------------------------------------------\n" ); -/* FIXME: This may print out stale hflags from env... */ -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU ,"------------------------------------------------\n" ); +/* FIXME: This may print out stale hflags from env... */ +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif LOG_DISAS ("\ntb %p idx %d hflags %04x\n" , tb, ctx.mem_idx, ctx.hflags);gen_icount_start ();@@ -8303,13 +8294,11 @@ done_generating:#ifdef DEBUG_DISAS LOG_DISAS ("\n" );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); - } -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); } +qemu_log_mask (CPU_LOG_TB_CPU ,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags);#endif }target-ppc/helper.c +29
-69@@ -40,14 +40,8 @@//#define FLUSH_ALL_TLBS #ifdef DEBUG_MMU -# define LOG_MMU (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) -# define LOG_MMU_STATE (env) do { \ - if (loglevel) \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } while (0) +# define LOG_MMU (...) qemu_log(__VA_ARGS__) +# define LOG_MMU_STATE (env) log_cpu_state((env), 0)#else # define LOG_MMU (...) do { } while (0)# define LOG_MMU_STATE (...) do { } while (0)@@ -55,37 +49,25 @@#ifdef DEBUG_SOFTWARE_TLB -# define LOG_SWTLB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_SWTLB (...) qemu_log(__VA_ARGS__)#else # define LOG_SWTLB (...) do { } while (0)#endif #ifdef DEBUG_BATS -# define LOG_BATS (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_BATS (...) qemu_log(__VA_ARGS__)#else # define LOG_BATS (...) do { } while (0)#endif #ifdef DEBUG_SLB -# define LOG_SLB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_SLB (...) qemu_log(__VA_ARGS__)#else # define LOG_SLB (...) do { } while (0)#endif #ifdef DEBUG_EXCEPTIONS -# define LOG_EXCP (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_EXCP (...) qemu_log(__VA_ARGS__)#else # define LOG_EXCP (...) do { } while (0)#endif @@ -257,8 +239,7 @@ static always_inline int _pte_check (mmu_ctx_t *ctx, int is_64b,if (ctx->raddr != (target_phys_addr_t)-1ULL ) {/* all matches should have equal RPN, WIMG & PP */ if ((ctx->raddr & mmask) != (pte1 & mmask)) { -if (loglevel !=0 ) -fprintf (logfile,"Bad RPN/WIMG/PP\n" ); +qemu_log ("Bad RPN/WIMG/PP\n" );return -3 ; } }@@ -988,11 +969,11 @@ static always_inline int get_segment (CPUState *env, mmu_ctx_t *ctx, } }#if defined (DUMP_PAGE_TABLES ) -if (loglevel !=0 ) { +if (qemu_log_enabled ()) {target_phys_addr_t curaddr;uint32_t a0, a1, a2, a3; -fprintf (logfile,"Page table: " PADDRX " len " PADDRX "\n" , - sdr, mask +0x80 ); +qemu_log ("Page table: " PADDRX " len " PADDRX "\n" , + sdr, mask +0x80 );for (curaddr = sdr; curaddr < (sdr + mask +0x80 ); curaddr +=16 ) { a0 =ldl_phys (curaddr);@@ -1000,8 +981,8 @@ static always_inline int get_segment (CPUState *env, mmu_ctx_t *ctx, a2 =ldl_phys (curaddr +8 ); a3 =ldl_phys (curaddr +12 );if (a0 !=0 || a1 !=0 || a2 !=0 || a3 !=0 ) { -fprintf (logfile,PADDRX ": %08x %08x %08x %08x\n" , - curaddr, a0, a1, a2, a3); +qemu_log (PADDRX ": %08x %08x %08x %08x\n" , + curaddr, a0, a1, a2, a3); } } }@@ -1037,10 +1018,8 @@ static always_inline int get_segment (CPUState *env, mmu_ctx_t *ctx,/* eciwx or ecowx */ return -4 ;default : -if (logfile) { -fprintf (logfile,"ERROR: instruction should not need " +qemu_log ("ERROR: instruction should not need " "address translation\n" ); - }return -4 ; }if ((rw ==1 || ctx->key !=1 ) && (rw ==0 || ctx->key !=0 )) {@@ -1064,8 +1043,7 @@ static always_inline int ppcemb_tlb_check (CPUState *env, ppcemb_tlb_t *tlb,/* Check valid flag */ if (!(tlb->prot &PAGE_VALID )) { -if (loglevel !=0 ) -fprintf (logfile,"%s: TLB %d not valid\n" , __func__, i); +qemu_log ("%s: TLB %d not valid\n" , __func__, i);return -1 ; } mask = ~(tlb->size -1 );@@ -1335,9 +1313,7 @@ int get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr,int ret;#if 0 -if (loglevel !=0 ) { -fprintf (logfile,"%s\n" , __func__); - } +qemu_log ("%s\n" , __func__);#endif if ((access_type ==ACCESS_CODE && msr_ir ==0 ) || (access_type !=ACCESS_CODE && msr_dr ==0 )) {@@ -1388,10 +1364,8 @@ int get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr, } }#if 0 -if (loglevel !=0 ) { -fprintf (logfile,"%s address " ADDRX " => %d " PADDRX "\n" , +qemu_log ("%s address " ADDRX " => %d " PADDRX "\n" , __func__, eaddr, ret, ctx->raddr); - }#endif return ret;@@ -2015,7 +1989,7 @@ void ppc_hw_interrupt (CPUState *env)#else /* defined (CONFIG_USER_ONLY) */ static always_inline void dump_syscall (CPUState *env) { -fprintf (logfile,"syscall r0=" REGX " r3=" REGX " r4=" REGX +qemu_log_mask (CPU_LOG_INT ,"syscall r0=" REGX " r3=" REGX " r4=" REGX " r5=" REGX " r6=" REGX " nip=" ADDRX "\n" ,ppc_dump_gpr (env,0 ),ppc_dump_gpr (env,3 ),ppc_dump_gpr (env,4 ),ppc_dump_gpr (env,5 ),ppc_dump_gpr (env,6 ), env->nip);@@ -2041,10 +2015,8 @@ static always_inline void powerpc_excp (CPUState *env, lpes1 =1 ; } -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"Raise exception at " ADDRX " => %08x (%02x)\n" , - env->nip, excp, env->error_code); - } +qemu_log_mask (CPU_LOG_INT ,"Raise exception at " ADDRX " => %08x (%02x)\n" , + env->nip, excp, env->error_code); msr = env->msr; new_msr = msr; srr0 =SPR_SRR0 ;@@ -2078,8 +2050,8 @@ static always_inline void powerpc_excp (CPUState *env,/* Machine check exception is not enabled. * Enter checkstop state. */ -if (loglevel !=0 ) { -fprintf (logfile,"Machine check while not allowed. " +if (qemu_log_enabled ()) { +qemu_log ("Machine check while not allowed. " "Entering checkstop state\n" ); }else { fprintf(stderr, "Machine check while not allowed. "@@ -2199,9 +2171,7 @@ static always_inline void powerpc_excp (CPUState *env,return ; } } -if (loglevel &CPU_LOG_INT ) { -dump_syscall (env); - } +dump_syscall (env); new_msr &= ~((target_ulong )1 <<MSR_RI ); lev = env->error_code;if (lev ==1 || (lpes0 ==0 && lpes1 ==0 ))@@ -2415,7 +2385,7 @@ static always_inline void powerpc_excp (CPUState *env,case POWERPC_EXCP_7x5: tlb_miss:#if defined (DEBUG_SOFTWARE_TLB ) -if (loglevel !=0 ) { +if (qemu_log_enabled ()) {const unsigned char *es;target_ulong *miss, *cmp;int en;@@ -2433,7 +2403,7 @@ static always_inline void powerpc_excp (CPUState *env, miss = &env->spr[SPR_DMISS ]; cmp = &env->spr[SPR_DCMP ]; } - fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX + qemu_log("6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX " H1 " ADDRX " H2 " ADDRX " %08x\n", es, en, *miss, en, *cmp, env->spr[SPR_HASH1], env->spr[SPR_HASH2],@@ -2448,7 +2418,7 @@ static always_inline void powerpc_excp (CPUState *env,case POWERPC_EXCP_74xx: tlb_miss_74xx:#if defined (DEBUG_SOFTWARE_TLB ) -if (loglevel !=0 ) { +if (qemu_log_enabled ()) {const unsigned char *es;target_ulong *miss, *cmp;int en;@@ -2466,7 +2436,7 @@ static always_inline void powerpc_excp (CPUState *env, miss = &env->spr[SPR_TLBMISS ]; cmp = &env->spr[SPR_PTEHI ]; } -fprintf (logfile,"74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX +qemu_log ("74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX " %08x\n" , es, en, *miss, en, *cmp, env->error_code); }@@ -2618,11 +2588,9 @@ void ppc_hw_interrupt (CPUPPCState *env)int hdice;#if 0 -if (loglevel &CPU_LOG_INT ) { -fprintf (logfile,"%s: %p pending %08x req %08x me %d ee %d\n" , +qemu_log_mask (CPU_LOG_INT ,"%s: %p pending %08x req %08x me %d ee %d\n" , __func__, env, env->pending_interrupts, env->interrupt_request, (int )msr_me, (int )msr_ee); - }#endif /* External reset */ if (env->pending_interrupts & (1 <<PPC_INTERRUPT_RESET )) {@@ -2734,16 +2702,8 @@ void ppc_hw_interrupt (CPUPPCState *env)void cpu_dump_rfi (target_ulong RA ,target_ulong msr) { -FILE *f; - -if (logfile) { - f = logfile; - }else { - f = stdout; -return ; - } -fprintf (f,"Return from exception at " ADDRX " with flags " ADDRX "\n" , -RA , msr); +qemu_log ("Return from exception at " ADDRX " with flags " ADDRX "\n" , +RA , msr); }void cpu_ppc_reset (void *opaque)target-ppc/op_helper.c +8
-25@@ -29,10 +29,7 @@//#define DEBUG_SOFTWARE_TLB #ifdef DEBUG_SOFTWARE_TLB -# define LOG_SWTLB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_SWTLB (...) qemu_log(__VA_ARGS__)#else # define LOG_SWTLB (...) do { } while (0)#endif @@ -84,18 +81,14 @@ void helper_store_cr (target_ulong val, uint32_t mask)/* SPR accesses */ void helper_load_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Read SPR %d %03x => " ADDRX "\n" , +qemu_log ("Read SPR %d %03x => " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }void helper_store_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Write SPR %d %03x <= " ADDRX "\n" , +qemu_log ("Write SPR %d %03x <= " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }target_ulong helper_load_tbl (void )@@ -192,10 +185,8 @@ void helper_store_hid0_601 (target_ulong val) env->hflags_nmsr &= ~(1 <<MSR_LE ); env->hflags_nmsr |= (1 <<MSR_LE ) & (((val >>3 ) &1 ) <<MSR_LE ); env->hflags |= env->hflags_nmsr; -if (loglevel !=0 ) { -fprintf (logfile,"%s: set endianness to %c => " ADDRX "\n" , +qemu_log ("%s: set endianness to %c => " ADDRX "\n" , __func__, val &0x8 ?'l' :'b' , env->hflags); - } } env->spr[SPR_HID0 ] = (uint32_t )val; }@@ -1870,15 +1861,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)target_ulong val =0 ;if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_read (env->dcr_env, dcrn, &val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR read error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR read error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }@@ -1888,15 +1875,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)void helper_store_dcr (target_ulong dcrn,target_ulong val) {if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_write (env->dcr_env, dcrn, val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR write error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR write error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }target-ppc/translate.c +21
-34@@ -43,10 +43,7 @@//#define DO_PPC_STATISTICS #ifdef PPC_DEBUG_DISAS -# define LOG_DISAS (...) do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DISAS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else # define LOG_DISAS (...) do { } while (0)#endif @@ -3900,10 +3897,8 @@ static always_inline void gen_op_mfspr (DisasContext *ctx)* allowing userland application to read the PVR */ if (sprn !=SPR_PVR ) { -if (loglevel !=0 ) { -fprintf (logfile,"Trying to read privileged spr %d %03x at " +qemu_log ("Trying to read privileged spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip); - }printf ("Trying to read privileged spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip); }@@ -3911,10 +3906,8 @@ static always_inline void gen_op_mfspr (DisasContext *ctx) } }else {/* Not defined */ -if (loglevel !=0 ) { -fprintf (logfile,"Trying to read invalid spr %d %03x at " +qemu_log ("Trying to read invalid spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip); - }printf ("Trying to read invalid spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip);gen_inval_exception (ctx,POWERPC_EXCP_INVAL_SPR );@@ -4046,20 +4039,16 @@ GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000001, PPC_MISC) (*write_cb)(ctx, sprn,rS (ctx->opcode)); }else {/* Privilege exception */ -if (loglevel !=0 ) { -fprintf (logfile,"Trying to write privileged spr %d %03x at " +qemu_log ("Trying to write privileged spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip); - }printf ("Trying to write privileged spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip);gen_inval_exception (ctx,POWERPC_EXCP_PRIV_REG ); } }else {/* Not defined */ -if (loglevel !=0 ) { -fprintf (logfile,"Trying to write invalid spr %d %03x at " +qemu_log ("Trying to write invalid spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip); - }printf ("Trying to write invalid spr %d %03x at " ADDRX "\n" , sprn, sprn, ctx->nip);gen_inval_exception (ctx,POWERPC_EXCP_INVAL_SPR );@@ -8267,11 +8256,11 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, }/* Is opcode *REALLY* valid ? */ if (unlikely (handler->handler == &gen_invalid)) { -if (loglevel !=0 ) { -fprintf (logfile,"invalid/unsupported opcode: " -"%02x - %02x - %02x (%08x) " ADDRX " %d\n" , -opc1 (ctx.opcode),opc2 (ctx.opcode), -opc3 (ctx.opcode), ctx.opcode, ctx.nip -4 , (int )msr_ir); +if (qemu_log_enabled ()) { +qemu_log ("invalid/unsupported opcode: " +"%02x - %02x - %02x (%08x) " ADDRX " %d\n" , +opc1 (ctx.opcode),opc2 (ctx.opcode), +opc3 (ctx.opcode), ctx.opcode, ctx.nip -4 , (int )msr_ir); }else { printf("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " ADDRX " %d\n",@@ -8280,12 +8269,12 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, } }else {if (unlikely ((ctx.opcode & handler->inval) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"invalid bits: %08x for opcode: " -"%02x - %02x - %02x (%08x) " ADDRX "\n" , - ctx.opcode & handler->inval,opc1 (ctx.opcode), -opc2 (ctx.opcode),opc3 (ctx.opcode), - ctx.opcode, ctx.nip -4 ); +if (qemu_log_enabled ()) { +qemu_log ("invalid bits: %08x for opcode: " +"%02x - %02x - %02x (%08x) " ADDRX "\n" , + ctx.opcode & handler->inval,opc1 (ctx.opcode), +opc2 (ctx.opcode),opc3 (ctx.opcode), + ctx.opcode, ctx.nip -4 ); }else { printf("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " ADDRX "\n",@@ -8343,17 +8332,15 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, tb->icount = num_insns; }#if defined(DEBUG_DISAS ) -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"---------------- excp: %04x\n" , ctx.exception); -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU ,"---------------- excp: %04x\n" , ctx.exception); +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (loglevel &CPU_LOG_TB_IN_ASM ) {int flags; flags = env->bfd_mach; flags |= ctx.le_mode <<16 ; -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.nip - pc_start, flags); -fprintf (logfile,"\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.nip - pc_start, flags); +qemu_log ("\n" ); }#endif }target-sh4/helper.c +3
-3@@ -151,9 +151,9 @@ void do_interrupt(CPUState * env) expname = do_irq ?"interrupt" :"???" ;break ; } -fprintf (logfile,"exception 0x%03x [%s] raised\n" , - irq_vector, expname); -cpu_dump_state (env, logfile, fprintf,0 ); +qemu_log ("exception 0x%03x [%s] raised\n" , + irq_vector, expname); +log_cpu_state (env,0 ); } env->ssr = env->sr;target-sh4/translate.c +7
-10@@ -1829,11 +1829,9 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb, ctx.features = env->features;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile, -"------------------------------------------------\n" ); -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU , +"------------------------------------------------\n" ); +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif ii =-1 ;@@ -1926,13 +1924,12 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,#ifdef DEBUG_DISAS #ifdef SH4_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"\n" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"\n" );#endif if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN:\n" );/* , lookup_symbol(pc_start)); */ -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("IN:\n" );/* , lookup_symbol(pc_start)); */ +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); }#endif }target-sparc/op_helper.c +10
-10@@ -2829,23 +2829,23 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64 +qemu_log ("%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64" SP=%016" PRIx64"\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;@@ -2956,22 +2956,22 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , +qemu_log ("%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;target-sparc/translate.c +6
-9@@ -4829,8 +4829,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, } }if (spc) { -if (loglevel >0 ) -fprintf (logfile,"Search PC...\n" ); +qemu_log ("Search PC...\n" ); j = gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;@@ -4897,9 +4896,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb,while (lj <= j) gen_opc_instr_start[lj++] =0 ;#if 0 -if (loglevel >0 ) { -page_dump (logfile); - } +log_page_dump ();#endif gen_opc_jump_pc[0 ] = dc->jump_pc[0 ]; gen_opc_jump_pc[1 ] = dc->jump_pc[1 ];@@ -4909,10 +4906,10 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, }#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, last_pc +4 - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, last_pc +4 - pc_start,0 ); +qemu_log ("\n" ); }#endif }tcg/tcg.c +4
-4@@ -1879,9 +1879,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP )) { -fprintf (logfile,"OP:\n" ); +qemu_log ("OP:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif @@ -1895,9 +1895,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP_OPT )) { -fprintf (logfile,"OP after la:\n" ); +qemu_log ("OP after la:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif translate-all.c +3
-3@@ -128,9 +128,9 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OUT_ASM ) { -fprintf (logfile,"OUT: [size=%d]\n" , *gen_code_size_ptr); -disas (logfile, tb->tc_ptr, *gen_code_size_ptr); -fprintf (logfile,"\n" ); +qemu_log ("OUT: [size=%d]\n" , *gen_code_size_ptr); +log_disas (tb->tc_ptr, *gen_code_size_ptr); +qemu_log ("\n" );fflush (logfile); }#endif vl.c +1
-4@@ -156,10 +156,7 @@#ifdef DEBUG_IOPORT -# define LOG_IOPORT (...) do { \ - if (loglevel & CPU_LOG_IOPORT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IOPORT (...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else # define LOG_IOPORT (...) do { } while (0)#endif
[Qemu-devel] Re: [PATCH 3/5] Convert references to logfile/loglevel to use qemu_log*() macros
Quoted 23 lines · Anthony Liguori
Quoted 5 lines · Eduardo Habkost
This is a large patch that changes all occurrences of logfile/loglevel global variables to use the new qemu_log*() macros.
Signed-off-by Eduardo Habkost <[email protected]>I applied the first two. The first one had a conflict but I repaired it. This one failed miserably:
Hunk #2 FAILED at 195.
1 out of 6 hunks FAILED -- saving rejects to file target-mips/helper.c.rej patching filetarget-mips/op_helper.c
Hunk #1 succeeded at 29 with fuzz 2.
missing header for unified diff at line 1142 of patch
can't find file to patch at input line 1142
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|env->error_code=error_code;
--------------------------
File to patch: ^C
Quoted 2 lines
Can you fix this, send out again, and then ping me on IRC and I'll apply it immediately to avoid this happening again.
Here is it. I am compile-testing it right now. But the conflict was on a commented-out region, so I guess it should be ok.
Quoted 1 line
From
a4eab1e9f26d3baf86a26e6b378ae4a29f6fcc61Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <[email protected]>
Date: Wed, 10 Dec 2008 20:07:44 -0200
Subject: [PATCH] Convert references to logfile/loglevel to use qemu_log*() macros
This is a large patch that changes all occurrences of logfile/loglevel global variables to use the new qemu_log*() macros.
--- block-raw-posix.c | 4 +- bsd-user/elfload.c | 2 +- bsd-user/main.c | 28 ++++++------- cpu-exec.c | 33 +++++++--------- darwin-user/commpage.c | 4 +- darwin-user/machload.c | 4 +- darwin-user/main.c | 6 +-- darwin-user/syscall.c | 4 +- exec.c | 24 +++++------ hw/alpha_palcode.c | 15 ++----- hw/mips_timer.c | 4 +- hw/ppc.c | 10 +---- hw/ppc4xx_devs.c | 5 +-- hw/ppc_prep.c | 9 +--- kqemu.c | 11 +---- linux-user/elfload.c | 2 +- linux-user/main.c | 34 +++++++--------- linux-user/vm86.c | 2 +- target-alpha/translate.c | 15 ++----- target-arm/translate.c | 8 ++-- target-cris/helper.c | 2 +- target-cris/mmu.c | 2 +- target-cris/op_helper.c | 4 +- target-cris/translate.c | 22 ++++------ target-i386/op_helper.c | 77 +++++++++++++----------------------- target-i386/translate.c | 18 ++++----- target-m68k/translate.c | 10 ++-- target-mips/helper.c | 39 +++++++------------ target-mips/op_helper.c | 66 +++++++++++++++--------------- target-mips/translate.c | 39 +++++++------------ target-ppc/helper.c | 98 +++++++++++++-------------------------------- target-ppc/op_helper.c | 33 ++++------------ target-ppc/translate.c | 55 ++++++++++---------------- target-sh4/helper.c | 6 +- target-sh4/translate.c | 17 +++----- target-sparc/op_helper.c | 20 +++++----- target-sparc/translate.c | 15 +++---- tcg/tcg.c | 8 ++-- translate-all.c | 6 +- vl.c | 5 +-- 40 files changed, 295 insertions(+), 471 deletions(-)
block-raw-posix.c +2 -2
@@ -67,8 +67,8 @@//#define DEBUG_BLOCK #if defined(DEBUG_BLOCK ) -#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ - { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0) +#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (qemu_log_enabled()) \ + { qemu_log(formatCstr, ##args); fflush(logfile); } } while (0)#else #define DEBUG_BLOCK_PRINT(formatCstr, args...)#endif
bsd-user/elfload.c +1 -1
@@ -1456,7 +1456,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);
bsd-user/main.c +13 -15
@@ -533,21 +533,19 @@ int main(int argc, char **argv)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();
cpu-exec.c +14 -19
@@ -390,9 +390,7 @@ int cpu_exec(CPUState *env1)svm_check_intercept (SVM_EXIT_INTR ); env->interrupt_request &= ~(CPU_INTERRUPT_HARD |CPU_INTERRUPT_VIRQ ); intno =cpu_get_pic_interrupt (env); -if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"Servicing hardware INT=0x%02x\n" , intno); - } +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 );/* ensure that no TB jump will be modified as the program flow was changed */
@@ -405,8 +403,7 @@ int cpu_exec(CPUState *env1)/* FIXME: this should respect TPR */ svm_check_intercept (SVM_EXIT_VINTR ); intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector)); -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"Servicing virtual hardware INT=0x%02x\n" , intno); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing virtual hardware INT=0x%02x\n" , intno);do_interrupt (intno,0 ,0 ,0 ,1 ); env->interrupt_request &= ~CPU_INTERRUPT_VIRQ ; next_tb =0 ;
@@ -540,28 +537,28 @@ int cpu_exec(CPUState *env1)regs_to_env ();#if defined(TARGET_I386 ) env->eflags = env->eflags |helper_cc_compute_all (CC_OP ) | (DF &DF_MASK ); -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_CCOP ); env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C );#elif defined(TARGET_ARM ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SPARC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_PPC ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_MIPS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_SH4 ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_ALPHA ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#elif defined(TARGET_CRIS ) -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#else #error unsupported target CPU#endif
@@ -579,11 +576,9 @@ int cpu_exec(CPUState *env1) tb_invalidated_flag =0 ; }#ifdef DEBUG_EXEC -if ((loglevel &CPU_LOG_EXEC )) { -fprintf (logfile,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , - (long )tb->tc_ptr, tb->pc, -lookup_symbol (tb->pc)); - } +qemu_log_mask (CPU_LOG_EXEC ,"Trace 0x%08lx [" TARGET_FMT_lx"] %s\n" , + (long )tb->tc_ptr, tb->pc, +lookup_symbol (tb->pc));#endif /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct
darwin-user/commpage.c +2 -2
@@ -35,9 +35,9 @@//#define DEBUG_COMMPAGE #ifdef DEBUG_COMMPAGE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif /********************************************************************
darwin-user/machload.c +2 -2
@@ -39,9 +39,9 @@//#define DEBUG_MACHLOAD #ifdef DEBUG_MACHLOAD -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)#else -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif # define check_mach_header (x) (x.magic == MH_CIGAM)
darwin-user/main.c +2 -4
@@ -160,10 +160,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)
darwin-user/syscall.c +2 -2
@@ -69,7 +69,7 @@# define DEBUG_ENABLE_ALL () static int __DEBUG_qemu_user_force_enable = 1DEBUG_ENABLE_ALL (); -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); \ +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); \ if(__DEBUG_qemu_user_force_enable) fprintf(stderr, __VA_ARGS__); \ } while(0)#else
@@ -77,7 +77,7 @@# define DEBUG_BEGIN_ENABLE # define DEBUG_END_ENABLE -# define DPRINTF (...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0) +# define DPRINTF (...) do { qemu_log(__VA_ARGS__); } while(0)#endif enum {
exec.c +11 -13
@@ -1004,12 +1004,10 @@ static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int leint offset, b;#if 0 if (1 ) { -if (loglevel) { -fprintf (logfile,"modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , - cpu_single_env->mem_io_vaddr, len, - cpu_single_env->eip, - cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); - } +qemu_log ("modifying code at 0x%x size=%d EIP=%x PC=%08x\n" , + cpu_single_env->mem_io_vaddr, len, + cpu_single_env->eip, + cpu_single_env->eip + (long )cpu_single_env->segs[R_CS ].base); }#endif p =page_find (start >>TARGET_PAGE_BITS );
@@ -1634,17 +1632,17 @@ void cpu_abort(CPUState *env, const char *fmt, ...)#else cpu_dump_state (env, stderr, fprintf,0 );#endif -if (logfile) { -fprintf (logfile,"qemu: fatal: " ); -vfprintf (logfile, fmt, ap2); -fprintf (logfile,"\n" ); +if (qemu_log_enabled ()) { +qemu_log ("qemu: fatal: " ); +qemu_log_vprintf (fmt, ap2); +qemu_log ("\n" );#ifdef TARGET_I386 -cpu_dump_state (env, logfile, fprintf,X86_DUMP_FPU |X86_DUMP_CCOP ); +log_cpu_state (env,X86_DUMP_FPU |X86_DUMP_CCOP );#else -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif fflush (logfile); -fclose (logfile); +qemu_log_close (); }va_end (ap2);va_end (ap);
hw/alpha_palcode.c +5 -10
@@ -1061,13 +1061,11 @@ void call_pal (CPUState *env, int palcode) {target_long ret; -if (logfile !=NULL ) -fprintf (logfile,"%s: palcode %02x\n" , __func__, palcode); +qemu_log ("%s: palcode %02x\n" , __func__, palcode);switch (palcode) {case 0x83 :/* CALLSYS */ -if (logfile !=NULL ) -fprintf (logfile,"CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); +qemu_log ("CALLSYS n " TARGET_FMT_ld"\n" , env->ir[0 ]); ret =do_syscall (env, env->ir[IR_V0 ], env->ir[IR_A0 ], env->ir[IR_A1 ], env->ir[IR_A2 ], env->ir[IR_A3 ], env->ir[IR_A4 ], env->ir[IR_A5 ]);
@@ -1082,18 +1080,15 @@ void call_pal (CPUState *env, int palcode)case 0x9E :/* RDUNIQUE */ env->ir[IR_V0 ] = env->unique; -if (logfile !=NULL ) -fprintf (logfile,"RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;case 0x9F :/* WRUNIQUE */ env->unique = env->ir[IR_A0 ]; -if (logfile !=NULL ) -fprintf (logfile,"WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique); +qemu_log ("WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique);break ;default : -if (logfile !=NULL ) -fprintf (logfile,"%s: unhandled palcode %02x\n" , +qemu_log ("%s: unhandled palcode %02x\n" , __func__, palcode);exit (1 ); }
hw/mips_timer.c +1 -3
@@ -84,9 +84,7 @@ static void mips_timer_cb (void *opaque) env = opaque;#if 0 -if (logfile) { -fprintf (logfile,"%s\n" , __func__); - } +qemu_log ("%s\n" , __func__);#endif if (env->CP0_Cause & (1 << CP0Ca_DC))
hw/ppc.c +2 -8
@@ -32,20 +32,14 @@//#define PPC_DEBUG_TB #ifdef PPC_DEBUG_IRQ -# define LOG_IRQ (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IRQ (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_IRQ (...) do { } while (0)#endif #ifdef PPC_DEBUG_TB -# define LOG_TB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_TB (...) qemu_log(__VA_ARGS__)#else # define LOG_TB (...) do { } while (0)#endif
hw/ppc4xx_devs.c +1 -4
@@ -33,10 +33,7 @@#ifdef DEBUG_UIC -# define LOG_UIC (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_UIC (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)#else # define LOG_UIC (...) do { } while (0)#endif
hw/ppc_prep.c +2 -7
@@ -53,18 +53,13 @@ #define PPC_IO_DPRINTF(fmt, args...) \ do { \ if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ + qemu_log("%s: " fmt, __func__ , ##args); \ } else { \ printf("%s : " fmt, __func__ , ##args); \ } \ } while (0)#elif defined (DEBUG_PPC_IO ) -#define PPC_IO_DPRINTF(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_IOPORT) { \ - fprintf(logfile, "%s: " fmt, __func__ , ##args); \ - } \ -} while (0) +#define PPC_IO_DPRINTF(fmt, args...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else #define PPC_IO_DPRINTF(fmt, args...) do { } while (0)#endif
kqemu.c +2 -9
@@ -49,15 +49,8 @@#ifdef DEBUG -# define LOG_INT (...) do { \ - if (loglevel & CPU_LOG_INT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) -# define LOG_INT_STATE (env) \ - do { \ - if (loglevel & CPU_LOG_INT) \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } while (0) +# define LOG_INT (...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__) +# define LOG_INT_STATE (env) log_cpu_state_mask(CPU_LOG_INT, (env), 0)#else # define LOG_INT (...) do { } while (0)# define LOG_INT_STATE (env) do { } while (0)
linux-user/elfload.c +1 -1
@@ -1454,7 +1454,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,free (elf_phdata); -if (loglevel) +if (qemu_log_enabled ())load_symbols (&elf_ex, bprm->fd);if (interpreter_type !=INTERPRETER_AOUT )close (bprm->fd);
linux-user/main.c +15 -19
@@ -1057,10 +1057,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) do { \ fprintf(stderr, fmt , ##args); \ cpu_dump_state(env, stderr, fprintf, 0); \ - if (loglevel != 0) { \ - fprintf(logfile, fmt , ##args); \ - cpu_dump_state(env, logfile, fprintf, 0); \ - } \ + qemu_log(fmt, ##args); \ + log_cpu_state(env, 0); \ } while (0) void cpu_loop(CPUPPCState *env)
@@ -2396,21 +2394,19 @@ int main(int argc, char **argv, char **envp)free (target_environ); -if (loglevel) { -page_dump (logfile); - -fprintf (logfile,"start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); -fprintf (logfile,"end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -fprintf (logfile,"start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -fprintf (logfile,"start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); -fprintf (logfile,"end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -fprintf (logfile,"start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); -fprintf (logfile,"brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); -fprintf (logfile,"entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); - } +log_page_dump (); + +qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk); +qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , + info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , + info->start_data); +qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , + info->start_stack); +qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk); +qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry);target_set_brk (info->brk);syscall_init ();
linux-user/vm86.c +1 -1
@@ -30,7 +30,7 @@//#define DEBUG_VM86 #ifdef DEBUG_VM86 -# define LOG_VM86 (...) fprintf(logfile, ## __VA_ARGS__); +# define LOG_VM86 (...) qemu_log(__VA_ARGS__);#else # define LOG_VM86 (...) do { } while (0)#endif
target-alpha/translate.c +5 -10
@@ -39,10 +39,7 @@#ifdef ALPHA_DEBUG_DISAS -# define LOG_DISAS (...) do { \ - if (logfile) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DISAS (...) qemu_log(__VA_ARGS__)#else # define LOG_DISAS (...) do { } while (0)#endif
@@ -2444,13 +2441,11 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, tb->icount = num_insns; }#if definedALPHA_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,0 ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,1 ); -fprintf (logfile,"\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,1 ); +qemu_log ("\n" ); }#endif }
target-arm/translate.c +4 -4
@@ -8871,10 +8871,10 @@ done_generating:#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start, env->thumb); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start, env->thumb); +qemu_log ("\n" ); }#endif if (search_pc) {
target-cris/helper.c +1 -1
@@ -34,7 +34,7 @@#ifdef CRIS_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
target-cris/mmu.c +1 -1
@@ -32,7 +32,7 @@#ifdef DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
target-cris/op_helper.c +2 -2
@@ -30,7 +30,7 @@#ifdef CRIS_OP_HELPER_DEBUG #define D (x) x -#define D_LOG (...) fprintf(logfile, ## __VA_ARGS__) +#define D_LOG (...) qemu_log(__VA__ARGS__)#else #define D (x)#define D_LOG (...) do { } while (0)
@@ -117,7 +117,7 @@ void helper_spc_write(uint32_t new_spc)void helper_dump (uint32_t a0,uint32_t a1,uint32_t a2) { - (fprintf (logfile,"%s: a0=%x a1=%x\n" , __func__, a0, a1)); +qemu_log ("%s: a0=%x a1=%x\n" , __func__, a0, a1); }/* Used by the tlb decoder. */
target-cris/translate.c +9 -13
@@ -44,10 +44,7 @@#define DISAS_CRIS 0#if DISAS_CRIS -# define LOG_DIS (...) do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else # define LOG_DIS (...) do { } while (0)#endif
@@ -131,7 +128,7 @@ typedef struct DisasContext {static void gen_BUG (DisasContext *dc,const char *file,int line) {printf ("BUG: pc=%x %s %d\n" , dc->pc, file, line); -fprintf (logfile,"BUG: pc=%x %s %d\n" , dc->pc, file, line); +qemu_log ("BUG: pc=%x %s %d\n" , dc->pc, file, line);cpu_abort (dc->env,"%s:%d\n" , file, line); }
@@ -798,7 +795,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,t_gen_subx_carry (dc, dst);break ;default : -fprintf (logfile,"illegal ALU op.\n" ); +qemu_log ("illegal ALU op.\n" );BUG ();break ; }
@@ -3147,8 +3144,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (!logfile) - logfile = stderr; +qemu_log_try_set_file (stderr);/* Odd PC indicates that branch is rexecuting due to exception in the * delayslot, like in real hw.
@@ -3184,7 +3180,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, dc->cpustate_changed =0 ;if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile, +qemu_log ("srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n" "pid=%x usp=%x\n" "%x.%x.%x.%x\n"
@@ -3202,8 +3198,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, env->regs[10 ], env->regs[11 ], env->regs[12 ], env->regs[13 ], env->regs[14], env->regs[15]); -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); } next_page_start = (pc_start &TARGET_PAGE_MASK ) +TARGET_PAGE_SIZE ;
@@ -3336,8 +3332,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS #if !DISAS_CRIS if (loglevel &CPU_LOG_TB_IN_ASM ) { -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\nisize=%d osize=%zd\n" , +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\nisize=%d osize=%zd\n" , dc->pc - pc_start, gen_opc_ptr - gen_opc_buf); }#endif
target-i386/op_helper.c +28 -49
191 lines not on this page · raw message
target-i386/translate.c +8 -10
@@ -7675,21 +7675,19 @@ static inline void gen_intermediate_code_internal(CPUState *env, }#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -cpu_dump_state (env, logfile, fprintf,X86_DUMP_CCOP ); - } +log_cpu_state_mask (CPU_LOG_TB_CPU , env,X86_DUMP_CCOP );if (loglevel &CPU_LOG_TB_IN_ASM ) {int disas_flags; -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));#ifdef TARGET_X86_64 if (dc->code64) disas_flags =2 ; else#endif disas_flags = !dc->code32; -target_disas (logfile, pc_start, pc_ptr - pc_start, disas_flags); -fprintf (logfile,"\n" ); +log_target_disas (pc_start, pc_ptr - pc_start, disas_flags); +qemu_log ("\n" ); }#endif
@@ -7716,13 +7714,13 @@ void gen_pc_load(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OP ) {int i; -fprintf (logfile,"RESTORE:\n" ); +qemu_log ("RESTORE:\n" );for (i =0 ;i <= pc_pos; i++) {if (gen_opc_instr_start[i]) { -fprintf (logfile,"0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); +qemu_log ("0x%04x: " TARGET_FMT_lx"\n" , i, gen_opc_pc[i]); } } -fprintf (logfile,"spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , +qemu_log ("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx" cs_base=%x\n" , searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base, (uint32_t )tb->cs_base); }
target-m68k/translate.c +5 -5
@@ -165,7 +165,7 @@ typedef void (*disas_proc)(DisasContext *, uint16_t);#define DISAS_INSN (name) \ static void real_disas_##name (DisasContext *s, uint16_t insn); \ static void disas_##name (DisasContext *s, uint16_t insn) { \ - if (logfile) fprintf(logfile, "Dispatch " #name "\n"); \ + qemu_log("Dispatch " #name "\n"); \ real_disas_##name(s, insn); } \ static void real_disas_##name (DisasContext *s, uint16_t insn)#else
@@ -3064,10 +3064,10 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"----------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, dc->pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("----------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, dc->pc - pc_start,0 ); +qemu_log ("\n" ); }#endif if (search_pc) {
target-mips/helper.c +14 -25
@@ -117,10 +117,7 @@ static int get_physical_address (CPUState *env, target_ulong *physical,int ret =TLBRET_MATCH ;#if 0 -if (logfile) { -fprintf (logfile,"user mode %d h %08x\n" , - user_mode, env->hflags); - } +qemu_log ("user mode %d h %08x\n" , user_mode, env->hflags);#endif if (address <= (int32_t )0x7FFFFFFFUL ) {
@@ -198,9 +195,8 @@ static int get_physical_address (CPUState *env, target_ulong *physical, } }#if 0 -if (logfile) { -fprintf (logfile, TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , - address, rw, access_type, *physical, *prot, ret); +qemu_log (TARGET_FMT_lx" %d %d => " TARGET_FMT_lx" %d (%d)\n" , + address, rw, access_type, *physical, *prot, ret); }#endif
@@ -233,13 +229,11 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,int access_type;int ret =0 ; -if (logfile) {#if 0 -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#endif -fprintf (logfile,"%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , - __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); - } +qemu_log ("%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , + __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); rw &=1 ;
@@ -252,10 +246,8 @@ int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,#else ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -if (logfile) { -fprintf (logfile,"%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , - __func__, address, ret, physical, prot); - } +qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_lx" prot %d\n" , + __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot,
@@ -357,14 +349,14 @@ void do_interrupt (CPUState *env)int cause =-1 ;const char *name; -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) {if (env->exception_index <0 || env->exception_index >EXCP_LAST ) name ="unknown" ;else name = excp_names[env->exception_index]; -fprintf (logfile,"%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , - __func__, env->active_tc.PC, env->CP0_EPC, name); +qemu_log ("%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , + __func__, env->active_tc.PC, env->CP0_EPC, name); }if (env->exception_index ==EXCP_EXT_INTERRUPT && (env->hflags &MIPS_HFLAG_DM ))
@@ -558,15 +550,12 @@ void do_interrupt (CPUState *env) env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default : -if (logfile) { -fprintf (logfile,"Invalid MIPS exception %d. Exiting\n" , - env->exception_index); - } +qemu_log ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);printf ("Invalid MIPS exception %d. Exiting\n" , env->exception_index);exit (1 ); } -if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) { - fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" +if (qemu_log_enabled () && env->exception_index !=EXCP_EXT_INTERRUPT ) { + qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
target-mips/op_helper.c +33 -33
117 lines not on this page · raw message
target-mips/translate.c +14 -25
@@ -514,18 +514,11 @@ static const char *fregnames_h[] = "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", };#ifdef MIPS_DEBUG_DISAS -#define MIPS_DEBUG(fmt, args...) \ -do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) { \ - fprintf(logfile, TARGET_FMT_lx ": %08x " fmt "\n", \ - ctx->pc, ctx->opcode , ##args); \ - } \ -} while (0) -#define LOG_DISAS (...) \ - do { \ - if (loglevel & CPU_LOG_TB_IN_ASM) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +#define MIPS_DEBUG(fmt, args...) \ + qemu_log_mask(CPU_LOG_TB_IN_ASM, \ + TARGET_FMT_lx ": %08x " fmt "\n", \ + ctx->pc, ctx->opcode , ##args) +#define LOG_DISAS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else #define MIPS_DEBUG(fmt, args...) do { } while(0)#define LOG_DISAS (...) do { } while (0)
@@ -8180,8 +8173,8 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,int num_insns;int max_insns; -if (search_pc && loglevel) -fprintf (logfile,"search pc %d\n" , search_pc); +if (search_pc) +qemu_log ("search pc %d\n" , search_pc); pc_start = tb->pc;/* Leave some spare opc slots for branch handling. */
@@ -8203,11 +8196,9 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,if (max_insns ==0 ) max_insns =CF_COUNT_MASK ;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"------------------------------------------------\n" ); -/* FIXME: This may print out stale hflags from env... */ -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU ,"------------------------------------------------\n" ); +/* FIXME: This may print out stale hflags from env... */ +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif LOG_DISAS ("\ntb %p idx %d hflags %04x\n" , tb, ctx.mem_idx, ctx.hflags);gen_icount_start ();
@@ -8299,13 +8290,11 @@ done_generating:#ifdef DEBUG_DISAS LOG_DISAS ("\n" );if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); - } -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); } +qemu_log_mask (CPU_LOG_TB_CPU ,"---------------- %d %08x\n" , ctx.bstate, ctx.hflags);#endif }
target-ppc/helper.c +29 -69
233 lines not on this page · raw message
target-ppc/op_helper.c +8 -25
@@ -29,10 +29,7 @@//#define DEBUG_SOFTWARE_TLB #ifdef DEBUG_SOFTWARE_TLB -# define LOG_SWTLB (...) do { \ - if (loglevel) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_SWTLB (...) qemu_log(__VA_ARGS__)#else # define LOG_SWTLB (...) do { } while (0)#endif
@@ -84,18 +81,14 @@ void helper_store_cr (target_ulong val, uint32_t mask)/* SPR accesses */ void helper_load_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Read SPR %d %03x => " ADDRX "\n" , +qemu_log ("Read SPR %d %03x => " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }void helper_store_dump_spr (uint32_t sprn) { -if (loglevel !=0 ) { -fprintf (logfile,"Write SPR %d %03x <= " ADDRX "\n" , +qemu_log ("Write SPR %d %03x <= " ADDRX "\n" , sprn, sprn, env->spr[sprn]); - } }target_ulong helper_load_tbl (void )
@@ -192,10 +185,8 @@ void helper_store_hid0_601 (target_ulong val) env->hflags_nmsr &= ~(1 <<MSR_LE ); env->hflags_nmsr |= (1 <<MSR_LE ) & (((val >>3 ) &1 ) <<MSR_LE ); env->hflags |= env->hflags_nmsr; -if (loglevel !=0 ) { -fprintf (logfile,"%s: set endianness to %c => " ADDRX "\n" , +qemu_log ("%s: set endianness to %c => " ADDRX "\n" , __func__, val &0x8 ?'l' :'b' , env->hflags); - } } env->spr[SPR_HID0 ] = (uint32_t )val; }
@@ -1870,15 +1861,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)target_ulong val =0 ;if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_read (env->dcr_env, dcrn, &val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR read error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR read error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
@@ -1888,15 +1875,11 @@ target_ulong helper_load_dcr (target_ulong dcrn)void helper_store_dcr (target_ulong dcrn,target_ulong val) {if (unlikely (env->dcr_env ==NULL )) { -if (loglevel !=0 ) { -fprintf (logfile,"No DCR environment\n" ); - } +qemu_log ("No DCR environment\n" );helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_write (env->dcr_env, dcrn, val) !=0 )) { -if (loglevel !=0 ) { -fprintf (logfile,"DCR write error %d %03x\n" , (int )dcrn, (int )dcrn); - } +qemu_log ("DCR write error %d %03x\n" , (int )dcrn, (int )dcrn);helper_raise_exception_err (POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
target-ppc/translate.c +21 -34
111 lines not on this page · raw message
target-sh4/helper.c +3 -3
@@ -151,9 +151,9 @@ void do_interrupt(CPUState * env) expname = do_irq ?"interrupt" :"???" ;break ; } -fprintf (logfile,"exception 0x%03x [%s] raised\n" , - irq_vector, expname); -cpu_dump_state (env, logfile, fprintf,0 ); +qemu_log ("exception 0x%03x [%s] raised\n" , + irq_vector, expname); +log_cpu_state (env,0 ); } env->ssr = env->sr;
target-sh4/translate.c +7 -10
@@ -1840,11 +1840,9 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb, ctx.features = env->features;#ifdef DEBUG_DISAS -if (loglevel &CPU_LOG_TB_CPU ) { -fprintf (logfile, -"------------------------------------------------\n" ); -cpu_dump_state (env, logfile, fprintf,0 ); - } +qemu_log_mask (CPU_LOG_TB_CPU , +"------------------------------------------------\n" ); +log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );#endif ii =-1 ;
@@ -1937,13 +1935,12 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,#ifdef DEBUG_DISAS #ifdef SH4_DEBUG_DISAS -if (loglevel &CPU_LOG_TB_IN_ASM ) -fprintf (logfile,"\n" ); +qemu_log_mask (CPU_LOG_TB_IN_ASM ,"\n" );#endif if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"IN:\n" );/* , lookup_symbol(pc_start)); */ -target_disas (logfile, pc_start, ctx.pc - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("IN:\n" );/* , lookup_symbol(pc_start)); */ +log_target_disas (pc_start, ctx.pc - pc_start,0 ); +qemu_log ("\n" ); }#endif }
target-sparc/op_helper.c +10 -10
@@ -2829,23 +2829,23 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64 +qemu_log ("%6d: %s (v=%04x) pc=%016" PRIx64" npc=%016" PRIx64" SP=%016" PRIx64"\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;
@@ -2956,22 +2956,22 @@ void do_interrupt(CPUState *env) name ="Unknown" ; } -fprintf (logfile,"%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , +qemu_log ("%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n" , count, name, intno, env->pc, env->npc, env->regwptr[6 ]); -cpu_dump_state (env, logfile, fprintf,0 ); +log_cpu_state (env,0 );#if 0 {int i;uint8_t *ptr; -fprintf (logfile," code=" ); +qemu_log (" code=" ); ptr = (uint8_t *)env->pc;for (i =0 ; i <16 ; i++) { -fprintf (logfile," %02x" ,ldub (ptr + i)); +qemu_log (" %02x" ,ldub (ptr + i)); } -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif count++;
target-sparc/translate.c +6 -9
@@ -4829,8 +4829,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, } }if (spc) { -if (loglevel >0 ) -fprintf (logfile,"Search PC...\n" ); +qemu_log ("Search PC...\n" ); j = gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;
@@ -4897,9 +4896,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb,while (lj <= j) gen_opc_instr_start[lj++] =0 ;#if 0 -if (loglevel >0 ) { -page_dump (logfile); - } +log_page_dump ();#endif gen_opc_jump_pc[0 ] = dc->jump_pc[0 ]; gen_opc_jump_pc[1 ] = dc->jump_pc[1 ];
@@ -4909,10 +4906,10 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, }#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) { -fprintf (logfile,"--------------\n" ); -fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start)); -target_disas (logfile, pc_start, last_pc +4 - pc_start,0 ); -fprintf (logfile,"\n" ); +qemu_log ("--------------\n" ); +qemu_log ("IN: %s\n" ,lookup_symbol (pc_start)); +log_target_disas (pc_start, last_pc +4 - pc_start,0 ); +qemu_log ("\n" ); }#endif }
tcg/tcg.c +4 -4
@@ -1879,9 +1879,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP )) { -fprintf (logfile,"OP:\n" ); +qemu_log ("OP:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif
@@ -1895,9 +1895,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#ifdef DEBUG_DISAS if (unlikely (loglevel &CPU_LOG_TB_OP_OPT )) { -fprintf (logfile,"OP after la:\n" ); +qemu_log ("OP after la:\n" );tcg_dump_ops (s, logfile); -fprintf (logfile,"\n" ); +qemu_log ("\n" ); }#endif
translate-all.c +3 -3
@@ -128,9 +128,9 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_OUT_ASM ) { -fprintf (logfile,"OUT: [size=%d]\n" , *gen_code_size_ptr); -disas (logfile, tb->tc_ptr, *gen_code_size_ptr); -fprintf (logfile,"\n" ); +qemu_log ("OUT: [size=%d]\n" , *gen_code_size_ptr); +log_disas (tb->tc_ptr, *gen_code_size_ptr); +qemu_log ("\n" );fflush (logfile); }#endif
vl.c +1 -4
@@ -156,10 +156,7 @@#ifdef DEBUG_IOPORT -# define LOG_IOPORT (...) do { \ - if (loglevel & CPU_LOG_IOPORT) \ - fprintf(logfile, ## __VA_ARGS__); \ - } while (0) +# define LOG_IOPORT (...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)#else # define LOG_IOPORT (...) do { } while (0)#endif
Signature · 4 lines
1.5.6.rc3.11.g5f54d -- Eduardo
Anthony Liguori
Applied[Qemu-devel] Re: [PATCH 5/5] global s/loglevel & X/qemu_loglevel_mask(X)/
In reply to Eduardo HabkostQuoted 5 lines · Eduardo Habkost
These are references to 'loglevel' that aren't on a simple 'if (loglevel &
X)qemu_log()' statement.Signed-off-by Eduardo Habkost <[email protected]>
Applied all. Thanks!
Regards,
Anthony Liguori