diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-01-30 09:47:51 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-01-30 09:47:51 +0000 |
commit | 11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f (patch) | |
tree | 04e6a5e6c5e68d91dedeec9d2a83c19a9f43d78d | |
parent | 30d9fefe1aca1e92c785214aa9201fd7c2287d56 (diff) | |
parent | 24f4d3d3aeabf83445839099d6d66cbb3089c37a (diff) | |
download | qemu-11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f.zip qemu-11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f.tar.gz qemu-11ed801d3df3c6e46b2f1f97dcfbf4ca3a2a2f4f.tar.bz2 |
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>
-rw-r--r-- | scripts/tracetool/__init__.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 0670ec1..1a9733d 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -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: |