qemu_log_lock/unlock now preserves the qemu_logfile handle.
qemu_log_lock() now returns a handle and qemu_log_unlock() receives a handle to unlock. This allows for changing the handle during logging and ensures the lock() and unlock() are for the same file. Also in target/tilegx/translate.c removed the qemu_log_lock()/unlock() calls (and the log("\n")), since the translator can longjmp out of the loop if it attempts to translate an instruction in an inaccessible page. Signed-off-by: Robert Foley <robert.foley@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20191118211528.3221-5-robert.foley@linaro.org>
This commit is contained in:
parent
b8121fe7c0
commit
fc59d2d870
@ -156,7 +156,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
|
|||||||
#if defined(DEBUG_DISAS)
|
#if defined(DEBUG_DISAS)
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_CPU)
|
if (qemu_loglevel_mask(CPU_LOG_TB_CPU)
|
||||||
&& qemu_log_in_addr_range(itb->pc)) {
|
&& qemu_log_in_addr_range(itb->pc)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) {
|
if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) {
|
||||||
flags |= CPU_DUMP_FPU;
|
flags |= CPU_DUMP_FPU;
|
||||||
@ -165,7 +165,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
|
|||||||
flags |= CPU_DUMP_CCOP;
|
flags |= CPU_DUMP_CCOP;
|
||||||
#endif
|
#endif
|
||||||
log_cpu_state(cpu, flags);
|
log_cpu_state(cpu, flags);
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_DISAS */
|
#endif /* DEBUG_DISAS */
|
||||||
|
|
||||||
|
@ -1804,7 +1804,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
|
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
|
||||||
qemu_log_in_addr_range(tb->pc)) {
|
qemu_log_in_addr_range(tb->pc)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("OUT: [size=%d]\n", gen_code_size);
|
qemu_log("OUT: [size=%d]\n", gen_code_size);
|
||||||
if (tcg_ctx->data_gen_ptr) {
|
if (tcg_ctx->data_gen_ptr) {
|
||||||
size_t code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr;
|
size_t code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr;
|
||||||
@ -1829,7 +1829,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_flush();
|
qemu_log_flush();
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -138,11 +138,11 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(db->pc_first)) {
|
&& qemu_log_in_addr_range(db->pc_first)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("----------------\n");
|
qemu_log("----------------\n");
|
||||||
ops->disas_log(db, cpu);
|
ops->disas_log(db, cpu);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
4
exec.c
4
exec.c
@ -1225,13 +1225,13 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
|
cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
|
||||||
if (qemu_log_separate()) {
|
if (qemu_log_separate()) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("qemu: fatal: ");
|
qemu_log("qemu: fatal: ");
|
||||||
qemu_log_vprintf(fmt, ap2);
|
qemu_log_vprintf(fmt, ap2);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP);
|
log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP);
|
||||||
qemu_log_flush();
|
qemu_log_flush();
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
qemu_log_close();
|
qemu_log_close();
|
||||||
}
|
}
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
|
@ -247,8 +247,8 @@ int can_sja_accept_filter(CanSJA1000State *s,
|
|||||||
static void can_display_msg(const char *prefix, const qemu_can_frame *msg)
|
static void can_display_msg(const char *prefix, const qemu_can_frame *msg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
FILE *logfile = qemu_log_lock();
|
||||||
|
|
||||||
qemu_log_lock();
|
|
||||||
qemu_log("%s%03X [%01d] %s %s",
|
qemu_log("%s%03X [%01d] %s %s",
|
||||||
prefix,
|
prefix,
|
||||||
msg->can_id & QEMU_CAN_EFF_MASK,
|
msg->can_id & QEMU_CAN_EFF_MASK,
|
||||||
@ -261,7 +261,7 @@ static void can_display_msg(const char *prefix, const qemu_can_frame *msg)
|
|||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_flush();
|
qemu_log_flush();
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame)
|
static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame)
|
||||||
|
@ -53,14 +53,17 @@ static inline bool qemu_log_separate(void)
|
|||||||
* qemu_loglevel is never set when qemu_logfile is unset.
|
* qemu_loglevel is never set when qemu_logfile is unset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void qemu_log_lock(void)
|
static inline FILE *qemu_log_lock(void)
|
||||||
{
|
{
|
||||||
qemu_flockfile(qemu_logfile);
|
qemu_flockfile(qemu_logfile);
|
||||||
|
return logfile->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qemu_log_unlock(void)
|
static inline void qemu_log_unlock(FILE *fd)
|
||||||
{
|
{
|
||||||
qemu_funlockfile(qemu_logfile);
|
if (fd) {
|
||||||
|
qemu_funlockfile(fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Logging functions: */
|
/* Logging functions: */
|
||||||
|
@ -76,8 +76,7 @@ QEMU_BUILD_BUG_ON(offsetof(qemu_can_frame, data)
|
|||||||
static void can_host_socketcan_display_msg(struct qemu_can_frame *msg)
|
static void can_host_socketcan_display_msg(struct qemu_can_frame *msg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log_lock();
|
|
||||||
qemu_log("[cansocketcan]: %03X [%01d] %s %s",
|
qemu_log("[cansocketcan]: %03X [%01d] %s %s",
|
||||||
msg->can_id & QEMU_CAN_EFF_MASK,
|
msg->can_id & QEMU_CAN_EFF_MASK,
|
||||||
msg->can_dlc,
|
msg->can_dlc,
|
||||||
@ -89,7 +88,7 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg)
|
|||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_flush();
|
qemu_log_flush();
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_host_socketcan_read(void *opaque)
|
static void can_host_socketcan_read(void *opaque)
|
||||||
|
@ -3273,11 +3273,11 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
#if !DISAS_CRIS
|
#if !DISAS_CRIS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(pc_start)) {
|
&& qemu_log_in_addr_range(pc_start)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("--------------\n");
|
qemu_log("--------------\n");
|
||||||
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
||||||
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -2502,14 +2502,15 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s)
|
|||||||
gen_illegal_opcode(s);
|
gen_illegal_opcode(s);
|
||||||
|
|
||||||
if (qemu_loglevel_mask(LOG_UNIMP)) {
|
if (qemu_loglevel_mask(LOG_UNIMP)) {
|
||||||
|
FILE *logfile = qemu_log_lock();
|
||||||
target_ulong pc = s->pc_start, end = s->pc;
|
target_ulong pc = s->pc_start, end = s->pc;
|
||||||
qemu_log_lock();
|
|
||||||
qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc);
|
qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc);
|
||||||
for (; pc < end; ++pc) {
|
for (; pc < end; ++pc) {
|
||||||
qemu_log(" %02x", cpu_ldub_code(env, pc));
|
qemu_log(" %02x", cpu_ldub_code(env, pc));
|
||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,10 +1137,10 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(pc_start)) {
|
&& qemu_log_in_addr_range(pc_start)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1765,10 +1765,10 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
#if !SIM_COMPAT
|
#if !SIM_COMPAT
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(pc_start)) {
|
&& qemu_log_in_addr_range(pc_start)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("--------------\n");
|
qemu_log("--------------\n");
|
||||||
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -892,11 +892,11 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(tb->pc)) {
|
&& qemu_log_in_addr_range(tb->pc)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("IN: %s\n", lookup_symbol(tb->pc));
|
qemu_log("IN: %s\n", lookup_symbol(tb->pc));
|
||||||
log_target_disas(cs, tb->pc, dc->pc - tb->pc);
|
log_target_disas(cs, tb->pc, dc->pc - tb->pc);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2388,7 +2388,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
dc->zero = NULL;
|
dc->zero = NULL;
|
||||||
|
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
||||||
qemu_log_lock();
|
|
||||||
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
||||||
}
|
}
|
||||||
gen_tb_start(tb);
|
gen_tb_start(tb);
|
||||||
@ -2417,11 +2416,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
|||||||
gen_tb_end(tb, num_insns);
|
gen_tb_end(tb, num_insns);
|
||||||
tb->size = dc->pc - pc_start;
|
tb->size = dc->pc - pc_start;
|
||||||
tb->icount = num_insns;
|
tb->icount = num_insns;
|
||||||
|
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
|
||||||
qemu_log("\n");
|
|
||||||
qemu_log_unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore_state_to_opc(CPUTLGState *env, TranslationBlock *tb,
|
void restore_state_to_opc(CPUTLGState *env, TranslationBlock *tb,
|
||||||
|
@ -1994,12 +1994,12 @@ done_generating:
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||||
&& qemu_log_in_addr_range(pc_start)) {
|
&& qemu_log_in_addr_range(pc_start)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("----------------\n");
|
qemu_log("----------------\n");
|
||||||
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
||||||
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
log_target_disas(cs, pc_start, dc->pc - pc_start);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
tb->size = dc->pc - pc_start;
|
tb->size = dc->pc - pc_start;
|
||||||
|
16
tcg/tcg.c
16
tcg/tcg.c
@ -1085,7 +1085,7 @@ void tcg_prologue_init(TCGContext *s)
|
|||||||
|
|
||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {
|
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("PROLOGUE: [size=%zu]\n", prologue_size);
|
qemu_log("PROLOGUE: [size=%zu]\n", prologue_size);
|
||||||
if (s->data_gen_ptr) {
|
if (s->data_gen_ptr) {
|
||||||
size_t code_size = s->data_gen_ptr - buf0;
|
size_t code_size = s->data_gen_ptr - buf0;
|
||||||
@ -1110,7 +1110,7 @@ void tcg_prologue_init(TCGContext *s)
|
|||||||
}
|
}
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_flush();
|
qemu_log_flush();
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4041,11 +4041,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
|
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
|
||||||
&& qemu_log_in_addr_range(tb->pc))) {
|
&& qemu_log_in_addr_range(tb->pc))) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("OP:\n");
|
qemu_log("OP:\n");
|
||||||
tcg_dump_ops(s, false);
|
tcg_dump_ops(s, false);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4086,11 +4086,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
|
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
|
||||||
&& qemu_log_in_addr_range(tb->pc))) {
|
&& qemu_log_in_addr_range(tb->pc))) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("OP before indirect lowering:\n");
|
qemu_log("OP before indirect lowering:\n");
|
||||||
tcg_dump_ops(s, false);
|
tcg_dump_ops(s, false);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Replace indirect temps with direct temps. */
|
/* Replace indirect temps with direct temps. */
|
||||||
@ -4107,11 +4107,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
|
|||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
|
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
|
||||||
&& qemu_log_in_addr_range(tb->pc))) {
|
&& qemu_log_in_addr_range(tb->pc))) {
|
||||||
qemu_log_lock();
|
FILE *logfile = qemu_log_lock();
|
||||||
qemu_log("OP after optimization and liveness analysis:\n");
|
qemu_log("OP after optimization and liveness analysis:\n");
|
||||||
tcg_dump_ops(s, true);
|
tcg_dump_ops(s, true);
|
||||||
qemu_log("\n");
|
qemu_log("\n");
|
||||||
qemu_log_unlock();
|
qemu_log_unlock(logfile);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user