qemu/trace/control-target.c
<<
>>
Prefs
   1/*
   2 * Interface for configuring and controlling the state of tracing events.
   3 *
   4 * Copyright (C) 2014-2017 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
  14void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
  15{
  16    bool state_pre;
  17    assert(trace_event_get_state_static(ev));
  18    /*
  19     * We ignore the "vcpu" property here, since no vCPUs have been created
  20     * yet. Then dstate can only be 1 or 0.
  21     */
  22    state_pre = *ev->dstate;
  23    if (state_pre != state) {
  24        if (state) {
  25            trace_events_enabled_count++;
  26            *ev->dstate = 1;
  27        } else {
  28            trace_events_enabled_count--;
  29            *ev->dstate = 0;
  30        }
  31    }
  32}
  33
  34void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
  35{
  36    assert(trace_event_get_state_static(ev));
  37
  38    /*
  39     * There is no longer a "vcpu" property, dstate can only be 1 or
  40     * 0. With it, we haven't instantiated any vCPU yet, so we will
  41     * set a global state instead, and trace_init_vcpu will reconcile
  42     * it afterwards.
  43     */
  44    bool state_pre = *ev->dstate;
  45    if (state_pre != state) {
  46        if (state) {
  47            trace_events_enabled_count++;
  48            *ev->dstate = 1;
  49        } else {
  50            trace_events_enabled_count--;
  51            *ev->dstate = 0;
  52        }
  53    }
  54}
  55