]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/tracetool/backend/log.py
Merge tag 'pull-qapi-2023-04-26' of https://repo.or.cz/qemu/armbru into staging
[mirror_qemu.git] / scripts / tracetool / backend / log.py
CommitLineData
9008d85a
LV
1# -*- coding: utf-8 -*-
2
3"""
4Stderr built-in backend.
5"""
6
7__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
1ff7b531 8__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
9008d85a
LV
9__license__ = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
f892b494 12__email__ = "stefanha@redhat.com"
9008d85a
LV
13
14
9d672e29
TDS
15import os.path
16
9008d85a
LV
17from tracetool import out
18
19
93fba161
LV
20PUBLIC = True
21
22
80dd5c49 23def generate_h_begin(events, group):
be0aa7ac 24 out('#include "qemu/log-for-trace.h"',
418ed142 25 '#include "qemu/error-report.h"',
1dad2ce9
LV
26 '')
27
28
80dd5c49 29def generate_h(event, group):
1dad2ce9
LV
30 argnames = ", ".join(event.args.names())
31 if len(event.args) > 0:
32 argnames = ", " + argnames
33
40b9cd25
LV
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())
39
be0aa7ac 40 out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
418ed142
SH
41 ' if (message_with_timestamp) {',
42 ' struct timeval _now;',
43 ' gettimeofday(&_now, NULL);',
7fb48c0e 44 '#line %(event_lineno)d "%(event_filename)s"',
418ed142
SH
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);',
7fb48c0e 49 '#line %(out_next_lineno)d "%(out_filename)s"',
418ed142
SH
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 ' }',
1ff7b531 55 ' }',
40b9cd25 56 cond=cond,
7fb48c0e 57 event_lineno=event.lineno,
9d672e29 58 event_filename=os.path.relpath(event.filename),
1dad2ce9
LV
59 name=event.name,
60 fmt=event.fmt.rstrip("\n"),
61 argnames=argnames)
3932ef3f
SH
62
63
64def 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())