mirror of https://github.com/xemu-project/xemu.git
tracetool: prefix parse errors with line numbers
Include the file line number in the message that is printed when trace-events parse errors are raised. [Use enumerate(fobj, 1) to avoid having to increment a 0-based index later, as suggested by Eric Blake. --Stefan] Suggested-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20180110202553.31889-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
6233b4a8c2
commit
5069b56189
|
@ -300,13 +300,18 @@ def read_events(fobj):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
events = []
|
events = []
|
||||||
for line in fobj:
|
for lineno, line in enumerate(fobj, 1):
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
continue
|
continue
|
||||||
if line.lstrip().startswith('#'):
|
if line.lstrip().startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
event = Event.build(line)
|
try:
|
||||||
|
event = Event.build(line)
|
||||||
|
except ValueError as e:
|
||||||
|
arg0 = 'Error on line %d: %s' % (lineno, e.args[0])
|
||||||
|
e.args = (arg0,) + e.args[1:]
|
||||||
|
raise
|
||||||
|
|
||||||
# transform TCG-enabled events
|
# transform TCG-enabled events
|
||||||
if "tcg" not in event.properties:
|
if "tcg" not in event.properties:
|
||||||
|
|
Loading…
Reference in New Issue