2012-04-03 22:47:44 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
2014-02-23 23:37:30 +04:00
|
|
|
trace/generated-tracers.c
|
2012-04-03 22:47:44 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
2014-02-23 23:37:30 +04:00
|
|
|
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
|
2012-04-03 22:47:44 +04:00
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
|
|
|
__email__ = "stefanha@linux.vnet.ibm.com"
|
|
|
|
|
|
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
def generate(events, backend, group):
|
2016-10-04 16:35:55 +03:00
|
|
|
active_events = [e for e in events
|
|
|
|
if "disable" not in e.properties]
|
2014-02-23 23:37:40 +04:00
|
|
|
|
2017-01-25 19:14:15 +03:00
|
|
|
if group == "root":
|
|
|
|
header = "trace-root.h"
|
|
|
|
else:
|
|
|
|
header = "trace.h"
|
|
|
|
|
2014-02-23 23:37:40 +04:00
|
|
|
out('/* This file is autogenerated by tracetool, do not edit. */',
|
2016-10-04 16:35:55 +03:00
|
|
|
'',
|
|
|
|
'#include "qemu/osdep.h"',
|
2017-01-25 19:14:15 +03:00
|
|
|
'#include "%s"' % header,
|
2014-02-23 23:37:40 +04:00
|
|
|
'')
|
2016-10-04 16:35:55 +03:00
|
|
|
|
|
|
|
for e in events:
|
|
|
|
out('uint16_t %s;' % e.api(e.QEMU_DSTATE))
|
|
|
|
|
|
|
|
for e in events:
|
|
|
|
if "vcpu" in e.properties:
|
|
|
|
vcpu_id = 0
|
|
|
|
else:
|
|
|
|
vcpu_id = "TRACE_VCPU_EVENT_NONE"
|
|
|
|
out('TraceEvent %(event)s = {',
|
|
|
|
' .id = 0,',
|
|
|
|
' .vcpu_id = %(vcpu_id)s,',
|
|
|
|
' .name = \"%(name)s\",',
|
|
|
|
' .sstate = %(sstate)s,',
|
|
|
|
' .dstate = &%(dstate)s ',
|
|
|
|
'};',
|
|
|
|
event = e.api(e.QEMU_EVENT),
|
|
|
|
vcpu_id = vcpu_id,
|
|
|
|
name = e.name,
|
|
|
|
sstate = "TRACE_%s_ENABLED" % e.name.upper(),
|
|
|
|
dstate = e.api(e.QEMU_DSTATE))
|
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
out('TraceEvent *%(group)s_trace_events[] = {',
|
|
|
|
group = group.lower())
|
2016-10-04 16:35:55 +03:00
|
|
|
|
|
|
|
for e in events:
|
|
|
|
out(' &%(event)s,', event = e.api(e.QEMU_EVENT))
|
|
|
|
|
|
|
|
out(' NULL,',
|
|
|
|
'};',
|
|
|
|
'')
|
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
out('static void trace_%(group)s_register_events(void)',
|
2016-10-04 16:35:55 +03:00
|
|
|
'{',
|
2016-10-04 16:35:59 +03:00
|
|
|
' trace_event_register_group(%(group)s_trace_events);',
|
2016-10-04 16:35:55 +03:00
|
|
|
'}',
|
2016-10-04 16:35:59 +03:00
|
|
|
'trace_init(trace_%(group)s_register_events)',
|
|
|
|
group = group.lower())
|
2016-10-04 16:35:55 +03:00
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
backend.generate_begin(active_events, group)
|
2016-10-04 16:35:55 +03:00
|
|
|
for event in active_events:
|
2016-10-04 16:35:59 +03:00
|
|
|
backend.generate(event, group)
|
|
|
|
backend.generate_end(active_events, group)
|