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"
17 from tracetool
import out
23 def generate_h_begin(events
, group
):
24 out('#include "qemu/log-for-trace.h"',
25 '#include "qemu/error-report.h"',
29 def generate_h(event
, group
):
30 argnames
= ", ".join(event
.args
.names())
31 if len(event
.args
) > 0:
32 argnames
= ", " + argnames
34 if "vcpu" in event
.properties
:
35 # already checked on the generic format code
38 cond
= "trace_event_get_state(%s)" % ("TRACE_" + event
.name
.upper())
40 out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
41 ' if (message_with_timestamp) {',
42 ' struct timeval _now;',
43 ' gettimeofday(&_now, NULL);',
44 '#line %(event_lineno)d "%(event_filename)s"',
45 ' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",',
46 ' qemu_get_thread_id(),',
47 ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
49 '#line %(out_next_lineno)d "%(out_filename)s"',
51 '#line %(event_lineno)d "%(event_filename)s"',
52 ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);',
53 '#line %(out_next_lineno)d "%(out_filename)s"',
57 event_lineno
=event
.lineno
,
58 event_filename
=os
.path
.relpath(event
.filename
),
60 fmt
=event
.fmt
.rstrip("\n"),
64 def generate_h_backend_dstate(event
, group
):
65 out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
66 event_id
="TRACE_" + event
.name
.upper())