#ifndef TRACE__CONTROL_H
#define TRACE__CONTROL_H
-#include "qemu-common.h"
-#include "trace/generated-events.h"
+#include "event-internal.h"
+
+typedef struct TraceEventIter {
+ size_t event;
+ size_t group;
+ const char *pattern;
+} TraceEventIter;
/**
- * TraceEventID:
- *
- * Unique tracing event identifier.
+ * trace_event_iter_init:
+ * @iter: the event iterator struct
+ * @pattern: optional pattern to filter events on name
*
- * These are named as 'TRACE_${EVENT_NAME}'.
- *
- * See also: "trace/generated-events.h"
+ * Initialize the event iterator struct @iter,
+ * optionally using @pattern to filter out events
+ * with non-matching names.
*/
-enum TraceEventID;
+void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
/**
- * trace_event_id:
- * @id: Event identifier.
+ * trace_event_iter_next:
+ * @iter: the event iterator struct
*
- * Get an event by its identifier.
- *
- * This routine has a constant cost, as opposed to trace_event_name and
- * trace_event_pattern.
- *
- * Pre-conditions: The identifier is valid.
- *
- * Returns: pointer to #TraceEvent.
+ * Get the next event, if any. When this returns NULL,
+ * the iterator should no longer be used.
*
+ * Returns: the next event, or NULL if no more events exist
*/
-static TraceEvent *trace_event_id(TraceEventID id);
+TraceEvent *trace_event_iter_next(TraceEventIter *iter);
+
/**
* trace_event_name:
*/
TraceEvent *trace_event_name(const char *name);
-/**
- * trace_event_pattern:
- * @pat: Event name pattern.
- * @ev: Event to start searching from (not included).
- *
- * Get all events with a given name pattern.
- *
- * Returns: pointer to #TraceEvent or NULL if not found.
- */
-TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev);
-
/**
* trace_event_is_pattern:
*
*/
static bool trace_event_is_pattern(const char *str);
+
/**
- * trace_event_count:
+ * trace_event_get_id:
*
- * Return the number of events.
+ * Get the identifier of an event.
*/
-static TraceEventID trace_event_count(void);
-
+static uint32_t trace_event_get_id(TraceEvent *ev);
+/**
+ * trace_event_get_vcpu_id:
+ *
+ * Get the per-vCPU identifier of an event.
+ *
+ * Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific
+ * (does not have the "vcpu" property).
+ */
+static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);
/**
- * trace_event_get_id:
+ * trace_event_is_vcpu:
*
- * Get the identifier of an event.
+ * Whether this is a per-vCPU event.
*/
-static TraceEventID trace_event_get_id(TraceEvent *ev);
+static bool trace_event_is_vcpu(TraceEvent *ev);
/**
* trace_event_get_name:
/**
* trace_event_get_state:
- * @id: Event identifier.
+ * @id: Event identifier name.
*
- * Get the tracing state of an event (both static and dynamic).
+ * Get the tracing state of an event, both static and the QEMU dynamic state.
*
* If the event has the disabled property, the check will have no performance
* impact.
- *
- * As a down side, you must always use an immediate #TraceEventID value.
*/
#define trace_event_get_state(id) \
((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
+/**
+ * trace_event_get_state_backends:
+ * @id: Event identifier name.
+ *
+ * Get the tracing state of an event, both static and dynamic state from all
+ * compiled-in backends.
+ *
+ * If the event has the disabled property, the check will have no performance
+ * impact.
+ *
+ * Returns: true if at least one backend has the event enabled and the event
+ * does not have the disabled property.
+ */
+#define trace_event_get_state_backends(id) \
+ ((id ##_ENABLED) && id ##_BACKEND_DSTATE())
+
/**
* trace_event_get_state_static:
* @id: Event identifier.
* trace_event_get_state_dynamic:
*
* Get the dynamic tracing state of an event.
+ *
+ * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
*/
static bool trace_event_get_state_dynamic(TraceEvent *ev);
/**
- * trace_event_set_state:
+ * trace_event_set_state_dynamic:
*
- * Set the tracing state of an event (only if possible).
+ * Set the dynamic tracing state of an event.
+ *
+ * If the event has the 'vcpu' property, sets the state on all vCPUs.
+ *
+ * Pre-condition: trace_event_get_state_static(ev) == true
*/
-#define trace_event_set_state(id, state) \
- do { \
- if ((id ##_ENABLED)) { \
- TraceEvent *_e = trace_event_id(id); \
- trace_event_set_state_dynamic(_e, state); \
- } \
- } while (0)
+void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
/**
- * trace_event_set_state_dynamic:
+ * trace_event_set_vcpu_state_dynamic:
*
- * Set the dynamic tracing state of an event.
+ * Set the dynamic tracing state of an event for the given vCPU.
*
- * Pre-condition: trace_event_get_state_static(ev) == true
+ * Pre-condition: trace_event_get_vcpu_state_static(ev) == true
+ *
+ * Note: Changes for execution-time events with the 'tcg' property will not be
+ * propagated until the next TB is executed (iff executing in TCG mode).
*/
-static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
+void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
+ TraceEvent *ev, bool state);
/**
* trace_init_backends:
* @file: Name of trace output file; may be NULL.
- * Corresponds to commandline option "-trace file=...".
+ * Corresponds to commandline option "--trace file=...".
*
* Initialize the tracing backend.
*
/**
* trace_init_file:
* @file: Name of trace output file; may be NULL.
- * Corresponds to commandline option "-trace file=...".
+ * Corresponds to commandline option "--trace file=...".
*
* Record the name of the output file for the tracing backend.
* Exits if no selected backend does not support specifying the
*/
void trace_init_file(const char *file);
+/**
+ * trace_init_vcpu:
+ * @vcpu: Added vCPU.
+ *
+ * Set initial dynamic event state for a hot-plugged vCPU.
+ */
+void trace_init_vcpu(CPUState *vcpu);
+
+/**
+ * trace_fini_vcpu:
+ * @vcpu: Removed vCPU.
+ *
+ * Disable dynamic event state for a hot-unplugged vCPU.
+ */
+void trace_fini_vcpu(CPUState *vcpu);
+
/**
* trace_list_events:
*
*/
char *trace_opt_parse(const char *optarg);
-#include "trace/control-internal.h"
+/**
+ * trace_get_vcpu_event_count:
+ *
+ * Return the number of known vcpu-specific events
+ */
+uint32_t trace_get_vcpu_event_count(void);
+
+
+#include "control-internal.h"
-#endif /* TRACE__CONTROL_H */
+#endif /* TRACE__CONTROL_H */