]> git.proxmox.com Git - mirror_qemu.git/blame - trace/control-target.c
tracing: install trace events file only if necessary
[mirror_qemu.git] / trace / control-target.c
CommitLineData
48151859
LV
1/*
2 * Interface for configuring and controlling the state of tracing events.
3 *
f5956d71 4 * Copyright (C) 2014-2017 Lluís Vilanova <vilanova@ac.upc.edu>
48151859
LV
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
10#include "qemu/osdep.h"
370ed600 11#include "qemu/lockable.h"
48151859 12#include "cpu.h"
243af022 13#include "trace/trace-root.h"
48151859 14#include "trace/control.h"
48151859
LV
15
16
a4d50b1d
LV
17void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
18{
8eb1b9db 19 bool state_pre;
a4d50b1d 20 assert(trace_event_get_state_static(ev));
8eb1b9db
LV
21 /*
22 * We ignore the "vcpu" property here, since no vCPUs have been created
23 * yet. Then dstate can only be 1 or 0.
24 */
93977402 25 state_pre = *ev->dstate;
8eb1b9db
LV
26 if (state_pre != state) {
27 if (state) {
28 trace_events_enabled_count++;
93977402 29 *ev->dstate = 1;
8eb1b9db
LV
30 } else {
31 trace_events_enabled_count--;
93977402 32 *ev->dstate = 0;
8eb1b9db
LV
33 }
34 }
a4d50b1d
LV
35}
36
48151859
LV
37void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
38{
48151859 39 assert(trace_event_get_state_static(ev));
48151859 40
89aafcf2
AB
41 /*
42 * There is no longer a "vcpu" property, dstate can only be 1 or
43 * 0. With it, we haven't instantiated any vCPU yet, so we will
44 * set a global state instead, and trace_init_vcpu will reconcile
45 * it afterwards.
46 */
47 bool state_pre = *ev->dstate;
48151859
LV
48 if (state_pre != state) {
49 if (state) {
50 trace_events_enabled_count++;
89aafcf2 51 *ev->dstate = 1;
48151859
LV
52 } else {
53 trace_events_enabled_count--;
89aafcf2 54 *ev->dstate = 0;
2bfe11c8
LV
55 }
56 }
57}