2012-04-03 20:47:44 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
2014-02-23 20:37:30 +01:00
|
|
|
trace/generated-tracers.c
|
2012-04-03 20:47:44 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
2014-02-23 20:37:30 +01:00
|
|
|
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
|
2012-04-03 20:47:44 +02:00
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
2020-05-11 10:28:16 +02:00
|
|
|
__email__ = "stefanha@redhat.com"
|
2012-04-03 20:47:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
2016-10-04 15:35:59 +02:00
|
|
|
def generate(events, backend, group):
|
2016-10-04 15:35:55 +02:00
|
|
|
active_events = [e for e in events
|
|
|
|
if "disable" not in e.properties]
|
2014-02-23 20:37:40 +01:00
|
|
|
|
2020-02-04 12:20:10 +01:00
|
|
|
header = "trace-" + group + ".h"
|
2017-01-25 17:14:15 +01:00
|
|
|
|
2014-02-23 20:37:40 +01:00
|
|
|
out('/* This file is autogenerated by tracetool, do not edit. */',
|
2016-10-04 15:35:55 +02:00
|
|
|
'',
|
|
|
|
'#include "qemu/osdep.h"',
|
2019-08-12 07:23:37 +02:00
|
|
|
'#include "qemu/module.h"',
|
2017-01-25 17:14:15 +01:00
|
|
|
'#include "%s"' % header,
|
2014-02-23 20:37:40 +01:00
|
|
|
'')
|
2016-10-04 15:35:55 +02: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 15:35:59 +02:00
|
|
|
out('TraceEvent *%(group)s_trace_events[] = {',
|
|
|
|
group = group.lower())
|
2016-10-04 15:35:55 +02:00
|
|
|
|
|
|
|
for e in events:
|
|
|
|
out(' &%(event)s,', event = e.api(e.QEMU_EVENT))
|
|
|
|
|
|
|
|
out(' NULL,',
|
|
|
|
'};',
|
|
|
|
'')
|
|
|
|
|
2016-10-04 15:35:59 +02:00
|
|
|
out('static void trace_%(group)s_register_events(void)',
|
2016-10-04 15:35:55 +02:00
|
|
|
'{',
|
2016-10-04 15:35:59 +02:00
|
|
|
' trace_event_register_group(%(group)s_trace_events);',
|
2016-10-04 15:35:55 +02:00
|
|
|
'}',
|
2016-10-04 15:35:59 +02:00
|
|
|
'trace_init(trace_%(group)s_register_events)',
|
|
|
|
group = group.lower())
|
2016-10-04 15:35:55 +02:00
|
|
|
|
2016-10-04 15:35:59 +02:00
|
|
|
backend.generate_begin(active_events, group)
|
2016-10-04 15:35:55 +02:00
|
|
|
for event in active_events:
|
2016-10-04 15:35:59 +02:00
|
|
|
backend.generate(event, group)
|
|
|
|
backend.generate_end(active_events, group)
|