1 # -*- coding: utf-8 -*-
4 Generate trace/generated-helpers.c.
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 Arguments
, out
16 from tracetool
.transform
import *
20 def vcpu_transform_args(args
, mode
):
22 # NOTE: this name must be kept in sync with the one in "tcg_h"
23 args
= Arguments([(args
.types()[0], "__tcg_" + args
.names()[0])])
26 # Does cast from helper requirements to tracing types
27 ("CPUState *", "env_cpu(%s)" % args
.names()[0]),
31 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
32 ("CPUArchState *", args
.names()[0]),
36 elif mode
== "wrapper":
37 return args
.transform(HOST_2_TCG
)
42 def generate(events
, backend
, group
):
44 header
= "trace/trace-root.h"
48 events
= [e
for e
in events
49 if "disable" not in e
.properties
]
51 out('/* This file is autogenerated by tracetool, do not edit. */',
53 '#include "qemu/osdep.h"',
55 '#include "exec/helper-proto.h"',
56 '#include "%s"' % header
,
61 if "tcg-exec" not in e
.properties
:
64 e_args_api
= tracetool
.vcpu
.transform_args(
65 "tcg_helper_c", e
.original
, "header").transform(
66 HOST_2_TCG_COMPAT
, TCG_2_TCG_HELPER_DEF
)
67 e_args_call
= tracetool
.vcpu
.transform_args(
68 "tcg_helper_c", e
, "code")
70 out('void %(name_tcg)s(%(args_api)s)',
72 # NOTE: the check was already performed at TCG-generation time
73 ' %(name)s(%(args_call)s);',
75 name_tcg
="helper_%s_proxy" % e
.api(),
76 name
=e
.api(e
.QEMU_TRACE_NOCHECK
),
78 args_call
=", ".join(e_args_call
.casted()),