2
0

control-vcpu.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Interface for configuring and controlling the state of tracing events.
  3. *
  4. * Copyright (C) 2011-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. #ifndef TRACE__CONTROL_VCPU_H
  10. #define TRACE__CONTROL_VCPU_H
  11. #include "control.h"
  12. #include "event-internal.h"
  13. #include "hw/core/cpu.h"
  14. /**
  15. * trace_event_get_vcpu_state:
  16. * @vcpu: Target vCPU.
  17. * @id: Event identifier name.
  18. *
  19. * Get the tracing state of an event (both static and dynamic) for the given
  20. * vCPU.
  21. *
  22. * If the event has the disabled property, the check will have no performance
  23. * impact.
  24. */
  25. #define trace_event_get_vcpu_state(vcpu, id) \
  26. ((id ##_ENABLED) && \
  27. trace_event_get_vcpu_state_dynamic_by_vcpu_id( \
  28. vcpu, _ ## id ## _EVENT.vcpu_id))
  29. /**
  30. * trace_event_get_vcpu_state_dynamic:
  31. *
  32. * Get the dynamic tracing state of an event for the given vCPU.
  33. */
  34. static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
  35. #include "control-internal.h"
  36. static inline bool
  37. trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
  38. uint32_t vcpu_id)
  39. {
  40. /* it's on fast path, avoid consistency checks (asserts) */
  41. if (unlikely(trace_events_enabled_count)) {
  42. return test_bit(vcpu_id, vcpu->trace_dstate);
  43. } else {
  44. return false;
  45. }
  46. }
  47. static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
  48. TraceEvent *ev)
  49. {
  50. uint32_t vcpu_id;
  51. assert(trace_event_is_vcpu(ev));
  52. vcpu_id = trace_event_get_vcpu_id(ev);
  53. return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
  54. }
  55. #endif