Avoid always-active qemu_log calls
cover Avoid always-active qemu_log calls
qemu_log calls should generally be wrapped by DEBUG_* preprocessor symbols or (preferred) qemu_log_mask should be used instead. This avoids that the upcoming integration of logging and tracing prints some log messages to stderr unconditionally.
Similarly, most occurrences of qemu_log_enabled() should be changed to qemu_log_mask(). One exception is when these always-active qemu_log calls are coupled with printfs to stdout or stderr. These should be skipped if stderr is _already_ the logging destination, and the series thus introduces a new predicate qemu_log_separate() to replace qemu_log_enabled() in some cases.
This series removes all the instances that I could find of these problems.
Paolo
Paolo Bonzini (11):
qemu-log: introduce qemu_log_separate
alpha: convert "naked" qemu_log to tracepoint
cris: avoid "naked" qemu_log
microblaze: avoid "naked" qemu_log
s390x: avoid "naked" qemu_log
ppc: cleanup logging
tricore: avoid "naked" qemu_log
xtensa: avoid "naked" qemu_log
user: introduce "-d page"
linux-user: avoid "naked" qemu_log
linux-user: convert DEBUG_SIGNAL logging to tracepoints
bsd-user/main.c | 4 +- bsd-user/signal.c | 2 - exec.c | 2 +- hw/alpha/pci.c | 3 +- hw/char/etraxfs_ser.c | 2 +- include/qemu/log.h | 8 +++ linux-user/elfload.c | 8 +-- linux-user/main.c | 75 ++++++++++++--------------- linux-user/signal.c | 118 +++++++++++++++++++++--------------------- qemu-log.c | 2 + target-cris/helper.h | 1 - target-cris/op_helper.c | 5 -- target-cris/translate.c | 8 +-- target-cris/translate_v10.c | 2 +- target-microblaze/helper.c | 2 +- target-microblaze/mmu.c | 20 +++---- target-microblaze/op_helper.c | 8 +-- target-microblaze/translate.c | 2 +- target-ppc/excp_helper.c | 8 +-- target-ppc/mmu-hash32.c | 12 +---- target-ppc/mmu-hash64.c | 9 +--- target-ppc/mmu_helper.c | 15 +++--- target-ppc/timebase_helper.c | 10 ++-- target-ppc/translate.c | 62 +++++++++++----------- target-s390x/cc_helper.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/misc_helper.c | 2 +- target-s390x/mmu_helper.c | 2 +- target-tricore/helper.c | 4 +- target-xtensa/gdbstub.c | 8 +-- target-xtensa/helper.c | 4 +- target-xtensa/op_helper.c | 20 +++---- target-xtensa/translate.c | 28 +++++----- target-xtensa/xtensa-semi.c | 2 +- trace-events | 14 +++++ 35 files changed, 237 insertions(+), 239 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/11 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.
--- exec.c | 2 +- include/qemu/log.h | 7 +++++++ linux-user/main.c | 4 ++-- target-cris/translate.c | 6 ++++-- target-ppc/excp_helper.c | 7 +++---- target-ppc/translate.c | 40 ++++++++++++++++++++++++---------------- target-s390x/helper.c | 2 +- target-s390x/mmu_helper.c | 2 +- 8 files changed, 43 insertions(+), 27 deletions(-)
exec.c +1 -1
@@ -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" );
include/qemu/log.h +7 -0
@@ -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)
linux-user/main.c +2 -2
@@ -1472,8 +1472,8 @@ do { \CPUState *cs =ENV_GET_CPU (env); \ fprintf(stderr, fmt , ## __VA_ARGS__); \cpu_dump_state (cs, stderr, fprintf,0 ); \ - qemu_log(fmt, ## __VA_ARGS__); \ -if (qemu_log_enabled ()) { \ +if (qemu_log_separate ()) { \ + qemu_log(fmt, ## __VA_ARGS__); \log_cpu_state (cs,0 ); \ } \ }while (0 )
target-cris/translate.c +4 -2
@@ -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); -qemu_log ("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); }
target-ppc/excp_helper.c +3 -4
@@ -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 ()) { +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" ); - }else { -fprintf (stderr,"Machine check while not allowed. " -"Entering checkstop state\n" ); } cs->halted =1 ; cs->interrupt_request |=CPU_INTERRUPT_EXITTB ;
target-ppc/translate.c +24 -16
@@ -4285,19 +4285,23 @@ static inline void gen_op_mfspr(DisasContext *ctx)* allowing userland application to read the PVR */ if (sprn !=SPR_PVR ) { -qemu_log ("Trying to read privileged spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); -printf ("Trying to read privileged spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +fprintf (stderr,"Trying to read privileged spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +if (qemu_log_separate ()) { +qemu_log ("Trying to read privileged spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); + } }gen_inval_exception (ctx,POWERPC_EXCP_PRIV_REG ); } }else {/* Not defined */ -qemu_log ("Trying to read invalid spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); -printf ("Trying to read invalid spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +fprintf (stderr,"Trying to read invalid spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +if (qemu_log_separate ()) { +qemu_log ("Trying to read invalid spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); + }gen_inval_exception (ctx,POWERPC_EXCP_INVAL_SPR ); } }
@@ -4431,18 +4435,22 @@ static void gen_mtspr(DisasContext *ctx) (*write_cb)(ctx, sprn,rS (ctx->opcode)); }else {/* Privilege exception */ -qemu_log ("Trying to write privileged spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); -printf ("Trying to write privileged spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +fprintf (stderr,"Trying to write privileged spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +if (qemu_log_separate ()) { +qemu_log ("Trying to write privileged spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); + }gen_inval_exception (ctx,POWERPC_EXCP_PRIV_REG ); } }else {/* Not defined */ -qemu_log ("Trying to write invalid spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); -printf ("Trying to write invalid spr %d (0x%03x) at " - TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); +if (qemu_log_separate ()) { +qemu_log ("Trying to write invalid spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 ); + } +fprintf (stderr,"Trying to write invalid spr %d (0x%03x) at " + TARGET_FMT_lx"\n" , sprn, sprn, ctx->nip -4 );gen_inval_exception (ctx,POWERPC_EXCP_INVAL_SPR ); } }
target-s390x/helper.c +1 -1
@@ -33,7 +33,7 @@#ifdef DEBUG_S390_STDOUT #define DPRINTF (fmt, ...) \ do { fprintf(stderr, fmt, ## __VA_ARGS__); \ - qemu_log(fmt, ##__VA_ARGS__); } while (0) + if (qemu_log_separate()) qemu_log(fmt, ##__VA_ARGS__); } while (0)#else #define DPRINTF (fmt, ...) \ do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
target-s390x/mmu_helper.c +1 -1
@@ -30,7 +30,7 @@#ifdef DEBUG_S390_STDOUT #define DPRINTF (fmt, ...) \ do { fprintf(stderr, fmt, ## __VA_ARGS__); \ - qemu_log(fmt, ##__VA_ARGS__); } while (0) + if (qemu_log_separate()) qemu_log(fmt, ##__VA_ARGS__); } while (0)#else #define DPRINTF (fmt, ...) \ do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
Signature · 1 line
2.5.0
PATCH 2/11 alpha: convert "naked" qemu_log to tracepoint
In reply to Paolo Bonzini--- hw/alpha/pci.c | 3 ++- trace-events | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)
hw/alpha/pci.c +2 -1
@@ -10,6 +10,7 @@#include "alpha_sys.h" #include "qemu/log.h" #include "sysemu/sysemu.h" +#include "trace.h" /* Fallback for unassigned PCI I/O operations. Avoids MCHK. */
@@ -73,7 +74,7 @@ static uint64_t iack_read(void *opaque, hwaddr addr, unsigned size)static void special_write (void *opaque,hwaddr addr,uint64_t val,unsigned size) { -qemu_log ("pci: special write cycle" ); +trace_alpha_pci_iack_write (); }const MemoryRegionOps alpha_pci_iack_ops = {
trace-events +3 -0
@@ -1756,6 +1756,9 @@ cpu_unhalt(int cpu_index) "unhalting cpu %d" # hw/arm/virt-acpi-build.c virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." +# hw/alpha/pci.c +alpha_pci_iack_write(void) "" + # audio/alsaaudio.c alsa_revents(int revents) "revents = %d" alsa_pollout(int i, int fd) "i = %d fd = %d"
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 02/11] alpha: convert "naked" qemu_log to tracepoint
Quoted 6 lines · Paolo Bonzini
Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- hw/alpha/pci.c | 3 ++- trace-events | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)
r~
PATCH 3/11 cris: avoid "naked" qemu_log
In reply to Paolo Bonzini--- hw/char/etraxfs_ser.c | 2 +- target-cris/helper.h | 1 - target-cris/op_helper.c | 5 ----- target-cris/translate.c | 2 +- target-cris/translate_v10.c | 2 +- 5 files changed, 3 insertions(+), 9 deletions(-)
hw/char/etraxfs_ser.c +1 -1
@@ -165,7 +165,7 @@ static void serial_receive(void *opaque, const uint8_t *buf, int size)/* Got a byte. */ if (s->rx_fifo_len >=16 ) { -qemu_log ("WARNING: UART dropped char.\n" ); +D (qemu_log ("WARNING: UART dropped char.\n" ));return ; }
target-cris/helper.h +0 -1
@@ -1,7 +1,6 @@ DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_2(tlb_flush_pid, void, env, i32) DEF_HELPER_2(spc_write, void, env, i32) -DEF_HELPER_3(dump, void, i32, i32, i32) DEF_HELPER_1(rfe, void, env)DEF_HELPER_1 (rfn, void, env)
target-cris/op_helper.c +0 -5
@@ -91,11 +91,6 @@ void helper_spc_write(CPUCRISState *env, uint32_t new_spc)#endif } -void helper_dump (uint32_t a0,uint32_t a1,uint32_t a2) -{ -qemu_log ("%s: a0=%x a1=%x\n" , __func__, a0, a1); -} -/* Used by the tlb decoder. */ #define EXTRACT_FIELD (src, start, end) \ (((src) >> start) & ((1 << (end - start + 1)) - 1))
target-cris/translate.c +1 -1
@@ -779,7 +779,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,t_gen_subx_carry (dc, dst);break ;default : -qemu_log ("illegal ALU op.\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"illegal ALU op.\n" );BUG ();break ; }
target-cris/translate_v10.c +1 -1
@@ -58,7 +58,7 @@ static inline int dec10_size(unsigned int size)static inline void cris_illegal_insn (DisasContext *dc) { -qemu_log ("illegal insn at pc=%x\n" , dc->pc); +qemu_log_mask (LOG_GUEST_ERROR ,"illegal insn at pc=%x\n" , dc->pc);t_gen_raise_exception (EXCP_BREAK ); }
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 03/11] cris: avoid "naked" qemu_log
Quoted 2 lines · Paolo Bonzini
Cc Edgar E. Iglesias <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Quoted 80 lines
--- hw/char/etraxfs_ser.c | 2 +- target-cris/helper.h | 1 - target-cris/op_helper.c | 5 ----- target-cris/translate.c | 2 +- target-cris/translate_v10.c | 2 +- 5 files changed, 3 insertions(+), 9 deletions(-)hw/char/etraxfs_ser.c +1
-1@@ -165,7 +165,7 @@ static void serial_receive(void *opaque, const uint8_t *buf, int size)/* Got a byte. */ if (s->rx_fifo_len >=16 ) { -qemu_log ("WARNING: UART dropped char.\n" ); +D (qemu_log ("WARNING: UART dropped char.\n" ));return ; }target-cris/helper.h +0
-1@@ -1,7 +1,6 @@ DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_2(tlb_flush_pid, void, env, i32) DEF_HELPER_2(spc_write, void, env, i32) -DEF_HELPER_3(dump, void, i32, i32, i32) DEF_HELPER_1(rfe, void, env)DEF_HELPER_1 (rfn, void, env)target-cris/op_helper.c +0
-5@@ -91,11 +91,6 @@ void helper_spc_write(CPUCRISState *env, uint32_t new_spc)#endif } -void helper_dump (uint32_t a0,uint32_t a1,uint32_t a2) -{ -qemu_log ("%s: a0=%x a1=%x\n" , __func__, a0, a1); -} -/* Used by the tlb decoder. */ #define EXTRACT_FIELD (src, start, end) \ (((src) >> start) & ((1 << (end - start + 1)) - 1))target-cris/translate.c +1
-1@@ -779,7 +779,7 @@ static void cris_alu_op_exec(DisasContext *dc, int op,t_gen_subx_carry (dc, dst);break ;default : -qemu_log ("illegal ALU op.\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"illegal ALU op.\n" );BUG ();break ; }target-cris/translate_v10.c +1
-1@@ -58,7 +58,7 @@ static inline int dec10_size(unsigned int size)static inline void cris_illegal_insn (DisasContext *dc) { -qemu_log ("illegal insn at pc=%x\n" , dc->pc); +qemu_log_mask (LOG_GUEST_ERROR ,"illegal insn at pc=%x\n" , dc->pc);t_gen_raise_exception (EXCP_BREAK ); }Signature · 1 line
2.5.0
PATCH 4/11 microblaze: avoid "naked" qemu_log
In reply to Paolo Bonzini--- target-microblaze/helper.c | 2 +- target-microblaze/mmu.c | 20 ++++++++++---------- target-microblaze/op_helper.c | 8 ++++---- target-microblaze/translate.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-)
target-microblaze/helper.c +1 -1
@@ -128,7 +128,7 @@ void mb_cpu_do_interrupt(CPUState *cs)switch (cs->exception_index) {case EXCP_HW_EXCP :if (!(env->pvr.regs[0 ] &PVR0_USE_EXC_MASK )) { -qemu_log ("Exception raised on system without exceptions!\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"Exception raised on system without exceptions!\n" );return ; }
target-microblaze/mmu.c +10 -10
@@ -60,7 +60,7 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid)uint32_t t;if (newpid & ~0xff ) -qemu_log ("Illegal rpid=%x\n" , newpid); +qemu_log_mask (LOG_GUEST_ERROR ,"Illegal rpid=%x\n" , newpid);for (i =0 ; i <ARRAY_SIZE (mmu->rams[RAM_TAG ]); i++) {/* Lookup and decode. */
@@ -121,7 +121,7 @@ unsigned int mmu_translate(struct microblaze_mmu *mmu, t0 &=0x3 ;if (tlb_zsel > mmu->c_mmu_zones) { -qemu_log ("tlb zone select out of range! %d\n" , tlb_zsel); +qemu_log_mask (LOG_GUEST_ERROR ,"tlb zone select out of range! %d\n" , tlb_zsel); t0 =1 ;/* Ignore. */ }
@@ -183,7 +183,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)uint32_t r;if (env->mmu.c_mmu <2 || !env->mmu.c_mmu_tlb_access) { -qemu_log ("MMU access on MMU-less system\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"MMU access on MMU-less system\n" );return 0 ; }
@@ -192,7 +192,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)case MMU_R_TLBLO :case MMU_R_TLBHI :if (!(env->mmu.c_mmu_tlb_access &1 )) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return 0 ; }
@@ -204,7 +204,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)case MMU_R_PID :case MMU_R_ZPR :if (!(env->mmu.c_mmu_tlb_access &1 )) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return 0 ; } r = env->mmu.regs[rn];
@@ -224,7 +224,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)D (qemu_log ("%s rn=%d=%x old=%x\n" , __func__, rn, v, env->mmu.regs[rn]));if (env->mmu.c_mmu <2 || !env->mmu.c_mmu_tlb_access) { -qemu_log ("MMU access on MMU-less system\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"MMU access on MMU-less system\n" );return ; }
@@ -235,7 +235,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v) i = env->mmu.regs[MMU_R_TLBX ] &0xff ;if (rn ==MMU_R_TLBHI ) {if (i <3 && !(v &TLB_VALID ) &&qemu_loglevel_mask (~0 )) -qemu_log ("invalidating index %x at pc=%x\n" , +qemu_log_mask (LOG_GUEST_ERROR ,"invalidating index %x at pc=%x\n" , i, env->sregs[SR_PC ]); env->mmu.tids[i] = env->mmu.regs[MMU_R_PID ] &0xff ;mmu_flush_idx (env, i);
@@ -246,7 +246,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)break ;case MMU_R_ZPR :if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }
@@ -259,7 +259,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)break ;case MMU_R_PID :if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }
@@ -274,7 +274,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)int hit;if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }
target-microblaze/op_helper.c +4 -4
@@ -55,7 +55,7 @@ void helper_put(uint32_t id, uint32_t ctrl, uint32_t data)int nonblock = ctrl &STREAM_NONBLOCK ;int exception = ctrl &STREAM_EXCEPTION ; - qemu_log("Unhandled stream put to stream-id=%d data=%x %s%s%s%s%s\n", + qemu_log_mask(LOG_UNIMP, "Unhandled stream put to stream-id=%d data=%x %s%s%s%s%s\n", id, data, test ? "t" : "", nonblock ? "n" : "",
@@ -72,7 +72,7 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)int nonblock = ctrl &STREAM_NONBLOCK ;int exception = ctrl &STREAM_EXCEPTION ; - qemu_log("Unhandled stream get from stream-id=%d %s%s%s%s%s\n", + qemu_log_mask(LOG_UNIMP, "Unhandled stream get from stream-id=%d %s%s%s%s%s\n", id, test ? "t" : "", nonblock ? "n" : "",
@@ -465,8 +465,8 @@ void helper_memalign(CPUMBState *env, uint32_t addr, uint32_t dr, uint32_t wr,void helper_stackprot (CPUMBState *env,uint32_t addr) {if (addr < env->slr || addr > env->shr) { -qemu_log ("Stack protector violation at %x %x %x\n" , - addr, env->slr, env->shr); +qemu_log_mask (CPU_LOG_INT ,"Stack protector violation at %x %x %x\n" , + addr, env->slr, env->shr); env->sregs[SR_EAR ] = addr; env->sregs[SR_ESR ] =ESR_EC_STACKPROT ;helper_raise_exception (env,EXCP_HW_EXCP );
target-microblaze/translate.c +1 -1
@@ -1516,7 +1516,7 @@ static void dec_null(DisasContext *dc)t_gen_raise_exception (dc,EXCP_HW_EXCP );return ; } -qemu_log ("unknown insn pc=%x opc=%x\n" , dc->pc, dc->opcode); +qemu_log_mask (LOG_GUEST_ERROR ,"unknown insn pc=%x opc=%x\n" , dc->pc, dc->opcode); dc->abort_at_next_insn =1 ; }
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 04/11] microblaze: avoid "naked" qemu_log
Quoted 2 lines · Paolo Bonzini
Cc Edgar E. Iglesias <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Thanks,
Edgar
Quoted 165 lines
--- target-microblaze/helper.c | 2 +- target-microblaze/mmu.c | 20 ++++++++++---------- target-microblaze/op_helper.c | 8 ++++---- target-microblaze/translate.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-)target-microblaze/helper.c +1
-1@@ -128,7 +128,7 @@ void mb_cpu_do_interrupt(CPUState *cs)switch (cs->exception_index) {case EXCP_HW_EXCP :if (!(env->pvr.regs[0 ] &PVR0_USE_EXC_MASK )) { -qemu_log ("Exception raised on system without exceptions!\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"Exception raised on system without exceptions!\n" );return ; }target-microblaze/mmu.c +10
-10@@ -60,7 +60,7 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid)uint32_t t;if (newpid & ~0xff ) -qemu_log ("Illegal rpid=%x\n" , newpid); +qemu_log_mask (LOG_GUEST_ERROR ,"Illegal rpid=%x\n" , newpid);for (i =0 ; i <ARRAY_SIZE (mmu->rams[RAM_TAG ]); i++) {/* Lookup and decode. */ @@ -121,7 +121,7 @@ unsigned int mmu_translate(struct microblaze_mmu *mmu, t0 &=0x3 ;if (tlb_zsel > mmu->c_mmu_zones) { -qemu_log ("tlb zone select out of range! %d\n" , tlb_zsel); +qemu_log_mask (LOG_GUEST_ERROR ,"tlb zone select out of range! %d\n" , tlb_zsel); t0 =1 ;/* Ignore. */ }@@ -183,7 +183,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)uint32_t r;if (env->mmu.c_mmu <2 || !env->mmu.c_mmu_tlb_access) { -qemu_log ("MMU access on MMU-less system\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"MMU access on MMU-less system\n" );return 0 ; }@@ -192,7 +192,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)case MMU_R_TLBLO :case MMU_R_TLBHI :if (!(env->mmu.c_mmu_tlb_access &1 )) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return 0 ; }@@ -204,7 +204,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)case MMU_R_PID :case MMU_R_ZPR :if (!(env->mmu.c_mmu_tlb_access &1 )) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return 0 ; } r = env->mmu.regs[rn];@@ -224,7 +224,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)D (qemu_log ("%s rn=%d=%x old=%x\n" , __func__, rn, v, env->mmu.regs[rn]));if (env->mmu.c_mmu <2 || !env->mmu.c_mmu_tlb_access) { -qemu_log ("MMU access on MMU-less system\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"MMU access on MMU-less system\n" );return ; }@@ -235,7 +235,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v) i = env->mmu.regs[MMU_R_TLBX ] &0xff ;if (rn ==MMU_R_TLBHI ) {if (i <3 && !(v &TLB_VALID ) &&qemu_loglevel_mask (~0 )) -qemu_log ("invalidating index %x at pc=%x\n" , +qemu_log_mask (LOG_GUEST_ERROR ,"invalidating index %x at pc=%x\n" , i, env->sregs[SR_PC ]); env->mmu.tids[i] = env->mmu.regs[MMU_R_PID ] &0xff ;mmu_flush_idx (env, i);@@ -246,7 +246,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)break ;case MMU_R_ZPR :if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }@@ -259,7 +259,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)break ;case MMU_R_PID :if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }@@ -274,7 +274,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)int hit;if (env->mmu.c_mmu_tlb_access <=1 ) { -qemu_log ("Invalid access to MMU reg %d\n" , rn); +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid access to MMU reg %d\n" , rn);return ; }target-microblaze/op_helper.c +4
-4@@ -55,7 +55,7 @@ void helper_put(uint32_t id, uint32_t ctrl, uint32_t data)int nonblock = ctrl &STREAM_NONBLOCK ;int exception = ctrl &STREAM_EXCEPTION ; - qemu_log("Unhandled stream put to stream-id=%d data=%x %s%s%s%s%s\n", + qemu_log_mask(LOG_UNIMP, "Unhandled stream put to stream-id=%d data=%x %s%s%s%s%s\n", id, data, test ? "t" : "", nonblock ? "n" : "",@@ -72,7 +72,7 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)int nonblock = ctrl &STREAM_NONBLOCK ;int exception = ctrl &STREAM_EXCEPTION ; - qemu_log("Unhandled stream get from stream-id=%d %s%s%s%s%s\n", + qemu_log_mask(LOG_UNIMP, "Unhandled stream get from stream-id=%d %s%s%s%s%s\n", id, test ? "t" : "", nonblock ? "n" : "",@@ -465,8 +465,8 @@ void helper_memalign(CPUMBState *env, uint32_t addr, uint32_t dr, uint32_t wr,void helper_stackprot (CPUMBState *env,uint32_t addr) {if (addr < env->slr || addr > env->shr) { -qemu_log ("Stack protector violation at %x %x %x\n" , - addr, env->slr, env->shr); +qemu_log_mask (CPU_LOG_INT ,"Stack protector violation at %x %x %x\n" , + addr, env->slr, env->shr); env->sregs[SR_EAR ] = addr; env->sregs[SR_ESR ] =ESR_EC_STACKPROT ;helper_raise_exception (env,EXCP_HW_EXCP );target-microblaze/translate.c +1
-1@@ -1516,7 +1516,7 @@ static void dec_null(DisasContext *dc)t_gen_raise_exception (dc,EXCP_HW_EXCP );return ; } -qemu_log ("unknown insn pc=%x opc=%x\n" , dc->pc, dc->opcode); +qemu_log_mask (LOG_GUEST_ERROR ,"unknown insn pc=%x opc=%x\n" , dc->pc, dc->opcode); dc->abort_at_next_insn =1 ; }Signature · 1 line
2.5.0
PATCH 5/11 s390x: avoid "naked" qemu_log
In reply to Paolo BonziniConvert to debug-only qemu_log.
--- target-s390x/cc_helper.c | 2 +- target-s390x/misc_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target-s390x/cc_helper.c +1 -1
@@ -560,7 +560,7 @@ void HELPER(sacf)(CPUS390XState *env, uint64_t a1) env->psw.mask |=PSW_ASC_HOME ;break ;default : -qemu_log ("unknown sacf mode: %" PRIx64"\n" , a1); +HELPER_LOG ("unknown sacf mode: %" PRIx64"\n" , a1);program_interrupt (env,PGM_SPECIFICATION ,2 );break ; }
target-s390x/misc_helper.c +1 -1
@@ -299,7 +299,7 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)uint32_t prefix = a1 &0x7fffe000 ; env->psa = prefix; -qemu_log ("prefix: %#x\n" , prefix); +HELPER_LOG ("prefix: %#x\n" , prefix);tlb_flush_page (cs,0 );tlb_flush_page (cs,TARGET_PAGE_SIZE ); }
Signature · 1 line
2.5.0
PATCH 6/11 ppc: cleanup logging
In reply to Paolo BonziniAvoid "naked" qemu_log, bring documentation for DEBUG #defines up to date.
--- target-ppc/excp_helper.c | 1 + target-ppc/mmu-hash32.c | 12 ++---------- target-ppc/mmu-hash64.c | 9 +-------- target-ppc/mmu_helper.c | 15 +++++++-------- target-ppc/timebase_helper.c | 10 ++++++---- target-ppc/translate.c | 22 +++++++++------------- 6 files changed, 26 insertions(+), 43 deletions(-)
target-ppc/excp_helper.c +1 -0
@@ -23,6 +23,7 @@#include "helper_regs.h" //#define DEBUG_OP +//#define DEBUG_SOFTWARE_TLB //#define DEBUG_EXCEPTIONS #ifdef DEBUG_EXCEPTIONS
target-ppc/mmu-hash32.c +2 -10
@@ -24,17 +24,10 @@#include "kvm_ppc.h" #include "mmu-hash32.h" -//#define DEBUG_MMU //#define DEBUG_BAT -#ifdef DEBUG_MMU -# define LOG_MMU_STATE (cpu) log_cpu_state((cpu), 0) -#else -# define LOG_MMU_STATE (cpu) do { } while (0) -#endif -#ifdef DEBUG_BATS -# define LOG_BATS (...) qemu_log(__VA_ARGS__) +# define LOG_BATS (...) qemu_log_mask(CPU_LOG_MMU, __VA_ARGS__)#else # define LOG_BATS (...) do { } while (0)#endif
@@ -281,9 +274,8 @@ static int ppc_hash32_direct_store(CPUPPCState *env, target_ulong sr, }return 1 ;default : -qemu_log ("ERROR: instruction should not need " +cpu_abort (cs,"ERROR: instruction should not need " "address translation\n" ); -abort (); }if ((rwx ==1 || key !=1 ) && (rwx ==0 || key !=0 )) { *raddr = eaddr;
target-ppc/mmu-hash64.c +1 -8
@@ -23,17 +23,10 @@#include "kvm_ppc.h" #include "mmu-hash64.h" -//#define DEBUG_MMU //#define DEBUG_SLB -#ifdef DEBUG_MMU -# define LOG_MMU_STATE (cpu) log_cpu_state((cpu), 0) -#else -# define LOG_MMU_STATE (cpu) do { } while (0) -#endif -#ifdef DEBUG_SLB -# define LOG_SLB (...) qemu_log(__VA_ARGS__) +# define LOG_SLB (...) qemu_log_mask(CPU_LOG_MMU, __VA_ARGS__)#else # define LOG_SLB (...) do { } while (0)#endif
target-ppc/mmu_helper.c +7 -8
@@ -28,23 +28,22 @@//#define DEBUG_BATS //#define DEBUG_SOFTWARE_TLB //#define DUMP_PAGE_TABLES -//#define DEBUG_SOFTWARE_TLB //#define FLUSH_ALL_TLBS #ifdef DEBUG_MMU -# define LOG_MMU_STATE (cpu) log_cpu_state((cpu), 0) +# define LOG_MMU_STATE (cpu) log_cpu_state_mask(CPU_LOG_MMU, (cpu), 0)#else # define LOG_MMU_STATE (cpu) do { } while (0)#endif #ifdef DEBUG_SOFTWARE_TLB -# define LOG_SWTLB (...) qemu_log(__VA_ARGS__) +# define LOG_SWTLB (...) qemu_log_mask(CPU_LOG_MMU, __VA_ARGS__)#else # define LOG_SWTLB (...) do { } while (0)#endif #ifdef DEBUG_BATS -# define LOG_BATS (...) qemu_log(__VA_ARGS__) +# define LOG_BATS (...) qemu_log_mask(CPU_LOG_MMU, __VA_ARGS__)#else # define LOG_BATS (...) do { } while (0)#endif
@@ -162,7 +161,7 @@ static inline int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target_ulong pte0,if (ctx->raddr != (hwaddr)-1ULL ) {/* all matches should have equal RPN, WIMG & PP */ if ((ctx->raddr & mmask) != (pte1 & mmask)) { -qemu_log ("Bad RPN/WIMG/PP\n" ); +qemu_log_mask (CPU_LOG_MMU ,"Bad RPN/WIMG/PP\n" );return -3 ; } }
@@ -508,7 +507,7 @@ static inline int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx,/* Software TLB search */ ret =ppc6xx_tlb_check (env, ctx, eaddr, rw, type);#if defined(DUMP_PAGE_TABLES ) -if (qemu_log_enabled ()) { +if (qemu_log_mask (CPU_LOG_MMU )) {hwaddr curaddr;uint32_t a0, a1, a2, a3;
@@ -575,8 +574,8 @@ static inline int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx,/* eciwx or ecowx */ return -4 ;default : -qemu_log ("ERROR: instruction should not need " -"address translation\n" ); +qemu_log_mask (CPU_LOG_MMU ,"ERROR: instruction should not need " +"address translation\n" );return -4 ; }if ((rw ==1 || ctx->key !=1 ) && (rw ==0 || ctx->key !=0 )) {
target-ppc/timebase_helper.c +6 -4
@@ -130,13 +130,14 @@ target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)uint32_t val =0 ;if (unlikely (env->dcr_env ==NULL )) { -qemu_log ("No DCR environment\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"No DCR environment\n" );helper_raise_exception_err (env,POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_read (env->dcr_env, (uint32_t )dcrn, &val) !=0 )) { -qemu_log ("DCR read error %d %03x\n" , (uint32_t )dcrn, (uint32_t )dcrn); +qemu_log_mask (LOG_GUEST_ERROR ,"DCR read error %d %03x\n" , + (uint32_t )dcrn, (uint32_t )dcrn);helper_raise_exception_err (env,POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
@@ -146,13 +147,14 @@ target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)void helper_store_dcr (CPUPPCState *env,target_ulong dcrn,target_ulong val) {if (unlikely (env->dcr_env ==NULL )) { -qemu_log ("No DCR environment\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"No DCR environment\n" );helper_raise_exception_err (env,POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_INVAL_INVAL ); }else if (unlikely (ppc_dcr_write (env->dcr_env, (uint32_t )dcrn, (uint32_t )val) !=0 )) { -qemu_log ("DCR write error %d %03x\n" , (uint32_t )dcrn, (uint32_t )dcrn); +qemu_log_mask (LOG_GUEST_ERROR ,"DCR write error %d %03x\n" , + (uint32_t )dcrn, (uint32_t )dcrn);helper_raise_exception_err (env,POWERPC_EXCP_PROGRAM ,POWERPC_EXCP_INVAL |POWERPC_EXCP_PRIV_REG ); }
target-ppc/translate.c +9 -13
@@ -11530,12 +11530,10 @@ void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb) }/* Is opcode *REALLY* valid ? */ if (unlikely (handler->handler == &gen_invalid)) { -if (qemu_log_enabled ()) { -qemu_log ("invalid/unsupported opcode: " -"%02x - %02x - %02x (%08x) " TARGET_FMT_lx" %d\n" , -opc1 (ctx.opcode),opc2 (ctx.opcode), -opc3 (ctx.opcode), ctx.opcode, ctx.nip -4 , (int )msr_ir); - } +qemu_log_mask (LOG_GUEST_ERROR ,"invalid/unsupported opcode: " +"%02x - %02x - %02x (%08x) " TARGET_FMT_lx" %d\n" , +opc1 (ctx.opcode),opc2 (ctx.opcode), +opc3 (ctx.opcode), ctx.opcode, ctx.nip -4 , (int )msr_ir); }else {uint32_t inval;
@@ -11546,13 +11544,11 @@ void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb) }if (unlikely ((ctx.opcode & inval) !=0 )) { -if (qemu_log_enabled ()) { -qemu_log ("invalid bits: %08x for opcode: " -"%02x - %02x - %02x (%08x) " TARGET_FMT_lx"\n" , - ctx.opcode & inval,opc1 (ctx.opcode), -opc2 (ctx.opcode),opc3 (ctx.opcode), - ctx.opcode, ctx.nip -4 ); - } +qemu_log_mask (LOG_GUEST_ERROR ,"invalid bits: %08x for opcode: " +"%02x - %02x - %02x (%08x) " TARGET_FMT_lx"\n" , + ctx.opcode & inval,opc1 (ctx.opcode), +opc2 (ctx.opcode),opc3 (ctx.opcode), + ctx.opcode, ctx.nip -4 );gen_inval_exception (ctxp,POWERPC_EXCP_INVAL_INVAL );break ; }
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 06/11] ppc: cleanup logging
Quoted 5 lines · Paolo Bonzini
Avoid "naked"
qemu_log, bring documentation for DEBUG #defines up to date.Cc David Gibson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 7/11 tricore: avoid "naked" qemu_log
In reply to Paolo Bonzini--- target-tricore/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-tricore/helper.c +2 -2
@@ -65,8 +65,8 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address, access_type =ACCESS_INT ; ret =get_physical_address (env, &physical, &prot, address, rw, access_type); -qemu_log ("%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_plx -" prot %d\n" , __func__, address, ret, physical, prot); +qemu_log_mask (CPU_LOG_MMU ,"%s address=" TARGET_FMT_lx" ret %d physical " TARGET_FMT_plx +" prot %d\n" , __func__, address, ret, physical, prot);if (ret ==TLBRET_MATCH ) { tlb_set_page(cs, address & TARGET_PAGE_MASK,
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 07/11] tricore: avoid "naked" qemu_log
Quoted 6 lines · Paolo Bonzini
Cc Bastian Koppelmann <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target-tricore/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
This doesn't look like something which should go into 2.5, so I'll add this into my queue for 2.6.
Cheers,
Bastian
Re: [Qemu-devel] [PATCH 07/11] tricore: avoid "naked" qemu_log
Quoted 10 lines · Bastian Koppelmann
Quoted 6 lines · Paolo Bonzini
Cc Bastian Koppelmann <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target-tricore/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)This doesn't look like something which should go into 2.5, so I'll add this into my queue for 2.6.
Nothing not already in master is going into 2.5 unless somebody finds a "make install runs rm -rf /" level bug at the last minute :-)
thanks
-- PMM
PATCH 8/11 xtensa: avoid "naked" qemu_log
In reply to Paolo Bonzini--- target-xtensa/gdbstub.c | 8 ++++---- target-xtensa/helper.c | 4 ++-- target-xtensa/op_helper.c | 20 ++++++++++---------- target-xtensa/translate.c | 28 ++++++++++++++-------------- target-xtensa/xtensa-semi.c | 2 +- 5 files changed, 31 insertions(+), 31 deletions(-)
target-xtensa/gdbstub.c +4 -4
@@ -63,8 +63,8 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)return gdb_get_reg32 (mem_buf, env->regs[reg->targno &0x0f ]);default : -qemu_log ("%s from reg %d of unsupported type %d\n" , - __func__, n, reg->type); +qemu_log_mask (LOG_UNIMP ,"%s from reg %d of unsupported type %d\n" , + __func__, n, reg->type);return 0 ; } }
@@ -117,8 +117,8 @@ int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)break ;default : -qemu_log ("%s to reg %d of unsupported type %d\n" , - __func__, n, reg->type); +qemu_log_mask (LOG_UNIMP ,"%s to reg %d of unsupported type %d\n" , + __func__, n, reg->type);return 0 ; }
target-xtensa/helper.c +2 -2
@@ -254,8 +254,8 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->config->exception_vector[cs->exception_index]); env->exception_taken =1 ; }else { -qemu_log ("%s(pc = %08x) bad exception_index: %d\n" , - __func__, env->pc, cs->exception_index); +qemu_log_mask (CPU_LOG_INT ,"%s(pc = %08x) bad exception_index: %d\n" , + __func__, env->pc, cs->exception_index); }break ;
target-xtensa/op_helper.c +10 -10
@@ -245,8 +245,8 @@ void HELPER(entry)(CPUXtensaState *env, uint32_t pc, uint32_t s, uint32_t imm) {int callinc = (env->sregs[PS ] &PS_CALLINC ) >>PS_CALLINC_SHIFT ;if (s >3 || ((env->sregs[PS ] & (PS_WOE |PS_EXCM )) ^PS_WOE ) !=0 ) { -qemu_log ("Illegal entry instruction(pc = %08x), PS = %08x\n" , - pc, env->sregs[PS ]); +qemu_log_mask (LOG_GUEST_ERROR ,"Illegal entry instruction(pc = %08x), PS = %08x\n" , + pc, env->sregs[PS ]);HELPER (exception_cause)(env, pc,ILLEGAL_INSTRUCTION_CAUSE ); }else { uint32_t windowstart = xtensa_replicate_windowstart(env) >>
@@ -307,9 +307,9 @@ uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc)if (n ==0 || (m !=0 && m != n) || ((env->sregs[PS ] & (PS_WOE |PS_EXCM )) ^PS_WOE ) !=0 ) { -qemu_log ("Illegal retw instruction(pc = %08x), " -"PS = %08x, m = %d, n = %d\n" , - pc, env->sregs[PS ], m, n); +qemu_log_mask (LOG_GUEST_ERROR ,"Illegal retw instruction(pc = %08x), " +"PS = %08x, m = %d, n = %d\n" , + pc, env->sregs[PS ], m, n);HELPER (exception_cause)(env, pc,ILLEGAL_INSTRUCTION_CAUSE ); }else {int owb = windowbase;
@@ -743,8 +743,8 @@ void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,xtensa_tlb_set_entry_mmu (env, entry, dtlb, wi, ei, vpn, pte);tlb_flush_page (cs, entry->vaddr); }else { -qemu_log ("%s %d, %d, %d trying to set immutable entry\n" , - __func__, dtlb, wi, ei); +qemu_log_mask (LOG_GUEST_ERROR ,"%s %d, %d, %d trying to set immutable entry\n" , + __func__, dtlb, wi, ei); } }else {tlb_flush_page (cs, entry->vaddr);
@@ -806,15 +806,15 @@ static void set_dbreak(CPUXtensaState *env, unsigned i, uint32_t dbreaka, }/* contiguous mask after inversion is one less than some power of 2 */ if ((~mask +1 ) & ~mask) { -qemu_log ("DBREAKC mask is not contiguous: 0x%08x\n" , dbreakc); +qemu_log_mask (LOG_GUEST_ERROR ,"DBREAKC mask is not contiguous: 0x%08x\n" , dbreakc);/* cut mask after the first zero bit */ mask =0xffffffff << (32 -clo32 (mask)); }if (cpu_watchpoint_insert (cs, dbreaka & mask, ~mask +1 , flags, &env->cpu_watchpoint[i])) { env->cpu_watchpoint[i] =NULL ; -qemu_log ("Failed to set data breakpoint at 0x%08x/%d\n" , - dbreaka & mask, ~mask +1 ); +qemu_log_mask (LOG_GUEST_ERROR ,"Failed to set data breakpoint at 0x%08x/%d\n" , + dbreaka & mask, ~mask +1 ); } }
target-xtensa/translate.c +14 -14
@@ -501,9 +501,9 @@ static bool gen_check_sr(DisasContext *dc, uint32_t sr, unsigned access) {if (!xtensa_option_bits_enabled (dc->config, sregnames[sr].opt_bits)) {if (sregnames[sr].name) { -qemu_log ("SR %s is not configured\n" , sregnames[sr].name); +qemu_log_mask (LOG_GUEST_ERROR ,"SR %s is not configured\n" , sregnames[sr].name); }else { -qemu_log ("SR %d is not implemented\n" , sr); +qemu_log_mask (LOG_UNIMP ,"SR %d is not implemented\n" , sr); }gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE );return false;
@@ -514,8 +514,8 @@ static bool gen_check_sr(DisasContext *dc, uint32_t sr, unsigned access) [SR_X ] ="xsr" , };assert (access <ARRAY_SIZE (access_text) && access_text[access]); -qemu_log ("SR %s is not available for %s\n" , sregnames[sr].name, - access_text[access]); +qemu_log_mask (LOG_GUEST_ERROR ,"SR %s is not available for %s\n" , sregnames[sr].name, + access_text[access]);gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE );return false; }
@@ -875,18 +875,18 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) {#define HAS_OPTION_BITS (opt) do { \ if (!option_bits_enabled(dc, opt)) { \ - qemu_log("Option is not enabled %s:%d\n", \ - __FILE__, __LINE__); \ + qemu_log_mask(LOG_GUEST_ERROR, "Option is not enabled %s:%d\n", \ + __FILE__, __LINE__); \ goto invalid_opcode; \ } \ } while (0)#define HAS_OPTION (opt) HAS_OPTION_BITS(XTENSA_OPTION_BIT(opt)) -#define TBD () qemu_log("TBD(pc = %08x): %s:%d\n", dc->pc, __FILE__, __LINE__) +#define TBD () qemu_log_mask(LOG_UNIMP, "TBD(pc = %08x): %s:%d\n", dc->pc, __FILE__, __LINE__)#define RESERVED () do { \ - qemu_log("RESERVED(pc = %08x, %02x%02x%02x): %s:%d\n", \ - dc->pc, b0, b1, b2, __FILE__, __LINE__); \ + qemu_log_mask(LOG_GUEST_ERROR, "RESERVED(pc = %08x, %02x%02x%02x): %s:%d\n", \ + dc->pc, b0, b1, b2, __FILE__, __LINE__); \ goto invalid_opcode; \ } while (0)
@@ -1186,7 +1186,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)gen_jump (dc, cpu_SR[EPC1 +RRR_S -1 ]); } }else { -qemu_log ("RFI %d is illegal\n" ,RRR_S ); +qemu_log_mask (LOG_GUEST_ERROR ,"RFI %d is illegal\n" ,RRR_S );gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE ); }break ;
@@ -1222,7 +1222,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)gen_helper_simcall (cpu_env); } }else { -qemu_log ("SIMCALL but semihosting is disabled\n" ); +qemu_log_mask (LOG_GUEST_ERROR ,"SIMCALL but semihosting is disabled\n" );gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE ); }break ;
@@ -1865,7 +1865,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)if (uregnames[st].name) {tcg_gen_mov_i32 (cpu_R[RRR_R ], cpu_UR[st]); }else { -qemu_log ("RUR %d not implemented, " , st); +qemu_log_mask (LOG_UNIMP ,"RUR %d not implemented, " , st);TBD (); } }
@@ -1876,7 +1876,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)if (uregnames[RSR_SR ].name) {gen_wur (RSR_SR , cpu_R[RRR_T ]); }else { -qemu_log ("WUR %d not implemented, " ,RSR_SR ); +qemu_log_mask (LOG_UNIMP ,"WUR %d not implemented, " ,RSR_SR );TBD (); } }
@@ -3006,7 +3006,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)return ; invalid_opcode: -qemu_log ("INVALID(pc = %08x)\n" , dc->pc); +qemu_log_mask (LOG_GUEST_ERROR ,"INVALID(pc = %08x)\n" , dc->pc);gen_exception_cause (dc,ILLEGAL_INSTRUCTION_CAUSE );#undef HAS_OPTION }
target-xtensa/xtensa-semi.c +1 -1
@@ -313,7 +313,7 @@ void HELPER(simcall)(CPUXtensaState *env)break ;default : -qemu_log ("%s(%d): not implemented\n" , __func__, regs[2 ]); +qemu_log_mask (LOG_GUEST_ERROR ,"%s(%d): not implemented\n" , __func__, regs[2 ]); regs[2 ] =-1 ; regs[3 ] =TARGET_ENOSYS ;break ;
Signature · 1 line
2.5.0
PATCH 9/11 user: introduce "-d page"
In reply to Paolo Bonzini--- bsd-user/main.c | 4 ++-- include/qemu/log.h | 1 + linux-user/elfload.c | 8 ++++---- linux-user/main.c | 4 ++-- qemu-log.c | 2 ++ 5 files changed, 11 insertions(+), 8 deletions(-)
bsd-user/main.c +2 -2
@@ -938,7 +938,7 @@ int main(int argc, char **argv)unsigned long tmp;if (fscanf (fp,"%lu" , &tmp) ==1 ) { mmap_min_addr = tmp; -qemu_log ("host mmap_min_addr=0x%lx\n" , mmap_min_addr); +qemu_log_mask (CPU_LOG_PAGE ,"host mmap_min_addr=0x%lx\n" , mmap_min_addr); }fclose (fp); }
@@ -955,7 +955,7 @@ int main(int argc, char **argv)free (target_environ); -if (qemu_log_enabled ()) { +if (qemu_loglevel_mask (CPU_LOG_PAGE )) {qemu_log ("guest_base 0x%lx\n" , guest_base);log_page_dump ();
include/qemu/log.h +1 -0
@@ -48,6 +48,7 @@ static inline bool qemu_log_separate(void)#define LOG_GUEST_ERROR (1 << 11)#define CPU_LOG_MMU (1 << 12)#define CPU_LOG_TB_NOCHAIN (1 << 13) +#define CPU_LOG_PAGE (1 << 14)/* Returns true if a bit is set in the current loglevel mask */
linux-user/elfload.c +4 -4
@@ -1743,7 +1743,7 @@ unsigned long init_guest_space(unsigned long host_start, } } -qemu_log ("Reserved 0x%lx bytes of guest address space\n" , host_size); +qemu_log_mask (CPU_LOG_PAGE ,"Reserved 0x%lx bytes of guest address space\n" , host_size);return real_start; }
@@ -1784,9 +1784,9 @@ static void probe_guest_base(const char *image_name, } guest_base = real_start - loaddr; -qemu_log ("Relocating guest address space from 0x" - TARGET_ABI_FMT_lx" to 0x%lx\n" , - loaddr, real_start); +qemu_log_mask (CPU_LOG_PAGE ,"Relocating guest address space from 0x" + TARGET_ABI_FMT_lx" to 0x%lx\n" , + loaddr, real_start); }return ;
linux-user/main.c +2 -2
@@ -4241,7 +4241,7 @@ int main(int argc, char **argv, char **envp)unsigned long tmp;if (fscanf (fp,"%lu" , &tmp) ==1 ) { mmap_min_addr = tmp; -qemu_log ("host mmap_min_addr=0x%lx\n" , mmap_min_addr); +qemu_log_mask (CPU_LOG_PAGE ,"host mmap_min_addr=0x%lx\n" , mmap_min_addr); }fclose (fp); }
@@ -4300,7 +4300,7 @@ int main(int argc, char **argv, char **envp)free (target_environ); -if (qemu_log_enabled ()) { +if (qemu_loglevel_mask (CPU_LOG_PAGE )) {qemu_log ("guest_base 0x%lx\n" , guest_base);log_page_dump ();
qemu-log.c +2 -0
@@ -117,6 +117,8 @@ const QEMULogItem qemu_log_items[] = { {LOG_GUEST_ERROR ,"guest_errors" ,"log when the guest OS does something invalid (eg accessing a\n" "non-existent register)" }, + { CPU_LOG_PAGE, "page", + "dump pages at beginning of user mode emulation" }, { CPU_LOG_TB_NOCHAIN, "nochain","do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" },
Signature · 1 line
2.5.0
PATCH 10/11 linux-user: avoid "naked" qemu_log
In reply to Paolo BonziniEnsure that all log writes are protected by qemu_loglevel_mask or, in serious cases, go to both the log and stderr.
--- linux-user/main.c | 71 ++++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 40 deletions(-)
linux-user/main.c +31 -40
@@ -45,6 +45,18 @@ static const char *cpu_model;unsigned long mmap_min_addr;unsigned long guest_base;int have_guest_base; + +#define EXCP_DUMP (env, fmt, ...) \ +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__); \ + log_cpu_state(cs, 0); \ + } \ +} while (0) +#if (TARGET_LONG_BITS ==32 ) && (HOST_LONG_BITS ==64 )/* * When running 32-on-64 we should make sure we can fit all of the possible
@@ -416,8 +428,8 @@ void cpu_loop(CPUX86State *env)break ;default : pc = env->segs[R_CS ].base + env->eip; -fprintf (stderr,"qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n" , - (long )pc, trapnr); +EXCP_DUMP (env,"qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n" , + (long )pc, trapnr);abort (); }process_pending_signals (env);
@@ -865,9 +877,7 @@ void cpu_loop(CPUARMState *env)break ;default : error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);
@@ -1056,9 +1066,7 @@ void cpu_loop(CPUARMState *env) env->xregs[0 ] =do_arm_semihosting (env);break ;default : -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);
@@ -1148,8 +1156,7 @@ void cpu_loop(CPUUniCore32State *env) } error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }#endif
@@ -1467,17 +1474,6 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)return -1 ; } -#define EXCP_DUMP (env, fmt, ...) \ -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__); \ - log_cpu_state(cs, 0); \ - } \ -} while (0) -static int do_store_exclusive (CPUPPCState *env) {target_ulong addr;
@@ -2636,9 +2632,7 @@ done_syscall:break ;default : error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);
@@ -2661,11 +2655,11 @@ void cpu_loop(CPUOpenRISCState *env)switch (trapnr) {case EXCP_RESET : -qemu_log ("\nReset request, exit, pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nReset request, exit, pc is %#x\n" , env->pc);exit (EXIT_FAILURE );break ;case EXCP_BUSERR : -qemu_log ("\nBus error, exit, pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nBus error, exit, pc is %#x\n" , env->pc); gdbsig =TARGET_SIGBUS ;break ;case EXCP_DPF :
@@ -2674,25 +2668,25 @@ void cpu_loop(CPUOpenRISCState *env) gdbsig =TARGET_SIGSEGV ;break ;case EXCP_TICK : -qemu_log ("\nTick time interrupt pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nTick time interrupt pc is %#x\n" , env->pc);break ;case EXCP_ALIGN : -qemu_log ("\nAlignment pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nAlignment pc is %#x\n" , env->pc); gdbsig =TARGET_SIGBUS ;break ;case EXCP_ILLEGAL : -qemu_log ("\nIllegal instructionpc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nIllegal instructionpc is %#x\n" , env->pc); gdbsig =TARGET_SIGILL ;break ;case EXCP_INT : -qemu_log ("\nExternal interruptpc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nExternal interruptpc is %#x\n" , env->pc);break ;case EXCP_DTLBMISS :case EXCP_ITLBMISS : -qemu_log ("\nTLB miss\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nTLB miss\n" );break ;case EXCP_RANGE : -qemu_log ("\nRange\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nRange\n" ); gdbsig =TARGET_SIGSEGV ;break ;case EXCP_SYSCALL :
@@ -2707,19 +2701,18 @@ void cpu_loop(CPUOpenRISCState *env) env->gpr[8], 0, 0);break ;case EXCP_FPE : -qemu_log ("\nFloating point error\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nFloating point error\n" );break ;case EXCP_TRAP : -qemu_log ("\nTrap\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nTrap\n" ); gdbsig =TARGET_SIGTRAP ;break ;case EXCP_NR : -qemu_log ("\nNR\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nNR\n" );break ;default : -qemu_log ("\nqemu: unhandled CPU exception %#x - aborting\n" , +EXCP_DUMP (env,"\nqemu: unhandled CPU exception %#x - aborting\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); gdbsig =TARGET_SIGILL ;break ; }
@@ -3047,9 +3040,7 @@ void cpu_loop(CPUM68KState *env) }break ;default : -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 10/11] linux-user: avoid "naked" qemu_log
Quoted 175 lines · Paolo Bonzini
Ensure that all log writes are protected by
qemu_loglevel_maskor, in serious cases, go to both the log and stderr.Signed-off-by Paolo Bonzini <[email protected]>--- linux-user/main.c | 71 ++++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 40 deletions(-)linux-user/main.c +30
-37@@ -45,6 +45,18 @@ static const char *cpu_model;unsigned long mmap_min_addr;unsigned long guest_base;int have_guest_base; + +#define EXCP_DUMP (env, fmt, ...) \ +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__); \ + log_cpu_state(cs, 0); \ + } \ +} while (0) +#if (TARGET_LONG_BITS ==32 ) && (HOST_LONG_BITS ==64 )/* * When running 32-on-64 we should make sure we can fit all of the possible @@ -416,8 +428,8 @@ void cpu_loop(CPUX86State *env)break ;default : pc = env->segs[R_CS ].base + env->eip; -fprintf (stderr,"qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n" , - (long )pc, trapnr); +EXCP_DUMP (env,"qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n" , + (long )pc, trapnr);abort (); }process_pending_signals (env);@@ -865,9 +877,7 @@ void cpu_loop(CPUARMState *env)break ;default : error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);@@ -1056,9 +1066,7 @@ void cpu_loop(CPUARMState *env) env->xregs[0 ] =do_arm_semihosting (env);break ;default : -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);@@ -1148,8 +1156,7 @@ void cpu_loop(CPUUniCore32State *env) } error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }#endif @@ -1467,17 +1474,6 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)return -1 ; } -#define EXCP_DUMP (env, fmt, ...) \ -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__); \ - log_cpu_state(cs, 0); \ - } \ -} while (0) -static int do_store_exclusive (CPUPPCState *env) {target_ulong addr;@@ -2636,9 +2632,7 @@ done_syscall:break ;default : error: -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);@@ -2661,11 +2655,11 @@ void cpu_loop(CPUOpenRISCState *env)switch (trapnr) {case EXCP_RESET : -qemu_log ("\nReset request, exit, pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nReset request, exit, pc is %#x\n" , env->pc);exit (EXIT_FAILURE );break ;case EXCP_BUSERR : -qemu_log ("\nBus error, exit, pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nBus error, exit, pc is %#x\n" , env->pc); gdbsig =TARGET_SIGBUS ;break ;case EXCP_DPF :@@ -2674,25 +2668,25 @@ void cpu_loop(CPUOpenRISCState *env) gdbsig =TARGET_SIGSEGV ;break ;case EXCP_TICK : -qemu_log ("\nTick time interrupt pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nTick time interrupt pc is %#x\n" , env->pc);break ;case EXCP_ALIGN : -qemu_log ("\nAlignment pc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nAlignment pc is %#x\n" , env->pc); gdbsig =TARGET_SIGBUS ;break ;case EXCP_ILLEGAL : -qemu_log ("\nIllegal instructionpc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nIllegal instructionpc is %#x\n" , env->pc); gdbsig =TARGET_SIGILL ;break ;case EXCP_INT : -qemu_log ("\nExternal interruptpc is %#x\n" , env->pc); +qemu_log_mask (CPU_LOG_INT ,"\nExternal interruptpc is %#x\n" , env->pc);break ;case EXCP_DTLBMISS :case EXCP_ITLBMISS : -qemu_log ("\nTLB miss\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nTLB miss\n" );break ;case EXCP_RANGE : -qemu_log ("\nRange\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nRange\n" ); gdbsig =TARGET_SIGSEGV ;break ;case EXCP_SYSCALL :@@ -2707,19 +2701,18 @@ void cpu_loop(CPUOpenRISCState *env) env->gpr[8], 0, 0);break ;case EXCP_FPE : -qemu_log ("\nFloating point error\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nFloating point error\n" );break ;case EXCP_TRAP : -qemu_log ("\nTrap\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nTrap\n" ); gdbsig =TARGET_SIGTRAP ;break ;case EXCP_NR : -qemu_log ("\nNR\n" ); +qemu_log_mask (CPU_LOG_INT ,"\nNR\n" );break ;default : -qemu_log ("\nqemu: unhandled CPU exception %#x - aborting\n" , +EXCP_DUMP (env,"\nqemu: unhandled CPU exception %#x - aborting\n" , trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); gdbsig =TARGET_SIGILL ;break ; }
linux-user/main.c void cpu_loop(CPUM68KState *env) · line 3046
Quoted 10 lines
linux-user/main.c +1
-3@@ -3047,9 +3040,7 @@ void cpu_loop(CPUM68KState *env) }break ;default : -fprintf (stderr,"qemu: unhandled CPU exception 0x%x - aborting\n" , - trapnr); -cpu_dump_state (cs, stderr, fprintf,0 ); +EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }process_pending_signals (env);
PATCH 11/11 linux-user: convert DEBUG_SIGNAL logging to tracepoints
In reply to Paolo Bonzini"Unimplemented" messages go to stderr, everything else goes to tracepoints
--- bsd-user/signal.c | 2 - linux-user/signal.c | 118 ++++++++++++++++++++++++++-------------------------- trace-events | 11 +++++ 3 files changed, 69 insertions(+), 62 deletions(-)
bsd-user/signal.c +0 -2
@@ -26,8 +26,6 @@#include "qemu.h" #include "target_signal.h" -//#define DEBUG_SIGNAL -void signal_init (void ) { }
linux-user/signal.c +58 -60
515 lines not on this page · raw message
trace-events +11 -0
@@ -1795,3 +1795,14 @@ qcrypto_tls_session_new(void *session, void *creds, const char *hostname, const # net/vhost-user.c vhost_user_event(const char *chr, int event) "chr: %s got event: %d" + +# linux-user/signal.c +user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_do_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_force_sig(void *env, int target_sig, int host_sig) "env=%p signal %d (host %d)" +user_handle_signal(void *env, int target_sig) "env=%p signal %d" +user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d(" +user_queue_signal(void *env, int target_sig) "env=%p signal %d" +user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_addr) "env=%p frame psw.addr "PRIx64 " current psw.addr "PRIx64""
Signature · 1 line
2.5.0
Re: [Qemu-devel] [PATCH 11/11] linux-user: convert DEBUG_SIGNAL logging to tracepoints
Quoted 612 lines · Paolo Bonzini
"Unimplemented" messages go to stderr, everything else goes to tracepoints
Signed-off-by Paolo Bonzini <[email protected]>--- bsd-user/signal.c | 2 - linux-user/signal.c | 118 ++++++++++++++++++++++++++-------------------------- trace-events | 11 +++++ 3 files changed, 69 insertions(+), 62 deletions(-)bsd-user/signal.c +0
-2@@ -26,8 +26,6 @@#include "qemu.h" #include "target_signal.h" -//#define DEBUG_SIGNAL -void signal_init (void ) { }linux-user/signal.c +58
-60@@ -28,8 +28,7 @@#include "qemu.h" #include "qemu-common.h" #include "target_signal.h" - -//#define DEBUG_SIGNAL +#include "trace.h" static struct target_sigaltstack target_sigaltstack_used = { .ss_sp =0 ,@@ -444,7 +443,9 @@ static void QEMU_NORETURN force_sig(int target_sig)TaskState *ts = (TaskState *)cpu->opaque;int host_sig, core_dumped =0 ;struct sigaction act; + host_sig =target_to_host_signal (target_sig); +trace_user_force_sig (env, target_sig, host_sig);gdb_signalled (env, target_sig);/* dump core if supported by target binary format */ @@ -499,10 +500,7 @@ int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)abi_ulong handler;int queue; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"queue_signal: sig=%d\n" , - sig); -#endif +trace_user_queue_signal (env, sig); k = &ts->sigtab[sig -1 ]; queue =gdb_queuesig (); handler = sigact_table[sig -1 ]._sa_handler;@@ -587,9 +585,7 @@ static void host_signal_handler(int host_signum, siginfo_t *info, sig =host_to_target_signal (host_signum);if (sig <1 || sig >TARGET_NSIG )return ; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"qemu: got signal %d\n" , sig); -#endif +trace_user_host_signal (env, host_signum, sig);host_to_target_siginfo_noswap (&tinfo, info);if (queue_signal (env, sig, &tinfo) ==1 ) {/* interrupt the virtual CPU as soon as possible */ @@ -682,10 +678,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,if (sig <1 || sig >TARGET_NSIG || sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP )return -EINVAL ; k = &sigact_table[sig -1 ]; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"sigaction sig=%d act=0x%p, oact=0x%p\n" , - sig, act, oact); -#endif if (oact) {__put_user (k->_sa_handler, &oact->_sa_handler);__put_user (k->sa_flags, &oact->sa_flags);@@ -909,6 +901,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -970,6 +963,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -1081,9 +1075,7 @@ long do_sigreturn(CPUX86State *env)sigset_t set;int eax, i; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"do_sigreturn\n" ); -#endif +trace_user_do_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;/* set blocked signals */ @@ -1115,6 +1107,7 @@ long do_rt_sigreturn(CPUX86State *env)int eax; frame_addr = env->regs[R_ESP ] -4 ; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;target_to_host_sigset (&set, &frame->uc.tuc_sigmask);@@ -1318,6 +1311,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,abi_ulong frame_addr, return_addr; frame_addr =get_sigframe (ka, env); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; }@@ -1377,6 +1371,7 @@ long do_rt_sigreturn(CPUARMState *env)struct target_rt_sigframe *frame =NULL ;abi_ulong frame_addr = env->xregs[31 ]; +trace_user_do_rt_sigreturn (env, frame_addr);if (frame_addr &15 ) { goto badframe; }@@ -1703,6 +1698,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka,abi_ulong frame_addr =get_sigframe (ka, regs,sizeof (*frame));int i; +trace_user_setup_frame (regs, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 ))return ;@@ -1724,6 +1720,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka,struct sigframe_v2 *frame;abi_ulong frame_addr =get_sigframe (ka, regs,sizeof (*frame)); +trace_user_setup_frame (regs, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 ))return ;@@ -1756,6 +1753,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,int i;abi_ulong info_addr, uc_addr; +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 ))return /* 1 */ ;@@ -1796,6 +1794,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,abi_ulong frame_addr =get_sigframe (ka, env,sizeof (*frame));abi_ulong info_addr, uc_addr; +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 ))return /* 1 */ ;@@ -1871,6 +1870,7 @@ static long do_sigreturn_v1(CPUARMState *env)* not, then the user is trying to mess with us. */ frame_addr = env->regs[13 ]; +trace_user_do_sigreturn (env, frame_addr);if (frame_addr &7 ) { goto badframe; }@@ -2007,6 +2007,7 @@ static long do_sigreturn_v2(CPUARMState *env)* not, then the user is trying to mess with us. */ frame_addr = env->regs[13 ]; +trace_user_do_sigreturn (env, frame_addr);if (frame_addr &7 ) { goto badframe; }@@ -2047,6 +2048,7 @@ static long do_rt_sigreturn_v1(CPUARMState *env)* not, then the user is trying to mess with us. */ frame_addr = env->regs[13 ]; +trace_user_do_rt_sigreturn (env, frame_addr);if (frame_addr &7 ) { goto badframe; }@@ -2088,6 +2090,7 @@ static long do_rt_sigreturn_v2(CPUARMState *env)* not, then the user is trying to mess with us. */ frame_addr = env->regs[13 ]; +trace_user_do_rt_sigreturn (env, frame_addr);if (frame_addr &7 ) { goto badframe; }@@ -2283,13 +2286,13 @@ static void setup_frame(int sig, struct target_sigaction *ka, sigframe_size =NF_ALIGNEDSZ ; sf_addr =get_sigframe (ka, env, sigframe_size); +trace_user_setup_frame (env, sf_addr); sf =lock_user (VERIFY_WRITE , sf_addr,sizeof (struct target_signal_frame ),0 );if (!sf) goto sigsegv; -//fprintf(stderr, "sf: %x pc %x fp %x sp %x\n", sf, env->pc, env->regwptr[UREG_FP], env->regwptr[UREG_SP]); #if 0 if (invalid_frame_pointer (sf, sigframe_size)) goto sigill_and_return;@@ -2356,7 +2359,6 @@ sigill_and_return:force_sig (TARGET_SIGILL );#endif sigsegv: -//fprintf(stderr, "force_sig\n"); unlock_user (sf, sf_addr,sizeof (struct target_signal_frame ));force_sig (TARGET_SIGSEGV ); }@@ -2378,13 +2380,9 @@ long do_sigreturn(CPUSPARCState *env)int err=0 , i; sf_addr = env->regwptr[UREG_FP ]; +trace_user_do_sigreturn (env, sf_addr);if (!lock_user_struct (VERIFY_READ , sf, sf_addr,1 )) goto segv_and_exit; -#if 0 -fprintf (stderr,"sigreturn\n" ); -fprintf (stderr,"sf: %x pc %x fp %x sp %x\n" , sf, env->pc, env->regwptr[UREG_FP ], env->regwptr[UREG_SP ]); -#endif -//cpu_dump_state(env, stderr, fprintf, 0); /* 1. Make sure we are not getting garbage from the user */ @@ -2443,6 +2441,7 @@ segv_and_exit:long do_rt_sigreturn (CPUSPARCState *env) { +trace_user_do_rt_sigreturn (env,0 );fprintf (stderr,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }@@ -2902,6 +2901,7 @@ static void setup_frame(int sig, struct target_sigaction * ka,int i; frame_addr =get_sigframe (ka, regs,sizeof (*frame)); +trace_user_setup_frame (regs, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -2948,10 +2948,8 @@ long do_sigreturn(CPUMIPSState *regs)target_sigset_t target_set;int i; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"do_sigreturn\n" ); -#endif frame_addr = regs->active_tc.gpr[29 ]; +trace_user_do_sigreturn (regs, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -2998,6 +2996,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -3055,10 +3054,8 @@ long do_rt_sigreturn(CPUMIPSState *env)abi_ulong frame_addr;sigset_t blocked; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"do_rt_sigreturn\n" ); -#endif frame_addr = env->active_tc.gpr[29 ]; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -3216,6 +3213,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int err =0 ; frame_addr =get_sigframe (ka, regs->gregs[15 ],sizeof (*frame)); +trace_user_setup_frame (regs, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -3265,6 +3263,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,int err =0 ; frame_addr =get_sigframe (ka, regs->gregs[15 ],sizeof (*frame)); +trace_user_setup_rt_frame (regs, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -3325,10 +3324,8 @@ long do_sigreturn(CPUSH4State *regs)int i;int err =0 ; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"do_sigreturn\n" ); -#endif frame_addr = regs->gregs[15 ]; +trace_user_do_sigreturn (regs, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -3361,10 +3358,8 @@ long do_rt_sigreturn(CPUSH4State *regs)sigset_t blocked;target_ulong r0; -#if defined(DEBUG_SIGNAL ) -fprintf (stderr,"do_rt_sigreturn\n" ); -#endif frame_addr = regs->gregs[15 ]; +trace_user_do_rt_sigreturn (regs, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -3514,6 +3509,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof *frame); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto badframe;@@ -3579,6 +3575,7 @@ long do_sigreturn(CPUMBState *env)int i; frame_addr = env->regs[R_SP ]; +trace_user_do_sigreturn (env, frame_addr);/* Make sure the guest isn't playing games. */ if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,1 )) goto badframe;@@ -3604,6 +3601,7 @@ long do_sigreturn(CPUMBState *env)long do_rt_sigreturn (CPUMBState *env) { +trace_user_do_rt_sigreturn (env,0 );fprintf (stderr,"Microblaze do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }@@ -3693,6 +3691,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (env,sizeof *frame); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto badframe;@@ -3746,6 +3745,7 @@ long do_sigreturn(CPUCRISState *env)int i; frame_addr = env->regs[R_SP ]; +trace_user_do_sigreturn (env, frame_addr);/* Make sure the guest isn't playing games. */ if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,1 )) goto badframe;@@ -3767,6 +3767,7 @@ long do_sigreturn(CPUCRISState *env)long do_rt_sigreturn (CPUCRISState *env) { +trace_user_do_rt_sigreturn (env,0 );fprintf (stderr,"CRIS do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }@@ -3911,6 +3912,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,abi_ulong info_addr, uc_addr; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; }@@ -3972,14 +3974,15 @@ give_sigsegv:long do_sigreturn (CPUOpenRISCState *env) { - -qemu_log ("do_sigreturn: not implemented\n" ); +trace_user_do_sigreturn (env,0 ); +fprintf (stderr,"do_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }long do_rt_sigreturn (CPUOpenRISCState *env) { -qemu_log ("do_rt_sigreturn: not implemented\n" ); +trace_user_do_rt_sigreturn (env,0 ); +fprintf (stderr,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }/* TARGET_OPENRISC */ @@ -4102,13 +4105,11 @@ static void setup_frame(int sig, struct target_sigaction *ka,abi_ulong frame_addr; frame_addr =get_sigframe (ka, env,sizeof (*frame)); -qemu_log ("%s: frame_addr 0x%llx\n" , __FUNCTION__, - (unsigned long long )frame_addr); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; } -qemu_log ("%s: 1\n" , __FUNCTION__);__put_user (set->sig[0 ], &frame->sc.oldmask[0 ]);save_sigregs (env, &frame->sregs);@@ -4149,7 +4150,6 @@ static void setup_frame(int sig, struct target_sigaction *ka,return ; give_sigsegv: -qemu_log ("%s: give_sigsegv\n" , __FUNCTION__);force_sig (TARGET_SIGSEGV ); }@@ -4162,13 +4162,11 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,abi_ulong frame_addr; frame_addr =get_sigframe (ka, env,sizeof *frame); -qemu_log ("%s: frame_addr 0x%llx\n" , __FUNCTION__, - (unsigned long long )frame_addr); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; } -qemu_log ("%s: 1\n" , __FUNCTION__);tswap_siginfo (&frame->info, info);/* Create the ucontext. */ @@ -4207,7 +4205,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,return ; give_sigsegv: -qemu_log ("%s: give_sigsegv\n" , __FUNCTION__);force_sig (TARGET_SIGSEGV ); }@@ -4222,9 +4219,8 @@ restore_sigregs(CPUS390XState *env, target_sigregs *sc) }__get_user (env->psw.mask, &sc->regs.psw.mask); -qemu_log ("%s: sc->regs.psw.addr 0x%llx env->psw.addr 0x%llx\n" , - __FUNCTION__, (unsigned long long )sc->regs.psw.addr, - (unsigned long long )env->psw.addr); +trace_user_s390x_restore_sigregs (env, (unsigned long long )sc->regs.psw.addr, + (unsigned long long )env->psw.addr);__get_user (env->psw.addr, &sc->regs.psw.addr);/* FIXME: 31-bit -> | PSW_ADDR_AMODE */ @@ -4242,11 +4238,10 @@ long do_sigreturn(CPUS390XState *env) {sigframe *frame;abi_ulong frame_addr = env->regs[15 ]; -qemu_log ("%s: frame_addr 0x%llx\n" , __FUNCTION__, - (unsigned long long )frame_addr);target_sigset_t target_set;sigset_t set; +trace_user_do_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) { goto badframe; }@@ -4271,10 +4266,9 @@ long do_rt_sigreturn(CPUS390XState *env) {rt_sigframe *frame;abi_ulong frame_addr = env->regs[15 ]; -qemu_log ("%s: frame_addr 0x%llx\n" , __FUNCTION__, - (unsigned long long )frame_addr);sigset_t set; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) { goto badframe; }@@ -4659,6 +4653,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,#endif frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,1 )) goto sigsegv; sc = &frame->sctx;@@ -4723,7 +4718,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, sigsegv:unlock_user_struct (frame, frame_addr,1 ); -qemu_log ("segfaulting from setup_frame\n" );force_sig (TARGET_SIGSEGV ); }@@ -4819,7 +4813,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, sigsegv:unlock_user_struct (rt_sf, rt_sf_addr,1 ); -qemu_log ("segfaulting from setup_rt_frame\n" );force_sig (TARGET_SIGSEGV ); }@@ -4857,7 +4850,6 @@ long do_sigreturn(CPUPPCState *env) sigsegv:unlock_user_struct (sr, sr_addr,1 );unlock_user_struct (sc, sc_addr,1 ); -qemu_log ("segfaulting from do_sigreturn\n" );force_sig (TARGET_SIGSEGV );return 0 ; }@@ -4913,7 +4905,6 @@ long do_rt_sigreturn(CPUPPCState *env) sigsegv:unlock_user_struct (rt_sf, rt_sf_addr,1 ); -qemu_log ("segfaulting from do_rt_sigreturn\n" );force_sig (TARGET_SIGSEGV );return 0 ; }@@ -5037,6 +5028,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof *frame); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -5153,6 +5145,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,int i; frame_addr =get_sigframe (ka, env,sizeof *frame); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) goto give_sigsegv;@@ -5220,6 +5213,7 @@ long do_sigreturn(CPUM68KState *env)sigset_t set;int d0, i; +trace_user_do_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -5254,6 +5248,7 @@ long do_rt_sigreturn(CPUM68KState *env)sigset_t set;int d0; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;@@ -5393,6 +5388,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,int err =0 ; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; }@@ -5437,6 +5433,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,int i, err =0 ; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; }@@ -5515,6 +5512,7 @@ long do_rt_sigreturn(CPUAlphaState *env)struct target_rt_sigframe *frame;sigset_t set; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) { goto badframe; }@@ -5622,6 +5620,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,unsigned long restorer; frame_addr =get_sigframe (ka, env,sizeof (*frame)); +trace_user_setup_rt_frame (env, frame_addr);if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { goto give_sigsegv; }@@ -5672,6 +5671,7 @@ long do_rt_sigreturn(CPUTLGState *env)struct target_rt_sigframe *frame;sigset_t set; +trace_user_do_rt_sigreturn (env, frame_addr);if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) { goto badframe; }@@ -5750,9 +5750,7 @@ void process_pending_signals(CPUArchState *cpu_env)return ; handle_signal: -#ifdef DEBUG_SIGNAL -fprintf (stderr,"qemu: process signal %d\n" , sig); -#endif +trace_user_handle_signal (cpu_env, sig);/* dequeue signal */ q = k->first; k->first = q->next;trace-events +1
-0@@ -1795,3 +1795,14 @@ qcrypto_tls_session_new(void *session, void *creds, const char *hostname, const # net/vhost-user.c vhost_user_event(const char *chr, int event) "chr: %s got event: %d" +
trace-events qcrypto_tls_session_new(void *session, void *creds, const char *hostname, const · line 1808
Quoted 10 lines
trace-events +10
-0+# linux-user/signal.c +user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_do_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr="PRIx64"" +user_force_sig(void *env, int target_sig, int host_sig) "env=%p signal %d (host %d)" +user_handle_signal(void *env, int target_sig) "env=%p signal %d" +user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d(" +user_queue_signal(void *env, int target_sig) "env=%p signal %d" +user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_addr) "env=%p frame psw.addr "PRIx64 " current psw.addr "PRIx64""
Re: [Qemu-devel] [PATCH 11/11] linux-user: convert DEBUG_SIGNAL logging to tracepoints
In reply to Paolo BonziniQuoted 4 lines · Paolo Bonzini
"Unimplemented" messages go to stderr, everything else goes to tracepoints
Signed-off-by Paolo Bonzini <[email protected]>---
[...]
Quoted 4 lines
linux-user/signal.c +0
-0
[...]
Quoted 8 lines
linux-user/signal.c +2
-2@@ -3972,14 +3974,15 @@ give_sigsegv:long do_sigreturn (CPUOpenRISCState *env) { - -qemu_log ("do_sigreturn: not implemented\n" ); +trace_user_do_sigreturn (env,0 ); +fprintf (stderr,"do_sigreturn: not implemented\n" );
linux-user/signal.c give_sigsegv: · line 3987
Quoted 10 lines
linux-user/signal.c +2
-1return -TARGET_ENOSYS ; }long do_rt_sigreturn (CPUOpenRISCState *env) { -qemu_log ("do_rt_sigreturn: not implemented\n" ); +trace_user_do_rt_sigreturn (env,0 ); +fprintf (stderr,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
Why not simply using qemu_log_mask(LOG_UNIMP, ...) instead? Isn't that what the LOG_UNIMP flag is good for?
Thomas
Re: [Qemu-devel] [PATCH 11/11] linux-user: convert DEBUG_SIGNAL logging to tracepoints
Quoted 22 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
"Unimplemented" messages go to stderr, everything else goes to tracepoints
Signed-off-by Paolo Bonzini <[email protected]>---
[...]
Quoted 4 lines
linux-user/signal.c +0
-0[...]
Quoted 11 lines
linux-user/signal.c +2
-2@@ -3972,14 +3974,15 @@ give_sigsegv:long do_sigreturn (CPUOpenRISCState *env) { - -qemu_log ("do_sigreturn: not implemented\n" ); +trace_user_do_sigreturn (env,0 ); +fprintf (stderr,"do_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
Quoted 10 lines
linux-user/signal.c give_sigsegv: · line 3987
Quoted 7 lines
linux-user/signal.c +2
-1long do_rt_sigreturn (CPUOpenRISCState *env) { -qemu_log ("do_rt_sigreturn: not implemented\n" ); +trace_user_do_rt_sigreturn (env,0 ); +fprintf (stderr,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }Why not simply using
qemu_log_mask(LOG_UNIMP, ...)instead? Isn't that what theLOG_UNIMPflag is good for?
LOG_UNIMP has to be enabled explicitly, because it is guest-triggerable.
Here the error is really fatal, so I decided to use fprintf. In fact,
it would probably be better to abort after printing an error, but I left the "return" untouched because I didn't want to do too many changes in the same patch.
Paolo