15de7f9c8SLluís Vilanova#!/usr/bin/env python 25de7f9c8SLluís Vilanova# -*- coding: utf-8 -*- 35de7f9c8SLluís Vilanova 45de7f9c8SLluís Vilanova""" 530b572efSLluís Vilanovatrace/generated-tracers.c 65de7f9c8SLluís Vilanova""" 75de7f9c8SLluís Vilanova 85de7f9c8SLluís Vilanova__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" 930b572efSLluís Vilanova__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>" 105de7f9c8SLluís Vilanova__license__ = "GPL version 2 or (at your option) any later version" 115de7f9c8SLluís Vilanova 125de7f9c8SLluís Vilanova__maintainer__ = "Stefan Hajnoczi" 135de7f9c8SLluís Vilanova__email__ = "stefanha@linux.vnet.ibm.com" 145de7f9c8SLluís Vilanova 155de7f9c8SLluís Vilanova 165de7f9c8SLluís Vilanovafrom tracetool import out 175de7f9c8SLluís Vilanova 185de7f9c8SLluís Vilanova 191dad2ce9SLluís Vilanovadef generate(events, backend): 20*34770187SDaniel P. Berrange active_events = [e for e in events 211dad2ce9SLluís Vilanova if "disable" not in e.properties] 221dad2ce9SLluís Vilanova 231dad2ce9SLluís Vilanova out('/* This file is autogenerated by tracetool, do not edit. */', 24*34770187SDaniel P. Berrange '', 25*34770187SDaniel P. Berrange '#include "qemu/osdep.h"', 26*34770187SDaniel P. Berrange '#include "trace.h"', 271dad2ce9SLluís Vilanova '') 28*34770187SDaniel P. Berrange 29*34770187SDaniel P. Berrange for e in events: 30*34770187SDaniel P. Berrange out('uint16_t %s;' % e.api(e.QEMU_DSTATE)) 31*34770187SDaniel P. Berrange 32*34770187SDaniel P. Berrange for e in events: 33*34770187SDaniel P. Berrange if "vcpu" in e.properties: 34*34770187SDaniel P. Berrange vcpu_id = 0 35*34770187SDaniel P. Berrange else: 36*34770187SDaniel P. Berrange vcpu_id = "TRACE_VCPU_EVENT_NONE" 37*34770187SDaniel P. Berrange out('TraceEvent %(event)s = {', 38*34770187SDaniel P. Berrange ' .id = 0,', 39*34770187SDaniel P. Berrange ' .vcpu_id = %(vcpu_id)s,', 40*34770187SDaniel P. Berrange ' .name = \"%(name)s\",', 41*34770187SDaniel P. Berrange ' .sstate = %(sstate)s,', 42*34770187SDaniel P. Berrange ' .dstate = &%(dstate)s ', 43*34770187SDaniel P. Berrange '};', 44*34770187SDaniel P. Berrange event = e.api(e.QEMU_EVENT), 45*34770187SDaniel P. Berrange vcpu_id = vcpu_id, 46*34770187SDaniel P. Berrange name = e.name, 47*34770187SDaniel P. Berrange sstate = "TRACE_%s_ENABLED" % e.name.upper(), 48*34770187SDaniel P. Berrange dstate = e.api(e.QEMU_DSTATE)) 49*34770187SDaniel P. Berrange 50*34770187SDaniel P. Berrange out('TraceEvent *trace_events[] = {') 51*34770187SDaniel P. Berrange 52*34770187SDaniel P. Berrange for e in events: 53*34770187SDaniel P. Berrange out(' &%(event)s,', event = e.api(e.QEMU_EVENT)) 54*34770187SDaniel P. Berrange 55*34770187SDaniel P. Berrange out(' NULL,', 56*34770187SDaniel P. Berrange '};', 57*34770187SDaniel P. Berrange '') 58*34770187SDaniel P. Berrange 59*34770187SDaniel P. Berrange out('static void trace_register_events(void)', 60*34770187SDaniel P. Berrange '{', 61*34770187SDaniel P. Berrange ' trace_event_register_group(trace_events);', 62*34770187SDaniel P. Berrange '}', 63*34770187SDaniel P. Berrange 'trace_init(trace_register_events)') 64*34770187SDaniel P. Berrange 65*34770187SDaniel P. Berrange backend.generate_begin(active_events) 66*34770187SDaniel P. Berrange for event in active_events: 671dad2ce9SLluís Vilanova backend.generate(event) 68*34770187SDaniel P. Berrange backend.generate_end(active_events) 69