[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 15/15] target-unicore32: Refactor debug output ma
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH v2 15/15] target-unicore32: Refactor debug output macros |
Date: |
Thu, 21 Feb 2013 05:25:11 +0100 |
Make debug output compile-testable even if disabled.
Signed-off-by: Andreas Färber <address@hidden>
---
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
- [Qemu-devel] [PATCH v2 08/15] target-i386: Refactor debug output macros, (continued)
- [Qemu-devel] [PATCH v2 08/15] target-i386: Refactor debug output macros, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 12/15] target-ppc: Refactor debug output macros, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 05/15] target-cris/mmu.c: Update Coding Style of cris_mmu_translate_page(), Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 11/15] target-openrisc: Refactor debug output macros, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 04/15] target-cris/helper.c: Update Coding Style, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 14/15] target-sparc: Refactor debug output macros, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 15/15] target-unicore32: Refactor debug output macros,
Andreas Färber <=
- [Qemu-devel] [PATCH v2 02/15] target-ppc: Move PPC_DUMP_CPU to translate.c, Andreas Färber, 2013/02/20
- [Qemu-devel] [PATCH v2 13/15] target-s390x: Refactor debug output macros, Andreas Färber, 2013/02/20
- Re: [Qemu-devel] [PATCH v2 00/15] Debug output revamp, Richard Henderson, 2013/02/21