aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-17 11:29:49 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-20 10:51:11 -0700
commit78b548583e0725bb7054162a31dac552b01c02a8 (patch)
treee8e56b975713665391fddd1534e8642ed000c29f /target
parent6fef222971e1f77d1e7b6c218edce72ceb568126 (diff)
downloadqemu-78b548583e0725bb7054162a31dac552b01c02a8.zip
qemu-78b548583e0725bb7054162a31dac552b01c02a8.tar.gz
qemu-78b548583e0725bb7054162a31dac552b01c02a8.tar.bz2
*: Use fprintf between qemu_log_trylock/unlock
Inside qemu_log, we perform qemu_log_trylock/unlock, which need not be done if we have already performed the lock beforehand. Always check the result of qemu_log_trylock -- only checking qemu_loglevel_mask races with the acquisition of the lock on the logfile. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-10-richard.henderson@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/i386/tcg/translate.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index f3cffee..bfd0f5b 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -2581,14 +2581,16 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s)
if (qemu_loglevel_mask(LOG_UNIMP)) {
FILE *logfile = qemu_log_trylock();
- target_ulong pc = s->pc_start, end = s->pc;
+ if (logfile) {
+ target_ulong pc = s->pc_start, end = s->pc;
- qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc);
- for (; pc < end; ++pc) {
- qemu_log(" %02x", cpu_ldub_code(env, pc));
+ fprintf(logfile, "ILLOPC: " TARGET_FMT_lx ":", pc);
+ for (; pc < end; ++pc) {
+ fprintf(logfile, " %02x", cpu_ldub_code(env, pc));
+ }
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
}
- qemu_log("\n");
- qemu_log_unlock(logfile);
}
}