2012-04-03 20:48:12 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
DTrace/SystemTAP backend.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
2017-07-04 10:50:46 +02:00
|
|
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
2012-04-03 20:48:12 +02:00
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
2020-05-11 10:28:16 +02:00
|
|
|
__email__ = "stefanha@redhat.com"
|
2012-04-03 20:48:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
2013-03-05 14:47:26 +01:00
|
|
|
PUBLIC = True
|
|
|
|
|
|
|
|
|
2012-04-03 20:48:12 +02:00
|
|
|
PROBEPREFIX = None
|
|
|
|
|
2014-02-23 20:37:40 +01:00
|
|
|
def probeprefix():
|
2012-04-03 20:48:12 +02:00
|
|
|
if PROBEPREFIX is None:
|
|
|
|
raise ValueError("you must set PROBEPREFIX")
|
|
|
|
return PROBEPREFIX
|
|
|
|
|
|
|
|
|
|
|
|
BINARY = None
|
|
|
|
|
2014-02-23 20:37:40 +01:00
|
|
|
def binary():
|
2012-04-03 20:48:12 +02:00
|
|
|
if BINARY is None:
|
|
|
|
raise ValueError("you must set BINARY")
|
|
|
|
return BINARY
|
|
|
|
|
|
|
|
|
2016-10-04 15:35:59 +02:00
|
|
|
def generate_h_begin(events, group):
|
2017-01-25 17:14:15 +01:00
|
|
|
if group == "root":
|
|
|
|
header = "trace-dtrace-root.h"
|
|
|
|
else:
|
2020-08-19 14:44:56 +02:00
|
|
|
header = "trace-dtrace-%s.h" % group
|
2017-01-25 17:14:15 +01:00
|
|
|
|
2020-06-25 16:07:57 +02:00
|
|
|
# Workaround for ust backend, which also includes <sys/sdt.h> and may
|
|
|
|
# require SDT_USE_VARIADIC to be defined. If dtrace includes <sys/sdt.h>
|
|
|
|
# first without defining SDT_USE_VARIADIC then ust breaks because the
|
|
|
|
# STAP_PROBEV() macro is not defined.
|
2020-07-29 17:39:26 +02:00
|
|
|
out('#ifndef SDT_USE_VARIADIC')
|
2020-06-25 16:07:57 +02:00
|
|
|
out('#define SDT_USE_VARIADIC 1')
|
2020-07-29 17:39:26 +02:00
|
|
|
out('#endif')
|
2020-06-25 16:07:57 +02:00
|
|
|
|
2017-01-25 17:14:15 +01:00
|
|
|
out('#include "%s"' % header,
|
2012-04-03 20:48:12 +02:00
|
|
|
'')
|
|
|
|
|
2020-07-29 17:39:26 +02:00
|
|
|
out('#undef SDT_USE_VARIADIC')
|
|
|
|
|
2017-07-31 16:07:17 +02:00
|
|
|
# SystemTap defines <provider>_<name>_ENABLED() but other DTrace
|
|
|
|
# implementations might not.
|
|
|
|
for e in events:
|
|
|
|
out('#ifndef QEMU_%(uppername)s_ENABLED',
|
|
|
|
'#define QEMU_%(uppername)s_ENABLED() true',
|
|
|
|
'#endif',
|
|
|
|
uppername=e.name.upper())
|
2014-02-23 20:37:40 +01:00
|
|
|
|
2016-10-04 15:35:59 +02:00
|
|
|
def generate_h(event, group):
|
2017-07-04 10:50:46 +02:00
|
|
|
out(' QEMU_%(uppername)s(%(argnames)s);',
|
2014-02-23 20:37:40 +01:00
|
|
|
uppername=event.name.upper(),
|
|
|
|
argnames=", ".join(event.args.names()))
|
2017-07-31 16:07:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
def generate_h_backend_dstate(event, group):
|
|
|
|
out(' QEMU_%(uppername)s_ENABLED() || \\',
|
|
|
|
uppername=event.name.upper())
|