-----BEGIN PGP SIGNATURE-----

iQEcBAABAgAGBQJab0JxAAoJEJykq7OBq3PIS4oH/iUa1Wy1LqOeq7uX9TtV6FPl
 ojsKipIRkezNtOq40+e4+xGvAor7Y7cP9P5/K8aG6AjhqWQXG6jpEisAC+RrjOON
 UM8jVPhw/cQhyiYwR2+EC1DlEinXoIHHC0Fse7gTgxNgNTAluHejDfONtm+Hf/UL
 DiwvE0gVos2G2TkW6o/4rRequc/Rz+9eOj5+4u9/w5iyd+VXrCbqJAa7njfy5YJa
 TVktNfAoQzpTZaYVe0yUDCImDeQvyl02tG4uN1w2P0vXfHQjHBiyGeDnlWb8nm4j
 cGS5at0zR7hn/PcCvn+u3g3K3w97tcWm7mLBkGnqA+E3IYGvEyqYP0bt9g2aR7w=
 =do4U
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging

# gpg: Signature made Mon 29 Jan 2018 15:49:05 GMT
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/tracing-pull-request:
  tracetool: report error on foo() instead of foo(void)
  tracetool: clarify that "formats" means "format strings"
  tracetool: prefix parse errors with line numbers

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-01-30 09:47:51 +00:00
commit 11ed801d3d

View file

@ -75,6 +75,8 @@ class Arguments:
res = []
for arg in arg_str.split(","):
arg = arg.strip()
if not arg:
raise ValueError("Empty argument (did you forget to use 'void'?)")
if arg == 'void':
continue
@ -173,7 +175,7 @@ class Event(object):
props : list of str
Property names.
fmt : str, list of str
Event printing format (or formats).
Event printing format string(s).
args : Arguments
Event arguments.
orig : Event or None
@ -237,9 +239,9 @@ class Event(object):
if "tcg-exec" in props:
raise ValueError("Invalid property 'tcg-exec'")
if "tcg" not in props and not isinstance(fmt, str):
raise ValueError("Only events with 'tcg' property can have two formats")
raise ValueError("Only events with 'tcg' property can have two format strings")
if "tcg" in props and isinstance(fmt, str):
raise ValueError("Events with 'tcg' property must have two formats")
raise ValueError("Events with 'tcg' property must have two format strings")
event = Event(name, props, fmt, args)
@ -263,7 +265,7 @@ class Event(object):
_FMT = re.compile("(%[\d\.]*\w+|%.*PRI\S+)")
def formats(self):
"""List of argument print formats."""
"""List conversion specifiers in the argument print format string."""
assert not isinstance(self.fmt, list)
return self._FMT.findall(self.fmt)
@ -300,13 +302,18 @@ def read_events(fobj):
"""
events = []
for line in fobj:
for lineno, line in enumerate(fobj, 1):
if not line.strip():
continue
if line.lstrip().startswith('#'):
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
if "tcg" not in event.properties: