summaryrefslogtreecommitdiffstats
path: root/tcg
diff options
context:
space:
mode:
authorRichard Henderson2022-04-17 20:29:49 +0200
committerRichard Henderson2022-04-20 19:51:11 +0200
commit78b548583e0725bb7054162a31dac552b01c02a8 (patch)
treee8e56b975713665391fddd1534e8642ed000c29f /tcg
parenthw/xen: Split out xen_pv_output_msg (diff)
downloadqemu-78b548583e0725bb7054162a31dac552b01c02a8.tar.gz
qemu-78b548583e0725bb7054162a31dac552b01c02a8.tar.xz
qemu-78b548583e0725bb7054162a31dac552b01c02a8.zip
*: 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 'tcg')
-rw-r--r--tcg/tcg.c78
1 files changed, 44 insertions, 34 deletions
diff --git a/tcg/tcg.c b/tcg/tcg.c
index abe4ef7799..d0e47e55dc 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -757,31 +757,35 @@ void tcg_prologue_init(TCGContext *s)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {
FILE *logfile = qemu_log_trylock();
- qemu_log("PROLOGUE: [size=%zu]\n", prologue_size);
- if (s->data_gen_ptr) {
- size_t code_size = s->data_gen_ptr - s->code_gen_ptr;
- size_t data_size = prologue_size - code_size;
- size_t i;
-
- log_disas(s->code_gen_ptr, code_size);
-
- for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
- if (sizeof(tcg_target_ulong) == 8) {
- qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
- (uintptr_t)s->data_gen_ptr + i,
- *(uint64_t *)(s->data_gen_ptr + i));
- } else {
- qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n",
- (uintptr_t)s->data_gen_ptr + i,
- *(uint32_t *)(s->data_gen_ptr + i));
+ if (logfile) {
+ fprintf(logfile, "PROLOGUE: [size=%zu]\n", prologue_size);
+ if (s->data_gen_ptr) {
+ size_t code_size = s->data_gen_ptr - s->code_gen_ptr;
+ size_t data_size = prologue_size - code_size;
+ size_t i;
+
+ disas(logfile, s->code_gen_ptr, code_size);
+
+ for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
+ if (sizeof(tcg_target_ulong) == 8) {
+ fprintf(logfile,
+ "0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
+ (uintptr_t)s->data_gen_ptr + i,
+ *(uint64_t *)(s->data_gen_ptr + i));
+ } else {
+ fprintf(logfile,
+ "0x%08" PRIxPTR ": .long 0x%08x\n",
+ (uintptr_t)s->data_gen_ptr + i,
+ *(uint32_t *)(s->data_gen_ptr + i));
+ }
}
+ } else {
+ disas(logfile, s->code_gen_ptr, prologue_size);
}
- } else {
- log_disas(s->code_gen_ptr, prologue_size);
+ fprintf(logfile, "\n");
+ qemu_log_flush();
+ qemu_log_unlock(logfile);
}
- qemu_log("\n");
- qemu_log_flush();
- qemu_log_unlock(logfile);
}
#endif
@@ -4201,10 +4205,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
&& qemu_log_in_addr_range(tb->pc))) {
FILE *logfile = qemu_log_trylock();
- qemu_log("OP:\n");
- tcg_dump_ops(s, false);
- qemu_log("\n");
- qemu_log_unlock(logfile);
+ if (logfile) {
+ fprintf(logfile, "OP:\n");
+ tcg_dump_ops(s, false);
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
+ }
}
#endif
@@ -4246,10 +4252,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
&& qemu_log_in_addr_range(tb->pc))) {
FILE *logfile = qemu_log_trylock();
- qemu_log("OP before indirect lowering:\n");
- tcg_dump_ops(s, false);
- qemu_log("\n");
- qemu_log_unlock(logfile);
+ if (logfile) {
+ fprintf(logfile, "OP before indirect lowering:\n");
+ tcg_dump_ops(s, false);
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
+ }
}
#endif
/* Replace indirect temps with direct temps. */
@@ -4267,10 +4275,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
&& qemu_log_in_addr_range(tb->pc))) {
FILE *logfile = qemu_log_trylock();
- qemu_log("OP after optimization and liveness analysis:\n");
- tcg_dump_ops(s, true);
- qemu_log("\n");
- qemu_log_unlock(logfile);
+ if (logfile) {
+ fprintf(logfile, "OP after optimization and liveness analysis:\n");
+ tcg_dump_ops(s, true);
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
+ }
}
#endif