1# -*- coding: utf-8 -*- 2 3""" 4DTrace/SystemTAP 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@redhat.com" 13 14 15from tracetool import out 16 17 18PUBLIC = True 19 20 21PROBEPREFIX = None 22 23def probeprefix(): 24 if PROBEPREFIX is None: 25 raise ValueError("you must set PROBEPREFIX") 26 return PROBEPREFIX 27 28 29BINARY = None 30 31def binary(): 32 if BINARY is None: 33 raise ValueError("you must set BINARY") 34 return BINARY 35 36 37def generate_h_begin(events, group): 38 if group == "root": 39 header = "trace-dtrace-root.h" 40 else: 41 header = "trace-dtrace-%s.h" % group 42 43 # Workaround for ust backend, which also includes <sys/sdt.h> and may 44 # require SDT_USE_VARIADIC to be defined. If dtrace includes <sys/sdt.h> 45 # first without defining SDT_USE_VARIADIC then ust breaks because the 46 # STAP_PROBEV() macro is not defined. 47 out('#ifndef SDT_USE_VARIADIC') 48 out('#define SDT_USE_VARIADIC 1') 49 out('#endif') 50 51 out('#include "%s"' % header, 52 '') 53 54 out('#undef SDT_USE_VARIADIC') 55 56 # SystemTap defines <provider>_<name>_ENABLED() but other DTrace 57 # implementations might not. 58 for e in events: 59 out('#ifndef QEMU_%(uppername)s_ENABLED', 60 '#define QEMU_%(uppername)s_ENABLED() true', 61 '#endif', 62 uppername=e.name.upper()) 63 64def generate_h(event, group): 65 out(' QEMU_%(uppername)s(%(argnames)s);', 66 uppername=event.name.upper(), 67 argnames=", ".join(event.args.names())) 68 69 70def generate_h_backend_dstate(event, group): 71 out(' QEMU_%(uppername)s_ENABLED() || \\', 72 uppername=event.name.upper()) 73