qapi: Reject multiple and empty feature descriptions
[qemu/kevin.git] / scripts / tracetool / backend / log.py
blobde27b7e62e4adaf122db536181aa80e3989409e4
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 import os.path
17 from tracetool import out
20 PUBLIC = True
23 def generate_h_begin(events, group):
24 out('#include "qemu/log-for-trace.h"',
25 '#include "qemu/error-report.h"',
26 '')
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
36 cond = "true"
37 else:
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',
48 ' %(argnames)s);',
49 '#line %(out_next_lineno)d "%(out_filename)s"',
50 ' } else {',
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"',
54 ' }',
55 ' }',
56 cond=cond,
57 event_lineno=event.lineno,
58 event_filename=os.path.relpath(event.filename),
59 name=event.name,
60 fmt=event.fmt.rstrip("\n"),
61 argnames=argnames)
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())