xen-bus / xen-block: add support for event channel polling
[qemu/ar7.git] / trace / control-internal.h
blobc7fbe2d3bfd373f8d7f22dd264fd1852c3e98faa
1 /*
2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2011-2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
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 */
10 #ifndef TRACE__CONTROL_INTERNAL_H
11 #define TRACE__CONTROL_INTERNAL_H
13 #include "qom/cpu.h"
16 extern int trace_events_enabled_count;
19 static inline bool trace_event_is_pattern(const char *str)
21 assert(str != NULL);
22 return strchr(str, '*') != NULL;
25 static inline uint32_t trace_event_get_id(TraceEvent *ev)
27 assert(ev != NULL);
28 return ev->id;
31 static inline uint32_t trace_event_get_vcpu_id(TraceEvent *ev)
33 return ev->vcpu_id;
36 static inline bool trace_event_is_vcpu(TraceEvent *ev)
38 return ev->vcpu_id != TRACE_VCPU_EVENT_NONE;
41 static inline const char * trace_event_get_name(TraceEvent *ev)
43 assert(ev != NULL);
44 return ev->name;
47 static inline bool trace_event_get_state_static(TraceEvent *ev)
49 assert(ev != NULL);
50 return ev->sstate;
53 /* it's on fast path, avoid consistency checks (asserts) */
54 #define trace_event_get_state_dynamic_by_id(id) \
55 (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE)
57 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
59 return unlikely(trace_events_enabled_count) && *ev->dstate;
62 static inline bool
63 trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
64 uint32_t vcpu_id)
66 /* it's on fast path, avoid consistency checks (asserts) */
67 if (unlikely(trace_events_enabled_count)) {
68 return test_bit(vcpu_id, vcpu->trace_dstate);
69 } else {
70 return false;
74 static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
75 TraceEvent *ev)
77 uint32_t vcpu_id;
78 assert(trace_event_is_vcpu(ev));
79 vcpu_id = trace_event_get_vcpu_id(ev);
80 return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
84 void trace_event_register_group(TraceEvent **events);
86 #endif /* TRACE__CONTROL_INTERNAL_H */