vfio/container: Introduce vfio_address_space_insert()
[qemu/armbru.git] / trace / control.h
blob6754bfe052b8a7eb2f93ebc4f7cc556990ac0d51
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 /* iter state */
17 size_t event;
18 size_t group;
19 /* filter conditions */
20 size_t group_id;
21 const char *pattern;
22 } TraceEventIter;
25 /**
26 * trace_event_iter_init_all:
27 * @iter: the event iterator struct
29 * Initialize the event iterator struct @iter,
30 * for all events.
32 void trace_event_iter_init_all(TraceEventIter *iter);
34 /**
35 * trace_event_iter_init_pattern:
36 * @iter: the event iterator struct
37 * @pattern: pattern to filter events on name
39 * Initialize the event iterator struct @iter,
40 * using @pattern to filter out events
41 * with non-matching names.
43 void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
45 /**
46 * trace_event_iter_init_group:
47 * @iter: the event iterator struct
48 * @group_id: group_id to filter events by group.
50 * Initialize the event iterator struct @iter,
51 * using @group_id to filter for events in the group.
53 void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id);
55 /**
56 * trace_event_iter_next:
57 * @iter: the event iterator struct
59 * Get the next event, if any. When this returns NULL,
60 * the iterator should no longer be used.
62 * Returns: the next event, or NULL if no more events exist
64 TraceEvent *trace_event_iter_next(TraceEventIter *iter);
67 /**
68 * trace_event_name:
69 * @id: Event name.
71 * Search an event by its name.
73 * Returns: pointer to #TraceEvent or NULL if not found.
75 TraceEvent *trace_event_name(const char *name);
77 /**
78 * trace_event_is_pattern:
80 * Whether the given string is an event name pattern.
82 static bool trace_event_is_pattern(const char *str);
85 /**
86 * trace_event_get_id:
88 * Get the identifier of an event.
90 static uint32_t trace_event_get_id(TraceEvent *ev);
92 /**
93 * trace_event_get_name:
95 * Get the name of an event.
97 static const char * trace_event_get_name(TraceEvent *ev);
99 /**
100 * trace_event_get_state:
101 * @id: Event identifier name.
103 * Get the tracing state of an event, both static and the QEMU dynamic state.
105 * If the event has the disabled property, the check will have no performance
106 * impact.
108 #define trace_event_get_state(id) \
109 ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
112 * trace_event_get_state_backends:
113 * @id: Event identifier name.
115 * Get the tracing state of an event, both static and dynamic state from all
116 * compiled-in backends.
118 * If the event has the disabled property, the check will have no performance
119 * impact.
121 * Returns: true if at least one backend has the event enabled and the event
122 * does not have the disabled property.
124 #define trace_event_get_state_backends(id) \
125 ((id ##_ENABLED) && id ##_BACKEND_DSTATE())
128 * trace_event_get_state_static:
129 * @id: Event identifier.
131 * Get the static tracing state of an event.
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).
136 static bool trace_event_get_state_static(TraceEvent *ev);
139 * trace_event_get_state_dynamic:
141 * Get the dynamic tracing state of an event.
143 * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
145 static bool trace_event_get_state_dynamic(TraceEvent *ev);
148 * trace_event_set_state_dynamic:
150 * Set the dynamic tracing state of an event.
152 * If the event has the 'vcpu' property, sets the state on all vCPUs.
154 * Pre-condition: trace_event_get_state_static(ev) == true
156 void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
159 * trace_init_backends:
161 * Initialize the tracing backend.
163 * Returns: Whether the backends could be successfully initialized.
165 bool trace_init_backends(void);
168 * trace_init_file:
170 * Record the name of the output file for the tracing backend.
171 * Exits if no selected backend does not support specifying the
172 * output file, and a file was specified with "-trace file=...".
174 void trace_init_file(void);
177 * trace_list_events:
178 * @f: Where to send output.
180 * List all available events.
182 void trace_list_events(FILE *f);
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.
189 * Enable or disable matching events.
191 void trace_enable_events(const char *line_buf);
194 * Definition of QEMU options describing trace subsystem configuration
196 extern QemuOptsList qemu_trace_opts;
199 * trace_opt_parse:
200 * @optstr: A string argument of --trace command line argument
202 * Initialize tracing subsystem.
204 void trace_opt_parse(const char *optstr);
207 * trace_get_vcpu_event_count:
209 * Return the number of known vcpu-specific events
211 uint32_t trace_get_vcpu_event_count(void);
214 #include "control-internal.h"
216 #endif /* TRACE__CONTROL_H */