From patchwork Wed Apr 18 14:07:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 153527 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 A2B31B6EE7 for ; Thu, 19 Apr 2012 00:48:29 +1000 (EST) Received: from localhost ([::1]:35718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKVaA-0007UF-RW for incoming@patchwork.ozlabs.org; Wed, 18 Apr 2012 10:10:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKVYv-0004F2-WE for qemu-devel@nongnu.org; Wed, 18 Apr 2012 10:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKVYr-0000CT-FY for qemu-devel@nongnu.org; Wed, 18 Apr 2012 10:08:49 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:32925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKVYr-0000Bs-5S for qemu-devel@nongnu.org; Wed, 18 Apr 2012 10:08:45 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Apr 2012 15:08:41 +0100 Received: from d06nrmr1707.portsmouth.uk.ibm.com (9.149.39.225) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Apr 2012 15:08:11 +0100 Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3IE8AhP2592910 for ; Wed, 18 Apr 2012 15:08:10 +0100 Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q3IE812W023821 for ; Wed, 18 Apr 2012 08:08:02 -0600 Received: from localhost (sig-9-146-161-195.uk.ibm.com [9.146.161.195]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q3IE8136023746; Wed, 18 Apr 2012 08:08:01 -0600 From: Stefan Hajnoczi To: Anthony Liguori Date: Wed, 18 Apr 2012 15:07:19 +0100 Message-Id: <1334758044-14443-5-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1334758044-14443-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1334758044-14443-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 x-cbid: 12041814-0542-0000-0000-0000019433D2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.113 Cc: Harsh Prateek Bora , qemu-devel@nongnu.org, Stefan Hajnoczi , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= Subject: [Qemu-devel] [PATCH 4/9] tracetool: Add support for the 'stderr' backend 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 From: Lluís Vilanova Signed-off-by: Lluís Vilanova Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/backend/stderr.py | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 scripts/tracetool/backend/stderr.py diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py new file mode 100644 index 0000000..917fde7 --- /dev/null +++ b/scripts/tracetool/backend/stderr.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Stderr built-in backend. +""" + +__author__ = "Lluís Vilanova " +__copyright__ = "Copyright 2012, Lluís Vilanova " +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Stefan Hajnoczi" +__email__ = "stefanha@linux.vnet.ibm.com" + + +from tracetool import out + + +def c(events): + out('#include "trace.h"', + '', + 'TraceEvent trace_list[] = {') + + for e in events: + out('{.tp_name = "%(name)s", .state=0},', + name = e.name, + ) + + out('};') + +def h(events): + out('#include ', + '#include "trace/stderr.h"', + '', + 'extern TraceEvent trace_list[];') + + for num, e in enumerate(events): + argnames = ", ".join(e.args.names()) + if len(e.args) > 0: + argnames = ", " + argnames + + out('static inline void trace_%(name)s(%(args)s)', + '{', + ' if (trace_list[%(event_num)s].state != 0) {', + ' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);', + ' }', + '}', + name = e.name, + args = e.args, + event_num = num, + fmt = e.fmt, + argnames = argnames, + ) + + out('', + '#define NR_TRACE_EVENTS %d' % len(events))