1 # -*- coding: utf-8 -*-
4 Stderr built-in backend.
7 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__
= "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
9 __license__
= "GPL version 2 or (at your option) any later version"
11 __maintainer__
= "Stefan Hajnoczi"
12 __email__
= "stefanha@redhat.com"
15 from tracetool
import out
21 def generate_h_begin(events
, group
):
22 out('#include "qemu/log-for-trace.h"',
23 '#include "qemu/error-report.h"',
27 def generate_h(event
, group
):
28 argnames
= ", ".join(event
.args
.names())
29 if len(event
.args
) > 0:
30 argnames
= ", " + argnames
32 if "vcpu" in event
.properties
:
33 # already checked on the generic format code
36 cond
= "trace_event_get_state(%s)" % ("TRACE_" + event
.name
.upper())
38 out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
39 ' if (message_with_timestamp) {',
40 ' struct timeval _now;',
41 ' gettimeofday(&_now, NULL);',
42 '#line %(event_lineno)d "%(event_filename)s"',
43 ' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",',
44 ' qemu_get_thread_id(),',
45 ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
47 '#line %(out_next_lineno)d "%(out_filename)s"',
49 '#line %(event_lineno)d "%(event_filename)s"',
50 ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);',
51 '#line %(out_next_lineno)d "%(out_filename)s"',
55 event_lineno
=event
.lineno
,
56 event_filename
=event
.filename
,
58 fmt
=event
.fmt
.rstrip("\n"),
62 def generate_h_backend_dstate(event
, group
):
63 out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
64 event_id
="TRACE_" + event
.name
.upper())