aboutsummaryrefslogtreecommitdiff
path: root/accel/tcg
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-20 12:47:15 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-20 12:47:15 -0700
commit27a985159a80430a0a43161797ca14ef946962b8 (patch)
tree54708343e87dc25dd9abf5230f43482ab5662ad5 /accel/tcg
parent2d20a57453f6a206938cbbf77bed0b378c806c1f (diff)
parent4e51069d679348d2617512e56e28cdc7bb34c833 (diff)
Merge tag 'pull-log-20220420' of https://gitlab.com/rth7680/qemu into staging
Clean up log locking. Use the FILE* from qemu_log_trylock more often. Support per-thread log files with -d tid. # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmJgStUdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+c9Af/ZXnKe6bz5yjXy1mS # mNIBJUPKrz1RXFfJxuCfEDWrtNc/gvQyvc3weZG5X0cXpiczeWA5V/9xbE9hu5gV # 4rePiIHWmOrais6GZlqEu2F8P3/XyqdPHtcdBfa1hDneixtpqMHCqnh36nQjHyiU # ogFxEJ/M9tTwhuWZrXe/JSYAiALEDYMK9bk4RUMOP1c4v37rXqUNOAM1IPhfxLL/ # bK9DQMpz5oUNsWWaqBQ2wQWHkNTOpUEkKGQv0xcQF5SdpYwaxakW9B7/h4QSeOUn # oY6MFTmkJ4BPrLnkcubn+3PICc9LW0OFuzNnUdMCbeqVbjAUQrdMDalKpy4uNFv9 # U1VqHg== # =Mt5s # -----END PGP SIGNATURE----- # gpg: Signature made Wed 20 Apr 2022 11:03:01 AM PDT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-log-20220420' of https://gitlab.com/rth7680/qemu: (39 commits) util/log: Support per-thread log files util/log: Limit RCUCloseFILE to file closing util/log: Rename QemuLogFile to RCUCloseFILE util/log: Combine two logfile closes util/log: Hoist the eval of is_daemonized in qemu_set_log_internal util/log: Rename qemu_logfile_mutex to global_mutex util/log: Rename qemu_logfile to global_file util/log: Rename logfilename to global_filename util/log: Remove qemu_log_close softmmu: Use qemu_set_log_filename_flags linux-user: Use qemu_set_log_filename_flags bsd-user: Use qemu_set_log_filename_flags util/log: Introduce qemu_set_log_filename_flags sysemu/os-win32: Test for and use _lock_file/_unlock_file include/qemu/log: Move entire implementation out-of-line include/exec/log: Do not reference QemuLogFile directly tests/unit: Do not reference QemuLogFile directly linux-user: Expand log_page_dump inline bsd-user: Expand log_page_dump inline util/log: Drop call to setvbuf ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'accel/tcg')
-rw-r--r--accel/tcg/cpu-exec.c18
-rw-r--r--accel/tcg/translate-all.c116
-rw-r--r--accel/tcg/translator.c12
3 files changed, 78 insertions, 68 deletions
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 083ada76b1..635aeecc0a 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -214,17 +214,19 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu,
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) {
- FILE *logfile = qemu_log_lock();
- int flags = 0;
+ FILE *logfile = qemu_log_trylock();
+ if (logfile) {
+ int flags = 0;
- if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) {
- flags |= CPU_DUMP_FPU;
- }
+ if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) {
+ flags |= CPU_DUMP_FPU;
+ }
#if defined(TARGET_I386)
- flags |= CPU_DUMP_CCOP;
+ flags |= CPU_DUMP_CCOP;
#endif
- log_cpu_state(cpu, flags);
- qemu_log_unlock(logfile);
+ cpu_dump_state(cpu, logfile, flags);
+ qemu_log_unlock(logfile);
+ }
}
#endif /* DEBUG_DISAS */
}
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index a6e03c1e50..291034cb09 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1527,69 +1527,75 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
qemu_log_in_addr_range(tb->pc)) {
- FILE *logfile = qemu_log_lock();
- int code_size, data_size;
- const tcg_target_ulong *rx_data_gen_ptr;
- size_t chunk_start;
- int insn = 0;
-
- if (tcg_ctx->data_gen_ptr) {
- rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr);
- code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr;
- data_size = gen_code_size - code_size;
- } else {
- rx_data_gen_ptr = 0;
- code_size = gen_code_size;
- data_size = 0;
- }
+ FILE *logfile = qemu_log_trylock();
+ if (logfile) {
+ int code_size, data_size;
+ const tcg_target_ulong *rx_data_gen_ptr;
+ size_t chunk_start;
+ int insn = 0;
+
+ if (tcg_ctx->data_gen_ptr) {
+ rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr);
+ code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr;
+ data_size = gen_code_size - code_size;
+ } else {
+ rx_data_gen_ptr = 0;
+ code_size = gen_code_size;
+ data_size = 0;
+ }
- /* Dump header and the first instruction */
- qemu_log("OUT: [size=%d]\n", gen_code_size);
- qemu_log(" -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n",
- tcg_ctx->gen_insn_data[insn][0]);
- chunk_start = tcg_ctx->gen_insn_end_off[insn];
- log_disas(tb->tc.ptr, chunk_start);
+ /* Dump header and the first instruction */
+ fprintf(logfile, "OUT: [size=%d]\n", gen_code_size);
+ fprintf(logfile,
+ " -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n",
+ tcg_ctx->gen_insn_data[insn][0]);
+ chunk_start = tcg_ctx->gen_insn_end_off[insn];
+ disas(logfile, tb->tc.ptr, chunk_start);
- /*
- * Dump each instruction chunk, wrapping up empty chunks into
- * the next instruction. The whole array is offset so the
- * first entry is the beginning of the 2nd instruction.
- */
- while (insn < tb->icount) {
- size_t chunk_end = tcg_ctx->gen_insn_end_off[insn];
- if (chunk_end > chunk_start) {
- qemu_log(" -- guest addr 0x" TARGET_FMT_lx "\n",
- tcg_ctx->gen_insn_data[insn][0]);
- log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start);
- chunk_start = chunk_end;
+ /*
+ * Dump each instruction chunk, wrapping up empty chunks into
+ * the next instruction. The whole array is offset so the
+ * first entry is the beginning of the 2nd instruction.
+ */
+ while (insn < tb->icount) {
+ size_t chunk_end = tcg_ctx->gen_insn_end_off[insn];
+ if (chunk_end > chunk_start) {
+ fprintf(logfile, " -- guest addr 0x" TARGET_FMT_lx "\n",
+ tcg_ctx->gen_insn_data[insn][0]);
+ disas(logfile, tb->tc.ptr + chunk_start,
+ chunk_end - chunk_start);
+ chunk_start = chunk_end;
+ }
+ insn++;
}
- insn++;
- }
- if (chunk_start < code_size) {
- qemu_log(" -- tb slow paths + alignment\n");
- log_disas(tb->tc.ptr + chunk_start, code_size - chunk_start);
- }
+ if (chunk_start < code_size) {
+ fprintf(logfile, " -- tb slow paths + alignment\n");
+ disas(logfile, tb->tc.ptr + chunk_start,
+ code_size - chunk_start);
+ }
- /* Finally dump any data we may have after the block */
- if (data_size) {
- int i;
- qemu_log(" data: [size=%d]\n", data_size);
- for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) {
- if (sizeof(tcg_target_ulong) == 8) {
- qemu_log("0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n",
- (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
- } else if (sizeof(tcg_target_ulong) == 4) {
- qemu_log("0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n",
- (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
- } else {
- qemu_build_not_reached();
+ /* Finally dump any data we may have after the block */
+ if (data_size) {
+ int i;
+ fprintf(logfile, " data: [size=%d]\n", data_size);
+ for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) {
+ if (sizeof(tcg_target_ulong) == 8) {
+ fprintf(logfile,
+ "0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n",
+ (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
+ } else if (sizeof(tcg_target_ulong) == 4) {
+ fprintf(logfile,
+ "0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n",
+ (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
+ } else {
+ qemu_build_not_reached();
+ }
}
}
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
}
- qemu_log("\n");
- qemu_log_flush();
- qemu_log_unlock(logfile);
}
#endif
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index f06c314266..fe7af9b943 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -139,11 +139,13 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(db->pc_first)) {
- FILE *logfile = qemu_log_lock();
- qemu_log("----------------\n");
- ops->disas_log(db, cpu);
- qemu_log("\n");
- qemu_log_unlock(logfile);
+ FILE *logfile = qemu_log_trylock();
+ if (logfile) {
+ fprintf(logfile, "----------------\n");
+ ops->disas_log(db, cpu, logfile);
+ fprintf(logfile, "\n");
+ qemu_log_unlock(logfile);
+ }
}
#endif
}