]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/tracetool/backend/dtrace.py
tracetool: carefully define SDT_USE_VARIADIC
[mirror_qemu.git] / scripts / tracetool / backend / dtrace.py
CommitLineData
52ef093a
LV
1# -*- coding: utf-8 -*-
2
3"""
4DTrace/SystemTAP backend.
5"""
6
7__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
1ff7b531 8__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
52ef093a
LV
9__license__ = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
f892b494 12__email__ = "stefanha@redhat.com"
52ef093a
LV
13
14
15from tracetool import out
16
17
93fba161
LV
18PUBLIC = True
19
20
52ef093a
LV
21PROBEPREFIX = None
22
1dad2ce9 23def probeprefix():
52ef093a
LV
24 if PROBEPREFIX is None:
25 raise ValueError("you must set PROBEPREFIX")
26 return PROBEPREFIX
27
28
29BINARY = None
30
1dad2ce9 31def binary():
52ef093a
LV
32 if BINARY is None:
33 raise ValueError("you must set BINARY")
34 return BINARY
35
36
80dd5c49 37def generate_h_begin(events, group):
0ab8ed18
DB
38 if group == "root":
39 header = "trace-dtrace-root.h"
40 else:
41 header = "trace-dtrace.h"
42
27e08bab
SH
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.
00082244 47 out('#ifndef SDT_USE_VARIADIC')
27e08bab 48 out('#define SDT_USE_VARIADIC 1')
00082244 49 out('#endif')
27e08bab 50
0ab8ed18 51 out('#include "%s"' % header,
52ef093a
LV
52 '')
53
00082244
SH
54 out('#undef SDT_USE_VARIADIC')
55
3932ef3f
SH
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())
1dad2ce9 63
80dd5c49 64def generate_h(event, group):
1ff7b531 65 out(' QEMU_%(uppername)s(%(argnames)s);',
1dad2ce9
LV
66 uppername=event.name.upper(),
67 argnames=", ".join(event.args.names()))
3932ef3f
SH
68
69
70def generate_h_backend_dstate(event, group):
71 out(' QEMU_%(uppername)s_ENABLED() || \\',
72 uppername=event.name.upper())