]> Git Repo - qemu.git/blob - scripts/tracetool/backend/dtrace.py
libqemuutil, qapi, trace: convert to meson
[qemu.git] / scripts / tracetool / backend / dtrace.py
1 # -*- coding: utf-8 -*-
2
3 """
4 DTrace/SystemTAP backend.
5 """
6
7 __author__     = "Lluís Vilanova <[email protected]>"
8 __copyright__  = "Copyright 2012-2017, Lluís Vilanova <[email protected]>"
9 __license__    = "GPL version 2 or (at your option) any later version"
10
11 __maintainer__ = "Stefan Hajnoczi"
12 __email__      = "[email protected]"
13
14
15 from tracetool import out
16
17
18 PUBLIC = True
19
20
21 PROBEPREFIX = None
22
23 def probeprefix():
24     if PROBEPREFIX is None:
25         raise ValueError("you must set PROBEPREFIX")
26     return PROBEPREFIX
27
28
29 BINARY = None
30
31 def binary():
32     if BINARY is None:
33         raise ValueError("you must set BINARY")
34     return BINARY
35
36
37 def generate_h_begin(events, group):
38     if group == "root":
39         header = "trace-dtrace-root.h"
40     else:
41         header = "trace-dtrace-%s.h" % group
42
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')
49     out('#endif')
50
51     out('#include "%s"' % header,
52         '')
53
54     out('#undef SDT_USE_VARIADIC')
55
56     # SystemTap defines <provider>_<name>_ENABLED() but other DTrace
57     # implementations might not.
58     for e in events:
59         out('#ifndef QEMU_%(uppername)s_ENABLED',
60             '#define QEMU_%(uppername)s_ENABLED() true',
61             '#endif',
62             uppername=e.name.upper())
63
64 def generate_h(event, group):
65     out('    QEMU_%(uppername)s(%(argnames)s);',
66         uppername=event.name.upper(),
67         argnames=", ".join(event.args.names()))
68
69
70 def generate_h_backend_dstate(event, group):
71     out('    QEMU_%(uppername)s_ENABLED() || \\',
72         uppername=event.name.upper())
This page took 0.036523 seconds and 4 git commands to generate.