]> Git Repo - qemu.git/blob - scripts/tracetool/backend/stderr.py
917fde7c155fe4c56abf3dc228cc8a6ecbf02ca5
[qemu.git] / scripts / tracetool / backend / stderr.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Stderr built-in backend.
6 """
7
8 __author__     = "Lluís Vilanova <[email protected]>"
9 __copyright__  = "Copyright 2012, Lluís Vilanova <[email protected]>"
10 __license__    = "GPL version 2 or (at your option) any later version"
11
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__      = "[email protected]"
14
15
16 from tracetool import out
17
18
19 def c(events):
20     out('#include "trace.h"',
21         '',
22         'TraceEvent trace_list[] = {')
23
24     for e in events:
25         out('{.tp_name = "%(name)s", .state=0},',
26             name = e.name,
27             )
28
29     out('};')
30
31 def h(events):
32     out('#include <stdio.h>',
33         '#include "trace/stderr.h"',
34         '',
35         'extern TraceEvent trace_list[];')
36
37     for num, e in enumerate(events):
38         argnames = ", ".join(e.args.names())
39         if len(e.args) > 0:
40             argnames = ", " + argnames
41
42         out('static inline void trace_%(name)s(%(args)s)',
43             '{',
44             '    if (trace_list[%(event_num)s].state != 0) {',
45             '        fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
46             '    }',
47             '}',
48             name = e.name,
49             args = e.args,
50             event_num = num,
51             fmt = e.fmt,
52             argnames = argnames,
53             )
54
55     out('',
56         '#define NR_TRACE_EVENTS %d' % len(events))
This page took 0.017824 seconds and 2 git commands to generate.