qdev: Fix device_add DRIVER,help to print to monitor
[qemu/ar7.git] / scripts / tracetool / backend / log.py
blob877222bbe9b7093423d3c8d0be8e619fa2307982
1 # -*- coding: utf-8 -*-
3 """
4 Stderr built-in backend.
5 """
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
18 PUBLIC = True
21 def generate_h_begin(events, group):
22 out('#include "qemu/log-for-trace.h"',
23 '')
26 def generate_h(event, group):
27 argnames = ", ".join(event.args.names())
28 if len(event.args) > 0:
29 argnames = ", " + argnames
31 if "vcpu" in event.properties:
32 # already checked on the generic format code
33 cond = "true"
34 else:
35 cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
37 out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
38 ' struct timeval _now;',
39 ' gettimeofday(&_now, NULL);',
40 ' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",',
41 ' qemu_get_thread_id(),',
42 ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
43 ' %(argnames)s);',
44 ' }',
45 cond=cond,
46 name=event.name,
47 fmt=event.fmt.rstrip("\n"),
48 argnames=argnames)
51 def generate_h_backend_dstate(event, group):
52 out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
53 event_id="TRACE_" + event.name.upper())