From: Tanish Desai <tanishdesai37@gmail.com>
To: qemu-devel@nongnu.org, pbonzini@redhat.com, tanishdesai37@gmail.com
Cc: Mads Ynddal <mads@ynddal.dk>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH v2 2/2] tracetool/format: remove redundent trace-event checks
Date: Wed, 6 Aug 2025 15:05:39 +0000 [thread overview]
Message-ID: <20250806150539.2871-3-tanishdesai37@gmail.com> (raw)
In-Reply-To: <20250806150539.2871-1-tanishdesai37@gmail.com>
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 | 12 +++++-------
scripts/tracetool/backend/log.py | 10 ++++------
scripts/tracetool/backend/simple.py | 9 ++-------
scripts/tracetool/backend/syslog.py | 8 ++------
4 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index 5fa30ccc08..c65d3b89b3 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):
@@ -28,11 +29,10 @@ def generate_h(event, group):
if len(event.args) > 0:
argnames = ", " + argnames
- out(' {',
- ' char ftrace_buf[MAX_TRACE_STRLEN];',
- ' int unused __attribute__ ((unused));',
- ' int trlen;',
- ' if (trace_event_get_state(%(event_id)s)) {',
+ out(' {',
+ ' char ftrace_buf[MAX_TRACE_STRLEN];',
+ ' int unused __attribute__ ((unused));',
+ ' int trlen;',
'#line %(event_lineno)d "%(event_filename)s"',
' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
@@ -40,10 +40,8 @@ def generate_h(event, group):
' 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..2aa180f4b4 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);',
+ ' 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,
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index 7c84c06b20..623ea7d8ed 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -16,7 +16,7 @@
PUBLIC = True
-
+CHECK_TRACE_EVENT_GET_STATE = True
def is_string(arg):
strtype = ('const char*', 'char*', 'const char *', 'char *')
@@ -36,13 +36,8 @@ def generate_h_begin(events, group):
def generate_h(event, group):
- event_id = 'TRACE_' + event.name.upper()
- cond = "trace_event_get_state(%s)" % event_id
- out(' if (%(cond)s) {',
- ' _simple_%(api)s(%(args)s);',
- ' }',
+ out(' _simple_%(api)s(%(args)s);',
api=event.api(),
- cond=cond,
args=", ".join(event.args.names()))
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index 3f82e54aab..04ec85717a 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -16,6 +16,7 @@
PUBLIC = True
+CHECK_TRACE_EVENT_GET_STATE = True
def generate_h_begin(events, group):
@@ -28,14 +29,9 @@ 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) {',
- '#line %(event_lineno)d "%(event_filename)s"',
+ out('#line %(event_lineno)d "%(event_filename)s"',
' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
'#line %(out_next_lineno)d "%(out_filename)s"',
- ' }',
- cond=cond,
event_lineno=event.lineno,
event_filename=event.filename,
name=event.name,
--
2.34.1
next prev parent reply other threads:[~2025-08-06 15:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 15:05 [PATCH v2 0/2] tracetool: remove no_check_foo() and if(true){..} blocks Tanish Desai
2025-08-06 15:05 ` [PATCH v2 1/2] tracetool: add CHECK_TRACE_EVENT_GET_STATE Tanish Desai
2025-08-06 19:13 ` Daniel P. Berrangé
2025-08-07 10:35 ` Paolo Bonzini
2025-08-20 12:14 ` Daniel P. Berrangé
2025-08-07 19:23 ` Stefan Hajnoczi
2025-08-06 15:05 ` Tanish Desai [this message]
2025-08-06 16:53 ` [PATCH v2 2/2] tracetool/format: remove redundent trace-event checks Daniel P. Berrangé
2025-08-07 19:25 ` Stefan Hajnoczi
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=20250806150539.2871-3-tanishdesai37@gmail.com \
--to=tanishdesai37@gmail.com \
--cc=mads@ynddal.dk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).