control-target.c (30e7d092b26146eb2abb77e0a0952aea012e36bf) control-target.c (2bfe11c8fac96db4f94abbe818fbc964a6744130)
1/*
2 * Interface for configuring and controlling the state of tracing events.
3 *
4 * Copyright (C) 2014-2016 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 */

--- 67 unchanged lines hidden (view full) ---

76 trace_events_dstate[id]++;
77 } else {
78 trace_events_enabled_count--;
79 clear_bit(vcpu_id, vcpu->trace_dstate);
80 trace_events_dstate[id]--;
81 }
82 }
83}
1/*
2 * Interface for configuring and controlling the state of tracing events.
3 *
4 * Copyright (C) 2014-2016 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 */

--- 67 unchanged lines hidden (view full) ---

76 trace_events_dstate[id]++;
77 } else {
78 trace_events_enabled_count--;
79 clear_bit(vcpu_id, vcpu->trace_dstate);
80 trace_events_dstate[id]--;
81 }
82 }
83}
84
85static bool adding_first_cpu(void)
86{
87 CPUState *cpu;
88 size_t count = 0;
89 CPU_FOREACH(cpu) {
90 count++;
91 if (count > 1) {
92 return false;
93 }
94 }
95 return true;
96}
97
98void trace_init_vcpu(CPUState *vcpu)
99{
100 TraceEvent *ev = NULL;
101
102 while ((ev = trace_event_pattern("*", ev)) != NULL) {
103 if (trace_event_is_vcpu(ev) &&
104 trace_event_get_state_static(ev) &&
105 trace_event_get_state_dynamic(ev)) {
106 TraceEventID id = trace_event_get_id(ev);
107 if (adding_first_cpu()) {
108 /* check preconditions */
109 assert(trace_events_dstate[id] == 1);
110 /* disable early-init state ... */
111 trace_events_dstate[id] = 0;
112 trace_events_enabled_count--;
113 /* ... and properly re-enable */
114 trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
115 } else {
116 trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
117 }
118 }
119 }
120}