Merge remote-tracking branch 'remotes/elmarco/tags/slirp-pull-request' into staging
[qemu.git] / scripts / tracetool / backend / dtrace.py
1 # -*- coding: utf-8 -*-
2
3 """
4 DTrace/SystemTAP backend.
5 """
6
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"
10
11 __maintainer__ = "Stefan Hajnoczi"
12 __email__ = "stefanha@linux.vnet.ibm.com"
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.h"
42
43 out('#include "%s"' % header,
44 '')
45
46 # SystemTap defines <provider>_<name>_ENABLED() but other DTrace
47 # implementations might not.
48 for e in events:
49 out('#ifndef QEMU_%(uppername)s_ENABLED',
50 '#define QEMU_%(uppername)s_ENABLED() true',
51 '#endif',
52 uppername=e.name.upper())
53
54 def generate_h(event, group):
55 out(' QEMU_%(uppername)s(%(argnames)s);',
56 uppername=event.name.upper(),
57 argnames=", ".join(event.args.names()))
58
59
60 def generate_h_backend_dstate(event, group):
61 out(' QEMU_%(uppername)s_ENABLED() || \\',
62 uppername=event.name.upper())