From patchwork Mon Feb 17 19:36:24 2014 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: 321120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46B272C00B1 for ; Tue, 18 Feb 2014 06:38:10 +1100 (EST) Received: from localhost ([::1]:43868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFU12-0002gu-4N for incoming@patchwork.ozlabs.org; Mon, 17 Feb 2014 14:38:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFTzZ-00013T-38 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 14:36:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFTzT-0004yr-Th for qemu-devel@nongnu.org; Mon, 17 Feb 2014 14:36:37 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:42652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFTzT-0004ym-D4 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 14:36:31 -0500 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id s1HJaPmv020089; Mon, 17 Feb 2014 20:36:25 +0100 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id EBD9ABF; Mon, 17 Feb 2014 20:36:24 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Mon, 17 Feb 2014 20:36:24 +0100 Message-Id: <20140217193624.25959.11574.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <20140217193618.25959.69101.stgit@fimbulvetr.bsc.es> References: <20140217193618.25959.69101.stgit@fimbulvetr.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 s1HJaPmv020089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: Kazuya Saito , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/4] trace: [tracetool] Add method 'Event.api' to build event names 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 Makes it easier to ensure proper naming across the different frontends and backends. Signed-off-by: Lluís Vilanova --- scripts/tracetool/__init__.py | 10 +++++++++- scripts/tracetool/backend/dtrace.py | 6 +++--- scripts/tracetool/backend/simple.py | 10 +++++----- scripts/tracetool/backend/stderr.py | 5 +++-- scripts/tracetool/backend/ust.py | 8 +++++--- scripts/tracetool/format/h.py | 6 +++--- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 175df08..7f9161d 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -6,7 +6,7 @@ Machinery for generating tracing-related intermediate files. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -173,6 +173,14 @@ class Event(object): self.args, self.fmt) + QEMU_TRACE = "trace_%(name)s" + + def api(self, fmt=None): + if fmt is None: + fmt = Event.QEMU_TRACE + return fmt % {"name": self.name} + + def _read_events(fobj): res = [] for line in fobj: diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py index e31bc79..3c369c4 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -6,7 +6,7 @@ DTrace/SystemTAP backend. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -44,10 +44,10 @@ def h(events): '') for e in events: - out('static inline void trace_%(name)s(%(args)s) {', + out('static inline void %(api)s(%(args)s) {', ' QEMU_%(uppername)s(%(argnames)s);', '}', - name = e.name, + api = e.api(), args = e.args, uppername = e.name.upper(), argnames = ", ".join(e.args.names()), diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py index 3dde372..ca48e12 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -6,7 +6,7 @@ Simple built-in backend. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -34,10 +34,10 @@ def c(events): ) for num, event in enumerate(events): - out('void trace_%(name)s(%(args)s)', + out('void %(api)s(%(args)s)', '{', ' TraceBufferRecord rec;', - name = event.name, + api = event.api(), args = event.args, ) sizes = [] @@ -95,7 +95,7 @@ def c(events): def h(events): for event in events: - out('void trace_%(name)s(%(args)s);', - name = event.name, + out('void %(api)s(%(args)s);', + api = event.api(), args = event.args, ) diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/stderr.py index 6f93dbd..6681e26 100644 --- a/scripts/tracetool/backend/stderr.py +++ b/scripts/tracetool/backend/stderr.py @@ -6,7 +6,7 @@ Stderr built-in backend. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -33,13 +33,14 @@ def h(events): if len(e.args) > 0: argnames = ", " + argnames - out('static inline void trace_%(name)s(%(args)s)', + out('static inline void %(api)s(%(args)s)', '{', ' bool _state = trace_event_get_state(%(event_id)s);', ' if (_state) {', ' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);', ' }', '}', + api = e.api(), name = e.name, args = e.args, event_id = "TRACE_" + e.name.upper(), diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py index ea36995..180b1bf 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -6,7 +6,7 @@ LTTng User Space Tracing backend. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -78,7 +78,8 @@ def h(events): for e in events: if len(e.args) > 0: out('DECLARE_TRACE(ust_%(name)s, TP_PROTO(%(args)s), TP_ARGS(%(argnames)s));', - '#define trace_%(name)s trace_ust_%(name)s', + '#define %(api)s trace_ust_%(name)s', + api = e.api(), name = e.name, args = e.args, argnames = ", ".join(e.args.names()), @@ -86,7 +87,8 @@ def h(events): else: out('_DECLARE_TRACEPOINT_NOARGS(ust_%(name)s);', - '#define trace_%(name)s trace_ust_%(name)s', + '#define %(api)s trace_ust_%(name)s', + api = e.api(), name = e.name, ) diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 93132fc..9b0903d 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -6,7 +6,7 @@ Generate .h file. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012, Lluís Vilanova " +__copyright__ = "Copyright 2012-2014, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -30,9 +30,9 @@ def end(events): def nop(events): for e in events: out('', - 'static inline void trace_%(name)s(%(args)s)', + 'static inline void %(api)s(%(args)s)', '{', '}', - name = e.name, + api = e.api(), args = e.args, )