tracetool: Add support for the 'simple' backend
[qemu.git] / scripts / tracetool / backend / simple.py
blobfbb5717c6642af9ed5d5363e4e73c834818c475b
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 Simple built-in backend.
6 """
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012, 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 c(events):
20 out('#include "trace.h"',
21 '',
22 'TraceEvent trace_list[] = {')
24 for e in events:
25 out('{.tp_name = "%(name)s", .state=0},',
26 name = e.name,
29 out('};')
31 def h(events):
32 out('#include "trace/simple.h"',
33 '')
35 for num, e in enumerate(events):
36 if len(e.args):
37 argstr = e.args.names()
38 arg_prefix = ', (uint64_t)(uintptr_t)'
39 cast_args = arg_prefix + arg_prefix.join(argstr)
40 simple_args = (str(num) + cast_args)
41 else:
42 simple_args = str(num)
44 out('static inline void trace_%(name)s(%(args)s)',
45 '{',
46 ' trace%(argc)d(%(trace_args)s);',
47 '}',
48 name = e.name,
49 args = e.args,
50 argc = len(e.args),
51 trace_args = simple_args,
54 out('#define NR_TRACE_EVENTS %d' % len(events))
55 out('extern TraceEvent trace_list[NR_TRACE_EVENTS];')