148151859SLluís Vilanova /* 248151859SLluís Vilanova * Interface for configuring and controlling the state of tracing events. 348151859SLluís Vilanova * 448151859SLluís Vilanova * Copyright (C) 2014-2016 Lluís Vilanova <vilanova@ac.upc.edu> 548151859SLluís Vilanova * 648151859SLluís Vilanova * This work is licensed under the terms of the GNU GPL, version 2 or later. 748151859SLluís Vilanova * See the COPYING file in the top-level directory. 848151859SLluís Vilanova */ 948151859SLluís Vilanova 1048151859SLluís Vilanova #include "qemu/osdep.h" 1148151859SLluís Vilanova #include "trace/control.h" 1248151859SLluís Vilanova 1348151859SLluís Vilanova trace_event_set_state_dynamic_init(TraceEvent * ev,bool state)14a4d50b1dSLluís Vilanovavoid trace_event_set_state_dynamic_init(TraceEvent *ev, bool state) 15a4d50b1dSLluís Vilanova { 16a4d50b1dSLluís Vilanova trace_event_set_state_dynamic(ev, state); 17a4d50b1dSLluís Vilanova } 18a4d50b1dSLluís Vilanova trace_event_set_state_dynamic(TraceEvent * ev,bool state)1948151859SLluís Vilanovavoid trace_event_set_state_dynamic(TraceEvent *ev, bool state) 2048151859SLluís Vilanova { 218eb1b9dbSLluís Vilanova bool state_pre; 2248151859SLluís Vilanova assert(trace_event_get_state_static(ev)); 23*93977402SDaniel P. Berrange 248eb1b9dbSLluís Vilanova /* 258eb1b9dbSLluís Vilanova * We ignore the "vcpu" property here, since there's no target code. Then 268eb1b9dbSLluís Vilanova * dstate can only be 1 or 0. 278eb1b9dbSLluís Vilanova */ 28*93977402SDaniel P. Berrange state_pre = *(ev->dstate); 298eb1b9dbSLluís Vilanova if (state_pre != state) { 308eb1b9dbSLluís Vilanova if (state) { 318eb1b9dbSLluís Vilanova trace_events_enabled_count++; 32*93977402SDaniel P. Berrange *(ev->dstate) = 1; 338eb1b9dbSLluís Vilanova } else { 348eb1b9dbSLluís Vilanova trace_events_enabled_count--; 35*93977402SDaniel P. Berrange *(ev->dstate) = 0; 368eb1b9dbSLluís Vilanova } 378eb1b9dbSLluís Vilanova } 3848151859SLluís Vilanova } 39