From patchwork Tue Mar 13 20:03:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 146474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B4240B6F62 for ; Wed, 14 Mar 2012 07:03:50 +1100 (EST) Received: from localhost ([::1]:59344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Xwi-0002lb-Fl for incoming@patchwork.ozlabs.org; Tue, 13 Mar 2012 16:03:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7XwK-0002NA-94 for qemu-devel@nongnu.org; Tue, 13 Mar 2012 16:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7XwF-0007xo-7C for qemu-devel@nongnu.org; Tue, 13 Mar 2012 16:03:23 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:38903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7XwE-0007xJ-TD for qemu-devel@nongnu.org; Tue, 13 Mar 2012 16:03:19 -0400 Received: from gw.ac.upc.edu (gw.ac.upc.es [147.83.30.3]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id q2DK3C6w023386; Tue, 13 Mar 2012 21:03:12 +0100 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id A6BE92D0018; Tue, 13 Mar 2012 21:03:11 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2012 21:03:10 +0100 Message-Id: <20120313200310.24179.49961.stgit@ginnungagap.bsc.es> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <20120313200235.24179.63987.stgit@ginnungagap.bsc.es> References: <20120313200235.24179.63987.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.16 MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id q2DK3C6w023386 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.33.10 Cc: stefanha@gmail.com, harsh@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 06/12] trace: [tracetool] Add support for event properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Using regular expressions yields more compact and error-proof code when breaking the event properties into pieces. Signed-off-by: LluĂ­s 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 4a85f26..fa646bc 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -39,11 +39,6 @@ Options: ''' sys.exit(1) -def get_properties(line, sep='('): - head, sep, tail = line.partition(sep) - property, sep, name = head.rpartition(' ') - return property.split() - def get_argnames(args): nfields = 0 str = [] @@ -381,7 +376,9 @@ trace_gen = { } # A trace event -cre = re.compile("(?P[^(\s]+)\((?P[^)]*)\)\s*(?P\".*)?") +cre = re.compile("((?P.*)\s+)?(?P[^(\s]+)\((?P[^)]*)\)\s*(?P\".*)?") + +VALID_PROPS = set(["disable"]) class Event(object): def __init__(self, line): @@ -397,7 +394,10 @@ class Event(object): self.argc = len(self.arglist) self.argnames = get_argnames(self.args) self.fmt = groups["fmt"] - self.properties = get_properties(line) + self.properties = groups["props"].split() + unknown_props = set(self.properties) - VALID_PROPS + if len(unknown_props) > 0: + raise ValueError("Unknown properties: %s" % ", ".join(unknown_props)) # Generator that yields Event objects given a trace-events file object def read_events(fobj):