xref: /openbmc/qemu/scripts/tracetool/backend/ust.py (revision 709395f8)
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-2017, 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
19PUBLIC = True
20
21
22def generate_h_begin(events, group):
23    if group == "root":
24        header = "trace-ust-root.h"
25    else:
26        header = "trace-ust.h"
27
28    out('#include <lttng/tracepoint.h>',
29        '#include "%s"' % header,
30        '',
31        '/* tracepoint_enabled() was introduced in LTTng UST 2.7 */',
32        '#ifndef tracepoint_enabled',
33        '#define tracepoint_enabled(a, b) true',
34        '#endif',
35        '')
36
37
38def generate_h(event, group):
39    argnames = ", ".join(event.args.names())
40    if len(event.args) > 0:
41        argnames = ", " + argnames
42
43    out('    tracepoint(qemu, %(name)s%(tp_args)s);',
44        name=event.name,
45        tp_args=argnames)
46
47
48def generate_h_backend_dstate(event, group):
49    out('    tracepoint_enabled(qemu, %(name)s) || \\',
50        name=event.name)
51