From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
qemu-block@nongnu.org, Cleber Rosa <crosa@redhat.com>
Subject: [PULL 3/5] tracetool: add out_lineno and out_next_lineno to out()
Date: Mon, 4 Jan 2021 14:31:52 +0000 [thread overview]
Message-ID: <20210104143154.462212-4-stefanha@redhat.com> (raw)
In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com>
Make the output file line number and next line number available to
out().
A later patch will use this to improve error messages.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20200827142915.108730-3-stefanha@redhat.com>
---
scripts/tracetool/__init__.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index a6013389a0..da5004ea45 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -31,6 +31,7 @@ def error(*lines):
sys.exit(1)
+out_lineno = 1
out_filename = '<none>'
out_fobj = sys.stdout
@@ -45,12 +46,19 @@ def out(*lines, **kwargs):
You can use kwargs as a shorthand for mapping variables when formatting all
the strings in lines.
- The 'out_filename' kwarg is automatically added with the output filename.
+ The 'out_lineno' kwarg is automatically added to reflect the current output
+ file line number. The 'out_next_lineno' kwarg is also automatically added
+ with the next output line number. The 'out_filename' kwarg is automatically
+ added with the output filename.
"""
+ global out_lineno
output = []
for l in lines:
+ kwargs['out_lineno'] = out_lineno
+ kwargs['out_next_lineno'] = out_lineno + 1
kwargs['out_filename'] = out_filename
output.append(l % kwargs)
+ out_lineno += 1
out_fobj.writelines("\n".join(output) + "\n")
--
2.29.2
next prev parent reply other threads:[~2021-01-04 14:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 14:31 [PULL 0/5] Tracing patches Stefan Hajnoczi
2021-01-04 14:31 ` [PULL 1/5] trace: Send "-d trace:help" output to stdout Stefan Hajnoczi
2021-01-04 15:12 ` Philippe Mathieu-Daudé
2021-01-04 14:31 ` [PULL 2/5] tracetool: add output filename command-line argument Stefan Hajnoczi
2021-01-04 14:31 ` Stefan Hajnoczi [this message]
2021-01-04 14:31 ` [PULL 4/5] tracetool: add input filename and line number to Event Stefan Hajnoczi
2021-01-04 14:31 ` [PULL 5/5] tracetool: show trace-events filename/lineno in fmt string errors Stefan Hajnoczi
2021-01-04 14:42 ` [PULL 0/5] Tracing patches no-reply
2021-01-05 16:18 ` Peter Maydell
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=20210104143154.462212-4-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).