diff mbox

[RFC,17/19] target-s390x: Refactor debug output macros

Message ID 1359293537-8251-18-git-send-email-afaerber@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Andreas Färber Jan. 27, 2013, 1:32 p.m. UTC
Make debug output compile-testable even if disabled.

Inline S390X_DEBUG_DISAS in translate.c.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-s390x/cc_helper.c   |   13 +++++++------
 target-s390x/fpu_helper.c  |   13 +++++++------
 target-s390x/helper.c      |   42 ++++++++++++++++++------------------------
 target-s390x/int_helper.c  |   13 +++++++------
 target-s390x/kvm.c         |    9 ++-------
 target-s390x/mem_helper.c  |   13 +++++++------
 target-s390x/misc_helper.c |   13 +++++++------
 target-s390x/translate.c   |   18 ++++++++----------
 8 Dateien geändert, 63 Zeilen hinzugefügt(+), 71 Zeilen entfernt(-)
diff mbox

Patch

diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index a6d60bf..a6fad6a 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -22,12 +22,13 @@ 
 #include "helper.h"
 #include "qemu/host-utils.h"
 
-/* #define DEBUG_HELPER */
-#ifdef DEBUG_HELPER
-#define HELPER_LOG(x...) qemu_log(x)
-#else
-#define HELPER_LOG(x...)
-#endif
+#define DEBUG_HELPER 0
+
+#define HELPER_LOG(...) G_STMT_START \
+    if (DEBUG_HELPER) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 static uint32_t cc_calc_ltgt_32(int32_t src, int32_t dst)
 {
diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c
index 94375b6..aba5e2c 100644
--- a/target-s390x/fpu_helper.c
+++ b/target-s390x/fpu_helper.c
@@ -25,12 +25,13 @@ 
 #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 DEBUG_HELPER 0
+
+#define HELPER_LOG(...) G_STMT_START \
+    if (DEBUG_HELPER) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 #define RET128(F) (env->retxl = F.low, F.high)
 
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 76fd558..90d62db 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -25,30 +25,24 @@ 
 #include "sysemu/sysemu.h"
 #endif
 
-//#define DEBUG_S390
-//#define DEBUG_S390_PTE
-//#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)
-#else
-#define DPRINTF(fmt, ...) \
-    do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
-#endif
-#else
-#define DPRINTF(fmt, ...) \
-    do { } while (0)
-#endif
-
-#ifdef DEBUG_S390_PTE
-#define PTE_DPRINTF DPRINTF
-#else
-#define PTE_DPRINTF(fmt, ...) \
-    do { } while (0)
-#endif
+#define DEBUG_S390 0
+#define DEBUG_S390_PTE 0
+#define DEBUG_S390_STDOUT 0
+
+#define DPRINTF(fmt, ...) G_STMT_START \
+    if (DEBUG_S390) { \
+        if (DEBUG_S390_STDOUT) { \
+            fprintf(stderr, fmt, ## __VA_ARGS__); \
+        } \
+        qemu_log(fmt, ## __VA_ARGS__); \
+    } \
+    G_STMT_END
+
+#define PTE_DPRINTF(fmt, ...) G_STMT_START \
+    if (DEBUG_S390_PTE) { \
+        DPRINTF(fmt, ## __VA_ARGS__); \
+    } \
+    G_STMT_END
 
 #ifndef CONFIG_USER_ONLY
 void s390x_tod_timer(void *opaque)
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index 6858301..acf2de0 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -22,12 +22,13 @@ 
 #include "qemu/host-utils.h"
 #include "helper.h"
 
-/* #define DEBUG_HELPER */
-#ifdef DEBUG_HELPER
-#define HELPER_LOG(x...) qemu_log(x)
-#else
-#define HELPER_LOG(x...)
-#endif
+#define DEBUG_HELPER 0
+
+#define HELPER_LOG(...) G_STMT_START \
+    if (DEBUG_HELPER) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 /* 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 add6a58..ee4c7f9 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -35,15 +35,10 @@ 
 #include "cpu.h"
 #include "sysemu/device_tree.h"
 
-/* #define DEBUG_KVM */
+#define DEBUG_KVM 0
 
-#ifdef DEBUG_KVM
 #define dprintf(fmt, ...) \
-    do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
-#else
-#define dprintf(fmt, ...) \
-    do { } while (0)
-#endif
+    do { if (DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0)
 
 #define IPA0_DIAG                       0x8300
 #define IPA0_SIGP                       0xae00
diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c
index 372334b..99e3d45 100644
--- a/target-s390x/mem_helper.c
+++ b/target-s390x/mem_helper.c
@@ -61,12 +61,13 @@  void tlb_fill(CPUS390XState *env, target_ulong addr, int is_write, int mmu_idx,
 
 #endif
 
-/* #define DEBUG_HELPER */
-#ifdef DEBUG_HELPER
-#define HELPER_LOG(x...) qemu_log(x)
-#else
-#define HELPER_LOG(x...)
-#endif
+#define DEBUG_HELPER 0
+
+#define HELPER_LOG(...) G_STMT_START \
+    if (DEBUG_HELPER) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 #ifndef CONFIG_USER_ONLY
 static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t dest,
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 09301d0..72dbdc1 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -34,12 +34,13 @@ 
 #include "sysemu/sysemu.h"
 #endif
 
-/* #define DEBUG_HELPER */
-#ifdef DEBUG_HELPER
-#define HELPER_LOG(x...) qemu_log(x)
-#else
-#define HELPER_LOG(x...)
-#endif
+#define DEBUG_HELPER 0
+
+#define HELPER_LOG(...) G_STMT_START \
+    if (DEBUG_HELPER) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 /* Raise an exception dynamically from a helper function.  */
 void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index a57296c..d72f9e0 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -19,14 +19,14 @@ 
  */
 
 /* #define DEBUG_INLINE_BRANCHES */
-#define S390X_DEBUG_DISAS
-/* #define S390X_DEBUG_DISAS_VERBOSE */
+#define S390X_DEBUG_DISAS 1
+#define S390X_DEBUG_DISAS_VERBOSE 0
 
-#ifdef S390X_DEBUG_DISAS_VERBOSE
-#  define LOG_DISAS(...) qemu_log(__VA_ARGS__)
-#else
-#  define LOG_DISAS(...) do { } while (0)
-#endif
+#define LOG_DISAS(...) G_STMT_START \
+    if (S390X_DEBUG_DISAS_VERBOSE) { \
+        qemu_log(__VA_ARGS__); \
+    } \
+    G_STMT_END
 
 #include "cpu.h"
 #include "disas/disas.h"
@@ -4859,13 +4859,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 (S390X_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)