1 # -*- coding: utf-8 -*-
4 trace/generated-tracers.h
7 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__
= "Copyright 2012-2017, 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
):
20 header
= "trace/control-vcpu.h"
22 header
= "trace/control.h"
24 out('/* This file is autogenerated by tracetool, do not edit. */',
26 '#ifndef TRACE_%s_GENERATED_TRACERS_H' % group
.upper(),
27 '#define TRACE_%s_GENERATED_TRACERS_H' % group
.upper(),
29 '#include "%s"' % header
,
33 out('extern TraceEvent %(event)s;',
34 event
= e
.api(e
.QEMU_EVENT
))
37 out('extern uint16_t %s;' % e
.api(e
.QEMU_DSTATE
))
41 if 'disable' in e
.properties
:
45 if "tcg-exec" in e
.properties
:
46 # a single define for the two "sub-events"
47 out('#define TRACE_%(name)s_ENABLED %(enabled)d',
48 name
=e
.original
.name
.upper(),
50 out('#define TRACE_%s_ENABLED %d' % (e
.name
.upper(), enabled
))
52 backend
.generate_begin(events
, group
)
55 # tracer-specific dstate
57 '#define %(api)s() ( \\',
58 api
=e
.api(e
.QEMU_BACKEND_DSTATE
))
60 if "disable" not in e
.properties
:
61 backend
.generate_backend_dstate(e
, group
)
65 # tracer without checks
67 'static inline void %(api)s(%(args)s)',
69 api
=e
.api(e
.QEMU_TRACE_NOCHECK
),
72 if "disable" not in e
.properties
:
73 backend
.generate(e
, group
)
77 # tracer wrapper with checks (per-vCPU tracing)
78 if "vcpu" in e
.properties
:
79 trace_cpu
= next(iter(e
.args
))[1]
80 cond
= "trace_event_get_vcpu_state(%(cpu)s,"\
89 'static inline void %(api)s(%(args)s)',
92 ' %(api_nocheck)s(%(names)s);',
96 api_nocheck
=e
.api(e
.QEMU_TRACE_NOCHECK
),
98 names
=", ".join(e
.args
.names()),
101 backend
.generate_end(events
, group
)
103 out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group
.upper())