2013-03-05 14:47:32 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
2014-02-23 20:37:30 +01:00
|
|
|
trace/generated-events.c
|
2013-03-05 14:47:32 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
2016-07-11 12:53:24 +02:00
|
|
|
__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
|
2013-03-05 14:47:32 +01: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
|
|
|
|
|
|
|
|
|
2014-02-23 20:37:40 +01:00
|
|
|
def generate(events, backend):
|
2013-03-05 14:47:32 +01:00
|
|
|
out('/* This file is autogenerated by tracetool, do not edit. */',
|
|
|
|
'',
|
2016-02-08 19:53:31 +01:00
|
|
|
'#include "qemu/osdep.h"',
|
2013-03-05 14:47:32 +01:00
|
|
|
'#include "trace.h"',
|
|
|
|
'#include "trace/generated-events.h"',
|
|
|
|
'#include "trace/control.h"',
|
2014-02-23 20:37:40 +01:00
|
|
|
'')
|
2013-03-05 14:47:32 +01:00
|
|
|
|
2016-10-04 15:35:45 +02:00
|
|
|
for e in events:
|
|
|
|
out('uint16_t %s;' % e.api(e.QEMU_DSTATE))
|
|
|
|
|
2016-10-04 15:35:49 +02:00
|
|
|
next_id = 0
|
|
|
|
next_vcpu_id = 0
|
2013-03-05 14:47:32 +01:00
|
|
|
for e in events:
|
2016-10-04 15:35:49 +02:00
|
|
|
id = next_id
|
|
|
|
next_id += 1
|
2016-07-11 12:53:24 +02:00
|
|
|
if "vcpu" in e.properties:
|
2016-10-04 15:35:49 +02:00
|
|
|
vcpu_id = next_vcpu_id
|
|
|
|
next_vcpu_id += 1
|
2016-07-11 12:53:24 +02:00
|
|
|
else:
|
2016-10-04 15:35:49 +02:00
|
|
|
vcpu_id = "TRACE_VCPU_EVENT_NONE"
|
2016-10-04 15:35:48 +02:00
|
|
|
out('TraceEvent %(event)s = {',
|
|
|
|
' .id = %(id)s,',
|
|
|
|
' .vcpu_id = %(vcpu_id)s,',
|
|
|
|
' .name = \"%(name)s\",',
|
|
|
|
' .sstate = %(sstate)s,',
|
|
|
|
' .dstate = &%(dstate)s ',
|
|
|
|
'};',
|
|
|
|
event = e.api(e.QEMU_EVENT),
|
2016-10-04 15:35:49 +02:00
|
|
|
id = id,
|
2016-07-11 12:53:24 +02:00
|
|
|
vcpu_id = vcpu_id,
|
2013-03-05 14:47:32 +01:00
|
|
|
name = e.name,
|
2016-10-04 15:35:45 +02:00
|
|
|
sstate = "TRACE_%s_ENABLED" % e.name.upper(),
|
|
|
|
dstate = e.api(e.QEMU_DSTATE))
|
2013-03-05 14:47:32 +01:00
|
|
|
|
2016-10-04 15:35:49 +02:00
|
|
|
out('TraceEvent *trace_events[] = {')
|
2016-10-04 15:35:48 +02:00
|
|
|
|
|
|
|
for e in events:
|
|
|
|
out(' &%(event)s,', event = e.api(e.QEMU_EVENT))
|
|
|
|
|
2016-10-04 15:35:49 +02:00
|
|
|
out(' NULL,',
|
|
|
|
'};',
|
2014-02-23 20:37:40 +01:00
|
|
|
'')
|
2016-10-04 15:35:52 +02:00
|
|
|
|
|
|
|
out('static void trace_register_events(void)',
|
|
|
|
'{',
|
|
|
|
' trace_event_register_group(trace_events);',
|
|
|
|
'}',
|
|
|
|
'trace_init(trace_register_events)')
|