]> git.proxmox.com Git - mirror_qemu.git/blob - trace/control-target.c
Merge remote-tracking branch 'remotes/stsquad/tags/pull-travis-20160718-1' into staging
[mirror_qemu.git] / trace / control-target.c
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 */
9
10 #include "qemu/osdep.h"
11 #include "cpu.h"
12 #include "trace/control.h"
13 #include "translate-all.h"
14
15
16 void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
17 {
18 CPUState *vcpu;
19 assert(trace_event_get_state_static(ev));
20 if (trace_event_is_vcpu(ev)) {
21 CPU_FOREACH(vcpu) {
22 trace_event_set_vcpu_state_dynamic(vcpu, ev, state);
23 }
24 } else {
25 TraceEventID id = trace_event_get_id(ev);
26 trace_events_enabled_count += state - trace_events_dstate[id];
27 trace_events_dstate[id] = state;
28 }
29 }
30
31 void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
32 TraceEvent *ev, bool state)
33 {
34 TraceEventID id;
35 TraceEventVCPUID vcpu_id;
36 bool state_pre;
37 assert(trace_event_get_state_static(ev));
38 assert(trace_event_is_vcpu(ev));
39 id = trace_event_get_id(ev);
40 vcpu_id = trace_event_get_vcpu_id(ev);
41 state_pre = test_bit(vcpu_id, vcpu->trace_dstate);
42 if (state_pre != state) {
43 if (state) {
44 trace_events_enabled_count++;
45 set_bit(vcpu_id, vcpu->trace_dstate);
46 trace_events_dstate[id]++;
47 } else {
48 trace_events_enabled_count--;
49 clear_bit(vcpu_id, vcpu->trace_dstate);
50 trace_events_dstate[id]--;
51 }
52 }
53 }