linux-user: avoid "naked" qemu_log
Ensure that all log writes are protected by qemu_loglevel_mask or, in serious cases, go to both the log and stderr. Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
1382902055
commit
120a9848c2
@ -45,6 +45,18 @@ static const char *cpu_model;
|
|||||||
unsigned long mmap_min_addr;
|
unsigned long mmap_min_addr;
|
||||||
unsigned long guest_base;
|
unsigned long guest_base;
|
||||||
int have_guest_base;
|
int have_guest_base;
|
||||||
|
|
||||||
|
#define EXCP_DUMP(env, fmt, ...) \
|
||||||
|
do { \
|
||||||
|
CPUState *cs = ENV_GET_CPU(env); \
|
||||||
|
fprintf(stderr, fmt , ## __VA_ARGS__); \
|
||||||
|
cpu_dump_state(cs, stderr, fprintf, 0); \
|
||||||
|
if (qemu_log_separate()) { \
|
||||||
|
qemu_log(fmt, ## __VA_ARGS__); \
|
||||||
|
log_cpu_state(cs, 0); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#if (TARGET_LONG_BITS == 32) && (HOST_LONG_BITS == 64)
|
#if (TARGET_LONG_BITS == 32) && (HOST_LONG_BITS == 64)
|
||||||
/*
|
/*
|
||||||
* When running 32-on-64 we should make sure we can fit all of the possible
|
* When running 32-on-64 we should make sure we can fit all of the possible
|
||||||
@ -416,7 +428,7 @@ void cpu_loop(CPUX86State *env)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pc = env->segs[R_CS].base + env->eip;
|
pc = env->segs[R_CS].base + env->eip;
|
||||||
fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
|
EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
|
||||||
(long)pc, trapnr);
|
(long)pc, trapnr);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -865,9 +877,7 @@ void cpu_loop(CPUARMState *env)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
||||||
trapnr);
|
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
process_pending_signals(env);
|
process_pending_signals(env);
|
||||||
@ -1056,9 +1066,7 @@ void cpu_loop(CPUARMState *env)
|
|||||||
env->xregs[0] = do_arm_semihosting(env);
|
env->xregs[0] = do_arm_semihosting(env);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
||||||
trapnr);
|
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
process_pending_signals(env);
|
process_pending_signals(env);
|
||||||
@ -1148,8 +1156,7 @@ void cpu_loop(CPUUniCore32State *env)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1467,17 +1474,6 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXCP_DUMP(env, fmt, ...) \
|
|
||||||
do { \
|
|
||||||
CPUState *cs = ENV_GET_CPU(env); \
|
|
||||||
fprintf(stderr, fmt , ## __VA_ARGS__); \
|
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0); \
|
|
||||||
if (qemu_log_separate()) { \
|
|
||||||
qemu_log(fmt, ## __VA_ARGS__); \
|
|
||||||
log_cpu_state(cs, 0); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static int do_store_exclusive(CPUPPCState *env)
|
static int do_store_exclusive(CPUPPCState *env)
|
||||||
{
|
{
|
||||||
target_ulong addr;
|
target_ulong addr;
|
||||||
@ -2636,9 +2632,7 @@ done_syscall:
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
||||||
trapnr);
|
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
process_pending_signals(env);
|
process_pending_signals(env);
|
||||||
@ -2661,11 +2655,11 @@ void cpu_loop(CPUOpenRISCState *env)
|
|||||||
|
|
||||||
switch (trapnr) {
|
switch (trapnr) {
|
||||||
case EXCP_RESET:
|
case EXCP_RESET:
|
||||||
qemu_log("\nReset request, exit, pc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nReset request, exit, pc is %#x\n", env->pc);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
break;
|
break;
|
||||||
case EXCP_BUSERR:
|
case EXCP_BUSERR:
|
||||||
qemu_log("\nBus error, exit, pc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nBus error, exit, pc is %#x\n", env->pc);
|
||||||
gdbsig = TARGET_SIGBUS;
|
gdbsig = TARGET_SIGBUS;
|
||||||
break;
|
break;
|
||||||
case EXCP_DPF:
|
case EXCP_DPF:
|
||||||
@ -2674,25 +2668,25 @@ void cpu_loop(CPUOpenRISCState *env)
|
|||||||
gdbsig = TARGET_SIGSEGV;
|
gdbsig = TARGET_SIGSEGV;
|
||||||
break;
|
break;
|
||||||
case EXCP_TICK:
|
case EXCP_TICK:
|
||||||
qemu_log("\nTick time interrupt pc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nTick time interrupt pc is %#x\n", env->pc);
|
||||||
break;
|
break;
|
||||||
case EXCP_ALIGN:
|
case EXCP_ALIGN:
|
||||||
qemu_log("\nAlignment pc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nAlignment pc is %#x\n", env->pc);
|
||||||
gdbsig = TARGET_SIGBUS;
|
gdbsig = TARGET_SIGBUS;
|
||||||
break;
|
break;
|
||||||
case EXCP_ILLEGAL:
|
case EXCP_ILLEGAL:
|
||||||
qemu_log("\nIllegal instructionpc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nIllegal instructionpc is %#x\n", env->pc);
|
||||||
gdbsig = TARGET_SIGILL;
|
gdbsig = TARGET_SIGILL;
|
||||||
break;
|
break;
|
||||||
case EXCP_INT:
|
case EXCP_INT:
|
||||||
qemu_log("\nExternal interruptpc is %#x\n", env->pc);
|
qemu_log_mask(CPU_LOG_INT, "\nExternal interruptpc is %#x\n", env->pc);
|
||||||
break;
|
break;
|
||||||
case EXCP_DTLBMISS:
|
case EXCP_DTLBMISS:
|
||||||
case EXCP_ITLBMISS:
|
case EXCP_ITLBMISS:
|
||||||
qemu_log("\nTLB miss\n");
|
qemu_log_mask(CPU_LOG_INT, "\nTLB miss\n");
|
||||||
break;
|
break;
|
||||||
case EXCP_RANGE:
|
case EXCP_RANGE:
|
||||||
qemu_log("\nRange\n");
|
qemu_log_mask(CPU_LOG_INT, "\nRange\n");
|
||||||
gdbsig = TARGET_SIGSEGV;
|
gdbsig = TARGET_SIGSEGV;
|
||||||
break;
|
break;
|
||||||
case EXCP_SYSCALL:
|
case EXCP_SYSCALL:
|
||||||
@ -2707,19 +2701,18 @@ void cpu_loop(CPUOpenRISCState *env)
|
|||||||
env->gpr[8], 0, 0);
|
env->gpr[8], 0, 0);
|
||||||
break;
|
break;
|
||||||
case EXCP_FPE:
|
case EXCP_FPE:
|
||||||
qemu_log("\nFloating point error\n");
|
qemu_log_mask(CPU_LOG_INT, "\nFloating point error\n");
|
||||||
break;
|
break;
|
||||||
case EXCP_TRAP:
|
case EXCP_TRAP:
|
||||||
qemu_log("\nTrap\n");
|
qemu_log_mask(CPU_LOG_INT, "\nTrap\n");
|
||||||
gdbsig = TARGET_SIGTRAP;
|
gdbsig = TARGET_SIGTRAP;
|
||||||
break;
|
break;
|
||||||
case EXCP_NR:
|
case EXCP_NR:
|
||||||
qemu_log("\nNR\n");
|
qemu_log_mask(CPU_LOG_INT, "\nNR\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemu_log("\nqemu: unhandled CPU exception %#x - aborting\n",
|
EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n",
|
||||||
trapnr);
|
trapnr);
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
gdbsig = TARGET_SIGILL;
|
gdbsig = TARGET_SIGILL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3047,9 +3040,7 @@ void cpu_loop(CPUM68KState *env)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
|
||||||
trapnr);
|
|
||||||
cpu_dump_state(cs, stderr, fprintf, 0);
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
process_pending_signals(env);
|
process_pending_signals(env);
|
||||||
|
Loading…
Reference in New Issue
Block a user