All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 03/12] trace: [tracetool] Add method 'Event.api' to get the name of public routines
Date: Fri, 31 Jan 2014 17:09:19 +0100	[thread overview]
Message-ID: <20140131160919.32741.79585.stgit@fimbulvetr.bsc.es> (raw)
In-Reply-To: <20140131160902.32741.2680.stgit@fimbulvetr.bsc.es>

This ensures proper naming across tracing backends, even when someone overrides
the value without backends knowing it.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 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 c76f648..1170aab 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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __license__    = "GPL version 2 or (at your option) any later version"
 
 __maintainer__ = "Stefan Hajnoczi"
@@ -174,6 +174,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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __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 <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
 __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,
             )

  parent reply	other threads:[~2014-01-31 16:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 16:09 [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 01/12] trace: [tcg] Add documentation Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 02/12] trace: [tracetool, tcg] Allow TCG types in trace event declarations Lluís Vilanova
2014-01-31 16:09 ` Lluís Vilanova [this message]
2014-01-31 16:09 ` [Qemu-devel] [PATCH 04/12] trace: [tracetool, tcg] Provide TCG-related type transformation rules Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 06/12] trace: [tcg] Declare TCG tracing helper routines Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 07/12] trace: [tcg] Define " Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 08/12] trace: [tcg] Include TCG-tracing helpers on all helper.h Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 10/12] trace: [trivial] Include event definitions in "trace.h" Lluís Vilanova
2014-01-31 16:10 ` [Qemu-devel] [PATCH 11/12] trace: [tcg] Include TCG-tracing header on all targets Lluís Vilanova
2014-01-31 16:10 ` [Qemu-devel] [PATCH 12/12] trace: [all] Add "guest_vmem" event Lluís Vilanova
2014-02-04 15:08   ` Richard Henderson
2014-02-04 20:01     ` Lluís Vilanova
2014-02-06 16:12       ` Richard Henderson
2014-02-10 13:29         ` Lluís Vilanova
2014-02-03 14:40 ` [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code Stefan Hajnoczi
2014-02-03 16:24   ` Lluís Vilanova
2014-02-04 14:57 ` Richard Henderson
2014-02-04 15:02   ` Peter Maydell
2014-02-04 15:17     ` Richard Henderson
2014-02-04 20:44       ` Lluís Vilanova
2014-02-04 20:34     ` Lluís Vilanova
2014-02-04 20:33   ` Lluís Vilanova
2014-02-06 15:57     ` Richard Henderson
2014-02-06 19:26       ` Lluís Vilanova
2014-02-07 14:49         ` Richard Henderson
2014-02-07 15:13           ` Peter Maydell
2014-02-07 15:24             ` Lluís Vilanova

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140131160919.32741.79585.stgit@fimbulvetr.bsc.es \
    --to=vilanova@ac.upc.edu \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.