]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/tracetool/format/h.py
trace: get rid of generated-events.h/generated-events.c
[mirror_qemu.git] / scripts / tracetool / format / h.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 trace/generated-tracers.h
6 """
7
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
10 __license__ = "GPL version 2 or (at your option) any later version"
11
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@linux.vnet.ibm.com"
14
15
16 from tracetool import out
17
18
19 def generate(events, backend):
20 out('/* This file is autogenerated by tracetool, do not edit. */',
21 '',
22 '#ifndef TRACE__GENERATED_TRACERS_H',
23 '#define TRACE__GENERATED_TRACERS_H',
24 '',
25 '#include "qemu-common.h"',
26 '#include "trace/control.h"',
27 '')
28
29 for e in events:
30 out('extern TraceEvent %(event)s;',
31 event = e.api(e.QEMU_EVENT))
32
33 for e in events:
34 out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE))
35
36 # static state
37 for e in events:
38 if 'disable' in e.properties:
39 enabled = 0
40 else:
41 enabled = 1
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(),
46 enabled=enabled)
47 out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
48
49 backend.generate_begin(events)
50
51 for e in events:
52 if "vcpu" in e.properties:
53 trace_cpu = next(iter(e.args))[1]
54 cond = "trace_event_get_vcpu_state(%(cpu)s,"\
55 " TRACE_%(id)s)"\
56 % dict(
57 cpu=trace_cpu,
58 id=e.name.upper())
59 else:
60 cond = "true"
61
62 out('',
63 'static inline void %(api)s(%(args)s)',
64 '{',
65 ' if (%(cond)s) {',
66 api=e.api(),
67 args=e.args,
68 cond=cond)
69
70 if "disable" not in e.properties:
71 backend.generate(e)
72
73 out(' }',
74 '}')
75
76 backend.generate_end(events)
77
78 out('#endif /* TRACE__GENERATED_TRACERS_H */')