@@ -26,6 +26,22 @@
//#define DEBUG_MMU
+#ifdef DEBUG_MMU
+static const bool debug_mmu = true;
+#else
+static const bool debug_mmu;
+#endif
+
+static void GCC_FMT_ATTR(1, 2) mmu_dprintf(const char *fmt, ...)
+{
+ if (debug_mmu) {
+ va_list ap;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ }
+}
+
static void cpu_x86_version(CPUX86State *env, int *family, int *model)
{
int cpuver = env->cpuid_version;
@@ -372,9 +388,8 @@ void x86_cpu_set_a20(X86CPU *cpu, 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);
@@ -390,9 +405,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);
@@ -433,18 +447,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)) {
@@ -510,10 +521,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)) {
@@ -37,13 +37,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) DPRINTF(const char *fmt, ...)
+{
+ if (debug_kvm) {
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+}
+
#define MSR_KVM_WALL_CLOCK 0x11
#define MSR_KVM_SYSTEM_TIME 0x12
@@ -29,14 +29,28 @@
#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)
+static const bool debug_pcall = true;
#else
-# define LOG_PCALL(...) do { } while (0)
-# define LOG_PCALL_STATE(env) do { } while (0)
+static const bool debug_pcall;
#endif
+static void GCC_FMT_ATTR(1, 2) LOG_PCALL(const char *fmt, ...)
+{
+ if (debug_pcall) {
+ va_list ap;
+ va_start(ap, fmt);
+ qemu_log_mask(CPU_LOG_PCALL, fmt, ap);
+ va_end(ap);
+ }
+}
+
+static inline void LOG_PCALL_STATE(CPUX86State *env)
+{
+ if (debug_pcall) {
+ log_cpu_state_mask(CPU_LOG_PCALL, (env), CPU_DUMP_CCOP);
+ }
+}
+
/* return non zero if error */
static inline int load_segment(CPUX86State *env, uint32_t *e1_ptr,
uint32_t *e2_ptr, int selector)
Make debug output compile-testable even if disabled. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Richard Henderson <rth@twiddle.net> --- target-i386/helper.c | 42 ++++++++++++++++++++++++++---------------- target-i386/kvm.c | 16 ++++++++++++---- target-i386/seg_helper.c | 24 +++++++++++++++++++----- 3 Dateien geändert, 57 Zeilen hinzugefügt(+), 25 Zeilen entfernt(-)