1 # -*- coding: utf-8 -*-
4 trace/generated-ust-provider.h
7 __author__
= "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
8 __copyright__
= "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
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
18 def generate(events
, backend
, group
):
19 events
= [e
for e
in events
20 if "disabled" not in e
.properties
]
23 include
= "trace-ust-all.h"
25 include
= "trace-ust.h"
27 out('/* This file is autogenerated by tracetool, do not edit. */',
29 '#undef TRACEPOINT_PROVIDER',
30 '#define TRACEPOINT_PROVIDER qemu',
32 '#undef TRACEPOINT_INCLUDE_FILE',
33 '#define TRACEPOINT_INCLUDE_FILE ./%s' % include
,
35 '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group
.upper(),
36 ' defined(TRACEPOINT_HEADER_MULTI_READ)',
37 '#define TRACE_%s_GENERATED_UST_H' % group
.upper(),
39 '#include <lttng/tracepoint.h>',
42 ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints',
43 ' * requiring no arguments. We define these macros introduced in more recent'
44 ' * versions of LTTng ust as a workaround',
46 '#ifndef _TP_EXPROTO1',
47 '#define _TP_EXPROTO1(a) void',
49 '#ifndef _TP_EXDATA_PROTO1',
50 '#define _TP_EXDATA_PROTO1(a) void *__tp_data',
52 '#ifndef _TP_EXDATA_VAR1',
53 '#define _TP_EXDATA_VAR1(a) __tp_data',
56 '#define _TP_EXVAR1(a)',
62 out('TRACEPOINT_EVENT(',
65 ' TP_ARGS(%(args)s),',
68 args
=", ".join(", ".join(i
) for i
in e
.args
))
70 types
= e
.args
.types()
71 names
= e
.args
.names()
73 for t
,n
,f
in zip(types
, names
, fmts
):
74 if ('char *' in t
) or ('char*' in t
):
75 out(' ctf_string(' + n
+ ', ' + n
+ ')')
76 elif ("%p" in f
) or ("x" in f
) or ("PRIx" in f
):
77 out(' ctf_integer_hex('+ t
+ ', ' + n
+ ', ' + n
+ ')')
78 elif ("ptr" in t
) or ("*" in t
):
79 out(' ctf_integer_hex('+ t
+ ', ' + n
+ ', ' + n
+ ')')
80 elif ('int' in t
) or ('long' in t
) or ('unsigned' in t
) \
81 or ('size_t' in t
) or ('bool' in t
):
82 out(' ctf_integer(' + t
+ ', ' + n
+ ', ' + n
+ ')')
83 elif ('double' in t
) or ('float' in t
):
84 out(' ctf_float(' + t
+ ', ' + n
+ ', ' + n
+ ')')
85 elif ('void *' in t
) or ('void*' in t
):
86 out(' ctf_integer_hex(unsigned long, ' + n
+ ', ' + n
+ ')')
93 out('TRACEPOINT_EVENT(',
102 out('#endif /* TRACE_%s_GENERATED_UST_H */' % group
.upper(),
104 '/* This part must be outside ifdef protection */',
105 '#include <lttng/tracepoint-event.h>')