xref: /openbmc/qemu/scripts/tracetool/backend/ust.py (revision 5964ed56)
1# -*- coding: utf-8 -*-
2
3"""
4LTTng User Space Tracing backend.
5"""
6
7__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
8__copyright__  = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
9__license__    = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
12__email__      = "stefanha@linux.vnet.ibm.com"
13
14
15from tracetool import out
16
17
18PUBLIC = True
19
20
21def generate_h_begin(events, group):
22    if group == "root":
23        header = "trace-ust-root.h"
24    else:
25        header = "trace-ust.h"
26
27    out('#include <lttng/tracepoint.h>',
28        '#include "%s"' % header,
29        '',
30        '/* tracepoint_enabled() was introduced in LTTng UST 2.7 */',
31        '#ifndef tracepoint_enabled',
32        '#define tracepoint_enabled(a, b) true',
33        '#endif',
34        '')
35
36
37def generate_h(event, group):
38    argnames = ", ".join(event.args.names())
39    if len(event.args) > 0:
40        argnames = ", " + argnames
41
42    out('    tracepoint(qemu, %(name)s%(tp_args)s);',
43        name=event.name,
44        tp_args=argnames)
45
46
47def generate_h_backend_dstate(event, group):
48    out('    tracepoint_enabled(qemu, %(name)s) || \\',
49        name=event.name)
50