target/i386: Fix bad patch application to translate.c
[qemu/ar7.git] / scripts / tracetool / format / stap.py
blobe8ef3e762d771962f255adcdaff059cc70b3d929
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 Generate .stp file (DTrace with SystemTAP only).
6 """
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
10 __license__ = "GPL version 2 or (at your option) any later version"
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@linux.vnet.ibm.com"
16 from tracetool import out
17 from tracetool.backend.dtrace import binary, probeprefix
20 # Technically 'self' is not used by systemtap yet, but
21 # they recommended we keep it in the reserved list anyway
22 RESERVED_WORDS = (
23 'break', 'catch', 'continue', 'delete', 'else', 'for',
24 'foreach', 'function', 'global', 'if', 'in', 'limit',
25 'long', 'next', 'probe', 'return', 'self', 'string',
26 'try', 'while'
30 def stap_escape(identifier):
31 # Append underscore to reserved keywords
32 if identifier in RESERVED_WORDS:
33 return identifier + '_'
34 return identifier
37 def generate(events, backend, group):
38 events = [e for e in events
39 if "disable" not in e.properties]
41 out('/* This file is autogenerated by tracetool, do not edit. */',
42 '')
44 for e in events:
45 # Define prototype for probe arguments
46 out('probe %(probeprefix)s.%(name)s = process("%(binary)s").mark("%(name)s")',
47 '{',
48 probeprefix=probeprefix(),
49 name=e.name,
50 binary=binary())
52 i = 1
53 if len(e.args) > 0:
54 for name in e.args.names():
55 name = stap_escape(name)
56 out(' %s = $arg%d;' % (name, i))
57 i += 1
59 out('}')
61 out()