2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2014-2016 LluĂs Vilanova <vilanova@ac.upc.edu>
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.
10 #include "qemu/osdep.h"
12 #include "trace/control.h"
13 #include "translate-all.h"
16 void trace_event_set_state_dynamic_init(TraceEvent
*ev
, bool state
)
18 TraceEventID id
= trace_event_get_id(ev
);
20 assert(trace_event_get_state_static(ev
));
22 * We ignore the "vcpu" property here, since no vCPUs have been created
23 * yet. Then dstate can only be 1 or 0.
25 state_pre
= trace_events_dstate
[id
];
26 if (state_pre
!= state
) {
28 trace_events_enabled_count
++;
29 trace_events_dstate
[id
] = 1;
31 trace_events_enabled_count
--;
32 trace_events_dstate
[id
] = 0;
37 void trace_event_set_state_dynamic(TraceEvent
*ev
, bool state
)
40 assert(trace_event_get_state_static(ev
));
41 if (trace_event_is_vcpu(ev
)) {
43 trace_event_set_vcpu_state_dynamic(vcpu
, ev
, state
);
46 /* Without the "vcpu" property, dstate can only be 1 or 0 */
47 TraceEventID id
= trace_event_get_id(ev
);
48 bool state_pre
= trace_events_dstate
[id
];
49 if (state_pre
!= state
) {
51 trace_events_enabled_count
++;
52 trace_events_dstate
[id
] = 1;
54 trace_events_enabled_count
--;
55 trace_events_dstate
[id
] = 0;
61 void trace_event_set_vcpu_state_dynamic(CPUState
*vcpu
,
62 TraceEvent
*ev
, bool state
)
65 TraceEventVCPUID vcpu_id
;
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
) {
74 trace_events_enabled_count
++;
75 set_bit(vcpu_id
, vcpu
->trace_dstate
);
76 trace_events_dstate
[id
]++;
78 trace_events_enabled_count
--;
79 clear_bit(vcpu_id
, vcpu
->trace_dstate
);
80 trace_events_dstate
[id
]--;