]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/tracetool/format/tcg_helper_c.py
iotests/281: Let NBD connection yield in iothread
[mirror_qemu.git] / scripts / tracetool / format / tcg_helper_c.py
1 # -*- coding: utf-8 -*-
2
3 """
4 Generate trace/generated-helpers.c.
5 """
6
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"
10
11 __maintainer__ = "Stefan Hajnoczi"
12 __email__ = "stefanha@redhat.com"
13
14
15 from tracetool import Arguments, out
16 from tracetool.transform import *
17 import tracetool.vcpu
18
19
20 def vcpu_transform_args(args, mode):
21 assert len(args) == 1
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])])
24 if mode == "code":
25 return Arguments([
26 # Does cast from helper requirements to tracing types
27 ("CPUState *", "env_cpu(%s)" % args.names()[0]),
28 ])
29 else:
30 args = Arguments([
31 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
32 ("CPUArchState *", args.names()[0]),
33 ])
34 if mode == "header":
35 return args
36 elif mode == "wrapper":
37 return args.transform(HOST_2_TCG)
38 else:
39 assert False
40
41
42 def generate(events, backend, group):
43 if group == "root":
44 header = "trace/trace-root.h"
45 else:
46 header = "trace.h"
47
48 events = [e for e in events
49 if "disable" not in e.properties]
50
51 out('/* This file is autogenerated by tracetool, do not edit. */',
52 '',
53 '#include "qemu/osdep.h"',
54 '#include "cpu.h"',
55 '#include "exec/helper-proto.h"',
56 '#include "%s"' % header,
57 '',
58 )
59
60 for e in events:
61 if "tcg-exec" not in e.properties:
62 continue
63
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")
69
70 out('void %(name_tcg)s(%(args_api)s)',
71 '{',
72 # NOTE: the check was already performed at TCG-generation time
73 ' %(name)s(%(args_call)s);',
74 '}',
75 name_tcg="helper_%s_proxy" % e.api(),
76 name=e.api(e.QEMU_TRACE_NOCHECK),
77 args_api=e_args_api,
78 args_call=", ".join(e_args_call.casted()),
79 )