2025-09-29 17:49:26 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
2012-04-03 20:47:50 +02:00
|
|
|
"""
|
2014-02-23 20:37:30 +01:00
|
|
|
trace/generated-tracers.h
|
2012-04-03 20:47:50 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
2017-07-04 10:46:39 +02:00
|
|
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
2012-04-03 20:47:50 +02:00
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
2020-05-11 10:28:16 +02:00
|
|
|
__email__ = "stefanha@redhat.com"
|
2012-04-03 20:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
|
|
2016-10-04 14:35:59 +01:00
|
|
|
def generate(events, backend, group):
|
2023-05-26 17:53:58 +01:00
|
|
|
header = "trace/control.h"
|
2019-08-12 07:23:37 +02:00
|
|
|
|
2012-04-03 20:47:50 +02:00
|
|
|
out('/* This file is autogenerated by tracetool, do not edit. */',
|
2025-09-16 09:16:34 +01:00
|
|
|
'/* SPDX-License-Identifier: GPL-2.0-or-later */',
|
2012-04-03 20:47:50 +02:00
|
|
|
'',
|
2016-10-04 14:35:59 +01:00
|
|
|
'#ifndef TRACE_%s_GENERATED_TRACERS_H' % group.upper(),
|
|
|
|
|
'#define TRACE_%s_GENERATED_TRACERS_H' % group.upper(),
|
2012-04-03 20:47:50 +02:00
|
|
|
'',
|
2019-08-12 07:23:37 +02:00
|
|
|
'#include "%s"' % header,
|
2014-02-23 20:37:40 +01:00
|
|
|
'')
|
2012-04-03 20:47:50 +02:00
|
|
|
|
2016-10-04 14:35:55 +01:00
|
|
|
for e in events:
|
|
|
|
|
out('extern TraceEvent %(event)s;',
|
|
|
|
|
event = e.api(e.QEMU_EVENT))
|
|
|
|
|
|
|
|
|
|
for e in events:
|
|
|
|
|
out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE))
|
|
|
|
|
|
|
|
|
|
# static state
|
|
|
|
|
for e in events:
|
|
|
|
|
if 'disable' in e.properties:
|
|
|
|
|
enabled = 0
|
|
|
|
|
else:
|
|
|
|
|
enabled = 1
|
|
|
|
|
out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
|
|
|
|
|
|
2016-10-04 14:35:59 +01:00
|
|
|
backend.generate_begin(events, group)
|
2012-04-03 20:47:50 +02:00
|
|
|
|
|
|
|
|
for e in events:
|
2017-07-31 15:07:17 +01:00
|
|
|
# tracer-specific dstate
|
|
|
|
|
out('',
|
|
|
|
|
'#define %(api)s() ( \\',
|
|
|
|
|
api=e.api(e.QEMU_BACKEND_DSTATE))
|
|
|
|
|
|
|
|
|
|
if "disable" not in e.properties:
|
|
|
|
|
backend.generate_backend_dstate(e, group)
|
|
|
|
|
|
|
|
|
|
out(' false)')
|
|
|
|
|
|
2017-07-04 10:46:39 +02:00
|
|
|
out('',
|
|
|
|
|
'static inline void %(api)s(%(args)s)',
|
|
|
|
|
'{',
|
tracetool: drop the probe "__nocheck__" wrapping
Every generated inline probe function is wrapped with a
trivial caller that has a hard-coded condition test:
static inline void _nocheck__trace_test_wibble(void * context, int value)
{
tracepoint(qemu, test_wibble, context, value);
}
static inline void trace_test_wibble(void * context, int value)
{
if (true) {
_nocheck__trace_test_wibble(context, value);
}
}
This was introduced for TCG probes back in
864a2178: trace: [tcg] Do not generate TCG code to trace dynamically-disabled events
but is obsolete since
126d4123 tracing: excise the tcg related from tracetool
This commit removes the wrapping such that we have
static inline void trace_test_wibble(void * context, int value)
{
tracepoint(qemu, test_wibble, context, value);
}
The default build of qemu-system-x86_64 on Fedora with the
'log' backend, has its size reduced by 1 MB
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20250916081638.764020-7-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2025-09-16 09:16:36 +01:00
|
|
|
api=e.api(),
|
2017-07-04 10:46:39 +02:00
|
|
|
args=e.args)
|
|
|
|
|
|
|
|
|
|
if "disable" not in e.properties:
|
2025-09-29 17:49:28 +02:00
|
|
|
backend.generate(e, group, check_trace_event_get_state=False)
|
|
|
|
|
|
|
|
|
|
if backend.check_trace_event_get_state:
|
|
|
|
|
event_id = 'TRACE_' + e.name.upper()
|
|
|
|
|
cond = "trace_event_get_state(%s)" % event_id
|
|
|
|
|
out(' if (%(cond)s) {',
|
|
|
|
|
cond=cond)
|
|
|
|
|
backend.generate(e, group, check_trace_event_get_state=True)
|
|
|
|
|
out(' }')
|
2017-07-04 10:46:39 +02:00
|
|
|
out('}')
|
|
|
|
|
|
2016-10-04 14:35:59 +01:00
|
|
|
backend.generate_end(events, group)
|
2014-02-23 20:37:40 +01:00
|
|
|
|
2016-10-04 14:35:59 +01:00
|
|
|
out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper())
|