Commit 013a2942 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

qemu-log: introduce qemu_log_separate



In some cases, the same message is printed both on stderr and in the log.
Avoid duplicate output in the default case where stderr _is_ the log,
and standardize this to stderr+log where it used to use stdio+log.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 31e38a22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -870,7 +870,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
    cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_FPU | CPU_DUMP_CCOP);
    if (qemu_log_enabled()) {
    if (qemu_log_separate()) {
        qemu_log("qemu: fatal: ");
        qemu_log_vprintf(fmt, ap2);
        qemu_log("\n");
+7 −0
Original line number Diff line number Diff line
@@ -28,6 +28,13 @@ static inline bool qemu_log_enabled(void)
    return qemu_logfile != NULL;
}

/* Returns true if qemu_log() will write somewhere else than stderr
 */
static inline bool qemu_log_separate(void)
{
    return qemu_logfile != NULL && qemu_logfile != stderr;
}

#define CPU_LOG_TB_OUT_ASM (1 << 0)
#define CPU_LOG_TB_IN_ASM  (1 << 1)
#define CPU_LOG_TB_OP      (1 << 2)
+2 −2
Original line number Diff line number Diff line
@@ -1472,8 +1472,8 @@ 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__);                                  \
    if (qemu_log_enabled()) {                                           \
        log_cpu_state(cs, 0);                                           \
    }                                                                   \
} while (0)
+4 −2
Original line number Diff line number Diff line
@@ -130,8 +130,10 @@ 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(stderr, "BUG: pc=%x %s %d\n", dc->pc, file, line);
    if (qemu_log_separate()) {
        qemu_log("BUG: pc=%x %s %d\n", dc->pc, file, line);
    }
    cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
}

+3 −4
Original line number Diff line number Diff line
@@ -131,12 +131,11 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
            /* Machine check exception is not enabled.
             * Enter checkstop state.
             */
            if (qemu_log_enabled()) {
                qemu_log("Machine check while not allowed. "
                        "Entering checkstop state\n");
            } else {
            fprintf(stderr, "Machine check while not allowed. "
                    "Entering checkstop state\n");
            if (qemu_log_separate()) {
                qemu_log("Machine check while not allowed. "
                        "Entering checkstop state\n");
            }
            cs->halted = 1;
            cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
Loading