]> git.proxmox.com Git - mirror_qemu.git/blame - trace/control-target.c
trace: Avoid implicit bool->integer conversions
[mirror_qemu.git] / trace / control-target.c
CommitLineData
48151859
LV
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
a4d50b1d
LV
16void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
17{
18 TraceEventID id = trace_event_get_id(ev);
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 */
25 state_pre = trace_events_dstate[id];
26 if (state_pre != state) {
27 if (state) {
28 trace_events_enabled_count++;
29 trace_events_dstate[id] = 1;
30 } else {
31 trace_events_enabled_count--;
32 trace_events_dstate[id] = 0;
33 }
34 }
a4d50b1d
LV
35}
36
48151859
LV
37void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
38{
39 CPUState *vcpu;
40 assert(trace_event_get_state_static(ev));
41 if (trace_event_is_vcpu(ev)) {
42 CPU_FOREACH(vcpu) {
43 trace_event_set_vcpu_state_dynamic(vcpu, ev, state);
44 }
45 } else {
8eb1b9db 46 /* Without the "vcpu" property, dstate can only be 1 or 0 */
48151859 47 TraceEventID id = trace_event_get_id(ev);
8eb1b9db
LV
48 bool state_pre = trace_events_dstate[id];
49 if (state_pre != state) {
50 if (state) {
51 trace_events_enabled_count++;
52 trace_events_dstate[id] = 1;
53 } else {
54 trace_events_enabled_count--;
55 trace_events_dstate[id] = 0;
56 }
57 }
48151859
LV
58 }
59}
60
61void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
62 TraceEvent *ev, bool state)
63{
64 TraceEventID id;
65 TraceEventVCPUID vcpu_id;
66 bool state_pre;
67 assert(trace_event_get_state_static(ev));
68 assert(trace_event_is_vcpu(ev));
69 id = trace_event_get_id(ev);
70 vcpu_id = trace_event_get_vcpu_id(ev);
71 state_pre = test_bit(vcpu_id, vcpu->trace_dstate);
72 if (state_pre != state) {
73 if (state) {
74 trace_events_enabled_count++;
75 set_bit(vcpu_id, vcpu->trace_dstate);
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}