Modify debug macros to have the same format through the codebase and use regular ifs instead of ifdef.
Remove header and __func__ in debug printfs, to avoid duplicated messages. Signed-off-by: Marc Marí <marc.mari.barc...@gmail.com> --- hw/net/xgmac.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c index aeffcb5..4db93d1 100644 --- a/hw/net/xgmac.c +++ b/hw/net/xgmac.c @@ -30,14 +30,17 @@ #include "net/net.h" #include "net/checksum.h" +//#define DEBUG_XGMAC + #ifdef DEBUG_XGMAC -#define DEBUGF_BRK(message, args...) do { \ - fprintf(stderr, (message), ## args); \ - } while (0) +#define DEBUG_XGMAC_ENABLED 1 #else -#define DEBUGF_BRK(message, args...) do { } while (0) +#define DEBUG_XGMAC_ENABLED 0 #endif +#define DEBUGF_BRK(message, args...) \ + QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, "xgmag", message, ## args) + #define XGMAC_CONTROL 0x00000000 /* MAC Configuration */ #define XGMAC_FRAME_FILTER 0x00000001 /* MAC Frame Filter */ #define XGMAC_FLOW_CTRL 0x00000006 /* MAC Flow Control */ @@ -218,20 +221,20 @@ static void xgmac_enet_send(XgmacState *s) len = (bd.buffer1_size & 0xfff) + (bd.buffer2_size & 0xfff); if ((bd.buffer1_size & 0xfff) > 2048) { - DEBUGF_BRK("qemu:%s:ERROR...ERROR...ERROR... -- " + DEBUGF_BRK("ERROR...ERROR...ERROR... -- " "xgmac buffer 1 len on send > 2048 (0x%x)\n", - __func__, bd.buffer1_size & 0xfff); + bd.buffer1_size & 0xfff); } if ((bd.buffer2_size & 0xfff) != 0) { - DEBUGF_BRK("qemu:%s:ERROR...ERROR...ERROR... -- " + DEBUGF_BRK("ERROR...ERROR...ERROR... -- " "xgmac buffer 2 len on send != 0 (0x%x)\n", - __func__, bd.buffer2_size & 0xfff); + bd.buffer2_size & 0xfff); } if (len >= sizeof(frame)) { - DEBUGF_BRK("qemu:%s: buffer overflow %d read into %zu " - "buffer\n" , __func__, len, sizeof(frame)); - DEBUGF_BRK("qemu:%s: buffer1.size=%d; buffer2.size=%d\n", - __func__, bd.buffer1_size, bd.buffer2_size); + DEBUGF_BRK("buffer overflow %d read into %zu " + "buffer\n" , len, sizeof(frame)); + DEBUGF_BRK("buffer1.size=%d; buffer2.size=%d\n", + bd.buffer1_size, bd.buffer2_size); } cpu_physical_memory_read(bd.buffer1_addr, ptr, len); -- 1.7.10.4