]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/tracetool/backend/ust.py
Merge remote-tracking branch 'remotes/stefanha/tags/qtest-monitor-process-pull-reques...
[mirror_qemu.git] / scripts / tracetool / backend / ust.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 LTTng User Space Tracing backend.
6 """
7
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
10 __license__ = "GPL version 2 or (at your option) any later version"
11
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@linux.vnet.ibm.com"
14
15
16 from tracetool import out
17
18
19 PUBLIC = True
20
21 def c(events):
22 pass
23
24
25 def h(events):
26 out('#include <lttng/tracepoint.h>',
27 '#include "trace/generated-ust-provider.h"',
28 '')
29 for e in events:
30 argnames = ", ".join(e.args.names())
31 if len(e.args) > 0:
32 argnames = ", " + argnames
33
34 out('static inline void trace_%(name)s(%(args)s)',
35 '{',
36 ' tracepoint(qemu, %(name)s%(tp_args)s);',
37 '}',
38 '',
39 name = e.name,
40 args = e.args,
41 tp_args = argnames,
42 )
43
44 def ust_events_c(events):
45 pass
46
47 def ust_events_h(events):
48 for e in events:
49 if len(e.args) > 0:
50 out('TRACEPOINT_EVENT(',
51 ' qemu,',
52 ' %(name)s,',
53 ' TP_ARGS(%(args)s),',
54 ' TP_FIELDS(',
55 name = e.name,
56 args = ", ".join(", ".join(i) for i in e.args),
57 )
58
59 for t,n in e.args:
60 if ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t):
61 out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
62 elif ('double' in t) or ('float' in t):
63 out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
64 elif ('char *' in t) or ('char*' in t):
65 out(' ctf_string(' + n + ', ' + n + ')')
66 elif ('void *' in t) or ('void*' in t):
67 out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
68
69 out(' )',
70 ')',
71 '')
72
73 else:
74 out('TRACEPOINT_EVENT(',
75 ' qemu,',
76 ' %(name)s,',
77 ' TP_ARGS(void),',
78 ' TP_FIELDS()',
79 ')',
80 '',
81 name = e.name,
82 )