]>
Commit | Line | Data |
---|---|---|
e4858974 LV |
1 | /* |
2 | * Interface for configuring and controlling the state of tracing events. | |
3 | * | |
3d211d9f | 4 | * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu> |
e4858974 | 5 | * |
b1bae816 LV |
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. | |
e4858974 LV |
8 | */ |
9 | ||
b1bae816 LV |
10 | #ifndef TRACE__CONTROL_H |
11 | #define TRACE__CONTROL_H | |
e4858974 | 12 | |
34770187 | 13 | #include "event-internal.h" |
fc764105 | 14 | |
6a1b0f3a | 15 | typedef struct TraceEventIter { |
c5cc58b1 | 16 | /* iter state */ |
6a1b0f3a | 17 | size_t event; |
fe4db84d | 18 | size_t group; |
c5cc58b1 GH |
19 | /* filter conditions */ |
20 | size_t group_id; | |
6a1b0f3a DB |
21 | const char *pattern; |
22 | } TraceEventIter; | |
fc764105 | 23 | |
6a1b0f3a DB |
24 | |
25 | /** | |
117856c3 | 26 | * trace_event_iter_init_all: |
6a1b0f3a | 27 | * @iter: the event iterator struct |
6a1b0f3a DB |
28 | * |
29 | * Initialize the event iterator struct @iter, | |
117856c3 GH |
30 | * for all events. |
31 | */ | |
32 | void trace_event_iter_init_all(TraceEventIter *iter); | |
33 | ||
34 | /** | |
35 | * trace_event_iter_init_pattern: | |
36 | * @iter: the event iterator struct | |
37 | * @pattern: pattern to filter events on name | |
38 | * | |
39 | * Initialize the event iterator struct @iter, | |
40 | * using @pattern to filter out events | |
6a1b0f3a DB |
41 | * with non-matching names. |
42 | */ | |
117856c3 | 43 | void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern); |
6a1b0f3a | 44 | |
c5cc58b1 GH |
45 | /** |
46 | * trace_event_iter_init_group: | |
47 | * @iter: the event iterator struct | |
48 | * @group_id: group_id to filter events by group. | |
49 | * | |
50 | * Initialize the event iterator struct @iter, | |
51 | * using @group_id to filter for events in the group. | |
52 | */ | |
53 | void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id); | |
54 | ||
6a1b0f3a DB |
55 | /** |
56 | * trace_event_iter_next: | |
57 | * @iter: the event iterator struct | |
58 | * | |
59 | * Get the next event, if any. When this returns NULL, | |
60 | * the iterator should no longer be used. | |
61 | * | |
62 | * Returns: the next event, or NULL if no more events exist | |
63 | */ | |
64 | TraceEvent *trace_event_iter_next(TraceEventIter *iter); | |
65 | ||
b1bae816 LV |
66 | |
67 | /** | |
68 | * trace_event_name: | |
69 | * @id: Event name. | |
70 | * | |
71 | * Search an event by its name. | |
72 | * | |
73 | * Returns: pointer to #TraceEvent or NULL if not found. | |
74 | */ | |
75 | TraceEvent *trace_event_name(const char *name); | |
76 | ||
b1bae816 LV |
77 | /** |
78 | * trace_event_is_pattern: | |
79 | * | |
80 | * Whether the given string is an event name pattern. | |
81 | */ | |
82 | static bool trace_event_is_pattern(const char *str); | |
83 | ||
b1bae816 LV |
84 | |
85 | /** | |
86 | * trace_event_get_id: | |
87 | * | |
88 | * Get the identifier of an event. | |
89 | */ | |
ef4c9fc8 | 90 | static uint32_t trace_event_get_id(TraceEvent *ev); |
b1bae816 LV |
91 | |
92 | /** | |
93 | * trace_event_get_name: | |
fc764105 | 94 | * |
b1bae816 | 95 | * Get the name of an event. |
fc764105 | 96 | */ |
b1bae816 | 97 | static const char * trace_event_get_name(TraceEvent *ev); |
e4858974 | 98 | |
b1bae816 LV |
99 | /** |
100 | * trace_event_get_state: | |
ef4c9fc8 | 101 | * @id: Event identifier name. |
b1bae816 | 102 | * |
d87aa138 | 103 | * Get the tracing state of an event, both static and the QEMU dynamic state. |
b1bae816 LV |
104 | * |
105 | * If the event has the disabled property, the check will have no performance | |
106 | * impact. | |
b1bae816 LV |
107 | */ |
108 | #define trace_event_get_state(id) \ | |
585ec727 | 109 | ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id)) |
b1bae816 | 110 | |
d87aa138 SH |
111 | /** |
112 | * trace_event_get_state_backends: | |
113 | * @id: Event identifier name. | |
114 | * | |
115 | * Get the tracing state of an event, both static and dynamic state from all | |
116 | * compiled-in backends. | |
117 | * | |
118 | * If the event has the disabled property, the check will have no performance | |
119 | * impact. | |
120 | * | |
121 | * Returns: true if at least one backend has the event enabled and the event | |
122 | * does not have the disabled property. | |
123 | */ | |
124 | #define trace_event_get_state_backends(id) \ | |
125 | ((id ##_ENABLED) && id ##_BACKEND_DSTATE()) | |
126 | ||
b1bae816 LV |
127 | /** |
128 | * trace_event_get_state_static: | |
129 | * @id: Event identifier. | |
130 | * | |
131 | * Get the static tracing state of an event. | |
132 | * | |
133 | * Use the define 'TRACE_${EVENT_NAME}_ENABLED' for compile-time checks (it will | |
134 | * be set to 1 or 0 according to the presence of the disabled property). | |
135 | */ | |
136 | static bool trace_event_get_state_static(TraceEvent *ev); | |
137 | ||
138 | /** | |
139 | * trace_event_get_state_dynamic: | |
140 | * | |
141 | * Get the dynamic tracing state of an event. | |
48151859 LV |
142 | * |
143 | * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs. | |
b1bae816 LV |
144 | */ |
145 | static bool trace_event_get_state_dynamic(TraceEvent *ev); | |
146 | ||
b1bae816 LV |
147 | /** |
148 | * trace_event_set_state_dynamic: | |
149 | * | |
150 | * Set the dynamic tracing state of an event. | |
151 | * | |
48151859 LV |
152 | * If the event has the 'vcpu' property, sets the state on all vCPUs. |
153 | * | |
b1bae816 LV |
154 | * Pre-condition: trace_event_get_state_static(ev) == true |
155 | */ | |
48151859 LV |
156 | void trace_event_set_state_dynamic(TraceEvent *ev, bool state); |
157 | ||
b1bae816 | 158 | /** |
5b808275 | 159 | * trace_init_backends: |
e4858974 | 160 | * |
b1bae816 LV |
161 | * Initialize the tracing backend. |
162 | * | |
5b808275 | 163 | * Returns: Whether the backends could be successfully initialized. |
23d15e86 | 164 | */ |
41fc57e4 | 165 | bool trace_init_backends(void); |
45bd0b41 | 166 | |
41fc57e4 PB |
167 | /** |
168 | * trace_init_file: | |
41fc57e4 PB |
169 | * |
170 | * Record the name of the output file for the tracing backend. | |
171 | * Exits if no selected backend does not support specifying the | |
92eecfff | 172 | * output file, and a file was specified with "-trace file=...". |
41fc57e4 | 173 | */ |
92eecfff | 174 | void trace_init_file(void); |
41fc57e4 | 175 | |
e9527dd3 PB |
176 | /** |
177 | * trace_list_events: | |
6745c8a0 | 178 | * @f: Where to send output. |
e9527dd3 PB |
179 | * |
180 | * List all available events. | |
181 | */ | |
6745c8a0 | 182 | void trace_list_events(FILE *f); |
e9527dd3 | 183 | |
10578a25 PB |
184 | /** |
185 | * trace_enable_events: | |
186 | * @line_buf: A string with a glob pattern of events to be enabled or, | |
187 | * if the string starts with '-', disabled. | |
188 | * | |
189 | * Enable or disable matching events. | |
190 | */ | |
191 | void trace_enable_events(const char *line_buf); | |
192 | ||
e9e0bb2a DL |
193 | /** |
194 | * Definition of QEMU options describing trace subsystem configuration | |
195 | */ | |
196 | extern QemuOptsList qemu_trace_opts; | |
197 | ||
198 | /** | |
199 | * trace_opt_parse: | |
200 | * @optarg: A string argument of --trace command line argument | |
201 | * | |
202 | * Initialize tracing subsystem. | |
e9e0bb2a | 203 | */ |
92eecfff | 204 | void trace_opt_parse(const char *optarg); |
b1bae816 | 205 | |
b7d48952 DB |
206 | /** |
207 | * trace_get_vcpu_event_count: | |
208 | * | |
209 | * Return the number of known vcpu-specific events | |
210 | */ | |
211 | uint32_t trace_get_vcpu_event_count(void); | |
212 | ||
48151859 | 213 | |
a3227142 | 214 | #include "control-internal.h" |
b1bae816 | 215 | |
175de524 | 216 | #endif /* TRACE__CONTROL_H */ |