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 14a4d50b1dSLluís Vilanova void 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 1948151859SLluís Vilanova void trace_event_set_state_dynamic(TraceEvent *ev, bool state) 2048151859SLluís Vilanova { 2148151859SLluís Vilanova TraceEventID id; 22*8eb1b9dbSLluís Vilanova bool state_pre; 2348151859SLluís Vilanova assert(trace_event_get_state_static(ev)); 2448151859SLluís Vilanova id = trace_event_get_id(ev); 25*8eb1b9dbSLluís Vilanova /* 26*8eb1b9dbSLluís Vilanova * We ignore the "vcpu" property here, since there's no target code. Then 27*8eb1b9dbSLluís Vilanova * dstate can only be 1 or 0. 28*8eb1b9dbSLluís Vilanova */ 29*8eb1b9dbSLluís Vilanova state_pre = trace_events_dstate[id]; 30*8eb1b9dbSLluís Vilanova if (state_pre != state) { 31*8eb1b9dbSLluís Vilanova if (state) { 32*8eb1b9dbSLluís Vilanova trace_events_enabled_count++; 33*8eb1b9dbSLluís Vilanova trace_events_dstate[id] = 1; 34*8eb1b9dbSLluís Vilanova } else { 35*8eb1b9dbSLluís Vilanova trace_events_enabled_count--; 36*8eb1b9dbSLluís Vilanova trace_events_dstate[id] = 0; 37*8eb1b9dbSLluís Vilanova } 38*8eb1b9dbSLluís Vilanova } 3948151859SLluís Vilanova } 4048151859SLluís Vilanova 4148151859SLluís Vilanova void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, 4248151859SLluís Vilanova TraceEvent *ev, bool state) 4348151859SLluís Vilanova { 4448151859SLluís Vilanova /* should never be called on non-target binaries */ 4548151859SLluís Vilanova abort(); 4648151859SLluís Vilanova } 47