Received: from eggs.gnu.org ([2001:4830:134:3::10]:52317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMZzg-0002SZ-NV for qemu-devel@nongnu.org; Wed, 27 Aug 2014 05:58:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMZzZ-0001uI-MV for qemu-devel@nongnu.org; Wed, 27 Aug 2014 05:58:20 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:45458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMZzZ-0001tz-BZ for qemu-devel@nongnu.org; Wed, 27 Aug 2014 05:58:13 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20140818130206.12941.54156.stgit@fimbulvetr.bsc.es> Date: Wed, 27 Aug 2014 11:58:07 +0200 In-Reply-To: <20140818130206.12941.54156.stgit@fimbulvetr.bsc.es> (=?utf-8?Q?=22Llu=C3=ADs?= Vilanova"'s message of "Mon, 18 Aug 2014 15:02:07 +0200") Message-ID: <87egw26yq8.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] trace: [ust] Fix format string computation in tcg-enabled events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alex =?utf-8?Q?Benn=C3=A9e?= , Stefan Hajnoczi Llu=C3=ADs Vilanova writes: > TCG-enabled events start with two format strings. Delay per-argument form= at > computation until requested ('Event.formats'). ping Without this fix, QEMU does not compile if an entry in trace-events has the "tcg" property. > Signed-off-by: Llu=C3=ADs Vilanova > --- > scripts/tracetool/__init__.py | 19 ++++++++++--------- > scripts/tracetool/format/ust_events_h.py | 2 +- > 2 files changed, 11 insertions(+), 10 deletions(-) > diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py > index 36c789d..854fb9e 100644 > --- a/scripts/tracetool/__init__.py > +++ b/scripts/tracetool/__init__.py > @@ -136,8 +136,7 @@ class Event(object): > Properties of the event. > args : Arguments > The event arguments. > - arg_fmts : str > - The format strings for each argument. > + > """ =20 > _CRE =3D re.compile("((?P.*)\s+)?" > @@ -146,11 +145,10 @@ class Event(object): > "\s*" > "(?:(?:(?P\".+),)?\s*(?P\".+))?" > "\s*") > - _FMT =3D re.compile("(%\w+|%.*PRI\S+)") =20 > _VALID_PROPS =3D set(["disable", "tcg", "tcg-trans", "tcg-exec"]) =20 > - def __init__(self, name, props, fmt, args, arg_fmts, orig=3DNone): > + def __init__(self, name, props, fmt, args, orig=3DNone): > """ > Parameters > ---------- > @@ -162,8 +160,6 @@ class Event(object): > Event printing format (or formats). > args : Arguments > Event arguments. > - arg_fmts : list of str > - Format strings for each argument. > orig : Event or None > Original Event before transformation. =20 > @@ -172,7 +168,6 @@ class Event(object): > self.properties =3D props > self.fmt =3D fmt > self.args =3D args > - self.arg_fmts =3D arg_fmts =20 > if orig is None: > self.original =3D weakref.ref(self) > @@ -210,7 +205,6 @@ class Event(object): > if len(fmt_trans) > 0: > fmt =3D [fmt_trans, fmt] > args =3D Arguments.build(groups["args"]) > - arg_fmts =3D Event._FMT.findall(fmt) =20 > if "tcg-trans" in props: > raise ValueError("Invalid property 'tcg-trans'") > @@ -221,7 +215,7 @@ class Event(object): > if "tcg" in props and isinstance(fmt, str): > raise ValueError("Events with 'tcg' property must have two f= ormats") =20 > - return Event(name, props, fmt, args, arg_fmts) > + return Event(name, props, fmt, args) =20 > def __repr__(self): > """Evaluable string representation for this object.""" > @@ -234,6 +228,13 @@ class Event(object): > self.args, > fmt) =20 > + _FMT =3D re.compile("(%\w+|%.*PRI\S+)") > + > + def formats(self): > + """List of argument print formats.""" > + assert not isinstance(self.fmt, list) > + return self._FMT.findall(self.fmt) > + > QEMU_TRACE =3D "trace_%(name)s" > QEMU_TRACE_TCG =3D QEMU_TRACE + "_tcg" =20 > diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool= /format/ust_events_h.py > index d189899..3e8a7cd 100644 > --- a/scripts/tracetool/format/ust_events_h.py > +++ b/scripts/tracetool/format/ust_events_h.py > @@ -65,7 +65,7 @@ def generate(events, backend): =20 > types =3D e.args.types() > names =3D e.args.names() > - fmts =3D e.arg_fmts > + fmts =3D e.formats() > for t,n,f in zip(types, names, fmts): > if ('char *' in t) or ('char*' in t): > out(' ctf_string(' + n + ', ' + n + ')') --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth