Make debug output compile-testable even if disabled. Signed-off-by: Andreas Färber <afaer...@suse.de> --- 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) -- 1.7.10.4