xref: /qemu/trace/control-target.c (revision c7b64948)
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/trace-root.h"
14 #include "trace/control.h"
15 
16 
17 void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
18 {
19     bool state_pre;
20     assert(trace_event_get_state_static(ev));
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      */
25     state_pre = *ev->dstate;
26     if (state_pre != state) {
27         if (state) {
28             trace_events_enabled_count++;
29             *ev->dstate = 1;
30         } else {
31             trace_events_enabled_count--;
32             *ev->dstate = 0;
33         }
34     }
35 }
36 
37 void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
38 {
39     assert(trace_event_get_state_static(ev));
40 
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;
48     if (state_pre != state) {
49         if (state) {
50             trace_events_enabled_count++;
51             *ev->dstate = 1;
52         } else {
53             trace_events_enabled_count--;
54             *ev->dstate = 0;
55         }
56     }
57 }
58