blob: b428f34c87881eb5af2f45be89e9a90e59b75d18 [file] [log] [blame]
Lluís Vilanova48151852016-07-11 12:53:41 +02001/*
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 "trace/control.h"
12
13
Lluís Vilanovaa4d50b12016-08-23 10:58:52 +020014void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
15{
16 trace_event_set_state_dynamic(ev, state);
17}
18
Lluís Vilanova48151852016-07-11 12:53:41 +020019void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
20{
Lluís Vilanova8eb1b9d2016-08-23 10:58:58 +020021 bool state_pre;
Lluís Vilanova48151852016-07-11 12:53:41 +020022 assert(trace_event_get_state_static(ev));
Daniel P. Berrange93977402016-10-04 14:35:45 +010023
Lluís Vilanova8eb1b9d2016-08-23 10:58:58 +020024 /*
25 * We ignore the "vcpu" property here, since there's no target code. Then
26 * dstate can only be 1 or 0.
27 */
Daniel P. Berrange93977402016-10-04 14:35:45 +010028 state_pre = *(ev->dstate);
Lluís Vilanova8eb1b9d2016-08-23 10:58:58 +020029 if (state_pre != state) {
30 if (state) {
31 trace_events_enabled_count++;
Daniel P. Berrange93977402016-10-04 14:35:45 +010032 *(ev->dstate) = 1;
Lluís Vilanova8eb1b9d2016-08-23 10:58:58 +020033 } else {
34 trace_events_enabled_count--;
Daniel P. Berrange93977402016-10-04 14:35:45 +010035 *(ev->dstate) = 0;
Lluís Vilanova8eb1b9d2016-08-23 10:58:58 +020036 }
37 }
Lluís Vilanova48151852016-07-11 12:53:41 +020038}