All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Novotny <minovotn@redhat.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Introduce DPRINTF() macro and convert serial printf() calls to DPRINTF()'s
Date: Mon, 13 Sep 2010 13:18:27 +0200	[thread overview]
Message-ID: <4C8E0883.3060405@redhat.com> (raw)

Hi,
this is the patch to introduce DPRINTF() macro as used in the rest of the
qemu source files for printing debug messages when the debugging macro is
set (i.e. the debugging is enabled) - e.g. as used in LSI SCSI controller
implementation.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
diff --git a/hw/serial.c b/hw/serial.c
index b66d13a..49431b2 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -99,6 +99,14 @@
  #define RECV_FIFO           1
  #define MAX_XMIT_RETRY      4

+#ifdef DEBUG_SERIAL
+#define DPRINTF(fmt, ...) \
+do { fprintf(stderr, "serial: " fmt , ## __VA_ARGS__); } while (0);
+#else
+#define DPRINTF(fmt, ...) \
+do {} while(0);
+#endif
+
  typedef struct SerialFIFO {
      uint8_t data[UART_FIFO_LENGTH];
      uint8_t count;
@@ -267,10 +275,9 @@ static void serial_update_parameters(SerialState *s)
      ssp.stop_bits = stop_bits;
      s->char_transmit_time =  (get_ticks_per_sec() / speed) * frame_size;
      qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
-#if 0
-    printf("speed=%d parity=%c data=%d stop=%d\n",
+
+    DPRINTF("speed=%d parity=%c data=%d stop=%d\n",
             speed, parity, data_bits, stop_bits);
-#endif
  }

  static void serial_update_msl(SerialState *s)
@@ -360,9 +367,7 @@ static void serial_ioport_write(void *opaque, 
uint32_t addr, uint32_t val)
      SerialState *s = opaque;

      addr &= 7;
-#ifdef DEBUG_SERIAL
-    printf("serial: write addr=0x%02x val=0x%02x\n", addr, val);
-#endif
+    DPRINTF("write addr=0x%02x val=0x%02x\n", addr, val);
      switch(addr) {
      default:
      case 0:
@@ -583,9 +588,7 @@ static uint32_t serial_ioport_read(void *opaque, 
uint32_t addr)
          ret = s->scr;
          break;
      }
-#ifdef DEBUG_SERIAL
-    printf("serial: read addr=0x%02x val=0x%02x\n", addr, ret);
-#endif
+    DPRINTF("read addr=0x%02x val=0x%02x\n", addr, ret);
      return ret;
  }

@@ -651,9 +654,7 @@ static void serial_receive1(void *opaque, const 
uint8_t *buf, int size)
  static void serial_event(void *opaque, int event)
  {
      SerialState *s = opaque;
-#ifdef DEBUG_SERIAL
-    printf("serial: event %x\n", event);
-#endif
+    DPRINTF("event %x\n", event);
      if (event == CHR_EVENT_BREAK)
          serial_receive_break(s);
  }

-- 
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat

             reply	other threads:[~2010-09-13 11:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13 11:18 Michal Novotny [this message]
2010-09-13 11:37 ` [Qemu-devel] Re: [PATCH] Introduce DPRINTF() macro and convert serial printf() calls to DPRINTF()'s Paolo Bonzini
2010-09-13 12:07 ` [Qemu-devel] " Edgar E. Iglesias
2010-09-13 12:37   ` Michal Novotny
2010-09-13 12:37     ` Edgar E. Iglesias
2010-09-13 22:34     ` Andreas Färber
2010-09-14  8:56       ` Michal Novotny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C8E0883.3060405@redhat.com \
    --to=minovotn@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.