rules: don't try to create missing include dirs
[qemu/ar7.git] / scripts / tracetool / format / ust_events_h.py
blob514294c2cc2eeb1b62250fcf1ce0ec3028c039da
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) or ('size_t' in t):
83 out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
84 elif ('double' in t) or ('float' in t):
85 out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
86 elif ('void *' in t) or ('void*' in t):
87 out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
89 out(' )',
90 ')',
91 '')
93 else:
94 out('TRACEPOINT_EVENT(',
95 ' qemu,',
96 ' %(name)s,',
97 ' TP_ARGS(void),',
98 ' TP_FIELDS()',
99 ')',
101 name=e.name)
103 out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(),
105 '/* This part must be outside ifdef protection */',
106 '#include <lttng/tracepoint-event.h>')