Received: from eggs.gnu.org ([208.118.235.92]:36299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKUQl-0006NX-Di for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:00:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKUQf-0007jq-PI for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:00:51 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:37422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKUQf-0007jj-3m for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:00:45 -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 r2QE0iRW005064 for ; Tue, 26 Mar 2013 15:00:44 +0100 Received: from localhost (unknown [84.88.51.85]) by gw.ac.upc.edu (Postfix) with ESMTP id D7D3C6B0246 for ; Tue, 26 Mar 2013 15:00:43 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova Date: Tue, 26 Mar 2013 15:00:44 +0100 Message-Id: <20130326140043.4471.72654.stgit@fimbulvetr.bsc.es> In-Reply-To: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> References: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 04/22] tracetool: Use method 'Event.api' to get the name of public routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This ensures proper naming across tracing backends, even when someone ove= rrides the value without backends knowing it. Signed-off-by: Llu=C3=ADs Vilanova --- scripts/tracetool/__init__.py | 8 ++++++++ scripts/tracetool/backend/dtrace.py | 4 ++-- scripts/tracetool/backend/simple.py | 8 ++++---- scripts/tracetool/backend/stderr.py | 3 ++- scripts/tracetool/backend/ust.py | 6 ++++-- scripts/tracetool/format/h.py | 4 ++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.p= y index 175df08..a0579a8 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -173,6 +173,14 @@ class Event(object): self.args, self.fmt) =20 + + QEMU_TRACE =3D "trace_%(name)s" + + def api(self, fmt =3D None): + if fmt is None: + fmt =3D Event.QEMU_TRACE + return fmt % { "name" : self.name } + def _read_events(fobj): res =3D [] for line in fobj: diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/back= end/dtrace.py index e31bc79..5fad33e 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -44,10 +44,10 @@ def h(events): '') =20 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 =3D e.name, + api =3D e.api(), args =3D e.args, uppername =3D e.name.upper(), argnames =3D ", ".join(e.args.names()), diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/back= end/simple.py index 30faac9..279551a 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -34,10 +34,10 @@ def c(events): ) =20 for num, event in enumerate(events): - out('void trace_%(name)s(%(args)s)', + out('void %(api)s(%(args)s)', '{', ' TraceBufferRecord rec;', - name =3D event.name, + api =3D event.api(), args =3D event.args, ) sizes =3D [] @@ -94,7 +94,7 @@ def c(events): =20 def h(events): for event in events: - out('void trace_%(name)s(%(args)s);', - name =3D event.name, + out('void %(api)s(%(args)s);', + api =3D event.api(), args =3D event.args, ) diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/back= end/stderr.py index 6f93dbd..70cb27d 100644 --- a/scripts/tracetool/backend/stderr.py +++ b/scripts/tracetool/backend/stderr.py @@ -33,13 +33,14 @@ def h(events): if len(e.args) > 0: argnames =3D ", " + argnames =20 - out('static inline void trace_%(name)s(%(args)s)', + out('static inline void %(api)s(%(args)s)', '{', ' bool _state =3D trace_event_get_state(%(event_id)s);', ' if (_state) {', ' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argname= s)s);', ' }', '}', + api =3D e.api(), name =3D e.name, args =3D e.args, event_id =3D "TRACE_" + e.name.upper(), diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend= /ust.py index ea36995..e9a49b4 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -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 =3D e.api(), name =3D e.name, args =3D e.args, argnames =3D ", ".join(e.args.names()), @@ -86,7 +87,8 @@ def h(events): =20 else: out('_DECLARE_TRACEPOINT_NOARGS(ust_%(name)s);', - '#define trace_%(name)s trace_ust_%(name)s', + '#define %(api)s trace_ust_%(name)s', + api =3D e.api(), name =3D e.name, ) =20 diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.p= y index 93132fc..575d2f1 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -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 =3D e.name, + api =3D e.api(), args =3D e.args, )