1 # -*- coding: utf-8 -*-
4 Generate .h file for TCG code generation.
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
, Arguments
19 def vcpu_transform_args(args
):
23 # NOTE: this name must be kept in sync with the one in "tcg_h"
24 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
25 ("TCGv_env", "__tcg_" + args
.names()[0]),
29 def generate(events
, backend
, group
):
31 header
= "trace-root.h"
35 out('/* This file is autogenerated by tracetool, do not edit. */',
36 '/* You must include this file after the inclusion of helper.h */',
38 '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group
.upper(),
39 '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group
.upper(),
41 '#include "exec/helper-proto.h"',
42 '#include "%s"' % header
,
47 # just keep one of them
48 if "tcg-exec" not in e
.properties
:
51 out('static inline void %(name_tcg)s(%(args)s)',
53 name_tcg
=e
.original
.api(e
.QEMU_TRACE_TCG
),
54 args
=tracetool
.vcpu
.transform_args("tcg_h", e
.original
))
56 if "disable" not in e
.properties
:
57 args_trans
= e
.original
.event_trans
.args
58 args_exec
= tracetool
.vcpu
.transform_args(
59 "tcg_helper_c", e
.original
.event_exec
, "wrapper")
60 if "vcpu" in e
.properties
:
61 trace_cpu
= e
.args
.names()[0]
62 cond
= "trace_event_get_vcpu_state(%(cpu)s,"\
66 id=e
.original
.event_exec
.name
.upper())
70 out(' %(name_trans)s(%(argnames_trans)s);',
72 ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
74 name_trans
=e
.original
.event_trans
.api(e
.QEMU_TRACE
),
75 name_exec
=e
.original
.event_exec
.api(e
.QEMU_TRACE
),
76 argnames_trans
=", ".join(args_trans
.names()),
77 argnames_exec
=", ".join(args_exec
.names()),
83 '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group
.upper())