1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5DTrace/SystemTAP 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
22PROBEPREFIX = None
23
24def probeprefix():
25    if PROBEPREFIX is None:
26        raise ValueError("you must set PROBEPREFIX")
27    return PROBEPREFIX
28
29
30BINARY = None
31
32def binary():
33    if BINARY is None:
34        raise ValueError("you must set BINARY")
35    return BINARY
36
37
38def generate_h_begin(events, group):
39    if group == "root":
40        header = "trace-dtrace-root.h"
41    else:
42        header = "trace-dtrace.h"
43
44    out('#include "%s"' % header,
45        '')
46
47    # SystemTap defines <provider>_<name>_ENABLED() but other DTrace
48    # implementations might not.
49    for e in events:
50        out('#ifndef QEMU_%(uppername)s_ENABLED',
51            '#define QEMU_%(uppername)s_ENABLED() true',
52            '#endif',
53            uppername=e.name.upper())
54
55def generate_h(event, group):
56    out('    QEMU_%(uppername)s(%(argnames)s);',
57        uppername=event.name.upper(),
58        argnames=", ".join(event.args.names()))
59
60
61def generate_h_backend_dstate(event, group):
62    out('    QEMU_%(uppername)s_ENABLED() || \\',
63        uppername=event.name.upper())
64