pci: assert configuration access is within bounds
[qemu/ar7.git] / scripts / tracetool / format / d.py
blobd3980b914b111ab0395b11bc414e2d76cdef5f4a
1 # -*- coding: utf-8 -*-
3 """
4 trace/generated-tracers.dtrace (DTrace only).
5 """
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@linux.vnet.ibm.com"
15 from tracetool import out
18 # Reserved keywords from
19 # https://wikis.oracle.com/display/DTrace/Types,+Operators+and+Expressions
20 RESERVED_WORDS = (
21 'auto', 'goto', 'sizeof', 'break', 'if', 'static', 'case', 'import',
22 'string', 'char', 'inline', 'stringof', 'const', 'int', 'struct',
23 'continue', 'long', 'switch', 'counter', 'offsetof', 'this',
24 'default', 'probe', 'translator', 'do', 'provider', 'typedef',
25 'double', 'register', 'union', 'else', 'restrict', 'unsigned',
26 'enum', 'return', 'void', 'extern', 'self', 'volatile', 'float',
27 'short', 'while', 'for', 'signed', 'xlate',
31 def generate(events, backend, group):
32 events = [e for e in events
33 if "disable" not in e.properties]
35 # SystemTap's dtrace(1) warns about empty "provider qemu {}" but is happy
36 # with an empty file. Avoid the warning.
37 if not events:
38 return
40 out('/* This file is autogenerated by tracetool, do not edit. */'
41 '',
42 'provider qemu {')
44 for e in events:
45 args = []
46 for type_, name in e.args:
47 if name in RESERVED_WORDS:
48 name += '_'
49 args.append(type_ + ' ' + name)
51 # Define prototype for probe arguments
52 out('',
53 'probe %(name)s(%(args)s);',
54 name=e.name,
55 args=','.join(args))
57 out('',
58 '};')