2 # -*- coding: utf-8 -*-
5 trace/generated-ust-provider.h
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
]
24 include
= "trace-ust-all.h"
26 include
= "trace-ust.h"
28 out('/* This file is autogenerated by tracetool, do not edit. */',
30 '#undef TRACEPOINT_PROVIDER',
31 '#define TRACEPOINT_PROVIDER qemu',
33 '#undef TRACEPOINT_INCLUDE_FILE',
34 '#define TRACEPOINT_INCLUDE_FILE ./%s' % include
,
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(),
40 '#include "qemu-common.h"',
41 '#include <lttng/tracepoint.h>',
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',
48 '#ifndef _TP_EXPROTO1',
49 '#define _TP_EXPROTO1(a) void',
51 '#ifndef _TP_EXDATA_PROTO1',
52 '#define _TP_EXDATA_PROTO1(a) void *__tp_data',
54 '#ifndef _TP_EXDATA_VAR1',
55 '#define _TP_EXDATA_VAR1(a) __tp_data',
58 '#define _TP_EXVAR1(a)',
64 out('TRACEPOINT_EVENT(',
67 ' TP_ARGS(%(args)s),',
70 args
=", ".join(", ".join(i
) for i
in e
.args
))
72 types
= e
.args
.types()
73 names
= e
.args
.names()
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
+ ')')
95 out('TRACEPOINT_EVENT(',
104 out('#endif /* TRACE_%s_GENERATED_UST_H */' % group
.upper(),
106 '/* This part must be outside ifdef protection */',
107 '#include <lttng/tracepoint-event.h>')