diff options
author | Lluís Vilanova <vilanova@ac.upc.edu> | 2012-04-03 20:48:12 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-04-18 14:03:00 +0100 |
commit | 52ef093aceddbe43dcc2cb4190e2178036dac60b (patch) | |
tree | 14249894e48fb2fe10f2ff7020ca30f850316db8 /scripts/tracetool/backend | |
parent | fbc54b9412a905c460d0f5e9e0508d64f9e9759b (diff) |
tracetool: Add support for the 'dtrace' backend
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'scripts/tracetool/backend')
-rw-r--r-- | scripts/tracetool/backend/dtrace.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py new file mode 100644 index 0000000000..cebbd57dd8 --- /dev/null +++ b/scripts/tracetool/backend/dtrace.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +DTrace/SystemTAP backend. +""" + +__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" +__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>" +__license__ = "GPL version 2 or (at your option) any later version" + +__maintainer__ = "Stefan Hajnoczi" +__email__ = "stefanha@linux.vnet.ibm.com" + + +from tracetool import out + + +PROBEPREFIX = None + +def _probeprefix(): + if PROBEPREFIX is None: + raise ValueError("you must set PROBEPREFIX") + return PROBEPREFIX + + +BINARY = None + +def _binary(): + if BINARY is None: + raise ValueError("you must set BINARY") + return BINARY + + +def c(events): + pass + + +def h(events): + out('#include "trace-dtrace.h"', + '') + + for e in events: + out('static inline void trace_%(name)s(%(args)s) {', + ' QEMU_%(uppername)s(%(argnames)s);', + '}', + name = e.name, + 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('', + '};') + + +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(): + # 'limit' is a reserved keyword + if name == 'limit': + name = '_limit' + out(' %s = $arg%d;' % (name.lstrip(), i)) + i += 1 + + out('}') + + out() |