trace: Conditionally trace events based on their per-vCPU state

Events with the 'vcpu' property are conditionally emitted according to
their per-vCPU state. Other events are emitted normally based on their
global tracing state.

Note that the per-vCPU condition check applies to all tracing backends.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Lluís Vilanova 2016-07-11 12:53:46 +02:00 committed by Stefan Hajnoczi
parent 4815185902
commit 40b9cd25f7
6 changed files with 57 additions and 29 deletions

View file

@ -23,21 +23,36 @@ def generate(events, backend):
'#define TRACE__GENERATED_TRACERS_H',
'',
'#include "qemu-common.h"',
'#include "trace/control.h"',
'')
backend.generate_begin(events)
for e in events:
if "vcpu" in e.properties:
trace_cpu = next(iter(e.args))[1]
cond = "trace_event_get_vcpu_state(%(cpu)s,"\
" TRACE_%(id)s,"\
" TRACE_VCPU_%(id)s)"\
% dict(
cpu=trace_cpu,
id=e.name.upper())
else:
cond = "true"
out('',
'static inline void %(api)s(%(args)s)',
'{',
' if (%(cond)s) {',
api=e.api(),
args=e.args)
args=e.args,
cond=cond)
if "disable" not in e.properties:
backend.generate(e)
out('}')
out(' }',
'}')
backend.generate_end(events)