All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Cc: qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH 1/6] hw/arm/z2: convert DPRINTF to tracepoints
Date: Fri, 19 Jan 2024 11:41:40 +0000	[thread overview]
Message-ID: <87v87pft3f.fsf@draig.linaro.org> (raw)
In-Reply-To: <021405f5ef53ebe80c7218e1df537635d34889b3.1705662313.git.manos.pitsidianakis@linaro.org> (Manos Pitsidianakis's message of "Fri, 19 Jan 2024 13:14:19 +0200")

Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:

> Tracing DPRINTFs to stderr might not be desired. A developer that relies
> on tracepoints should be able to opt-in to each tracepoint and rely on
> QEMU's log redirection, instead of stderr by default.
>
> This commit converts DPRINTFs in this file that are used for tracing
> into tracepoints.
>
> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> ---
>  hw/arm/trace-events |  8 ++++++++
>  hw/arm/z2.c         | 26 +++++++++-----------------
>  2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/hw/arm/trace-events b/hw/arm/trace-events
> index cdc1ea06a8..a262ad2e6a 100644
> --- a/hw/arm/trace-events
> +++ b/hw/arm/trace-events
> @@ -55,3 +55,11 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s
>  smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
>  smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
>  
> +# z2.c
> +z2_lcd_cur_reg_update(uint8_t r) "reg: 0x%x"
> +z2_lcd_enable_disable(uint16_t v) "value: 0x%x"
> +z2_lcd_enable_disable_result(const char * result) "LCD %s"
> +z2_lcd_invalid_command(uint8_t value) "0x%x"
> +z2_aer915_send_too_log(int8_t msg) "message too long (%i bytes)"
> +z2_aer915_send(uint8_t reg, uint8_t value) "reg %d value 0x%02x"
> +z2_aer915_i2c_start_recv(uint16_t len) "I2C_START_RECV: short message with len %d"
> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
> index 83741a4909..6c0889d698 100644
> --- a/hw/arm/z2.c
> +++ b/hw/arm/z2.c
> @@ -28,13 +28,7 @@
>  #include "cpu.h"
>  #include "qom/object.h"
>  #include "qapi/error.h"
> -
> -#ifdef DEBUG_Z2
> -#define DPRINTF(fmt, ...) \
> -        printf(fmt, ## __VA_ARGS__)
> -#else
> -#define DPRINTF(fmt, ...)
> -#endif
> +#include "trace.h"
>  
>  static const struct keymap map[0x100] = {
>      [0 ... 0xff] = { -1, -1 },
> @@ -127,22 +121,22 @@ static uint32_t zipit_lcd_transfer(SSIPeripheral *dev, uint32_t value)
>      if (z->pos == 3) {

Maybe we could just have:

   trace_z2_lcd_reg_update(z->buf[0], z->buf[1], z->buf[2]);

here

>          switch (z->buf[0]) {
>          case 0x74:
> -            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
> +            trace_z2_lcd_cur_reg_update(z->buf[2]);

drop this

>              z->cur_reg = z->buf[2];
>              break;
>          case 0x76:
>              val = z->buf[1] << 8 | z->buf[2];
> -            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
> +            trace_z2_lcd_enable_disable(val);

and this

>              if (z->cur_reg == 0x22 && val == 0x0000) {
>                  z->enabled = 1;
> -                printf("%s: LCD enabled\n", __func__);
> +                trace_z2_lcd_enable_disable_result("enabled");
>              } else if (z->cur_reg == 0x10 && val == 0x0000) {
>                  z->enabled = 0;
> -                printf("%s: LCD disabled\n", __func__);
> +                trace_z2_lcd_enable_disable_result("disabled");

and just have two trace points, one for enable and one for disable to
save spamming a string into the log.

>              }
>              break;
>          default:
> -            DPRINTF("%s: unknown command!\n", __func__);
> +            trace_z2_lcd_invalid_command(z->buf[0]);

drop this, it can be inferred if we trace the command stream above.

>              break;
>          }
>          z->pos = 0;
> @@ -212,14 +206,12 @@ static int aer915_send(I2CSlave *i2c, uint8_t data)
>  
>      s->buf[s->len] = data;
>      if (s->len++ > 2) {
> -        DPRINTF("%s: message too long (%i bytes)\n",
> -            __func__, s->len);
> +        trace_z2_aer915_send_too_log(s->len);

long

>          return 1;
>      }
>  
>      if (s->len == 2) {
> -        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
> -                s->buf[0], s->buf[1]);
> +        trace_z2_aer915_send(s->buf[0], s->buf[1]);
>      }
>  
>      return 0;
> @@ -235,7 +227,7 @@ static int aer915_event(I2CSlave *i2c, enum i2c_event event)
>          break;
>      case I2C_START_RECV:
>          if (s->len != 1) {
> -            DPRINTF("%s: short message!?\n", __func__);
> +            trace_z2_aer915_i2c_start_recv(s->len);
>          }
>          break;
>      case I2C_FINISH:

maybe better just to have a:

  trace_aer915_event(event, s->len)

before the return?

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

  reply	other threads:[~2024-01-19 11:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 11:14 [PATCH 0/6] hw/{arm,xen} convert printfs to trace/reports Manos Pitsidianakis
2024-01-19 11:14 ` [PATCH 1/6] hw/arm/z2: convert DPRINTF to tracepoints Manos Pitsidianakis
2024-01-19 11:41   ` Alex Bennée [this message]
2024-01-19 11:14 ` [PATCH 2/6] hw/arm/strongarm.c: " Manos Pitsidianakis
2024-01-19 11:57   ` Alex Bennée
2024-01-19 11:14 ` [PATCH 3/6] hw/arm/xen_arm.c: " Manos Pitsidianakis
2024-01-19 12:05   ` Alex Bennée
2024-01-19 11:14 ` [PATCH 4/6] hw/xen/xen-mapcache.c: " Manos Pitsidianakis
2024-01-19 11:14 ` [PATCH 5/6] hw/xen/xen-hvm-common.c: " Manos Pitsidianakis
2024-01-19 11:14 ` [PATCH 6/6] hw/xen: convert stderr prints to error/warn reports Manos Pitsidianakis

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=87v87pft3f.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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.