From: Marc Marí <5.markm...@gmail.com> Modify debug macros as explained in https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg03642.html
Signed-off-by: Marc Marí <5.markm...@gmail.com> --- migration-rdma.c | 47 ++++++++++++++++++++++++++++------------------- page_cache.c | 17 +++++++++++------ xen-all.c | 17 ++++++++++------- xen-mapcache.c | 19 +++++++++++-------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/migration-rdma.c b/migration-rdma.c index eeb4302..0e2f21c 100644 --- a/migration-rdma.c +++ b/migration-rdma.c @@ -27,33 +27,42 @@ #include <string.h> #include <rdma/rdma_cma.h> -//#define DEBUG_RDMA -//#define DEBUG_RDMA_VERBOSE -//#define DEBUG_RDMA_REALLY_VERBOSE +//#define DEBUG_RDMA 1 +//#define DEBUG_RDMA_VERBOSE 1 +//#define DEBUG_RDMA_REALLY_VERBOSE 1 + +#ifndef DEBUG_RDMA +#define DEBUG_RDMA 0 +#endif -#ifdef DEBUG_RDMA -#define DPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) -#else #define DPRINTF(fmt, ...) \ - do { } while (0) + do { \ + if(DEBUG_RDMA) { \ + printf("rdma: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + +#ifndef DEBUG_RDMA_VERBOSE +#define DEBUG_RDMA_VERBOSE 0 #endif -#ifdef DEBUG_RDMA_VERBOSE #define DDPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DDPRINTF(fmt, ...) \ - do { } while (0) + do { \ + if(DEBUG_RDMA_VERBOSE) { \ + printf("rdma: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + +#ifndef DEBUG_RDMA_REALLY_VERBOSE +#define DEBUG_RDMA_REALLY_VERBOSE 0 #endif -#ifdef DEBUG_RDMA_REALLY_VERBOSE -#define DDDPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) -#else #define DDDPRINTF(fmt, ...) \ - do { } while (0) -#endif + do { \ + if(DEBUG_RDMA_REALLY_VERBOSE) { \ + printf("rdma: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) /* * Print and error on both the Monitor and the Log file. diff --git a/page_cache.c b/page_cache.c index b033681..d1b8c4f 100644 --- a/page_cache.c +++ b/page_cache.c @@ -25,14 +25,19 @@ #include "qemu-common.h" #include "migration/page_cache.h" -#ifdef DEBUG_CACHE -#define DPRINTF(fmt, ...) \ - do { fprintf(stdout, "cache: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) +//#define DEBUG_CACHE 1 + +#ifndef DEBUG_CACHE +#define DEBUG_CACHE 0 #endif +#define DPRINTF(fmt, ...) \ + do { \ + if(DEBUG_CACHE) { \ + fprintf(stdout, "cache: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + typedef struct CacheItem CacheItem; struct CacheItem { diff --git a/xen-all.c b/xen-all.c index ba34739..34ffd3f 100644 --- a/xen-all.c +++ b/xen-all.c @@ -26,16 +26,19 @@ #include <xen/hvm/params.h> #include <xen/hvm/e820.h> -//#define DEBUG_XEN +//#define DEBUG_XEN 1 -#ifdef DEBUG_XEN -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) +#ifndef DEBUG_XEN +#define DEBUG_XEN 0 #endif +#define DPRINTF(fmt, ...) \ + do { \ + if(DEBUG_XEN) { \ + fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi; static MemoryRegion *framebuffer; static bool xen_in_migration; diff --git a/xen-mapcache.c b/xen-mapcache.c index eda914a..b1a68f1 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -23,16 +23,19 @@ #include "trace.h" -//#define MAPCACHE_DEBUG - -#ifdef MAPCACHE_DEBUG -# define DPRINTF(fmt, ...) do { \ - fprintf(stderr, "xen_mapcache: " fmt, ## __VA_ARGS__); \ -} while (0) -#else -# define DPRINTF(fmt, ...) do { } while (0) +//#define MAPCACHE_DEBUG 1 + +#ifndef MAPCACHE_DEBUG +#define MAPCACHE_DEBUG 0 #endif +# define DPRINTF(fmt, ...) \ + do { \ + if(MAPCACHE_DEBUG) { \ + fprintf(stderr, "xen_mapcache: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + #if defined(__i386__) # define MCACHE_BUCKET_SHIFT 16 # define MCACHE_MAX_SIZE (1UL<<31) /* 2GB Cap */ -- 1.7.10.4