From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rktpz-0000t1-37 for qemu-devel@nongnu.org; Wed, 11 Jan 2012 03:47:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rktpx-0007uW-O6 for qemu-devel@nongnu.org; Wed, 11 Jan 2012 03:47:15 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:36514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rktpx-0007tE-6r for qemu-devel@nongnu.org; Wed, 11 Jan 2012 03:47:13 -0500 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Jan 2012 08:43:15 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0B8gKN33215466 for ; Wed, 11 Jan 2012 19:42:21 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0B8kiVT032491 for ; Wed, 11 Jan 2012 19:46:45 +1100 Message-ID: <4F0D4C73.2010006@linux.vnet.ibm.com> Date: Wed, 11 Jan 2012 14:16:43 +0530 From: Harsh Bora MIME-Version: 1.0 References: <1326193179-19677-1-git-send-email-harsh@linux.vnet.ibm.com> <1326193179-19677-2-git-send-email-harsh@linux.vnet.ibm.com> <87vcojrx20.fsf@ginnungagap.bsc.es> <4F0D2E66.9010401@linux.vnet.ibm.com> In-Reply-To: <4F0D2E66.9010401@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC PATCH v3 1/3] Converting tracetool.sh to tracetool.py List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-1?Q?Llu=EDs_Vilanova?= , stefanha@linux.vnet.ibm.com Cc: aneesh.kumar@linux.vnet.ibm.com, qemu-devel@nongnu.org On 01/11/2012 12:08 PM, Harsh Bora wrote: > On 01/11/2012 04:21 AM, Lluís Vilanova wrote: >> Harsh Prateek Bora writes: >> >>> Signed-off-by: Harsh Prateek Bora >>> --- >>> Makefile.objs | 6 +- >>> Makefile.target | 10 +- >>> configure | 7 +- >>> scripts/tracetool | 643 >>> -------------------------------------------------- >>> scripts/tracetool.py | 585 +++++++++++++++++++++++++++++++++++++++++++++ >>> 5 files changed, 597 insertions(+), 654 deletions(-) >>> delete mode 100755 scripts/tracetool >>> create mode 100755 scripts/tracetool.py >> [...] >>> +def main(): >>> + global backend, output, binary, targettype, targetarch, probeprefix >>> + supported_backends = ["simple", "nop", "stderr", "dtrace", "ust"] >>> + short_options = "hcd" >>> + long_options = ["stap", "backend=", "binary=", "target-arch=", >>> "target-type=", "probe-prefix=", "list-backends", "check-backend"] >>> + try: >>> + opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) >>> + except getopt.GetoptError, err: >>> + # print help information and exit: >>> + print str(err) # will print something like "option -a not recognized" >>> + usage() >>> + sys.exit(2) >>> + for opt, arg in opts: >>> + if opt == '-h': >>> + output = 'h' >>> + elif opt == '-c': >>> + output = 'c' >>> + elif opt == '-d': >>> + output = 'd' >>> + elif opt == '--stap': >>> + output = 'stap' >>> + elif opt == '--backend': >>> + backend = arg >>> + elif opt == '--binary': >>> + binary = arg >>> + elif opt == '--target-arch': >>> + targetarch = arg >>> + elif opt == '--target-type': >>> + targettype = arg >>> + elif opt == '--probe-prefix': >>> + probeprefix = arg >>> + elif opt == '--list-backends': >>> + print 'simple, nop, stderr, dtrace' >>> + sys.exit(0) >>> + elif opt == "--check-backend": >>> + if any(backend in s for s in supported_backends): >>> + sys.exit(0) >>> + else: >>> + sys.exit(1) >>> + else: >>> + #assert False, "unhandled option" >>> + print "unhandled option: ", opt >>> + usage() >>> + >>> + if backend == "" or output == "": >>> + usage() >>> + sys.exit(0) >>> + >>> + events = read_events(sys.stdin) >>> + trace_gen[output]['begin']() >>> + converters[backend][output](events) >> >> This should use the "disable" property to establish whether to use >> output or >> "nop". Will it be better to again break converters to their begin, process_line, end counterparts and call respective converters accordingly for enabled/disabled events, or let all the backends handle disabled events on their own ? Stefan ? - Harsh >> >>> + trace_gen[output]['end']() >>> + return >>> + >>> +if __name__ == "__main__": >>> + main() >>> + >>> -- >>> 1.7.1.1 >> >> Lluis >> >> > >