From patchwork Thu Feb 21 04:25:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [v2,15/15] target-unicore32: Refactor debug output macros X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 222175 Message-Id: <1361420711-15698-16-git-send-email-afaerber@suse.de> To: qemu-devel@nongnu.org Cc: Guan Xuetao , =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 21 Feb 2013 05:25:11 +0100 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= List-Id: Make debug output compile-testable even if disabled. Signed-off-by: Andreas Färber --- target-unicore32/helper.c | 18 ++++++++++++++++-- target-unicore32/softmmu.c | 17 +++++++++++++++-- 2 Dateien geändert, 31 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-) diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 7eeb9bc..d462ced 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -20,9 +20,23 @@ #undef DEBUG_UC32 #ifdef DEBUG_UC32 -#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__) +static const bool debug_helper = true; #else -#define DPRINTF(fmt, ...) do {} while (0) +static const bool debug_helper; +#endif + +#define DPRINTF(fmt, ...) \ + helper_dprintf("%s: " fmt , __func__, ## __VA_ARGS__) +#ifndef CONFIG_USER_ONLY +static void GCC_FMT_ATTR(1, 2) helper_dprintf(const char *fmt, ...) +{ + if (debug_helper) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + } +} #endif CPUUniCore32State *uc32_cpu_init(const char *cpu_model) diff --git a/target-unicore32/softmmu.c b/target-unicore32/softmmu.c index fc27100..d45fafc 100644 --- a/target-unicore32/softmmu.c +++ b/target-unicore32/softmmu.c @@ -17,11 +17,24 @@ #undef DEBUG_UC32 #ifdef DEBUG_UC32 -#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__) +static const bool debug_softmmu = true; #else -#define DPRINTF(fmt, ...) do {} while (0) +static const bool debug_softmmu; #endif +#define DPRINTF(fmt, ...) \ + softmmu_dprintf("%s: " fmt , __func__, ## __VA_ARGS__) + +static void GCC_FMT_ATTR(1, 2) softmmu_dprintf(const char *fmt, ...) +{ + if (debug_softmmu) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + } +} + #define SUPERPAGE_SIZE (1 << 22) #define UC32_PAGETABLE_READ (1 << 8) #define UC32_PAGETABLE_WRITE (1 << 7)