diff mbox

[8/8] i.MX: Standardize i.MX GPT debug

Message ID a329206f5ef816e6fefc06e4ff10e09ef83e1f58.1445375687.git.jcd@tribudubois.net
State New
Headers show

Commit Message

Jean-Christophe Dubois Oct. 20, 2015, 9:20 p.m. UTC
The goal is to have debug code always compiled during build.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
---
 hw/timer/imx_gpt.c | 40 +++++++++++++++-------------------------
 1 file changed, 15 insertions(+), 25 deletions(-)

Comments

Peter Crosthwaite Oct. 20, 2015, 11:17 p.m. UTC | #1
On Tue, Oct 20, 2015 at 2:20 PM, Jean-Christophe Dubois
<jcd@tribudubois.net> wrote:
> The goal is to have debug code always compiled during build.
>
> Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
> ---
>  hw/timer/imx_gpt.c | 40 +++++++++++++++-------------------------
>  1 file changed, 15 insertions(+), 25 deletions(-)
>
> diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
> index 4bac67d..b217d86 100644
> --- a/hw/timer/imx_gpt.c
> +++ b/hw/timer/imx_gpt.c
> @@ -16,11 +16,17 @@
>  #include "hw/misc/imx_ccm.h"
>  #include "qemu/main-loop.h"
>
> -/*
> - * Define to 1 for debug messages
> - */
> -#define DEBUG_TIMER 0
> -#if DEBUG_TIMER
> +#ifndef DEBUG_IMX_GPT
> +#define DEBUG_IMX_GPT 0
> +#endif
> +
> +#define DPRINTF(fmt, args...) \
> +          do { \
> +              if (DEBUG_IMX_GPT) { \
> +                  fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_GPT, \
> +                                                   __func__, ##args); \
> +              } \
> +          } while (0)
>
>  static char const *imx_gpt_reg_name(uint32_t reg)
>  {
> @@ -50,24 +56,6 @@ static char const *imx_gpt_reg_name(uint32_t reg)
>      }
>  }
>
> -#  define DPRINTF(fmt, args...) \
> -          do { printf("%s: " fmt , __func__, ##args); } while (0)
> -#else
> -#  define DPRINTF(fmt, args...) do {} while (0)
> -#endif
> -
> -/*
> - * Define to 1 for messages about attempts to
> - * access unimplemented registers or similar.
> - */
> -#define DEBUG_IMPLEMENTATION 1
> -#if DEBUG_IMPLEMENTATION
> -#  define IPRINTF(fmt, args...) \
> -          do { fprintf(stderr, "%s: " fmt, __func__, ##args); } while (0)
> -#else
> -#  define IPRINTF(fmt, args...) do {} while (0)
> -#endif
> -
>  static const VMStateDescription vmstate_imx_timer_gpt = {
>      .name = TYPE_IMX_GPT,
>      .version_id = 3,
> @@ -271,7 +259,8 @@ static uint64_t imx_gpt_read(void *opaque, hwaddr offset, unsigned size)
>          break;
>
>      default:
> -        IPRINTF("Bad offset %x\n", reg);
> +        qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
> +                      TYPE_IMX_GPT, __func__, (int)reg);
>          break;
>      }
>
> @@ -403,7 +392,8 @@ static void imx_gpt_write(void *opaque, hwaddr offset, uint64_t value,
>          break;
>
>      default:
> -        IPRINTF("Bad offset %x\n", reg);
> +        qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
> +                      TYPE_IMX_GPT, __func__, (int)reg);
>          break;
>      }
>  }
> --
> 2.1.4
>

Remainder of series looks good too, just needs a general sweep for the
comments I made on P1, using PRIs when possible and expanding commit
messages to indicate the changes made.

Regards.
Peter
diff mbox

Patch

diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
index 4bac67d..b217d86 100644
--- a/hw/timer/imx_gpt.c
+++ b/hw/timer/imx_gpt.c
@@ -16,11 +16,17 @@ 
 #include "hw/misc/imx_ccm.h"
 #include "qemu/main-loop.h"
 
-/*
- * Define to 1 for debug messages
- */
-#define DEBUG_TIMER 0
-#if DEBUG_TIMER
+#ifndef DEBUG_IMX_GPT
+#define DEBUG_IMX_GPT 0
+#endif
+
+#define DPRINTF(fmt, args...) \
+          do { \
+              if (DEBUG_IMX_GPT) { \
+                  fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_GPT, \
+                                                   __func__, ##args); \
+              } \
+          } while (0)
 
 static char const *imx_gpt_reg_name(uint32_t reg)
 {
@@ -50,24 +56,6 @@  static char const *imx_gpt_reg_name(uint32_t reg)
     }
 }
 
-#  define DPRINTF(fmt, args...) \
-          do { printf("%s: " fmt , __func__, ##args); } while (0)
-#else
-#  define DPRINTF(fmt, args...) do {} while (0)
-#endif
-
-/*
- * Define to 1 for messages about attempts to
- * access unimplemented registers or similar.
- */
-#define DEBUG_IMPLEMENTATION 1
-#if DEBUG_IMPLEMENTATION
-#  define IPRINTF(fmt, args...) \
-          do { fprintf(stderr, "%s: " fmt, __func__, ##args); } while (0)
-#else
-#  define IPRINTF(fmt, args...) do {} while (0)
-#endif
-
 static const VMStateDescription vmstate_imx_timer_gpt = {
     .name = TYPE_IMX_GPT,
     .version_id = 3,
@@ -271,7 +259,8 @@  static uint64_t imx_gpt_read(void *opaque, hwaddr offset, unsigned size)
         break;
 
     default:
-        IPRINTF("Bad offset %x\n", reg);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
+                      TYPE_IMX_GPT, __func__, (int)reg);
         break;
     }
 
@@ -403,7 +392,8 @@  static void imx_gpt_write(void *opaque, hwaddr offset, uint64_t value,
         break;
 
     default:
-        IPRINTF("Bad offset %x\n", reg);
+        qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad register at offset %d\n",
+                      TYPE_IMX_GPT, __func__, (int)reg);
         break;
     }
 }