]> git.proxmox.com Git - mirror_qemu.git/blame - trace/control.h
qmp: Add deprecation information to query-machines
[mirror_qemu.git] / trace / control.h
CommitLineData
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
DB
15typedef struct TraceEventIter {
16 size_t event;
fe4db84d 17 size_t group;
6a1b0f3a
DB
18 const char *pattern;
19} TraceEventIter;
fc764105 20
6a1b0f3a
DB
21
22/**
23 * trace_event_iter_init:
24 * @iter: the event iterator struct
25 * @pattern: optional pattern to filter events on name
26 *
27 * Initialize the event iterator struct @iter,
28 * optionally using @pattern to filter out events
29 * with non-matching names.
30 */
31void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
32
33/**
34 * trace_event_iter_next:
35 * @iter: the event iterator struct
36 *
37 * Get the next event, if any. When this returns NULL,
38 * the iterator should no longer be used.
39 *
40 * Returns: the next event, or NULL if no more events exist
41 */
42TraceEvent *trace_event_iter_next(TraceEventIter *iter);
43
b1bae816
LV
44
45/**
46 * trace_event_name:
47 * @id: Event name.
48 *
49 * Search an event by its name.
50 *
51 * Returns: pointer to #TraceEvent or NULL if not found.
52 */
53TraceEvent *trace_event_name(const char *name);
54
b1bae816
LV
55/**
56 * trace_event_is_pattern:
57 *
58 * Whether the given string is an event name pattern.
59 */
60static bool trace_event_is_pattern(const char *str);
61
b1bae816
LV
62
63/**
64 * trace_event_get_id:
65 *
66 * Get the identifier of an event.
67 */
ef4c9fc8 68static uint32_t trace_event_get_id(TraceEvent *ev);
b1bae816 69
17f7ac75
LV
70/**
71 * trace_event_get_vcpu_id:
72 *
73 * Get the per-vCPU identifier of an event.
74 *
ef4c9fc8 75 * Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific
17f7ac75
LV
76 * (does not have the "vcpu" property).
77 */
ef4c9fc8 78static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);
17f7ac75
LV
79
80/**
81 * trace_event_is_vcpu:
82 *
83 * Whether this is a per-vCPU event.
84 */
85static bool trace_event_is_vcpu(TraceEvent *ev);
86
b1bae816
LV
87/**
88 * trace_event_get_name:
fc764105 89 *
b1bae816 90 * Get the name of an event.
fc764105 91 */
b1bae816 92static const char * trace_event_get_name(TraceEvent *ev);
e4858974 93
b1bae816
LV
94/**
95 * trace_event_get_state:
ef4c9fc8 96 * @id: Event identifier name.
b1bae816 97 *
d87aa138 98 * Get the tracing state of an event, both static and the QEMU dynamic state.
b1bae816
LV
99 *
100 * If the event has the disabled property, the check will have no performance
101 * impact.
b1bae816
LV
102 */
103#define trace_event_get_state(id) \
585ec727 104 ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
b1bae816 105
d87aa138
SH
106/**
107 * trace_event_get_state_backends:
108 * @id: Event identifier name.
109 *
110 * Get the tracing state of an event, both static and dynamic state from all
111 * compiled-in backends.
112 *
113 * If the event has the disabled property, the check will have no performance
114 * impact.
115 *
116 * Returns: true if at least one backend has the event enabled and the event
117 * does not have the disabled property.
118 */
119#define trace_event_get_state_backends(id) \
120 ((id ##_ENABLED) && id ##_BACKEND_DSTATE())
121
48151859
LV
122/**
123 * trace_event_get_vcpu_state:
124 * @vcpu: Target vCPU.
ef4c9fc8 125 * @id: Event identifier name.
48151859
LV
126 *
127 * Get the tracing state of an event (both static and dynamic) for the given
128 * vCPU.
129 *
130 * If the event has the disabled property, the check will have no performance
131 * impact.
48151859 132 */
ef4c9fc8
DB
133#define trace_event_get_vcpu_state(vcpu, id) \
134 ((id ##_ENABLED) && \
135 trace_event_get_vcpu_state_dynamic_by_vcpu_id( \
136 vcpu, _ ## id ## _EVENT.vcpu_id))
48151859 137
b1bae816
LV
138/**
139 * trace_event_get_state_static:
140 * @id: Event identifier.
141 *
142 * Get the static tracing state of an event.
143 *
144 * Use the define 'TRACE_${EVENT_NAME}_ENABLED' for compile-time checks (it will
145 * be set to 1 or 0 according to the presence of the disabled property).
146 */
147static bool trace_event_get_state_static(TraceEvent *ev);
148
149/**
150 * trace_event_get_state_dynamic:
151 *
152 * Get the dynamic tracing state of an event.
48151859
LV
153 *
154 * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
b1bae816
LV
155 */
156static bool trace_event_get_state_dynamic(TraceEvent *ev);
157
48151859
LV
158/**
159 * trace_event_get_vcpu_state_dynamic:
160 *
161 * Get the dynamic tracing state of an event for the given vCPU.
162 */
163static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
164
48151859 165
b1bae816
LV
166/**
167 * trace_event_set_state_dynamic:
168 *
169 * Set the dynamic tracing state of an event.
170 *
48151859
LV
171 * If the event has the 'vcpu' property, sets the state on all vCPUs.
172 *
b1bae816
LV
173 * Pre-condition: trace_event_get_state_static(ev) == true
174 */
48151859
LV
175void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
176
177/**
178 * trace_event_set_vcpu_state_dynamic:
179 *
180 * Set the dynamic tracing state of an event for the given vCPU.
181 *
182 * Pre-condition: trace_event_get_vcpu_state_static(ev) == true
61a67f71
LV
183 *
184 * Note: Changes for execution-time events with the 'tcg' property will not be
185 * propagated until the next TB is executed (iff executing in TCG mode).
48151859
LV
186 */
187void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
188 TraceEvent *ev, bool state);
b1bae816 189
b1bae816
LV
190
191
b1bae816 192/**
5b808275 193 * trace_init_backends:
b1bae816 194 * @file: Name of trace output file; may be NULL.
db817b8c 195 * Corresponds to commandline option "--trace file=...".
e4858974 196 *
b1bae816
LV
197 * Initialize the tracing backend.
198 *
5b808275 199 * Returns: Whether the backends could be successfully initialized.
23d15e86 200 */
41fc57e4 201bool trace_init_backends(void);
45bd0b41 202
41fc57e4
PB
203/**
204 * trace_init_file:
205 * @file: Name of trace output file; may be NULL.
db817b8c 206 * Corresponds to commandline option "--trace file=...".
41fc57e4
PB
207 *
208 * Record the name of the output file for the tracing backend.
209 * Exits if no selected backend does not support specifying the
210 * output file, and a non-NULL file was passed.
211 */
212void trace_init_file(const char *file);
213
2bfe11c8
LV
214/**
215 * trace_init_vcpu:
216 * @vcpu: Added vCPU.
217 *
218 * Set initial dynamic event state for a hot-plugged vCPU.
219 */
220void trace_init_vcpu(CPUState *vcpu);
221
82e95ec8
LV
222/**
223 * trace_fini_vcpu:
224 * @vcpu: Removed vCPU.
225 *
226 * Disable dynamic event state for a hot-unplugged vCPU.
227 */
228void trace_fini_vcpu(CPUState *vcpu);
229
e9527dd3
PB
230/**
231 * trace_list_events:
232 *
233 * List all available events.
234 */
235void trace_list_events(void);
236
10578a25
PB
237/**
238 * trace_enable_events:
239 * @line_buf: A string with a glob pattern of events to be enabled or,
240 * if the string starts with '-', disabled.
241 *
242 * Enable or disable matching events.
243 */
244void trace_enable_events(const char *line_buf);
245
e9e0bb2a
DL
246/**
247 * Definition of QEMU options describing trace subsystem configuration
248 */
249extern QemuOptsList qemu_trace_opts;
250
251/**
252 * trace_opt_parse:
253 * @optarg: A string argument of --trace command line argument
254 *
255 * Initialize tracing subsystem.
256 *
257 * Returns the filename to save trace to. It must be freed with g_free().
258 */
259char *trace_opt_parse(const char *optarg);
b1bae816 260
b7d48952
DB
261/**
262 * trace_get_vcpu_event_count:
263 *
264 * Return the number of known vcpu-specific events
265 */
266uint32_t trace_get_vcpu_event_count(void);
267
48151859 268
a3227142 269#include "control-internal.h"
b1bae816 270
175de524 271#endif /* TRACE__CONTROL_H */