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
):
19 header
= "trace/control.h"
21 out('/* This file is autogenerated by tracetool, do not edit. */',
23 '#ifndef TRACE_%s_GENERATED_TRACERS_H' % group
.upper(),
24 '#define TRACE_%s_GENERATED_TRACERS_H' % group
.upper(),
26 '#include "%s"' % header
,
30 out('extern TraceEvent %(event)s;',
31 event
= e
.api(e
.QEMU_EVENT
))
34 out('extern uint16_t %s;' % e
.api(e
.QEMU_DSTATE
))
38 if 'disable' in e
.properties
:
42 if "tcg-exec" in e
.properties
:
43 # a single define for the two "sub-events"
44 out('#define TRACE_%(name)s_ENABLED %(enabled)d',
45 name
=e
.original
.name
.upper(),
47 out('#define TRACE_%s_ENABLED %d' % (e
.name
.upper(), enabled
))
49 backend
.generate_begin(events
, group
)
52 # tracer-specific dstate
54 '#define %(api)s() ( \\',
55 api
=e
.api(e
.QEMU_BACKEND_DSTATE
))
57 if "disable" not in e
.properties
:
58 backend
.generate_backend_dstate(e
, group
)
62 # tracer without checks
64 'static inline void %(api)s(%(args)s)',
66 api
=e
.api(e
.QEMU_TRACE_NOCHECK
),
69 if "disable" not in e
.properties
:
70 backend
.generate(e
, group
)
77 'static inline void %(api)s(%(args)s)',
80 ' %(api_nocheck)s(%(names)s);',
84 api_nocheck
=e
.api(e
.QEMU_TRACE_NOCHECK
),
86 names
=", ".join(e
.args
.names()),
89 backend
.generate_end(events
, group
)
91 out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group
.upper())