migration: Make explicit that we are quitting multifd
[qemu/ar7.git] / trace / control.h
blob570492d6e829bc9a754605d427c0179a92f0f5c7
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_H
11 #define TRACE__CONTROL_H
13 #include "event-internal.h"
15 typedef struct TraceEventIter {
16 size_t event;
17 size_t group;
18 const char *pattern;
19 } TraceEventIter;
22 /**
23 * trace_event_iter_init:
24 * @iter: the event iterator struct
25 * @pattern: optional pattern to filter events on name
27 * Initialize the event iterator struct @iter,
28 * optionally using @pattern to filter out events
29 * with non-matching names.
31 void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
33 /**
34 * trace_event_iter_next:
35 * @iter: the event iterator struct
37 * Get the next event, if any. When this returns NULL,
38 * the iterator should no longer be used.
40 * Returns: the next event, or NULL if no more events exist
42 TraceEvent *trace_event_iter_next(TraceEventIter *iter);
45 /**
46 * trace_event_name:
47 * @id: Event name.
49 * Search an event by its name.
51 * Returns: pointer to #TraceEvent or NULL if not found.
53 TraceEvent *trace_event_name(const char *name);
55 /**
56 * trace_event_is_pattern:
58 * Whether the given string is an event name pattern.
60 static bool trace_event_is_pattern(const char *str);
63 /**
64 * trace_event_get_id:
66 * Get the identifier of an event.
68 static uint32_t trace_event_get_id(TraceEvent *ev);
70 /**
71 * trace_event_get_vcpu_id:
73 * Get the per-vCPU identifier of an event.
75 * Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific
76 * (does not have the "vcpu" property).
78 static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);
80 /**
81 * trace_event_is_vcpu:
83 * Whether this is a per-vCPU event.
85 static bool trace_event_is_vcpu(TraceEvent *ev);
87 /**
88 * trace_event_get_name:
90 * Get the name of an event.
92 static const char * trace_event_get_name(TraceEvent *ev);
94 /**
95 * trace_event_get_state:
96 * @id: Event identifier name.
98 * Get the tracing state of an event, both static and the QEMU dynamic state.
100 * If the event has the disabled property, the check will have no performance
101 * impact.
103 #define trace_event_get_state(id) \
104 ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
107 * trace_event_get_state_backends:
108 * @id: Event identifier name.
110 * Get the tracing state of an event, both static and dynamic state from all
111 * compiled-in backends.
113 * If the event has the disabled property, the check will have no performance
114 * impact.
116 * Returns: true if at least one backend has the event enabled and the event
117 * does not have the disabled property.
119 #define trace_event_get_state_backends(id) \
120 ((id ##_ENABLED) && id ##_BACKEND_DSTATE())
123 * trace_event_get_vcpu_state:
124 * @vcpu: Target vCPU.
125 * @id: Event identifier name.
127 * Get the tracing state of an event (both static and dynamic) for the given
128 * vCPU.
130 * If the event has the disabled property, the check will have no performance
131 * impact.
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))
139 * trace_event_get_state_static:
140 * @id: Event identifier.
142 * Get the static tracing state of an event.
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).
147 static bool trace_event_get_state_static(TraceEvent *ev);
150 * trace_event_get_state_dynamic:
152 * Get the dynamic tracing state of an event.
154 * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
156 static bool trace_event_get_state_dynamic(TraceEvent *ev);
159 * trace_event_get_vcpu_state_dynamic:
161 * Get the dynamic tracing state of an event for the given vCPU.
163 static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
167 * trace_event_set_state_dynamic:
169 * Set the dynamic tracing state of an event.
171 * If the event has the 'vcpu' property, sets the state on all vCPUs.
173 * Pre-condition: trace_event_get_state_static(ev) == true
175 void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
178 * trace_event_set_vcpu_state_dynamic:
180 * Set the dynamic tracing state of an event for the given vCPU.
182 * Pre-condition: trace_event_get_vcpu_state_static(ev) == true
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).
187 void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
188 TraceEvent *ev, bool state);
193 * trace_init_backends:
194 * @file: Name of trace output file; may be NULL.
195 * Corresponds to commandline option "--trace file=...".
197 * Initialize the tracing backend.
199 * Returns: Whether the backends could be successfully initialized.
201 bool trace_init_backends(void);
204 * trace_init_file:
205 * @file: Name of trace output file; may be NULL.
206 * Corresponds to commandline option "--trace file=...".
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.
212 void trace_init_file(const char *file);
215 * trace_init_vcpu:
216 * @vcpu: Added vCPU.
218 * Set initial dynamic event state for a hot-plugged vCPU.
220 void trace_init_vcpu(CPUState *vcpu);
223 * trace_fini_vcpu:
224 * @vcpu: Removed vCPU.
226 * Disable dynamic event state for a hot-unplugged vCPU.
228 void trace_fini_vcpu(CPUState *vcpu);
231 * trace_list_events:
233 * List all available events.
235 void trace_list_events(void);
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.
242 * Enable or disable matching events.
244 void trace_enable_events(const char *line_buf);
247 * Definition of QEMU options describing trace subsystem configuration
249 extern QemuOptsList qemu_trace_opts;
252 * trace_opt_parse:
253 * @optarg: A string argument of --trace command line argument
255 * Initialize tracing subsystem.
257 * Returns the filename to save trace to. It must be freed with g_free().
259 char *trace_opt_parse(const char *optarg);
262 * trace_get_vcpu_event_count:
264 * Return the number of known vcpu-specific events
266 uint32_t trace_get_vcpu_event_count(void);
269 #include "control-internal.h"
271 #endif /* TRACE__CONTROL_H */