1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4""" 5trace/generated-tracers.h 6""" 7 8__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" 9__copyright__ = "Copyright 2012-2016, 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 generate(events, backend): 20 out('/* This file is autogenerated by tracetool, do not edit. */', 21 '', 22 '#ifndef TRACE__GENERATED_TRACERS_H', 23 '#define TRACE__GENERATED_TRACERS_H', 24 '', 25 '#include "qemu-common.h"', 26 '#include "trace/control.h"', 27 '') 28 29 backend.generate_begin(events) 30 31 for e in events: 32 if "vcpu" in e.properties: 33 trace_cpu = next(iter(e.args))[1] 34 cond = "trace_event_get_vcpu_state(%(cpu)s,"\ 35 " TRACE_%(id)s)"\ 36 % dict( 37 cpu=trace_cpu, 38 id=e.name.upper()) 39 else: 40 cond = "true" 41 42 out('', 43 'static inline void %(api)s(%(args)s)', 44 '{', 45 ' if (%(cond)s) {', 46 api=e.api(), 47 args=e.args, 48 cond=cond) 49 50 if "disable" not in e.properties: 51 backend.generate(e) 52 53 out(' }', 54 '}') 55 56 backend.generate_end(events) 57 58 out('#endif /* TRACE__GENERATED_TRACERS_H */') 59