From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SATTQ-0004P5-Co for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SATTO-0001go-HQ for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:39 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:42827 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SATTO-0001ga-6o for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:38 -0400 From: =?utf-8?b?TGx1w61z?= Vilanova Date: Wed, 21 Mar 2012 22:53:01 +0100 Message-Id: <20120321215300.3272.72664.stgit@ginnungagap.bsc.es> In-Reply-To: <20120321215224.3272.37570.stgit@ginnungagap.bsc.es> References: <20120321215224.3272.37570.stgit@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v7 06/11] trace: [tracetool] Add support for event properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, harsh@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com Using regular expressions yields more compact and error-proof code when b= reaking the event properties into pieces. Signed-off-by: Llu=C3=ADs Vilanova Signed-off-by: Harsh Prateek Bora --- scripts/tracetool.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/tracetool.py b/scripts/tracetool.py index c2d5c24..27d1db4 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -39,11 +39,6 @@ Options: ''' sys.exit(1) =20 -def get_properties(line, sep=3D'('): - head, sep, tail =3D line.partition(sep) - property, sep, name =3D head.rpartition(' ') - return property.split() - def get_argnames(args): nfields =3D 0 str =3D [] @@ -379,7 +374,9 @@ trace_gen =3D { } =20 # A trace event -cre =3D re.compile("(?P[^(\s]+)\((?P[^)]*)\)\s*(?P\".*)= ?") +cre =3D re.compile("((?P.*)\s+)?(?P[^(\s]+)\((?P[^)]*= )\)\s*(?P\".*)?") + +VALID_PROPS =3D set(["disable"]) =20 class Event(object): def __init__(self, line): @@ -395,7 +392,10 @@ class Event(object): self.argc =3D len(self.arglist) self.argnames =3D get_argnames(self.args) self.fmt =3D groups["fmt"] - self.properties =3D get_properties(line) + self.properties =3D groups["props"].split() + unknown_props =3D set(self.properties) - VALID_PROPS + if len(unknown_props) > 0: + raise ValueError("Unknown properties: %s" % ", ".join(unknow= n_props)) =20 # Generator that yields Event objects given a trace-events file object def read_events(fobj):