From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8398C433E6 for ; Mon, 31 Aug 2020 21:37:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70FF220866 for ; Mon, 31 Aug 2020 21:37:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70FF220866 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCrUF-0004zj-Iq for qemu-devel@archiver.kernel.org; Mon, 31 Aug 2020 17:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCrD9-0003be-2T for qemu-devel@nongnu.org; Mon, 31 Aug 2020 17:19:31 -0400 Received: from mail-qv1-f46.google.com ([209.85.219.46]:46861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCrD6-0001Wz-JE for qemu-devel@nongnu.org; Mon, 31 Aug 2020 17:19:30 -0400 Received: by mail-qv1-f46.google.com with SMTP id di5so3039982qvb.13 for ; Mon, 31 Aug 2020 14:19:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jitkdYcjeayspJVVJ0UxUprYAeKS3h1ZR5VKH/KAGWM=; b=HbOd1EVxzSUJAkScfgWs3+dE5hOFhHHUPYrlJRW3Ng5/lVLY8cATjZaokgAq5TFUnA N034nCxjhjm7G12Aohei7Mk7Fq631C7Jg6uQBRkElJ6nYPyY0k7XK2t1qyU+Rg9wff4Q q20o/3Lhrh/RL1CPWUrK+f4e2z3PsMOV/G+xKhsyVbKhietInDRfmaSPCZx9pY/n/2yr oDVrJv1SAAXtxAul319CQmPIUXJADkyyTV4Lm01Ebj8poy8rkVjv0FvhUqgNblzSTInm qWbbtfC2byz0wk8z7IqG8GEV4RGmnMv8asMI5AphX+fVCv694emM9VMSDDjqWXDOOPV/ mBCA== X-Gm-Message-State: AOAM530NVROm2Ie8f0B+gG+OUOmH1j5Kip0Wv1ie6IKr5Ny9ZpEYoYr8 0bGF1iDe3q4MAdvVlsaBrGwUH5F2ttPwJXH2RF2Nzqgs X-Google-Smtp-Source: ABdhPJy1A/LN0Av7gXcZ9usoo3Lzt26VImwuHKHryL2+UUtFEd+d+F4CSb9OwgmaNEfp84HDLqgdFEAkmFDDppQcKVg= X-Received: by 2002:a0c:dc90:: with SMTP id n16mr3018564qvk.168.1598908767694; Mon, 31 Aug 2020 14:19:27 -0700 (PDT) MIME-Version: 1.0 References: <20200827142915.108730-1-stefanha@redhat.com> <20200827142915.108730-2-stefanha@redhat.com> In-Reply-To: <20200827142915.108730-2-stefanha@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Date: Mon, 31 Aug 2020 22:17:42 +0200 Message-ID: Subject: Re: [PATCH 1/4] tracetool: add output filename command-line argument To: Stefan Hajnoczi Content-Type: multipart/alternative; boundary="00000000000020718a05ae32f5c2" Received-SPF: pass client-ip=209.85.219.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-qv1-f46.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 17:19:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cleber Rosa , "qemu-devel@nongnu.org Developers" , Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000020718a05ae32f5c2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le jeu. 27 ao=C3=BBt 2020 16:30, Stefan Hajnoczi a = =C3=A9crit : > The tracetool.py script writes to stdout. This means the output filename > is not available to the script. Add the output filename to the > command-line so that the script has access to the filename. > > This also simplifies the tracetool.py invocation. It's no longer > necessary to use meson's custom_build(capture : true) to save output. > > Signed-off-by: Stefan Hajnoczi > --- > docs/devel/tracing.txt | 3 ++- > meson.build | 3 +-- > scripts/tracetool.py | 12 +++++++----- > scripts/tracetool/__init__.py | 18 ++++++++++++++++-- > trace/meson.build | 23 ++++++++--------------- > 5 files changed, 34 insertions(+), 25 deletions(-) > > diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt > index 6144d9921b..c84d4c00ac 100644 > --- a/docs/devel/tracing.txt > +++ b/docs/devel/tracing.txt > @@ -318,7 +318,8 @@ probes: > --target-type system \ > --target-name x86_64 \ > --group=3Dall \ > - trace-events-all >qemu.stp > + trace-events-all \ > + qemu.stp > > To facilitate simple usage of systemtap where there merely needs to be > printf > logging of certain probes, a helper script "qemu-trace-stap" is provided= . > diff --git a/meson.build b/meson.build > index f0fe5f8799..fadeb0c268 100644 > --- a/meson.build > +++ b/meson.build > @@ -1037,7 +1037,6 @@ foreach target : target_dirs > custom_target(exe_name + stp['ext'], > input: trace_events_all, > output: exe_name + stp['ext'], > - capture: true, > install: stp['install'], > install_dir: config_host['qemu_datadir'] / > '../systemtap/tapset', > command: [ > @@ -1046,7 +1045,7 @@ foreach target : target_dirs > '--target-name=3D' + target_name, > '--target-type=3D' + target_type, > '--probe-prefix=3Dqemu.' + target_type + '.' + > target_name, > - '@INPUT@', > + '@INPUT@', '@OUTPUT@' > ]) > endforeach > endif > diff --git a/scripts/tracetool.py b/scripts/tracetool.py > index 31146242b7..ab7653a5ce 100644 > --- a/scripts/tracetool.py > +++ b/scripts/tracetool.py > @@ -16,7 +16,7 @@ __email__ =3D "stefanha@redhat.com" > import sys > import getopt > > -from tracetool import error_write, out > +from tracetool import error_write, out, out_open > import tracetool.backend > import tracetool.format > > @@ -32,7 +32,7 @@ def error_opt(msg =3D None): > format_descr =3D "\n".join([ " %-15s %s" % (n, d) > for n,d in tracetool.format.get_list() ]) > error_write("""\ > -Usage: %(script)s --format=3D --backends=3D [= ] > +Usage: %(script)s --format=3D --backends=3D [= ] > ... > > Backends: > %(backends)s > @@ -135,13 +135,15 @@ def main(args): > if probe_prefix is None: > probe_prefix =3D ".".join(["qemu", target_type, target_name]= ) > > - if len(args) < 1: > - error_opt("missing trace-events filepath") > + if len(args) < 2: > + error_opt("missing trace-events and output filepaths") > events =3D [] > - for arg in args: > + for arg in args[:-1]: > with open(arg, "r") as fh: > events.extend(tracetool.read_events(fh, arg)) > > + out_open(args[-1]) > + > try: > tracetool.generate(events, arg_group, arg_format, arg_backends, > binary=3Dbinary, probe_prefix=3Dprobe_prefix) > diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.p= y > index 3ccfa1e116..98104fa50e 100644 > --- a/scripts/tracetool/__init__.py > +++ b/scripts/tracetool/__init__.py > @@ -31,14 +31,28 @@ def error(*lines): > sys.exit(1) > > > +out_filename =3D '' > +out_fobj =3D sys.stdout > These appear to be always overwritten (is initialization useful?) Anyway: Reviewed-by: Philippe Mathieu-Daud=C3=A9 + > +def out_open(filename): > + global out_filename, out_fobj > + out_filename =3D filename > + out_fobj =3D open(filename, 'wt') > + > def out(*lines, **kwargs): > """Write a set of output lines. > > You can use kwargs as a shorthand for mapping variables when > formating all > the strings in lines. > + > + The 'out_filename' kwarg is automatically added with the output > filename. > """ > - lines =3D [ l % kwargs for l in lines ] > - sys.stdout.writelines("\n".join(lines) + "\n") > + output =3D [] > + for l in lines: > + kwargs['out_filename'] =3D out_filename > + output.append(l % kwargs) > + > + out_fobj.writelines("\n".join(output) + "\n") > > # We only want to allow standard C types or fixed sized > # integer types. We don't want QEMU specific types > diff --git a/trace/meson.build b/trace/meson.build > index 56e870848e..16eccc0c22 100644 > --- a/trace/meson.build > +++ b/trace/meson.build > @@ -11,20 +11,17 @@ foreach dir : [ '.' ] + trace_events_subdirs > trace_h =3D custom_target(fmt.format('trace', 'h'), > output: fmt.format('trace', 'h'), > input: trace_events_file, > - command: [ tracetool, group, '--format=3Dh', > '@INPUT@' ], > - capture: true) > + command: [ tracetool, group, '--format=3Dh', > '@INPUT@', '@OUTPUT@' ]) > genh +=3D trace_h > trace_c =3D custom_target(fmt.format('trace', 'c'), > output: fmt.format('trace', 'c'), > input: trace_events_file, > - command: [ tracetool, group, '--format=3Dc', > '@INPUT@' ], > - capture: true) > + command: [ tracetool, group, '--format=3Dc', > '@INPUT@', '@OUTPUT@' ]) > if 'CONFIG_TRACE_UST' in config_host > trace_ust_h =3D custom_target(fmt.format('trace-ust', 'h'), > output: fmt.format('trace-ust', 'h'), > input: trace_events_file, > - command: [ tracetool, group, > '--format=3Dust-events-h', '@INPUT@' ], > - capture: true) > + command: [ tracetool, group, > '--format=3Dust-events-h', '@INPUT@', '@OUTPUT@' ]) > trace_ss.add(trace_ust_h, lttng, urcubp) > genh +=3D trace_ust_h > endif > @@ -33,8 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs > trace_dtrace =3D custom_target(fmt.format('trace-dtrace', 'dtrace'), > output: fmt.format('trace-dtrace', > 'dtrace'), > input: trace_events_file, > - command: [ tracetool, group, > '--format=3Dd', '@INPUT@' ], > - capture: true) > + command: [ tracetool, group, > '--format=3Dd', '@INPUT@', '@OUTPUT@' ]) > trace_dtrace_h =3D custom_target(fmt.format('trace-dtrace', 'h'), > output: fmt.format('trace-dtrace', > 'h'), > input: trace_dtrace, > @@ -66,9 +62,8 @@ foreach d : [ > gen =3D custom_target(d[0], > output: d[0], > input: meson.source_root() / 'trace-events', > - command: [ tracetool, '--group=3Droot', '--format=3D@0@'= .format(d[1]), > '@INPUT@' ], > - build_by_default: true, # to be removed when added to a > target > - capture: true) > + command: [ tracetool, '--group=3Droot', '--format=3D@0@'= .format(d[1]), > '@INPUT@', '@OUTPUT@' ], > + build_by_default: true) # to be removed when added to a > target > specific_ss.add(gen) > endforeach > > @@ -76,13 +71,11 @@ if 'CONFIG_TRACE_UST' in config_host > trace_ust_all_h =3D custom_target('trace-ust-all.h', > output: 'trace-ust-all.h', > input: trace_events_files, > - command: [ tracetool, '--group=3Dall', > '--format=3Dust-events-h', '@INPUT@' ], > - capture: true) > + command: [ tracetool, '--group=3Dall', > '--format=3Dust-events-h', '@INPUT@', '@OUTPUT@' ]) > trace_ust_all_c =3D custom_target('trace-ust-all.c', > output: 'trace-ust-all.c', > input: trace_events_files, > - command: [ tracetool, '--group=3Dall', > '--format=3Dust-events-c', '@INPUT@' ], > - capture: true) > + command: [ tracetool, '--group=3Dall', > '--format=3Dust-events-c', '@INPUT@', '@OUTPUT@' ]) > trace_ss.add(trace_ust_all_h, trace_ust_all_c) > genh +=3D trace_ust_all_h > endif > -- > 2.26.2 > > --00000000000020718a05ae32f5c2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Le jeu. 27 ao=C3=BBt 2020 16:30, Stefan Hajnoczi <<= a href=3D"mailto:stefanha@redhat.com">stefanha@redhat.com> a =C3=A9c= rit=C2=A0:
The tracetool.py script = writes to stdout. This means the output filename
is not available to the script. Add the output filename to the
command-line so that the script has access to the filename.

This also simplifies the tracetool.py invocation. It's no longer
necessary to use meson's custom_build(capture : true) to save output.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
=C2=A0docs/devel/tracing.txt=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 3 ++-
=C2=A0meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0|=C2=A0 3 +--
=C2=A0scripts/tracetool.py=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 12 +++++++--= ---
=C2=A0scripts/tracetool/__init__.py | 18 ++++++++++++++++--
=C2=A0trace/meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 23= ++++++++---------------
=C2=A05 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt
index 6144d9921b..c84d4c00ac 100644
--- a/docs/devel/tracing.txt
+++ b/docs/devel/tracing.txt
@@ -318,7 +318,8 @@ probes:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 --target-type system \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 --target-name x86_64 \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 --group=3Dall \
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0trace-events-all >qemu.stp
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0trace-events-all \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0qemu.stp

=C2=A0To facilitate simple usage of systemtap where there merely needs to b= e printf
=C2=A0logging of certain probes, a helper script "qemu-trace-stap"= ; is provided.
diff --git a/meson.build b/meson.build
index f0fe5f8799..fadeb0c268 100644
--- a/meson.build
+++ b/meson.build
@@ -1037,7 +1037,6 @@ foreach target : target_dirs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0custom_target(exe_name + stp['ext'= ;],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0input: trace_events_all,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0output: exe_name + stp['ext'],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 capture: true,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0install: stp['install'],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0install_dir: config_host['qemu_datadir'] / '../system= tap/tapset',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0command: [
@@ -1046,7 +1045,7 @@ foreach target : target_dirs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0'--target-name=3D' + target_name,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0'--target-type=3D' + target_type,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0'--probe-prefix=3Dqemu.' + target_type + '.= 9; + target_name,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 '@INPUT@',
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 '@INPUT@', '@OUTPUT@'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0])
=C2=A0 =C2=A0 =C2=A0 =C2=A0endforeach
=C2=A0 =C2=A0 =C2=A0endif
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 31146242b7..ab7653a5ce 100644
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -16,7 +16,7 @@ __email__=C2=A0 =C2=A0 =C2=A0 =3D "stefanha@redhat.= com"
=C2=A0import sys
=C2=A0import getopt

-from tracetool import error_write, out
+from tracetool import error_write, out, out_open
=C2=A0import tracetool.backend
=C2=A0import tracetool.format

@@ -32,7 +32,7 @@ def error_opt(msg =3D None):
=C2=A0 =C2=A0 =C2=A0format_descr =3D "\n".join([ "=C2=A0 =C2= =A0 %-15s %s" % (n, d)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for n,d in tracetool.format.get_list= () ])
=C2=A0 =C2=A0 =C2=A0error_write("""\
-Usage: %(script)s --format=3D<format> --backends=3D<backends> = [<options>]
+Usage: %(script)s --format=3D<format> --backends=3D<backends> = [<options>] <trace-events> ... <output>

=C2=A0Backends:
=C2=A0%(backends)s
@@ -135,13 +135,15 @@ def main(args):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if probe_prefix is None:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0probe_prefix =3D ".&qu= ot;.join(["qemu", target_type, target_name])

-=C2=A0 =C2=A0 if len(args) < 1:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 error_opt("missing trace-events filepath&= quot;)
+=C2=A0 =C2=A0 if len(args) < 2:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 error_opt("missing trace-events and outpu= t filepaths")
=C2=A0 =C2=A0 =C2=A0events =3D []
-=C2=A0 =C2=A0 for arg in args:
+=C2=A0 =C2=A0 for arg in args[:-1]:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0with open(arg, "r") as fh:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0events.extend(tracetool.rea= d_events(fh, arg))

+=C2=A0 =C2=A0 out_open(args[-1])
+
=C2=A0 =C2=A0 =C2=A0try:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tracetool.generate(events, arg_group, arg= _format, arg_backends,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 binary=3Dbinary, probe_prefix=3Dprobe_prefix)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py<= br> index 3ccfa1e116..98104fa50e 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -31,14 +31,28 @@ def error(*lines):
=C2=A0 =C2=A0 =C2=A0sys.exit(1)


+out_filename =3D '<none>'
+out_fobj =3D sys.stdout

=
These appear to be always overwritten (is initializ= ation useful?)

Anyway:
Reviewed-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>

+
+def out_open(filename):
+=C2=A0 =C2=A0 global out_filename, out_fobj
+=C2=A0 =C2=A0 out_filename =3D filename
+=C2=A0 =C2=A0 out_fobj =3D open(filename, 'wt')
+
=C2=A0def out(*lines, **kwargs):
=C2=A0 =C2=A0 =C2=A0"""Write a set of output lines.

=C2=A0 =C2=A0 =C2=A0You can use kwargs as a shorthand for mapping variables= when formating all
=C2=A0 =C2=A0 =C2=A0the strings in lines.
+
+=C2=A0 =C2=A0 The 'out_filename' kwarg is automatically added with= the output filename.
=C2=A0 =C2=A0 =C2=A0"""
-=C2=A0 =C2=A0 lines =3D [ l % kwargs for l in lines ]
-=C2=A0 =C2=A0 sys.stdout.writelines("\n".join(lines) + "\n&= quot;)
+=C2=A0 =C2=A0 output =3D []
+=C2=A0 =C2=A0 for l in lines:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 kwargs['out_filename'] =3D out_filenam= e
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 output.append(l % kwargs)
+
+=C2=A0 =C2=A0 out_fobj.writelines("\n".join(output) + "\n&q= uot;)

=C2=A0# We only want to allow standard C types or fixed sized
=C2=A0# integer types. We don't want QEMU specific types
diff --git a/trace/meson.build b/trace/meson.build
index 56e870848e..16eccc0c22 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -11,20 +11,17 @@ foreach dir : [ '.' ] + trace_events_subdirs =C2=A0 =C2=A0trace_h =3D custom_target(fmt.format('trace', 'h&#= 39;),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0output: fmt.format('trace', 'h'), =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_file,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--format=3Dh', '= ;@INPUT@' ],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--format=3Dh', '= ;@INPUT@', '@OUTPUT@' ])
=C2=A0 =C2=A0genh +=3D trace_h
=C2=A0 =C2=A0trace_c =3D custom_target(fmt.format('trace', 'c&#= 39;),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0output: fmt.format('trace', 'c'), =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_file,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--format=3Dc', '= ;@INPUT@' ],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--format=3Dc', '= ;@INPUT@', '@OUTPUT@' ])
=C2=A0 =C2=A0if 'CONFIG_TRACE_UST' in config_host
=C2=A0 =C2=A0 =C2=A0trace_ust_h =3D custom_target(fmt.format('trace-ust= ', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: fmt.format('trace-= ust', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_file,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--= format=3Dust-events-h', '@INPUT@' ],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, group, '--= format=3Dust-events-h', '@INPUT@', '@OUTPUT@' ])
=C2=A0 =C2=A0 =C2=A0trace_ss.add(trace_ust_h, lttng, urcubp)
=C2=A0 =C2=A0 =C2=A0genh +=3D trace_ust_h
=C2=A0 =C2=A0endif
@@ -33,8 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
=C2=A0 =C2=A0 =C2=A0trace_dtrace =3D custom_target(fmt.format('trace-dt= race', 'dtrace'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 output: fmt.format('trace= -dtrace', 'dtrace'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 input: trace_events_file,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0command: [ tracetool, group, &= #39;--format=3Dd', '@INPUT@' ],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0command: [ tracetool, group, &= #39;--format=3Dd', '@INPUT@', '@OUTPUT@' ])
=C2=A0 =C2=A0 =C2=A0trace_dtrace_h =3D custom_target(fmt.format('trace-= dtrace', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 output: fmt.format(= 9;trace-dtrace', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 input: trace_dtrace, @@ -66,9 +62,8 @@ foreach d : [
=C2=A0 =C2=A0gen =3D custom_target(d[0],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: d[0],=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: meson.= source_root() / 'trace-events',
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ traceto= ol, '--group=3Droot', '--format=3D@0@'.format(d[1]), '@= INPUT@' ],
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 build_by_default: = true, # to be removed when added to a target
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ traceto= ol, '--group=3Droot', '--format=3D@0@'.format(d[1]), '@= INPUT@', '@OUTPUT@' ],
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 build_by_default: = true) # to be removed when added to a target
=C2=A0 =C2=A0specific_ss.add(gen)
=C2=A0endforeach

@@ -76,13 +71,11 @@ if 'CONFIG_TRACE_UST' in config_host
=C2=A0 =C2=A0trace_ust_all_h =3D custom_target('trace-ust-all.h', =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: 'trace-ust-= all.h',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_fil= es,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, '--= group=3Dall', '--format=3Dust-events-h', '@INPUT@' ], -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, '--= group=3Dall', '--format=3Dust-events-h', '@INPUT@', = 9;@OUTPUT@' ])
=C2=A0 =C2=A0trace_ust_all_c =3D custom_target('trace-ust-all.c', =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: 'trace-ust-= all.c',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_fil= es,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, '--= group=3Dall', '--format=3Dust-events-c', '@INPUT@' ], -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture: true)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 command: [ tracetool, '--= group=3Dall', '--format=3Dust-events-c', '@INPUT@', = 9;@OUTPUT@' ])
=C2=A0 =C2=A0trace_ss.add(trace_ust_all_h, trace_ust_all_c)
=C2=A0 =C2=A0genh +=3D trace_ust_all_h
=C2=A0endif
--
2.26.2

--00000000000020718a05ae32f5c2--