15de7f9c8SLluís Vilanova# -*- coding: utf-8 -*- 25de7f9c8SLluís Vilanova 35de7f9c8SLluís Vilanova""" 430b572efSLluís Vilanovatrace/generated-tracers.c 55de7f9c8SLluís Vilanova""" 65de7f9c8SLluís Vilanova 75de7f9c8SLluís Vilanova__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" 830b572efSLluís Vilanova__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>" 95de7f9c8SLluís Vilanova__license__ = "GPL version 2 or (at your option) any later version" 105de7f9c8SLluís Vilanova 115de7f9c8SLluís Vilanova__maintainer__ = "Stefan Hajnoczi" 12f892b494SPhilippe Mathieu-Daudé__email__ = "stefanha@redhat.com" 135de7f9c8SLluís Vilanova 145de7f9c8SLluís Vilanova 155de7f9c8SLluís Vilanovafrom tracetool import out 165de7f9c8SLluís Vilanova 175de7f9c8SLluís Vilanova 1880dd5c49SDaniel P. Berrangedef generate(events, backend, group): 1934770187SDaniel P. Berrange active_events = [e for e in events 201dad2ce9SLluís Vilanova if "disable" not in e.properties] 211dad2ce9SLluís Vilanova 22*243af022SPaolo Bonzini header = "trace-" + group + ".h" 230ab8ed18SDaniel P. Berrange 241dad2ce9SLluís Vilanova out('/* This file is autogenerated by tracetool, do not edit. */', 2534770187SDaniel P. Berrange '', 2634770187SDaniel P. Berrange '#include "qemu/osdep.h"', 2713d4ff07SMarkus Armbruster '#include "qemu/module.h"', 280ab8ed18SDaniel P. Berrange '#include "%s"' % header, 291dad2ce9SLluís Vilanova '') 3034770187SDaniel P. Berrange 3134770187SDaniel P. Berrange for e in events: 3234770187SDaniel P. Berrange out('uint16_t %s;' % e.api(e.QEMU_DSTATE)) 3334770187SDaniel P. Berrange 3434770187SDaniel P. Berrange for e in events: 3534770187SDaniel P. Berrange out('TraceEvent %(event)s = {', 3634770187SDaniel P. Berrange ' .id = 0,', 3734770187SDaniel P. Berrange ' .name = \"%(name)s\",', 3834770187SDaniel P. Berrange ' .sstate = %(sstate)s,', 3934770187SDaniel P. Berrange ' .dstate = &%(dstate)s ', 4034770187SDaniel P. Berrange '};', 4134770187SDaniel P. Berrange event = e.api(e.QEMU_EVENT), 4234770187SDaniel P. Berrange name = e.name, 4334770187SDaniel P. Berrange sstate = "TRACE_%s_ENABLED" % e.name.upper(), 4434770187SDaniel P. Berrange dstate = e.api(e.QEMU_DSTATE)) 4534770187SDaniel P. Berrange 4680dd5c49SDaniel P. Berrange out('TraceEvent *%(group)s_trace_events[] = {', 4780dd5c49SDaniel P. Berrange group = group.lower()) 4834770187SDaniel P. Berrange 4934770187SDaniel P. Berrange for e in events: 5034770187SDaniel P. Berrange out(' &%(event)s,', event = e.api(e.QEMU_EVENT)) 5134770187SDaniel P. Berrange 5234770187SDaniel P. Berrange out(' NULL,', 5334770187SDaniel P. Berrange '};', 5434770187SDaniel P. Berrange '') 5534770187SDaniel P. Berrange 5680dd5c49SDaniel P. Berrange out('static void trace_%(group)s_register_events(void)', 5734770187SDaniel P. Berrange '{', 5880dd5c49SDaniel P. Berrange ' trace_event_register_group(%(group)s_trace_events);', 5934770187SDaniel P. Berrange '}', 6080dd5c49SDaniel P. Berrange 'trace_init(trace_%(group)s_register_events)', 6180dd5c49SDaniel P. Berrange group = group.lower()) 6234770187SDaniel P. Berrange 6380dd5c49SDaniel P. Berrange backend.generate_begin(active_events, group) 6434770187SDaniel P. Berrange for event in active_events: 6580dd5c49SDaniel P. Berrange backend.generate(event, group) 6680dd5c49SDaniel P. Berrange backend.generate_end(active_events, group) 67