]> git.proxmox.com Git - mirror_qemu.git/blob - trace/control-internal.h
trace: remove some now unused functions
[mirror_qemu.git] / trace / control-internal.h
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
10 #ifndef TRACE__CONTROL_INTERNAL_H
11 #define TRACE__CONTROL_INTERNAL_H
12
13 #include <stddef.h> /* size_t */
14
15 #include "qom/cpu.h"
16
17
18 extern TraceEvent trace_events[];
19 extern uint16_t trace_events_dstate[];
20 extern int trace_events_enabled_count;
21
22
23 static inline bool trace_event_is_pattern(const char *str)
24 {
25 assert(str != NULL);
26 return strchr(str, '*') != NULL;
27 }
28
29 static inline TraceEventID trace_event_get_id(TraceEvent *ev)
30 {
31 assert(ev != NULL);
32 return ev->id;
33 }
34
35 static inline TraceEventVCPUID trace_event_get_vcpu_id(TraceEvent *ev)
36 {
37 return ev->vcpu_id;
38 }
39
40 static inline bool trace_event_is_vcpu(TraceEvent *ev)
41 {
42 return ev->vcpu_id != TRACE_VCPU_EVENT_COUNT;
43 }
44
45 static inline const char * trace_event_get_name(TraceEvent *ev)
46 {
47 assert(ev != NULL);
48 return ev->name;
49 }
50
51 static inline bool trace_event_get_state_static(TraceEvent *ev)
52 {
53 assert(ev != NULL);
54 return ev->sstate;
55 }
56
57 static inline bool trace_event_get_state_dynamic_by_id(TraceEventID id)
58 {
59 /* it's on fast path, avoid consistency checks (asserts) */
60 return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
61 }
62
63 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
64 {
65 TraceEventID id;
66 assert(trace_event_get_state_static(ev));
67 id = trace_event_get_id(ev);
68 return trace_event_get_state_dynamic_by_id(id);
69 }
70
71 static inline bool trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
72 TraceEventVCPUID id)
73 {
74 /* it's on fast path, avoid consistency checks (asserts) */
75 if (unlikely(trace_events_enabled_count)) {
76 return test_bit(id, vcpu->trace_dstate);
77 } else {
78 return false;
79 }
80 }
81
82 static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
83 TraceEvent *ev)
84 {
85 TraceEventVCPUID id;
86 assert(trace_event_is_vcpu(ev));
87 id = trace_event_get_vcpu_id(ev);
88 return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, id);
89 }
90
91 #endif /* TRACE__CONTROL_INTERNAL_H */