Commit 93fcfe39 authored by aliguori's avatar aliguori
Browse files

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.
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6338 c046a42c-6fe2-441c-8c8c-71466251a162
parent 6cec5487
......@@ -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
......
......@@ -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);
......
......@@ -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();
......
......@@ -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
......
......@@ -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
/********************************************************************
......
......@@ -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)
......
......@@ -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)
......
......@@ -69,7 +69,7 @@
# define DEBUG_ENABLE_ALL() static int __DEBUG_qemu_user_force_enable = 1
DEBUG_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 {
......
......@@ -1004,12 +1004,10 @@ static inline void tb_invalidate_phys_page_fast(target_phys_addr_t start, int le
int 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);
......
......@@ -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);
}
......
......@@ -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))
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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);
......
......@@ -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();
......
......@@ -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
......
......@@ -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 defined ALPHA_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
}
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment