control-internal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_INTERNAL_H
  10. #define TRACE__CONTROL_INTERNAL_H
  11. extern int trace_events_enabled_count;
  12. static inline bool trace_event_is_pattern(const char *str)
  13. {
  14. assert(str != NULL);
  15. return strchr(str, '*') != NULL;
  16. }
  17. static inline uint32_t trace_event_get_id(TraceEvent *ev)
  18. {
  19. assert(ev != NULL);
  20. return ev->id;
  21. }
  22. static inline uint32_t trace_event_get_vcpu_id(TraceEvent *ev)
  23. {
  24. return ev->vcpu_id;
  25. }
  26. static inline bool trace_event_is_vcpu(TraceEvent *ev)
  27. {
  28. return ev->vcpu_id != TRACE_VCPU_EVENT_NONE;
  29. }
  30. static inline const char * trace_event_get_name(TraceEvent *ev)
  31. {
  32. assert(ev != NULL);
  33. return ev->name;
  34. }
  35. static inline bool trace_event_get_state_static(TraceEvent *ev)
  36. {
  37. assert(ev != NULL);
  38. return ev->sstate;
  39. }
  40. /* it's on fast path, avoid consistency checks (asserts) */
  41. #define trace_event_get_state_dynamic_by_id(id) \
  42. (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE)
  43. static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
  44. {
  45. return unlikely(trace_events_enabled_count) && *ev->dstate;
  46. }
  47. void trace_event_register_group(TraceEvent **events);
  48. #endif /* TRACE__CONTROL_INTERNAL_H */