From patchwork Wed Mar 21 21:53:17 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: 148084 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 63E01B6F6E for ; Thu, 22 Mar 2012 09:27:24 +1100 (EST) Received: from localhost ([::1]:33722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAU02-0006gd-4X for incoming@patchwork.ozlabs.org; Wed, 21 Mar 2012 18:27:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SATTh-0004uU-GV for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SATTf-0001j7-KE for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:57 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:42840 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SATTe-0001ix-Vo for qemu-devel@nongnu.org; Wed, 21 Mar 2012 17:53:55 -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 q2LLroeX002190; Wed, 21 Mar 2012 22:53:50 +0100 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id 4AF2C2D0018; Wed, 21 Mar 2012 22:53:49 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Wed, 21 Mar 2012 22:53:17 +0100 Message-Id: <20120321215317.3272.88059.stgit@ginnungagap.bsc.es> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <20120321215224.3272.37570.stgit@ginnungagap.bsc.es> References: <20120321215224.3272.37570.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 q2LLroeX002190 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 v7 09/11] trace: [tracetool] Make format-specific code optional and with access to events 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 First, routines for format-specific code are not mandatory. Second, all format-specific routines get the list of events as an argument. Signed-off-by: LluĂ­s Vilanova Signed-off-by: Harsh Prateek Bora --- scripts/tracetool.py | 32 ++++++++++---------------------- 1 files changed, 10 insertions(+), 22 deletions(-) diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 3c47252..5379e19 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -39,7 +39,7 @@ Options: ''' sys.exit(1) -def trace_h_begin(): +def trace_h_begin(events): print '''#ifndef TRACE_H #define TRACE_H @@ -47,17 +47,12 @@ def trace_h_begin(): #include "qemu-common.h"''' - -def trace_h_end(): +def trace_h_end(events): print '#endif /* TRACE_H */' - -def trace_c_begin(): +def trace_c_begin(events): print '/* This file is autogenerated by tracetool, do not edit. */' -def trace_c_end(): - pass # nop, required for trace_gen - def nop_h(events): print for event in events: @@ -282,18 +277,12 @@ probe %(probeprefix)s.%(name)s = process("%(binary)s").mark("%(name)s") def dtrace_nop_stp(events): pass -def trace_stap_begin(): +def trace_stap_begin(events): print '/* This file is autogenerated by tracetool, do not edit. */' -def trace_stap_end(): - pass #nop, reqd for trace_gen - -def trace_d_begin(): +def trace_d_begin(events): print '/* This file is autogenerated by tracetool, do not edit. */' -def trace_d_end(): - pass #nop, reqd for trace_gen - # Registry of backends and their converter functions converters = { @@ -329,22 +318,19 @@ converters = { } # Trace file header and footer code generators -trace_gen = { +formats = { 'h': { 'begin': trace_h_begin, 'end': trace_h_end, }, 'c': { 'begin': trace_c_begin, - 'end': trace_c_end, }, 'd': { 'begin': trace_d_begin, - 'end': trace_d_end, }, 'stap': { 'begin': trace_stap_begin, - 'end': trace_stap_end, }, } @@ -487,10 +473,12 @@ def main(): events = read_events(sys.stdin) - trace_gen[output]['begin']() + if 'begin' in formats[output]: + formats[output]['begin'](events) converters[backend][output]([ e for e in events if 'disable' not in e.properties ]) converters['nop'][output]([ e for e in events if 'disable' in e.properties ]) - trace_gen[output]['end']() + if 'end' in formats[output]: + formats[output]['end'](events) if __name__ == "__main__": main()