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 2/2] tracetool/format: remove redundent trace-event checks
Date: Tue, 5 Aug 2025 21:10:00 +0100	[thread overview]
Message-ID: <aJJlGOA_jibz5hKZ@redhat.com> (raw)
In-Reply-To: <20250804112039.16377-3-tanishdesai37@gmail.com>

On Mon, Aug 04, 2025 at 11:20:39AM +0000, Tanish Desai wrote:
> Remove redundent if(check_trace_event) check
> from individual backends.
> Adding CHECK_TRACE_EVENT_GET_STATE in log,syslog,
> dtrace and simple backend.
> 
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>  scripts/tracetool/backend/ftrace.py | 4 +---
>  scripts/tracetool/backend/log.py    | 6 ++----
>  scripts/tracetool/backend/simple.py | 9 ++-------
>  scripts/tracetool/backend/syslog.py | 8 ++------
>  4 files changed, 7 insertions(+), 20 deletions(-)
> 
> diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
> index 5fa30ccc08..b38f527461 100644
> --- a/scripts/tracetool/backend/ftrace.py
> +++ b/scripts/tracetool/backend/ftrace.py
> @@ -16,6 +16,7 @@
>  
>  
>  PUBLIC = True
> +CHECK_TRACE_EVENT_GET_STATE = True
>  
>  
>  def generate_h_begin(events, group):
> @@ -32,18 +33,15 @@ def generate_h(event, group):
>          '        char ftrace_buf[MAX_TRACE_STRLEN];',
>          '        int unused __attribute__ ((unused));',
>          '        int trlen;',
> -        '        if (trace_event_get_state(%(event_id)s)) {',
>          '#line %(event_lineno)d "%(event_filename)s"',
>          '            trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
>          '                             "%(name)s " %(fmt)s "\\n" %(argnames)s);',
>          '#line %(out_next_lineno)d "%(out_filename)s"',
>          '            trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
>          '            unused = write(trace_marker_fd, ftrace_buf, trlen);',
> -        '        }',
>          '    }',
>          name=event.name,
>          args=event.args,
> -        event_id="TRACE_" + event.name.upper(),
>          event_lineno=event.lineno,
>          event_filename=event.filename,
>          fmt=event.fmt.rstrip("\n"),
> diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
> index eb50ceea34..d8406d226b 100644
> --- a/scripts/tracetool/backend/log.py
> +++ b/scripts/tracetool/backend/log.py
> @@ -16,6 +16,7 @@
>  
>  
>  PUBLIC = True
> +CHECK_TRACE_EVENT_GET_STATE = True
>  
>  
>  def generate_h_begin(events, group):
> @@ -28,14 +29,11 @@ def generate_h(event, group):
>      if len(event.args) > 0:
>          argnames = ", " + argnames
>  
> -    cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
> -
> -    out('    if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
> +    out('    if (qemu_loglevel_mask(LOG_TRACE)) {',
>          '#line %(event_lineno)d "%(event_filename)s"',
>          '        qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);',
>          '#line %(out_next_lineno)d "%(out_filename)s"',
>          '    }',
> -        cond=cond,
>          event_lineno=event.lineno,
>          event_filename=event.filename,
>          name=event.name,

This change results in bad indentation of the generated inline function
nested if conditions. e.g. the result looks like this:

static inline void trace_test_blah(void *context, const char *filename)
{
    if (trace_event_get_state(TRACE_TEST_BLAH)) {
    if (qemu_loglevel_mask(LOG_TRACE)) {
#line 4 "trace-events"
        qemu_log("test_blah " "Blah context=%p filename=%s" "\n", context, filename);
#line 29 "../../../../../../../../dev/stdout"
    }
    }
}


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:10 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é
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é [this message]
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=aJJlGOA_jibz5hKZ@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.