]> Git Repo - qemu.git/blame - scripts/tracetool/format/h.py
works with less than base ISA qemu-system-riscv32 -M virt -bios none -kernel output...
[qemu.git] / scripts / tracetool / format / h.py
CommitLineData
c419e62a
LV
1# -*- coding: utf-8 -*-
2
3"""
30b572ef 4trace/generated-tracers.h
c419e62a
LV
5"""
6
7__author__ = "Lluís Vilanova <[email protected]>"
864a2178 8__copyright__ = "Copyright 2012-2017, Lluís Vilanova <[email protected]>"
c419e62a
LV
9__license__ = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
f892b494 12__email__ = "[email protected]"
c419e62a
LV
13
14
15from tracetool import out
16
17
80dd5c49 18def generate(events, backend, group):
13d4ff07
MA
19 if group == "root":
20 header = "trace/control-vcpu.h"
21 else:
22 header = "trace/control.h"
23
c419e62a
LV
24 out('/* This file is autogenerated by tracetool, do not edit. */',
25 '',
80dd5c49
DB
26 '#ifndef TRACE_%s_GENERATED_TRACERS_H' % group.upper(),
27 '#define TRACE_%s_GENERATED_TRACERS_H' % group.upper(),
c419e62a 28 '',
13d4ff07 29 '#include "%s"' % header,
1dad2ce9 30 '')
c419e62a 31
34770187
DB
32 for e in events:
33 out('extern TraceEvent %(event)s;',
34 event = e.api(e.QEMU_EVENT))
35
36 for e in events:
37 out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE))
38
39 # static state
40 for e in events:
41 if 'disable' in e.properties:
42 enabled = 0
43 else:
44 enabled = 1
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(),
49 enabled=enabled)
50 out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
51
80dd5c49 52 backend.generate_begin(events, group)
c419e62a 53
c419e62a 54 for e in events:
3932ef3f
SH
55 # tracer-specific dstate
56 out('',
57 '#define %(api)s() ( \\',
58 api=e.api(e.QEMU_BACKEND_DSTATE))
59
60 if "disable" not in e.properties:
61 backend.generate_backend_dstate(e, group)
62
63 out(' false)')
64
864a2178
LV
65 # tracer without checks
66 out('',
67 'static inline void %(api)s(%(args)s)',
68 '{',
69 api=e.api(e.QEMU_TRACE_NOCHECK),
70 args=e.args)
71
72 if "disable" not in e.properties:
73 backend.generate(e, group)
74
75 out('}')
76
77 # tracer wrapper with checks (per-vCPU tracing)
40b9cd25
LV
78 if "vcpu" in e.properties:
79 trace_cpu = next(iter(e.args))[1]
80 cond = "trace_event_get_vcpu_state(%(cpu)s,"\
ef4c9fc8 81 " TRACE_%(id)s)"\
40b9cd25
LV
82 % dict(
83 cpu=trace_cpu,
84 id=e.name.upper())
85 else:
86 cond = "true"
87
c419e62a 88 out('',
7d08f0da 89 'static inline void %(api)s(%(args)s)',
c419e62a 90 '{',
40b9cd25 91 ' if (%(cond)s) {',
864a2178
LV
92 ' %(api_nocheck)s(%(names)s);',
93 ' }',
94 '}',
1dad2ce9 95 api=e.api(),
864a2178 96 api_nocheck=e.api(e.QEMU_TRACE_NOCHECK),
40b9cd25 97 args=e.args,
864a2178 98 names=", ".join(e.args.names()),
40b9cd25 99 cond=cond)
1dad2ce9 100
80dd5c49 101 backend.generate_end(events, group)
1dad2ce9 102
80dd5c49 103 out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper())
This page took 0.515675 seconds and 4 git commands to generate.