qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] jazz led: Fix debug prints
@ 2010-07-31  9:05 Hervé Poussineau
  2010-07-31 15:16 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Hervé Poussineau @ 2010-07-31  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hervé Poussineau

Add a macro to easily enable/disable debug prints
Also fix wrong printf formatters

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/jazz_led.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/hw/jazz_led.c b/hw/jazz_led.c
index 18780e9..4cb680c 100644
--- a/hw/jazz_led.c
+++ b/hw/jazz_led.c
@@ -29,6 +29,15 @@
 
 //#define DEBUG_LED
 
+#ifdef DEBUG_LED
+#define DPRINTF(fmt, ...) \
+do { printf("jazz led: " fmt , ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(fmt, ...) do {} while (0)
+#endif
+#define BADF(fmt, ...) \
+do { fprintf(stderr, "jazz led ERROR: " fmt , ## __VA_ARGS__);} while (0)
+
 typedef enum {
     REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2,
 } screen_state_t;
@@ -49,12 +58,12 @@ static uint32_t led_readb(void *opaque, target_phys_addr_t addr)
             val = s->segments;
             break;
         default:
-#ifdef DEBUG_LED
-            printf("jazz led: invalid read [0x%x]\n", relative_addr);
-#endif
+            BADF("invalid read at [" TARGET_FMT_plx "]\n", addr);
             val = 0;
     }
 
+    DPRINTF("read addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val);
+
     return val;
 }
 
@@ -92,15 +101,15 @@ static void led_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
     LedState *s = opaque;
 
+    DPRINTF("write addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val);
+
     switch (addr) {
         case 0:
             s->segments = val;
             s->state |= REDRAW_SEGMENTS;
             break;
         default:
-#ifdef DEBUG_LED
-            printf("jazz led: invalid write of 0x%02x at [0x%x]\n", val, relative_addr);
-#endif
+            BADF("invalid write of 0x%08x at [" TARGET_FMT_plx "]\n", val, addr);
             break;
     }
 }
-- 
1.7.1.GIT

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] jazz led: Fix debug prints
  2010-07-31  9:05 [Qemu-devel] [PATCH] jazz led: Fix debug prints Hervé Poussineau
@ 2010-07-31 15:16 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2010-07-31 15:16 UTC (permalink / raw)
  To: Hervé Poussineau; +Cc: qemu-devel

On Sat, Jul 31, 2010 at 11:05:28AM +0200, Hervé Poussineau wrote:
> Add a macro to easily enable/disable debug prints
> Also fix wrong printf formatters
> 
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
>  hw/jazz_led.c |   21 +++++++++++++++------
>  1 files changed, 15 insertions(+), 6 deletions(-)

Thanks, applied.

> diff --git a/hw/jazz_led.c b/hw/jazz_led.c
> index 18780e9..4cb680c 100644
> --- a/hw/jazz_led.c
> +++ b/hw/jazz_led.c
> @@ -29,6 +29,15 @@
>  
>  //#define DEBUG_LED
>  
> +#ifdef DEBUG_LED
> +#define DPRINTF(fmt, ...) \
> +do { printf("jazz led: " fmt , ## __VA_ARGS__); } while (0)
> +#else
> +#define DPRINTF(fmt, ...) do {} while (0)
> +#endif
> +#define BADF(fmt, ...) \
> +do { fprintf(stderr, "jazz led ERROR: " fmt , ## __VA_ARGS__);} while (0)
> +
>  typedef enum {
>      REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2,
>  } screen_state_t;
> @@ -49,12 +58,12 @@ static uint32_t led_readb(void *opaque, target_phys_addr_t addr)
>              val = s->segments;
>              break;
>          default:
> -#ifdef DEBUG_LED
> -            printf("jazz led: invalid read [0x%x]\n", relative_addr);
> -#endif
> +            BADF("invalid read at [" TARGET_FMT_plx "]\n", addr);
>              val = 0;
>      }
>  
> +    DPRINTF("read addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val);
> +
>      return val;
>  }
>  
> @@ -92,15 +101,15 @@ static void led_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
>  {
>      LedState *s = opaque;
>  
> +    DPRINTF("write addr=" TARGET_FMT_plx " val=0x%02x\n", addr, val);
> +
>      switch (addr) {
>          case 0:
>              s->segments = val;
>              s->state |= REDRAW_SEGMENTS;
>              break;
>          default:
> -#ifdef DEBUG_LED
> -            printf("jazz led: invalid write of 0x%02x at [0x%x]\n", val, relative_addr);
> -#endif
> +            BADF("invalid write of 0x%08x at [" TARGET_FMT_plx "]\n", val, addr);
>              break;
>      }
>  }
> -- 
> 1.7.1.GIT
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-31 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-31  9:05 [Qemu-devel] [PATCH] jazz led: Fix debug prints Hervé Poussineau
2010-07-31 15:16 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).