From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Eduardo Habkost <ehabkost@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: [PATCH 2/4] tracetool: add out_lineno and out_next_lineno to out()
Date: Thu, 27 Aug 2020 15:29:13 +0100 [thread overview]
Message-ID: <20200827142915.108730-3-stefanha@redhat.com> (raw)
In-Reply-To: <20200827142915.108730-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>
---
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 98104fa50e..e4ee4d5e61 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 formating 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.26.2
next prev parent reply other threads:[~2020-08-27 14:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 14:29 [PATCH 0/4] tracetool: show trace-events filename/lineno in fmt string errors Stefan Hajnoczi
2020-08-27 14:29 ` [PATCH 1/4] tracetool: add output filename command-line argument Stefan Hajnoczi
2020-08-31 20:17 ` Philippe Mathieu-Daudé
2020-09-01 12:55 ` Peter Maydell
2020-08-27 14:29 ` Stefan Hajnoczi [this message]
2020-09-01 12:49 ` [PATCH 2/4] tracetool: add out_lineno and out_next_lineno to out() Peter Maydell
2020-08-27 14:29 ` [PATCH 3/4] tracetool: add input filename and line number to Event Stefan Hajnoczi
2020-08-31 20:20 ` Philippe Mathieu-Daudé
2020-09-01 12:50 ` Peter Maydell
2020-08-27 14:29 ` [PATCH 4/4] tracetool: show trace-events filename/lineno in fmt string errors Stefan Hajnoczi
2020-08-27 14:59 ` Peter Maydell
2020-08-28 15:36 ` Stefan Hajnoczi
2020-09-01 12:52 ` Peter Maydell
2020-12-08 14:20 ` [PATCH 0/4] " 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=20200827142915.108730-3-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=peter.maydell@linaro.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).