From patchwork Thu Feb 21 04:25:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 2170491 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 487FF40B0D for ; Thu, 21 Feb 2013 04:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445Ab3BUEZu (ORCPT ); Wed, 20 Feb 2013 23:25:50 -0500 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 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B8E56A5207; Thu, 21 Feb 2013 05:25:43 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org 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) 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> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361420711-15698-1-git-send-email-afaerber@suse.de> References: <1361420711-15698-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Make debug output compile-testable even if disabled. Rename dprintf() in kvm.c to kvm_dprintf() due to a conflict with glibc. 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ärber Reviewed-by: Alexander Graf --- 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ändert, 120 Zeilen hinzugefügt(+), 52 Zeilen entfernt(-) 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 @@ /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper = true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif +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 == 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 -/* #define DEBUG_HELPER */ -#ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) -#else -#define HELPER_LOG(x...) -#endif - #define RET128(F) (env->retxl = F.low, F.high) #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 #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 = 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 = true; #else -#define DPRINTF(fmt, ...) \ - do { } while (0) +static const bool debug_pte; #endif -#ifdef DEBUG_S390_PTE -#define PTE_DPRINTF DPRINTF +#ifdef DEBUG_S390_STDOUT +static const bool debug_to_stdout = 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_list 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 #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 @@ /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper = true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif +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 */ #ifdef DEBUG_KVM -#define dprintf(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +static const bool debug_kvm = true; #else -#define dprintf(fmt, ...) \ - do { } while (0) +static const bool debug_kvm; #endif +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 = (run->s390_sieic.ipb & 0xffff0000) >> 16; uint8_t ipb = run->s390_sieic.ipb & 0xff; - dprintf("KVM: PRIV: %d\n", ipa1); + kvm_dprintf("KVM: PRIV: %d\n", ipa1); switch (ipa1) { case PRIV_SCLP_CALL: r = kvm_sclp_service_call(cpu, run, ipbh0); @@ -531,7 +539,7 @@ static int handle_priv(S390CPU *cpu, struct kvm_run *run, r = 0; } } else { - dprintf("KVM: unknown PRIV: 0x%x\n", ipa1); + kvm_dprintf("KVM: unknown PRIV: 0x%x\n", ipa1); r = -1; } break; @@ -560,7 +568,7 @@ static int handle_diag(CPUS390XState *env, struct kvm_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 = -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; } @@ -600,7 +608,7 @@ static int s390_cpu_initial_reset(S390CPU *cpu) env->regs[i] = 0; } - dprintf("DONE: SIGP initial reset: %p\n", env); + kvm_dprintf("DONE: SIGP initial reset: %p\n", env); return 0; } @@ -670,7 +678,8 @@ static int handle_instruction(S390CPU *cpu, struct kvm_run *run) int ipb_code = (run->s390_sieic.ipb & 0x0fff0000) >> 16; int r = -1; - 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 = run->s390_sieic.icptcode; int r = 0; - 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 = 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, /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper = true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif +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 dest, 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 @@ /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER -#define HELPER_LOG(x...) qemu_log(x) +static const bool debug_helper = true; #else -#define HELPER_LOG(x...) +static const bool debug_helper; #endif +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 . */ -/* #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" +/* #define DEBUG_INLINE_BRANCHES */ +#define S390X_DEBUG_DISAS + +#ifdef S390X_DEBUG_DISAS +static const bool debug_disas = true; +#else +static const bool debug_disas; +#endif + /* global register indexes */ static TCGv_ptr cpu_env; @@ -4859,13 +4858,11 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, tb->icount = num_insns; } -#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 } void gen_intermediate_code (CPUS390XState *env, struct TranslationBlock *tb)