[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 3/5] trace: include filename when printing parser err
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 3/5] trace: include filename when printing parser error messages |
Date: |
Mon, 12 Mar 2018 16:00:12 +0000 |
From: Daniel P. Berrangé <address@hidden>
Improves error messages from:
ValueError: Error on line 72: need more than 1 value to unpack
To
ValueError: Error at /home/berrange/src/virt/qemu/trace-events:72:
need more than 1 value to unpack
Signed-off-by: Daniel P. Berrangé <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
scripts/simpletrace.py | 4 ++--
scripts/tracetool.py | 2 +-
scripts/tracetool/__init__.py | 6 ++++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py
index be3d1affaf..9d45c6ba4e 100755
--- a/scripts/simpletrace.py
+++ b/scripts/simpletrace.py
@@ -168,7 +168,7 @@ class Analyzer(object):
def process(events, log, analyzer, read_header=True):
"""Invoke an analyzer on each event in a log."""
if isinstance(events, str):
- events = read_events(open(events, 'r'))
+ events = read_events(open(events, 'r'), events)
if isinstance(log, str):
log = open(log, 'rb')
@@ -233,7 +233,7 @@ def run(analyzer):
'<trace-file>\n' % sys.argv[0])
sys.exit(1)
- events = read_events(open(sys.argv[1], 'r'))
+ events = read_events(open(sys.argv[1], 'r'), sys.argv[1])
process(events, sys.argv[2], analyzer, read_header=read_header)
if __name__ == '__main__':
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index c55a21518b..fe2b0771f2 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -142,7 +142,7 @@ def main(args):
events = []
for arg in args:
with open(arg, "r") as fh:
- events.extend(tracetool.read_events(fh))
+ events.extend(tracetool.read_events(fh, arg))
try:
tracetool.generate(events, arg_group, arg_format, arg_backends,
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 3646c2b9fc..4236062650 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -291,13 +291,15 @@ class Event(object):
self)
-def read_events(fobj):
+def read_events(fobj, fname):
"""Generate the output for the given (format, backends) pair.
Parameters
----------
fobj : file
Event description file.
+ fname : str
+ Name of event file
Returns a list of Event objects
"""
@@ -312,7 +314,7 @@ def read_events(fobj):
try:
event = Event.build(line)
except ValueError as e:
- arg0 = 'Error on line %d: %s' % (lineno, e.args[0])
+ arg0 = 'Error at %s:%d: %s' % (fname, lineno, e.args[0])
e.args = (arg0,) + e.args[1:]
raise
--
2.14.3
- [Qemu-devel] [PULL 0/5] Tracing patches, Stefan Hajnoczi, 2018/03/12
- [Qemu-devel] [PULL 4/5] trace: remove use of QEMU specific types from trace probes, Stefan Hajnoczi, 2018/03/12
- [Qemu-devel] [PULL 2/5] simpletrace: fix timestamp argument type, Stefan Hajnoczi, 2018/03/12
- [Qemu-devel] [PULL 5/5] trace: only permit standard C types and fixed size integer types, Stefan Hajnoczi, 2018/03/12
- [Qemu-devel] [PULL 1/5] log-for-trace.h: Split out parts of log.h used by trace.h, Stefan Hajnoczi, 2018/03/12
- [Qemu-devel] [PULL 3/5] trace: include filename when printing parser error messages,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PULL 0/5] Tracing patches, Peter Maydell, 2018/03/13