summary refs log tree commit diff stats
path: root/scripts/tracetool/backend/dtrace.py
diff options
context:
space:
mode:
authorLluís Vilanova <vilanova@ac.upc.edu>2014-02-23 20:37:40 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-05-07 19:07:18 +0200
commit1dad2ce97345f3424c4990cb232b40a35d5e936b (patch)
tree1e7ebf28f38266aca24947f76294f8b6ac340bc5 /scripts/tracetool/backend/dtrace.py
parentef0bd3bba674769c7d36bf400fc4fe7ea43244c5 (diff)
downloadfocaccia-qemu-1dad2ce97345f3424c4990cb232b40a35d5e936b.tar.gz
focaccia-qemu-1dad2ce97345f3424c4990cb232b40a35d5e936b.zip
trace: [tracetool] Minimize the amount of per-backend code
Backends now only contain the essential backend-specific code, and most of the work is moved to frontend code.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/tracetool/backend/dtrace.py')
-rw-r--r--scripts/tracetool/backend/dtrace.py79
1 files changed, 8 insertions, 71 deletions
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index 3c369c4780..fabfe99881 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -21,7 +21,7 @@ PUBLIC = True
 
 PROBEPREFIX = None
 
-def _probeprefix():
+def probeprefix():
     if PROBEPREFIX is None:
         raise ValueError("you must set PROBEPREFIX")
     return PROBEPREFIX
@@ -29,81 +29,18 @@ def _probeprefix():
 
 BINARY = None
 
-def _binary():
+def binary():
     if BINARY is None:
         raise ValueError("you must set BINARY")
     return BINARY
 
 
-def c(events):
-    pass
-
-
-def h(events):
+def generate_h_begin(events):
     out('#include "trace/generated-tracers-dtrace.h"',
         '')
 
-    for e in events:
-        out('static inline void %(api)s(%(args)s) {',
-            '    QEMU_%(uppername)s(%(argnames)s);',
-            '}',
-            api = e.api(),
-            args = e.args,
-            uppername = e.name.upper(),
-            argnames = ", ".join(e.args.names()),
-            )
-
-
-def d(events):
-    out('provider qemu {')
-
-    for e in events:
-        args = str(e.args)
-
-        # DTrace provider syntax expects foo() for empty
-        # params, not foo(void)
-        if args == 'void':
-            args = ''
-
-        # Define prototype for probe arguments
-        out('',
-            'probe %(name)s(%(args)s);',
-            name = e.name,
-            args = args,
-            )
-
-    out('',
-        '};')
-
-
-# Technically 'self' is not used by systemtap yet, but
-# they recommended we keep it in the reserved list anyway
-RESERVED_WORDS = (
-    'break', 'catch', 'continue', 'delete', 'else', 'for',
-    'foreach', 'function', 'global', 'if', 'in', 'limit',
-    'long', 'next', 'probe', 'return', 'self', 'string',
-    'try', 'while'
-    )
-
-def stap(events):
-    for e in events:
-        # Define prototype for probe arguments
-        out('probe %(probeprefix)s.%(name)s = process("%(binary)s").mark("%(name)s")',
-            '{',
-            probeprefix = _probeprefix(),
-            name = e.name,
-            binary = _binary(),
-            )
-
-        i = 1
-        if len(e.args) > 0:
-            for name in e.args.names():
-                # Append underscore to reserved keywords
-                if name in RESERVED_WORDS:
-                    name += '_'
-                out('  %s = $arg%d;' % (name, i))
-                i += 1
-
-        out('}')
-
-    out()
+
+def generate_h(event):
+    out('    QEMU_%(uppername)s(%(argnames)s);',
+        uppername=event.name.upper(),
+        argnames=", ".join(event.args.names()))