1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4""" 5Simple built-in 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 "trace.h"', 21 '', 22 'TraceEvent trace_list[] = {') 23 24 for e in events: 25 out('{.tp_name = "%(name)s", .state=0},', 26 name = e.name, 27 ) 28 29 out('};') 30 31def h(events): 32 out('#include "trace/simple.h"', 33 '') 34 35 for num, e in enumerate(events): 36 if len(e.args): 37 argstr = e.args.names() 38 arg_prefix = ', (uint64_t)(uintptr_t)' 39 cast_args = arg_prefix + arg_prefix.join(argstr) 40 simple_args = (str(num) + cast_args) 41 else: 42 simple_args = str(num) 43 44 out('static inline void trace_%(name)s(%(args)s)', 45 '{', 46 ' trace%(argc)d(%(trace_args)s);', 47 '}', 48 name = e.name, 49 args = e.args, 50 argc = len(e.args), 51 trace_args = simple_args, 52 ) 53 54 out('#define NR_TRACE_EVENTS %d' % len(events)) 55 out('extern TraceEvent trace_list[NR_TRACE_EVENTS];') 56