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):
20 events = [e for e in events
21 if "disabled" not in e.properties]
23 out('/* This file is autogenerated by tracetool, do not edit. */',
25 '#undef TRACEPOINT_PROVIDER',
26 '#define TRACEPOINT_PROVIDER qemu',
28 '#undef TRACEPOINT_INCLUDE_FILE',
29 '#define TRACEPOINT_INCLUDE_FILE ./generated-ust-provider.h',
31 '#if !defined (TRACE__GENERATED_UST_H) || defined(TRACEPOINT_HEADER_MULTI_READ)',
32 '#define TRACE__GENERATED_UST_H',
34 '#include "qemu-common.h"',
35 '#include <lttng/tracepoint.h>',
38 ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints',
39 ' * requiring no arguments. We define these macros introduced in more recent'
40 ' * versions of LTTng ust as a workaround',
42 '#ifndef _TP_EXPROTO1',
43 '#define _TP_EXPROTO1(a) void',
45 '#ifndef _TP_EXDATA_PROTO1',
46 '#define _TP_EXDATA_PROTO1(a) void *__tp_data',
48 '#ifndef _TP_EXDATA_VAR1',
49 '#define _TP_EXDATA_VAR1(a) __tp_data',
52 '#define _TP_EXVAR1(a)',
58 out('TRACEPOINT_EVENT(',
61 ' TP_ARGS(%(args)s),',
64 args=", ".join(", ".join(i) for i in e.args))
66 types = e.args.types()
67 names = e.args.names()
69 for t,n,f in zip(types, names, fmts):
70 if ('char *' in t) or ('char*' in t):
71 out(' ctf_string(' + n + ', ' + n + ')')
72 elif ("%p" in f) or ("x" in f) or ("PRIx" in f):
73 out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
74 elif ("ptr" in t) or ("*" in t):
75 out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
76 elif ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t):
77 out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
78 elif ('double' in t) or ('float' in t):
79 out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
80 elif ('void *' in t) or ('void*' in t):
81 out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
88 out('TRACEPOINT_EVENT(',
97 out('#endif /* TRACE__GENERATED_UST_H */',
99 '/* This part must be outside ifdef protection */',
100 '#include <lttng/tracepoint-event.h>')