From patchwork Mon Apr 2 21:44:41 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: 150265 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 7F8A3B6FA3 for ; Tue, 3 Apr 2012 07:45:09 +1000 (EST) Received: from localhost ([::1]:44983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEp3j-0000Ih-Am for incoming@patchwork.ozlabs.org; Mon, 02 Apr 2012 17:45:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEp3F-0007zZ-Va for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEp3E-0001vq-A2 for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:44:37 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:57562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEp3D-0001vf-VC for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:44:36 -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 q32LiXFe029059; Mon, 2 Apr 2012 23:44:33 +0200 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id C4E702D0017; Mon, 2 Apr 2012 23:44:32 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Mon, 2 Apr 2012 23:44:41 +0200 Message-Id: <20120402214441.775.45404.stgit@ginnungagap.bsc.es> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <20120402214417.775.35250.stgit@ginnungagap.bsc.es> References: <20120402214417.775.35250.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 q32LiXFe029059 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 Subject: [Qemu-devel] [PATCH v7 4/8] 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 Signed-off-by: Lluís Vilanova --- scripts/tracetool/backend/stderr.py | 56 +++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) 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))