util: add helper APIs for dealing with inotify in portable manner
[qemu/ar7.git] / scripts / tracetool / format / ust_events_h.py
blob4e95e9b3f905dd99dcf6bc5337873000e0eeea71
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 trace/generated-ust-provider.h
6 """
8 __author__ = "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
9 __copyright__ = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
10 __license__ = "GPL version 2 or (at your option) any later version"
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@redhat.com"
16 from tracetool import out
19 def generate(events, backend, group):
20 events = [e for e in events
21 if "disabled" not in e.properties]
23 if group == "all":
24 include = "trace-ust-all.h"
25 else:
26 include = "trace-ust.h"
28 out('/* This file is autogenerated by tracetool, do not edit. */',
29 '',
30 '#undef TRACEPOINT_PROVIDER',
31 '#define TRACEPOINT_PROVIDER qemu',
32 '',
33 '#undef TRACEPOINT_INCLUDE_FILE',
34 '#define TRACEPOINT_INCLUDE_FILE ./%s' % include,
35 '',
36 '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(),
37 ' defined(TRACEPOINT_HEADER_MULTI_READ)',
38 '#define TRACE_%s_GENERATED_UST_H' % group.upper(),
39 '',
40 '#include "qemu-common.h"',
41 '#include <lttng/tracepoint.h>',
42 '',
43 '/*',
44 ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints',
45 ' * requiring no arguments. We define these macros introduced in more recent'
46 ' * versions of LTTng ust as a workaround',
47 ' */',
48 '#ifndef _TP_EXPROTO1',
49 '#define _TP_EXPROTO1(a) void',
50 '#endif',
51 '#ifndef _TP_EXDATA_PROTO1',
52 '#define _TP_EXDATA_PROTO1(a) void *__tp_data',
53 '#endif',
54 '#ifndef _TP_EXDATA_VAR1',
55 '#define _TP_EXDATA_VAR1(a) __tp_data',
56 '#endif',
57 '#ifndef _TP_EXVAR1',
58 '#define _TP_EXVAR1(a)',
59 '#endif',
60 '')
62 for e in events:
63 if len(e.args) > 0:
64 out('TRACEPOINT_EVENT(',
65 ' qemu,',
66 ' %(name)s,',
67 ' TP_ARGS(%(args)s),',
68 ' TP_FIELDS(',
69 name=e.name,
70 args=", ".join(", ".join(i) for i in e.args))
72 types = e.args.types()
73 names = e.args.names()
74 fmts = e.formats()
75 for t,n,f in zip(types, names, fmts):
76 if ('char *' in t) or ('char*' in t):
77 out(' ctf_string(' + n + ', ' + n + ')')
78 elif ("%p" in f) or ("x" in f) or ("PRIx" in f):
79 out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
80 elif ("ptr" in t) or ("*" in t):
81 out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
82 elif ('int' in t) or ('long' in t) or ('unsigned' in t) \
83 or ('size_t' in t) or ('bool' in t):
84 out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
85 elif ('double' in t) or ('float' in t):
86 out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
87 elif ('void *' in t) or ('void*' in t):
88 out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
90 out(' )',
91 ')',
92 '')
94 else:
95 out('TRACEPOINT_EVENT(',
96 ' qemu,',
97 ' %(name)s,',
98 ' TP_ARGS(void),',
99 ' TP_FIELDS()',
100 ')',
102 name=e.name)
104 out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(),
106 '/* This part must be outside ifdef protection */',
107 '#include <lttng/tracepoint-event.h>')