[PATCH 0/2] tracetool: remove no_check_foo() and if(true){..} blocks

Tanish Desai posted 2 patches 3 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250804112039.16377-1-tanishdesai37@gmail.com
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, Mads Ynddal <mads@ynddal.dk>
There is a newer version of this series
scripts/tracetool/__init__.py         |  1 -
scripts/tracetool/backend/__init__.py | 26 ++++++++++++++++-------
scripts/tracetool/backend/ftrace.py   |  4 +---
scripts/tracetool/backend/log.py      |  6 ++----
scripts/tracetool/backend/simple.py   |  9 ++------
scripts/tracetool/backend/syslog.py   |  8 ++-----
scripts/tracetool/format/h.py         | 30 ++++++++++-----------------
7 files changed, 37 insertions(+), 47 deletions(-)
[PATCH 0/2] tracetool: remove no_check_foo() and if(true){..} blocks
Posted by Tanish Desai 3 months, 1 week ago
This patch series eliminates unnecessary
if (true) { no_check_foo(...) } blocks and
integrates the no_check_foo(...) logic directly
into trace_foo(...). This results in cleaner,
more maintainable code generation.

A new backend attribute, TRACE_EVENT_GET_STATE,
is introduced. When enabled, it automatically
generates conditional block :
if (trace_event_get_state(...)) { ... }. The
generate() function emits code within this
conditional structure for that backend.

Previously, without TRACE_EVENT_GET_STATE,
each backend was required to manually implement
out("if (trace_event_get_state(...)) {") in its
generate() function, leading to code duplication.

Tanish Desai (2):
  tracetool: add CHECK_TRACE_EVENT_GET_STATE
  tracetool/format: remove redundent trace-event checks

 scripts/tracetool/__init__.py         |  1 -
 scripts/tracetool/backend/__init__.py | 26 ++++++++++++++++-------
 scripts/tracetool/backend/ftrace.py   |  4 +---
 scripts/tracetool/backend/log.py      |  6 ++----
 scripts/tracetool/backend/simple.py   |  9 ++------
 scripts/tracetool/backend/syslog.py   |  8 ++-----
 scripts/tracetool/format/h.py         | 30 ++++++++++-----------------
 7 files changed, 37 insertions(+), 47 deletions(-)

-- 
2.34.1
Re: [PATCH 0/2] tracetool: remove no_check_foo() and if(true){..} blocks
Posted by Daniel P. Berrangé 3 months, 1 week ago
On Mon, Aug 04, 2025 at 11:20:37AM +0000, Tanish Desai wrote:
> This patch series eliminates unnecessary
> if (true) { no_check_foo(...) } blocks and
> integrates the no_check_foo(...) logic directly
> into trace_foo(...). This results in cleaner,
> more maintainable code generation.
> 
> A new backend attribute, TRACE_EVENT_GET_STATE,
> is introduced. When enabled, it automatically
> generates conditional block :
> if (trace_event_get_state(...)) { ... }. The
> generate() function emits code within this
> conditional structure for that backend.
> 
> Previously, without TRACE_EVENT_GET_STATE,
> each backend was required to manually implement
> out("if (trace_event_get_state(...)) {") in its
> generate() function, leading to code duplication.

FWIW, I rebased your patches on top of this series
just posted, which is how I found the two bugs
pointed out against the patches

  https://lists.nongnu.org/archive/html/qemu-devel/2025-08/msg00942.html


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 :|