1 /*
2 * Interface for configuring and controlling the state of tracing events.
3 *
4 * Copyright (C) 2014-2017 Lluís Vilanova <vilanova@ac.upc.edu>
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"
11 #include "qemu/lockable.h"
12 #include "cpu.h"
13 #include "trace/control.h"
14
15
trace_event_set_state_dynamic_init(TraceEvent * ev,bool state)16 void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
17 {
18 bool state_pre;
19 assert(trace_event_get_state_static(ev));
20 /*
21 * We ignore the "vcpu" property here, since no vCPUs have been created
22 * yet. Then dstate can only be 1 or 0.
23 */
24 state_pre = *ev->dstate;
25 if (state_pre != state) {
26 if (state) {
27 trace_events_enabled_count++;
28 *ev->dstate = 1;
29 } else {
30 trace_events_enabled_count--;
31 *ev->dstate = 0;
32 }
33 }
34 }
35
trace_event_set_state_dynamic(TraceEvent * ev,bool state)36 void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
37 {
38 assert(trace_event_get_state_static(ev));
39
40 /*
41 * There is no longer a "vcpu" property, dstate can only be 1 or
42 * 0. With it, we haven't instantiated any vCPU yet, so we will
43 * set a global state instead, and trace_init_vcpu will reconcile
44 * it afterwards.
45 */
46 bool state_pre = *ev->dstate;
47 if (state_pre != state) {
48 if (state) {
49 trace_events_enabled_count++;
50 *ev->dstate = 1;
51 } else {
52 trace_events_enabled_count--;
53 *ev->dstate = 0;
54 }
55 }
56 }
57