]> git.proxmox.com Git - mirror_qemu.git/blame - 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
CommitLineData
fbc54b94
LV
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5LTTng 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
16from tracetool import out
17
18
93fba161
LV
19PUBLIC = True
20
fbc54b94 21def c(events):
9530570f
MG
22 pass
23
fbc54b94 24
9530570f
MG
25def h(events):
26 out('#include <lttng/tracepoint.h>',
27 '#include "trace/generated-ust-provider.h"',
28 '')
fbc54b94
LV
29 for e in events:
30 argnames = ", ".join(e.args.names())
31 if len(e.args) > 0:
9530570f 32 argnames = ", " + argnames
fbc54b94 33
9530570f
MG
34 out('static inline void trace_%(name)s(%(args)s)',
35 '{',
36 ' tracepoint(qemu, %(name)s%(tp_args)s);',
37 '}',
38 '',
fbc54b94 39 name = e.name,
9530570f
MG
40 args = e.args,
41 tp_args = argnames,
fbc54b94
LV
42 )
43
9530570f
MG
44def ust_events_c(events):
45 pass
fbc54b94 46
9530570f 47def ust_events_h(events):
fbc54b94
LV
48 for e in events:
49 if len(e.args) > 0:
9530570f
MG
50 out('TRACEPOINT_EVENT(',
51 ' qemu,',
52 ' %(name)s,',
53 ' TP_ARGS(%(args)s),',
54 ' TP_FIELDS(',
fbc54b94 55 name = e.name,
9530570f 56 args = ", ".join(", ".join(i) for i in e.args),
fbc54b94
LV
57 )
58
9530570f
MG
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
fbc54b94 73 else:
9530570f
MG
74 out('TRACEPOINT_EVENT(',
75 ' qemu,',
76 ' %(name)s,',
77 ' TP_ARGS(void),',
78 ' TP_FIELDS()',
79 ')',
80 '',
fbc54b94 81 name = e.name,
9530570f 82 )