1 # -*- coding: utf-8 -*-
4 trace/generated-tracers.c
7 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__
= "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
9 __license__
= "GPL version 2 or (at your option) any later version"
11 __maintainer__
= "Stefan Hajnoczi"
12 __email__
= "stefanha@redhat.com"
15 from tracetool
import out
18 def generate(events
, backend
, group
):
19 active_events
= [e
for e
in events
20 if "disable" not in e
.properties
]
22 header
= "trace-" + group
+ ".h"
24 out('/* This file is autogenerated by tracetool, do not edit. */',
26 '#include "qemu/osdep.h"',
27 '#include "qemu/module.h"',
28 '#include "%s"' % header
,
32 out('uint16_t %s;' % e
.api(e
.QEMU_DSTATE
))
35 out('TraceEvent %(event)s = {',
37 ' .name = \"%(name)s\",',
38 ' .sstate = %(sstate)s,',
39 ' .dstate = &%(dstate)s ',
41 event
= e
.api(e
.QEMU_EVENT
),
43 sstate
= "TRACE_%s_ENABLED" % e
.name
.upper(),
44 dstate
= e
.api(e
.QEMU_DSTATE
))
46 out('TraceEvent *%(group)s_trace_events[] = {',
47 group
= group
.lower())
50 out(' &%(event)s,', event
= e
.api(e
.QEMU_EVENT
))
56 out('static void trace_%(group)s_register_events(void)',
58 ' trace_event_register_group(%(group)s_trace_events);',
60 'trace_init(trace_%(group)s_register_events)',
61 group
= group
.lower())
63 backend
.generate_begin(active_events
, group
)
64 for event
in active_events
:
65 backend
.generate(event
, group
)
66 backend
.generate_end(active_events
, group
)