ui: split setup of VNC auth scheme into separate method
[qemu.git] / scripts / tracetool / backend / stderr.py
blobca580546214f5f1499845f139317c966056402d0
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 Stderr built-in backend.
6 """
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012-2014, 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 PUBLIC = True
22 def generate_h_begin(events):
23 out('#include <stdio.h>',
24 '#include <sys/time.h>',
25 '#include <sys/types.h>',
26 '#include <unistd.h>',
27 '#include "trace/control.h"',
28 '')
31 def generate_h(event):
32 argnames = ", ".join(event.args.names())
33 if len(event.args) > 0:
34 argnames = ", " + argnames
36 out(' if (trace_event_get_state(%(event_id)s)) {',
37 ' struct timeval _now;',
38 ' gettimeofday(&_now, NULL);',
39 ' fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
40 ' getpid(),',
41 ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
42 ' %(argnames)s);',
43 ' }',
44 event_id="TRACE_" + event.name.upper(),
45 name=event.name,
46 fmt=event.fmt.rstrip("\n"),
47 argnames=argnames)