]>
Commit | Line | Data |
---|---|---|
52ef093a LV |
1 | # -*- coding: utf-8 -*- |
2 | ||
3 | """ | |
4 | DTrace/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 | ||
15 | from tracetool import out | |
16 | ||
17 | ||
93fba161 LV |
18 | PUBLIC = True |
19 | ||
20 | ||
52ef093a LV |
21 | PROBEPREFIX = None |
22 | ||
1dad2ce9 | 23 | def probeprefix(): |
52ef093a LV |
24 | if PROBEPREFIX is None: |
25 | raise ValueError("you must set PROBEPREFIX") | |
26 | return PROBEPREFIX | |
27 | ||
28 | ||
29 | BINARY = None | |
30 | ||
1dad2ce9 | 31 | def binary(): |
52ef093a LV |
32 | if BINARY is None: |
33 | raise ValueError("you must set BINARY") | |
34 | return BINARY | |
35 | ||
36 | ||
80dd5c49 | 37 | def generate_h_begin(events, group): |
0ab8ed18 DB |
38 | if group == "root": |
39 | header = "trace-dtrace-root.h" | |
40 | else: | |
a81df1b6 | 41 | header = "trace-dtrace-%s.h" % group |
0ab8ed18 | 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 | 64 | def 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 | ||
70 | def generate_h_backend_dstate(event, group): | |
71 | out(' QEMU_%(uppername)s_ENABLED() || \\', | |
72 | uppername=event.name.upper()) |