1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4""" 5trace/generated-ust-provider.h 6""" 7 8__author__ = "Mohamad Gebai <mohamad.gebai@polymtl.ca>" 9__copyright__ = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>" 10__license__ = "GPL version 2 or (at your option) any later version" 11 12__maintainer__ = "Stefan Hajnoczi" 13__email__ = "stefanha@redhat.com" 14 15 16from tracetool import out 17 18 19def generate(events, backend): 20 events = [e for e in events 21 if "disabled" not in e.properties] 22 23 out('/* This file is autogenerated by tracetool, do not edit. */', 24 '', 25 '#undef TRACEPOINT_PROVIDER', 26 '#define TRACEPOINT_PROVIDER qemu', 27 '', 28 '#undef TRACEPOINT_INCLUDE_FILE', 29 '#define TRACEPOINT_INCLUDE_FILE ./generated-ust-provider.h', 30 '', 31 '#if !defined (TRACE__GENERATED_UST_H) || defined(TRACEPOINT_HEADER_MULTI_READ)', 32 '#define TRACE__GENERATED_UST_H', 33 '', 34 '#include "qemu-common.h"', 35 '#include <lttng/tracepoint.h>', 36 '', 37 '/*', 38 ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints', 39 ' * requiring no arguments. We define these macros introduced in more recent' 40 ' * versions of LTTng ust as a workaround', 41 ' */', 42 '#ifndef _TP_EXPROTO1', 43 '#define _TP_EXPROTO1(a) void', 44 '#endif', 45 '#ifndef _TP_EXDATA_PROTO1', 46 '#define _TP_EXDATA_PROTO1(a) void *__tp_data', 47 '#endif', 48 '#ifndef _TP_EXDATA_VAR1', 49 '#define _TP_EXDATA_VAR1(a) __tp_data', 50 '#endif', 51 '#ifndef _TP_EXVAR1', 52 '#define _TP_EXVAR1(a)', 53 '#endif', 54 '') 55 56 for e in events: 57 if len(e.args) > 0: 58 out('TRACEPOINT_EVENT(', 59 ' qemu,', 60 ' %(name)s,', 61 ' TP_ARGS(%(args)s),', 62 ' TP_FIELDS(', 63 name=e.name, 64 args=", ".join(", ".join(i) for i in e.args)) 65 66 for t, n in e.args: 67 if ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t): 68 out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')') 69 elif ('double' in t) or ('float' in t): 70 out(' ctf_float(' + t + ', ' + n + ', ' + n + ')') 71 elif ('char *' in t) or ('char*' in t): 72 out(' ctf_string(' + n + ', ' + n + ')') 73 elif ('void *' in t) or ('void*' in t): 74 out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')') 75 76 out(' )', 77 ')', 78 '') 79 80 else: 81 out('TRACEPOINT_EVENT(', 82 ' qemu,', 83 ' %(name)s,', 84 ' TP_ARGS(void),', 85 ' TP_FIELDS()', 86 ')', 87 '', 88 name=e.name) 89 90 out('#endif /* TRACE__GENERATED_UST_H */', 91 '', 92 '/* This part must be outside ifdef protection */', 93 '#include <lttng/tracepoint-event.h>') 94