timer.h: fix typo
[qemu/ar7.git] / scripts / tracetool / format / h.py
blob3763e9aecbc323ea7f1413e9f84c4d5b5d82d327
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 trace/generated-tracers.h
6 """
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"
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@linux.vnet.ibm.com"
16 from tracetool import out
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 '')
29 backend.generate_begin(events)
31 for e in events:
32 if "vcpu" in e.properties:
33 trace_cpu = next(iter(e.args))[1]
34 cond = "trace_event_get_vcpu_state(%(cpu)s,"\
35 " TRACE_%(id)s,"\
36 " TRACE_VCPU_%(id)s)"\
37 % dict(
38 cpu=trace_cpu,
39 id=e.name.upper())
40 else:
41 cond = "true"
43 out('',
44 'static inline void %(api)s(%(args)s)',
45 '{',
46 ' if (%(cond)s) {',
47 api=e.api(),
48 args=e.args,
49 cond=cond)
51 if "disable" not in e.properties:
52 backend.generate(e)
54 out(' }',
55 '}')
57 backend.generate_end(events)
59 out('#endif /* TRACE__GENERATED_TRACERS_H */')