From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXTFl-0006iV-E5 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 07:00:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXTFg-0005m7-Or for qemu-devel@nongnu.org; Fri, 26 Sep 2014 06:59:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXTFg-0005lT-HW for qemu-devel@nongnu.org; Fri, 26 Sep 2014 06:59:52 -0400 From: Stefan Hajnoczi Date: Fri, 26 Sep 2014 11:59:22 +0100 Message-Id: <1411729177-5222-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1411729177-5222-1-git-send-email-stefanha@redhat.com> References: <1411729177-5222-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 01/16] 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: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi From: Llu=C3=ADs Vilanova TCG-enabled events start with two format strings. Delay per-argument form= at computation until requested ('Event.formats'). Signed-off-by: Llu=C3=ADs Vilanova Signed-off-by: Stefan Hajnoczi --- 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__.p= y 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 1.9.3