From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2 13/15] target-s390x: Refactor debug output macros Date: Thu, 21 Feb 2013 05:25:09 +0100 Message-ID: <1361420711-15698-14-git-send-email-afaerber@suse.de> References: <1361420711-15698-1-git-send-email-afaerber@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson (maintainer:S390), Alexander Graf (maintainer:S390), Gleb Natapov (supporter:Overall), Marcelo Tosatti (supporter:Overall), kvm@vger.kernel.org (open list:Overall) To: qemu-devel@nongnu.org Return-path: Received: from cantor2.suse.de ([195.135.220.15]:49388 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407Ab3BUEZq (ORCPT ); Wed, 20 Feb 2013 23:25:46 -0500 In-Reply-To: <1361420711-15698-1-git-send-email-afaerber@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Make debug output compile-testable even if disabled. Rename dprintf() in kvm.c to kvm_dprintf() due to a conflict with glibc= =2E Drop unused DEBUG_HELPER and LOG_HELPER() in fpu_helper.c. Drop unused LOG_DISAS() in translate.c and inline S390X_DEBUG_DISAS. Signed-off-by: Andreas F=C3=A4rber --- target-s390x/cc_helper.c | 14 ++++++++++-- target-s390x/fpu_helper.c | 7 ------ target-s390x/helper.c | 53 ++++++++++++++++++++++++++++++++++--= -------- target-s390x/int_helper.c | 14 ++++++++++-- target-s390x/kvm.c | 33 +++++++++++++++++---------- target-s390x/mem_helper.c | 14 ++++++++++-- target-s390x/misc_helper.c | 14 ++++++++++-- target-s390x/translate.c | 23 +++++++++---------- 8 Dateien ge=C3=A4ndert, 120 Zeilen hinzugef=C3=BCgt(+), 52 Zeilen ent= fernt(-) diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c index a6d60bf..e45a19a 100644 --- a/target-s390x/cc_helper.c +++ b/target-s390x/cc_helper.c @@ -24,11 +24,21 @@ =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper =3D true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif =20 +static void GCC_FMT_ATTR(1, 2) HELPER_LOG(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + qemu_log_vprintf(fmt, ap); + va_end(ap); + } +} + static uint32_t cc_calc_ltgt_32(int32_t src, int32_t dst) { if (src =3D=3D dst) { diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c index 94375b6..937da59 100644 --- a/target-s390x/fpu_helper.c +++ b/target-s390x/fpu_helper.c @@ -25,13 +25,6 @@ #include "exec/softmmu_exec.h" #endif =20 -/* #define DEBUG_HELPER */ -#ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) -#else -#define HELPER_LOG(x...) -#endif - #define RET128(F) (env->retxl =3D F.low, F.high) =20 #define convert_bit(mask, from, to) \ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 1183b45..4a02251 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -30,24 +30,53 @@ //#define DEBUG_S390_STDOUT =20 #ifdef DEBUG_S390 -#ifdef DEBUG_S390_STDOUT -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); \ - qemu_log(fmt, ##__VA_ARGS__); } while (0) +static const bool debug_helper =3D true; #else -#define DPRINTF(fmt, ...) \ - do { qemu_log(fmt, ## __VA_ARGS__); } while (0) +static const bool debug_helper; #endif + +#ifdef DEBUG_S390_PTE +static const bool debug_pte =3D true; #else -#define DPRINTF(fmt, ...) \ - do { } while (0) +static const bool debug_pte; #endif =20 -#ifdef DEBUG_S390_PTE -#define PTE_DPRINTF DPRINTF +#ifdef DEBUG_S390_STDOUT +static const bool debug_to_stdout =3D true; #else -#define PTE_DPRINTF(fmt, ...) \ - do { } while (0) +static const bool debug_to_stdout; +#endif + +#ifndef CONFIG_USER_ONLY +static inline void GCC_FMT_ATTR(1, 0) vDPRINTF(const char *fmt, va_lis= t ap) +{ + if (debug_helper) { + if (debug_to_stdout) { + vfprintf(stderr, fmt, ap); + } + qemu_log_vprintf(fmt, ap); + } +} + +static void GCC_FMT_ATTR(1, 2) DPRINTF(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + vDPRINTF(fmt, ap); + va_end(ap); + } +} + +static void GCC_FMT_ATTR(1, 2) PTE_DPRINTF(const char *fmt, ...) +{ + if (debug_pte) { + va_list ap; + va_start(ap, fmt); + vDPRINTF(fmt, ap); + va_end(ap); + } +} #endif =20 #ifndef CONFIG_USER_ONLY diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index 6858301..c7da7e6 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -24,11 +24,21 @@ =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper =3D true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif =20 +static void GCC_FMT_ATTR(1, 2) HELPER_LOG(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + qemu_log_vprintf(fmt, ap); + va_end(ap); + } +} + /* 64/64 -> 128 unsigned multiplication */ uint64_t HELPER(mul128)(CPUS390XState *env, uint64_t v1, uint64_t v2) { diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 3929771..8eea7f1 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -38,13 +38,21 @@ /* #define DEBUG_KVM */ =20 #ifdef DEBUG_KVM -#define dprintf(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +static const bool debug_kvm =3D true; #else -#define dprintf(fmt, ...) \ - do { } while (0) +static const bool debug_kvm; #endif =20 +static void GCC_FMT_ATTR(1, 2) kvm_dprintf(const char *fmt, ...) +{ + if (debug_kvm) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + } +} + #define IPA0_DIAG 0x8300 #define IPA0_SIGP 0xae00 #define IPA0_B2 0xb200 @@ -518,7 +526,7 @@ static int handle_priv(S390CPU *cpu, struct kvm_run= *run, uint16_t ipbh0 =3D (run->s390_sieic.ipb & 0xffff0000) >> 16; uint8_t ipb =3D run->s390_sieic.ipb & 0xff; =20 - dprintf("KVM: PRIV: %d\n", ipa1); + kvm_dprintf("KVM: PRIV: %d\n", ipa1); switch (ipa1) { case PRIV_SCLP_CALL: r =3D kvm_sclp_service_call(cpu, run, ipbh0); @@ -531,7 +539,7 @@ static int handle_priv(S390CPU *cpu, struct kvm_run= *run, r =3D 0; } } else { - dprintf("KVM: unknown PRIV: 0x%x\n", ipa1); + kvm_dprintf("KVM: unknown PRIV: 0x%x\n", ipa1); r =3D -1; } break; @@ -560,7 +568,7 @@ static int handle_diag(CPUS390XState *env, struct k= vm_run *run, int ipb_code) sleep(10); break; default: - dprintf("KVM: unknown DIAG: 0x%x\n", ipb_code); + kvm_dprintf("KVM: unknown DIAG: 0x%x\n", ipb_code); r =3D -1; break; } @@ -573,7 +581,7 @@ static int s390_cpu_restart(S390CPU *cpu) kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0); s390_add_running_cpu(cpu); qemu_cpu_kick(CPU(cpu)); - dprintf("DONE: SIGP cpu restart: %p\n", &cpu->env); + kvm_dprintf("DONE: SIGP cpu restart: %p\n", &cpu->env); return 0; } =20 @@ -600,7 +608,7 @@ static int s390_cpu_initial_reset(S390CPU *cpu) env->regs[i] =3D 0; } =20 - dprintf("DONE: SIGP initial reset: %p\n", env); + kvm_dprintf("DONE: SIGP initial reset: %p\n", env); return 0; } =20 @@ -670,7 +678,8 @@ static int handle_instruction(S390CPU *cpu, struct = kvm_run *run) int ipb_code =3D (run->s390_sieic.ipb & 0x0fff0000) >> 16; int r =3D -1; =20 - dprintf("handle_instruction 0x%x 0x%x\n", run->s390_sieic.ipa, run= ->s390_sieic.ipb); + kvm_dprintf("handle_instruction 0x%x 0x%x\n", + run->s390_sieic.ipa, run->s390_sieic.ipb); switch (ipa0) { case IPA0_B2: case IPA0_B9: @@ -704,8 +713,8 @@ static int handle_intercept(S390CPU *cpu) int icpt_code =3D run->s390_sieic.icptcode; int r =3D 0; =20 - dprintf("intercept: 0x%x (at 0x%lx)\n", icpt_code, - (long)cs->kvm_run->psw_addr); + kvm_dprintf("intercept: 0x%x (at 0x%lx)\n", icpt_code, + (long)cs->kvm_run->psw_addr); switch (icpt_code) { case ICPT_INSTRUCTION: r =3D handle_instruction(cpu, run); diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 372334b..4108124 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -63,11 +63,21 @@ void tlb_fill(CPUS390XState *env, target_ulong addr= , int is_write, int mmu_idx, =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper =3D true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif =20 +static void GCC_FMT_ATTR(1, 2) HELPER_LOG(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + qemu_log_vprintf(fmt, ap); + va_end(ap); + } +} + #ifndef CONFIG_USER_ONLY static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t d= est, uint8_t byte) diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index 09301d0..1cb7514 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -36,11 +36,21 @@ =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper =3D true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif =20 +static void GCC_FMT_ATTR(1, 2) HELPER_LOG(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + qemu_log_vprintf(fmt, ap); + va_end(ap); + } +} + /* Raise an exception dynamically from a helper function. */ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp, uintptr_t retaddr) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index a57296c..6e3cd2a 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -18,22 +18,21 @@ * License along with this library; if not, see . */ =20 -/* #define DEBUG_INLINE_BRANCHES */ -#define S390X_DEBUG_DISAS -/* #define S390X_DEBUG_DISAS_VERBOSE */ - -#ifdef S390X_DEBUG_DISAS_VERBOSE -# define LOG_DISAS(...) qemu_log(__VA_ARGS__) -#else -# define LOG_DISAS(...) do { } while (0) -#endif - #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" #include "qemu/log.h" #include "qemu/host-utils.h" =20 +/* #define DEBUG_INLINE_BRANCHES */ +#define S390X_DEBUG_DISAS + +#ifdef S390X_DEBUG_DISAS +static const bool debug_disas =3D true; +#else +static const bool debug_disas; +#endif + /* global register indexes */ static TCGv_ptr cpu_env; =20 @@ -4859,13 +4858,11 @@ static inline void gen_intermediate_code_intern= al(CPUS390XState *env, tb->icount =3D num_insns; } =20 -#if defined(S390X_DEBUG_DISAS) - if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { + if (debug_disas && qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, dc.pc - pc_start, 1); qemu_log("\n"); } -#endif } =20 void gen_intermediate_code (CPUS390XState *env, struct TranslationBloc= k *tb) --=20 1.7.10.4