All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Tanish Desai <tanishdesai37@gmail.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Mads Ynddal <mads@ynddal.dk>
Subject: Re: [PATCH 1/2] tracetool: add CHECK_TRACE_EVENT_GET_STATE
Date: Tue, 5 Aug 2025 21:11:54 +0100	[thread overview]
Message-ID: <aJJliv-xKgH4piH6@redhat.com> (raw)
In-Reply-To: <20250804112039.16377-2-tanishdesai37@gmail.com>

On Mon, Aug 04, 2025 at 11:20:38AM +0000, Tanish Desai wrote:
> New attributed added in backends
> CHECK_TRACE_EVENT_GET_STATE which when
> present and is True wraps the code generated
> by generate function in check_trace_event_get_state
> check else it is outside the conditional block.
> 
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>  scripts/tracetool/__init__.py         |  1 -
>  scripts/tracetool/backend/__init__.py | 26 ++++++++++++++++-------
>  scripts/tracetool/format/h.py         | 30 ++++++++++-----------------
>  3 files changed, 30 insertions(+), 27 deletions(-)
> 
> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> index 2ae2e562d6..d0a02c45d7 100644
> --- a/scripts/tracetool/__init__.py
> +++ b/scripts/tracetool/__init__.py
> @@ -332,7 +332,6 @@ def formats(self):
>          return self._FMT.findall(self.fmt)
>  
>      QEMU_TRACE               = "trace_%(name)s"
> -    QEMU_TRACE_NOCHECK       = "_nocheck__" + QEMU_TRACE
>      QEMU_TRACE_TCG           = QEMU_TRACE + "_tcg"
>      QEMU_DSTATE              = "_TRACE_%(NAME)s_DSTATE"
>      QEMU_BACKEND_DSTATE      = "TRACE_%(NAME)s_BACKEND_DSTATE"
> diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
> index 7bfcc86cc5..3c900f01e9 100644
> --- a/scripts/tracetool/backend/__init__.py
> +++ b/scripts/tracetool/backend/__init__.py
> @@ -23,6 +23,8 @@
>  Attribute Description
>  ========= ====================================================================
>  PUBLIC    If exists and is set to 'True', the backend is considered "public".
> +CHECK_TRACE_EVENT_GET_STATE    If exists and is set to 'True', generate function
> +emits code inside check_trace_event_get_state check.
>  ========= ====================================================================
>  
>  
> @@ -101,22 +103,32 @@ class Wrapper:
>      def __init__(self, backends, format):
>          self._backends = [backend.replace("-", "_") for backend in backends]
>          self._format = format.replace("-", "_")
> +        self.check_trace_event_get_state = False
>          for backend in self._backends:
>              assert exists(backend)
>          assert tracetool.format.exists(self._format)
> +        for backend in self.backend_modules():
> +            check_trace_event_get_state = getattr(backend, "CHECK_TRACE_EVENT_GET_STATE", False)
> +            self.check_trace_event_get_state = self.check_trace_event_get_state or check_trace_event_get_state
>  
> -    def _run_function(self, name, *args, **kwargs):
> +    def backend_modules(self):
>          for backend in self._backends:
> -            func = tracetool.try_import("tracetool.backend." + backend,
> -                                        name % self._format, None)[1]
> -            if func is not None:
> -                func(*args, **kwargs)
> +             module = tracetool.try_import("tracetool.backend." + backend)[1]
> +             if module is not None:
> +                 yield module
> +
> +    def _run_function(self, name, *args, check_trace_event_get_state=None, **kwargs):
> +        for backend in self.backend_modules():
> +            func = getattr(backend,name%self._format,None)
> +            if func is not None and (check_trace_event_get_state is None or
> +                    check_trace_event_get_state == getattr(backend, 'CHECK_TRACE_EVENT_GET_STATE', False)):
> +                    func(*args, **kwargs)

Something here is broken with the "simple" trace backend, as the entire
'.c' file content is no longer generated, causing link errors

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-08-05 20:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04 11:20 [PATCH 0/2] tracetool: remove no_check_foo() and if(true){..} blocks Tanish Desai
2025-08-04 11:20 ` [PATCH 1/2] tracetool: add CHECK_TRACE_EVENT_GET_STATE Tanish Desai
2025-08-05 20:11   ` Daniel P. Berrangé [this message]
2025-08-05 22:32     ` Paolo Bonzini
2025-08-06  2:27       ` Tanish Desai
2025-08-04 11:20 ` [PATCH 2/2] tracetool/format: remove redundent trace-event checks Tanish Desai
2025-08-05 20:10   ` Daniel P. Berrangé
2025-08-05 21:02 ` [PATCH 0/2] tracetool: remove no_check_foo() and if(true){..} blocks Daniel P. Berrangé

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=aJJliv-xKgH4piH6@redhat.com \
    --to=berrange@redhat.com \
    --cc=mads@ynddal.dk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tanishdesai37@gmail.com \
    /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.