tracetool: add output filename command-line argument
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>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20200827142915.108730-2-stefanha@redhat.com>
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 3114624..ab7653a 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -16,7 +16,7 @@
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 @@
format_descr = "\n".join([ " %-15s %s" % (n, d)
for n,d in tracetool.format.get_list() ])
error_write("""\
-Usage: %(script)s --format=<format> --backends=<backends> [<options>]
+Usage: %(script)s --format=<format> --backends=<backends> [<options>] <trace-events> ... <output>
Backends:
%(backends)s
@@ -135,13 +135,15 @@
if probe_prefix is None:
probe_prefix = ".".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 = []
- 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=binary, probe_prefix=probe_prefix)