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.h" 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('#define SDT_USE_VARIADIC 1') 48 49 out('#include "%s"' % header, 50 '') 51 52 # SystemTap defines <provider>_<name>_ENABLED() but other DTrace 53 # implementations might not. 54 for e in events: 55 out('#ifndef QEMU_%(uppername)s_ENABLED', 56 '#define QEMU_%(uppername)s_ENABLED() true', 57 '#endif', 58 uppername=e.name.upper()) 59 60def generate_h(event, group): 61 out(' QEMU_%(uppername)s(%(argnames)s);', 62 uppername=event.name.upper(), 63 argnames=", ".join(event.args.names())) 64 65 66def generate_h_backend_dstate(event, group): 67 out(' QEMU_%(uppername)s_ENABLED() || \\', 68 uppername=event.name.upper()) 69