1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4""" 5LTTng User Space Tracing backend. 6""" 7 8__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" 9__copyright__ = "Copyright 2012, 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 19def c(events): 20 out('#include <ust/marker.h>', 21 '#undef mutex_lock', 22 '#undef mutex_unlock', 23 '#undef inline', 24 '#undef wmb', 25 '#include "trace.h"') 26 27 for e in events: 28 argnames = ", ".join(e.args.names()) 29 if len(e.args) > 0: 30 argnames = ', ' + argnames 31 32 out('DEFINE_TRACE(ust_%(name)s);', 33 '', 34 'static void ust_%(name)s_probe(%(args)s)', 35 '{', 36 ' trace_mark(ust, %(name)s, %(fmt)s%(argnames)s);', 37 '}', 38 name = e.name, 39 args = e.args, 40 fmt = e.fmt, 41 argnames = argnames, 42 ) 43 44 else: 45 out('DEFINE_TRACE(ust_%(name)s);', 46 '', 47 'static void ust_%(name)s_probe(%(args)s)', 48 '{', 49 ' trace_mark(ust, %(name)s, UST_MARKER_NOARGS);', 50 '}', 51 name = e.name, 52 args = e.args, 53 ) 54 55 # register probes 56 out('', 57 'static void __attribute__((constructor)) trace_init(void)', 58 '{') 59 60 for e in events: 61 out(' register_trace_ust_%(name)s(ust_%(name)s_probe);', 62 name = e.name, 63 ) 64 65 out('}') 66 67 68def h(events): 69 out('#include <ust/tracepoint.h>', 70 '#undef mutex_lock', 71 '#undef mutex_unlock', 72 '#undef inline', 73 '#undef wmb') 74 75 for e in events: 76 if len(e.args) > 0: 77 out('DECLARE_TRACE(ust_%(name)s, TP_PROTO(%(args)s), TP_ARGS(%(argnames)s));', 78 '#define trace_%(name)s trace_ust_%(name)s', 79 name = e.name, 80 args = e.args, 81 argnames = ", ".join(e.args.names()), 82 ) 83 84 else: 85 out('_DECLARE_TRACEPOINT_NOARGS(ust_%(name)s);', 86 '#define trace_%(name)s trace_ust_%(name)s', 87 name = e.name, 88 ) 89 90 out() 91