From patchwork Sun Jan 27 13:32:10 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: 2051631 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 624DBDFE86 for ; Sun, 27 Jan 2013 13:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756697Ab3A0Nc7 (ORCPT ); Sun, 27 Jan 2013 08:32:59 -0500 Received: from cantor2.suse.de ([195.135.220.15]:48509 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756045Ab3A0Nc5 (ORCPT ); Sun, 27 Jan 2013 08:32:57 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D49A2A5232; Sun, 27 Jan 2013 14:32:55 +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 , Gleb Natapov (supporter:X86), Marcelo Tosatti (supporter:X86), kvm@vger.kernel.org (open list:X86) Subject: [RFC 12/19] target-i386: Refactor debug output macros Date: Sun, 27 Jan 2013 14:32:10 +0100 Message-Id: <1359293537-8251-13-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359293537-8251-1-git-send-email-afaerber@suse.de> References: <1359293537-8251-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. Signed-off-by: Andreas Färber Cc: Richard Henderson --- target-i386/helper.c | 33 ++++++++++++++++----------------- target-i386/kvm.c | 16 +++++++--------- target-i386/seg_helper.c | 20 +++++++++++--------- 3 Dateien geändert, 34 Zeilen hinzugefügt(+), 35 Zeilen entfernt(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 547c25e..aa94289 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -24,7 +24,12 @@ #include "monitor/monitor.h" #endif -//#define DEBUG_MMU +#define DEBUG_MMU 0 +#define MMU_DPRINTF(...) G_STMT_START \ + if (DEBUG_MMU) { \ + printf(__VA_ARGS__); \ + } \ + G_STMT_END static void cpu_x86_version(CPUX86State *env, int *family, int *model) { @@ -370,9 +375,8 @@ void cpu_x86_set_a20(CPUX86State *env, int a20_state) { a20_state = (a20_state != 0); if (a20_state != ((env->a20_mask >> 20) & 1)) { -#if defined(DEBUG_MMU) - printf("A20 update: a20=%d\n", a20_state); -#endif + MMU_DPRINTF("A20 update: a20=%d\n", a20_state); + /* if the cpu is currently executing code, we must unlink it and all the potentially executing TB */ cpu_interrupt(env, CPU_INTERRUPT_EXITTB); @@ -388,9 +392,8 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0) { int pe_state; -#if defined(DEBUG_MMU) - printf("CR0 update: CR0=0x%08x\n", new_cr0); -#endif + MMU_DPRINTF("CR0 update: CR0=0x%08x\n", new_cr0); + if ((new_cr0 & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK)) != (env->cr[0] & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK))) { tlb_flush(env, 1); @@ -431,18 +434,15 @@ void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3) { env->cr[3] = new_cr3; if (env->cr[0] & CR0_PG_MASK) { -#if defined(DEBUG_MMU) - printf("CR3 update: CR3=" TARGET_FMT_lx "\n", new_cr3); -#endif + MMU_DPRINTF("CR3 update: CR3=" TARGET_FMT_lx "\n", new_cr3); tlb_flush(env, 0); } } void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4) { -#if defined(DEBUG_MMU) - printf("CR4 update: CR4=%08x\n", (uint32_t)env->cr[4]); -#endif + MMU_DPRINTF("CR4 update: CR4=%08x\n", (uint32_t)env->cr[4]); + if ((new_cr4 ^ env->cr[4]) & (CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK | CR4_SMEP_MASK | CR4_SMAP_MASK)) { @@ -508,10 +508,9 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, target_ulong vaddr, virt_addr; is_user = mmu_idx == MMU_USER_IDX; -#if defined(DEBUG_MMU) - printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n", - addr, is_write1, is_user, env->eip); -#endif + MMU_DPRINTF("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d" + " eip=" TARGET_FMT_lx "\n", + addr, is_write1, is_user, env->eip); is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 3acff40..732e5fd 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -34,15 +34,13 @@ #include "hyperv.h" #include "hw/pci/pci.h" -//#define DEBUG_KVM - -#ifdef DEBUG_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#define DEBUG_KVM 0 + +#define DPRINTF(fmt, ...) G_STMT_START \ + if (DEBUG_KVM) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ + G_STMT_END #define MSR_KVM_WALL_CLOCK 0x11 #define MSR_KVM_SYSTEM_TIME 0x12 diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index 3247dee..b626b68 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -22,20 +22,22 @@ #include "qemu/log.h" #include "helper.h" -//#define DEBUG_PCALL +#define DEBUG_PCALL 0 #if !defined(CONFIG_USER_ONLY) #include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ -#ifdef DEBUG_PCALL -# define LOG_PCALL(...) qemu_log_mask(CPU_LOG_PCALL, ## __VA_ARGS__) -# define LOG_PCALL_STATE(env) \ - log_cpu_state_mask(CPU_LOG_PCALL, (env), CPU_DUMP_CCOP) -#else -# define LOG_PCALL(...) do { } while (0) -# define LOG_PCALL_STATE(env) do { } while (0) -#endif +#define LOG_PCALL(...) G_STMT_START \ + if (DEBUG_PCALL) { \ + qemu_log_mask(CPU_LOG_PCALL, ## __VA_ARGS__); \ + } \ + G_STMT_END +#define LOG_PCALL_STATE(env) G_STMT_START \ + if (DEBUG_PCALL) { \ + log_cpu_state_mask(CPU_LOG_PCALL, (env), CPU_DUMP_CCOP); \ + } \ + G_STMT_END /* return non zero if error */ static inline int load_segment(CPUX86State *env, uint32_t *e1_ptr,