1 # -*- coding: utf-8 -*-
4 DTrace/SystemTAP backend.
7 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__
= "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
9 __license__
= "GPL version 2 or (at your option) any later version"
11 __maintainer__
= "Stefan Hajnoczi"
12 __email__
= "stefanha@redhat.com"
15 from tracetool
import out
24 if PROBEPREFIX
is None:
25 raise ValueError("you must set PROBEPREFIX")
33 raise ValueError("you must set BINARY")
37 def generate_h_begin(events
, group
):
39 header
= "trace-dtrace-root.h"
41 header
= "trace-dtrace-%s.h" % group
43 # Workaround for ust backend, which also includes <sys/sdt.h> and may
44 # require SDT_USE_VARIADIC to be defined. If dtrace includes <sys/sdt.h>
45 # first without defining SDT_USE_VARIADIC then ust breaks because the
46 # STAP_PROBEV() macro is not defined.
47 out('#ifndef SDT_USE_VARIADIC')
48 out('#define SDT_USE_VARIADIC 1')
51 out('#include "%s"' % header
,
54 out('#undef SDT_USE_VARIADIC')
56 # SystemTap defines <provider>_<name>_ENABLED() but other DTrace
57 # implementations might not.
59 out('#ifndef QEMU_%(uppername)s_ENABLED',
60 '#define QEMU_%(uppername)s_ENABLED() true',
62 uppername
=e
.name
.upper())
64 def generate_h(event
, group
):
65 out(' QEMU_%(uppername)s(%(argnames)s);',
66 uppername
=event
.name
.upper(),
67 argnames
=", ".join(event
.args
.names()))
70 def generate_h_backend_dstate(event
, group
):
71 out(' QEMU_%(uppername)s_ENABLED() || \\',
72 uppername
=event
.name
.upper())