Received: from eggs.gnu.org ([2001:4830:134:3::10]:41507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9Gew-000832-A9 for qemu-devel@nongnu.org; Fri, 31 Jan 2014 11:09:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9Geq-0000qc-3w for qemu-devel@nongnu.org; Fri, 31 Jan 2014 11:09:38 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:58457 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9Gep-0000qV-LQ for qemu-devel@nongnu.org; Fri, 31 Jan 2014 11:09:31 -0500 From: =?utf-8?b?TGx1w61z?= Vilanova Date: Fri, 31 Jan 2014 17:09:30 +0100 Message-Id: <20140131160930.32741.28718.stgit@fimbulvetr.bsc.es> In-Reply-To: <20140131160902.32741.2680.stgit@fimbulvetr.bsc.es> References: <20140131160902.32741.2680.stgit@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi Signed-off-by: Llu=C3=ADs Vilanova --- scripts/tracetool/__init__.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.p= y index 1170aab..aab6d31 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -15,6 +15,7 @@ __email__ =3D "stefanha@linux.vnet.ibm.com" =20 import re import sys +import weakref =20 import tracetool.format import tracetool.backend @@ -105,6 +106,18 @@ class Arguments: """List of argument types.""" return [ type_ for type_, _ in self._args ] =20 + def transform(self, *trans): + """Return a new Arguments instance with transformed types. + + The types in the resulting Arguments instance are transformed ac= cording + to tracetool.transform.transform_type. + """ + res =3D [] + for type_, name in self._args: + res.append((tracetool.transform.transform_type(type_, *trans= ), + name)) + return Arguments(res) + =20 class Event(object): """Event description. @@ -125,7 +138,7 @@ class Event(object): =20 _VALID_PROPS =3D set(["disable", "tcg"]) =20 - def __init__(self, name, props, fmt, args): + def __init__(self, name, props, fmt, args, orig=3DNone): """ Parameters ---------- @@ -137,12 +150,19 @@ class Event(object): Event printing format. args : Arguments Event arguments. + orig : Event or None + Original Event before transformation. """ self.name =3D name self.properties =3D props self.fmt =3D fmt self.args =3D args =20 + if orig is None: + self.original =3D weakref.ref(self) + else: + self.original =3D orig + unknown_props =3D set(self.properties) - self._VALID_PROPS if len(unknown_props) > 0: raise ValueError("Unknown properties: %s" % ", ".join(unknow= n_props)) @@ -181,6 +201,14 @@ class Event(object): fmt =3D Event.QEMU_TRACE return fmt % {"name": self.name} =20 + def transform(self, *trans): + """Return a new Event with transformed Arguments.""" + return Event(self.name, + self.properties, + self.fmt, + self.args.transform(*trans), + self) + =20 def _read_events(fobj): res =3D []