1 # -*- coding: utf-8 -*-
4 trace/generated-tracers.dtrace (DTrace only).
7 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__
= "Copyright 2012-2014, 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
16 from sys
import platform
19 # Reserved keywords from
20 # https://wikis.oracle.com/display/DTrace/Types,+Operators+and+Expressions
22 'auto', 'goto', 'sizeof', 'break', 'if', 'static', 'case', 'import',
23 'string', 'char', 'inline', 'stringof', 'const', 'int', 'struct',
24 'continue', 'long', 'switch', 'counter', 'offsetof', 'this',
25 'default', 'probe', 'translator', 'do', 'provider', 'typedef',
26 'double', 'register', 'union', 'else', 'restrict', 'unsigned',
27 'enum', 'return', 'void', 'extern', 'self', 'volatile', 'float',
28 'short', 'while', 'for', 'signed', 'xlate',
32 def generate(events
, backend
, group
):
33 events
= [e
for e
in events
34 if "disable" not in e
.properties
]
36 # SystemTap's dtrace(1) warns about empty "provider qemu {}" but is happy
37 # with an empty file. Avoid the warning.
38 # But dtrace on macOS can't deal with empty files.
39 if not events
and platform
!= "darwin":
42 out('/* This file is autogenerated by tracetool, do not edit. */'
48 for type_
, name
in e
.args
:
49 if platform
== "darwin":
50 # macOS dtrace accepts only C99 _Bool
55 # It converts int8_t * in probe points to char * in header
56 # files and introduces [-Wpointer-sign] warning.
57 # Avoid it by changing probe type to signed char * beforehand.
58 if type_
== 'int8_t *':
59 type_
= 'signed char *'
61 # SystemTap dtrace(1) emits a warning when long long is used
62 type_
= type_
.replace('unsigned long long', 'uint64_t')
63 type_
= type_
.replace('signed long long', 'int64_t')
64 type_
= type_
.replace('long long', 'int64_t')
66 if name
in RESERVED_WORDS
:
68 args
.append(type_
+ ' ' + name
)
70 # Define prototype for probe arguments
72 'probe %(name)s(%(args)s);',