control-target.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "qemu/osdep.h"
  10. #include "trace/control.h"
  11. void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
  12. {
  13. bool state_pre;
  14. assert(trace_event_get_state_static(ev));
  15. /*
  16. * We ignore the "vcpu" property here, since no vCPUs have been created
  17. * yet. Then dstate can only be 1 or 0.
  18. */
  19. state_pre = *ev->dstate;
  20. if (state_pre != state) {
  21. if (state) {
  22. trace_events_enabled_count++;
  23. *ev->dstate = 1;
  24. } else {
  25. trace_events_enabled_count--;
  26. *ev->dstate = 0;
  27. }
  28. }
  29. }
  30. void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
  31. {
  32. assert(trace_event_get_state_static(ev));
  33. /*
  34. * There is no longer a "vcpu" property, dstate can only be 1 or
  35. * 0. With it, we haven't instantiated any vCPU yet, so we will
  36. * set a global state instead, and trace_init_vcpu will reconcile
  37. * it afterwards.
  38. */
  39. bool state_pre = *ev->dstate;
  40. if (state_pre != state) {
  41. if (state) {
  42. trace_events_enabled_count++;
  43. *ev->dstate = 1;
  44. } else {
  45. trace_events_enabled_count--;
  46. *ev->dstate = 0;
  47. }
  48. }
  49. }