X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=trace%2Fcontrol.h;h=23b8393b297e379bb64e504f99a4606d705be768;hb=8f3e5ce773c62bb5c4a847f3a9a5c98bbb3b359f;hp=0413b28769d486d014243baad783dcdc2993159b;hpb=1df8ffb286b65cd446b77f54418293487a85dc43;p=mirror_qemu.git diff --git a/trace/control.h b/trace/control.h index 0413b28769..23b8393b29 100644 --- a/trace/control.h +++ b/trace/control.h @@ -10,36 +10,59 @@ #ifndef TRACE__CONTROL_H #define TRACE__CONTROL_H -#include "qemu-common.h" -#include "trace/generated-events.h" +#include "event-internal.h" + +typedef struct TraceEventIter { + /* iter state */ + size_t event; + size_t group; + /* filter conditions */ + size_t group_id; + const char *pattern; +} TraceEventIter; /** - * TraceEventID: - * - * Unique tracing event identifier. - * - * These are named as 'TRACE_${EVENT_NAME}'. + * trace_event_iter_init_all: + * @iter: the event iterator struct * - * See also: "trace/generated-events.h" + * Initialize the event iterator struct @iter, + * for all events. */ -enum TraceEventID; +void trace_event_iter_init_all(TraceEventIter *iter); /** - * trace_event_id: - * @id: Event identifier. - * - * Get an event by its identifier. + * trace_event_iter_init_pattern: + * @iter: the event iterator struct + * @pattern: pattern to filter events on name * - * This routine has a constant cost, as opposed to trace_event_name and - * trace_event_pattern. + * Initialize the event iterator struct @iter, + * using @pattern to filter out events + * with non-matching names. + */ +void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern); + +/** + * trace_event_iter_init_group: + * @iter: the event iterator struct + * @group_id: group_id to filter events by group. * - * Pre-conditions: The identifier is valid. + * Initialize the event iterator struct @iter, + * using @group_id to filter for events in the group. + */ +void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id); + +/** + * trace_event_iter_next: + * @iter: the event iterator struct * - * 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: @@ -51,17 +74,6 @@ static TraceEvent *trace_event_id(TraceEventID id); */ 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: * @@ -69,31 +81,23 @@ TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev); */ static bool trace_event_is_pattern(const char *str); -/** - * trace_event_count: - * - * Return the number of events. - */ -static TraceEventID trace_event_count(void); - - /** * trace_event_get_id: * * Get the identifier of an event. */ -static TraceEventID trace_event_get_id(TraceEvent *ev); +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_COUNT means the event is not vCPU-specific + * Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific * (does not have the "vcpu" property). */ -static TraceEventVCPUID trace_event_get_vcpu_id(TraceEvent *ev); +static uint32_t trace_event_get_vcpu_id(TraceEvent *ev); /** * trace_event_is_vcpu: @@ -111,34 +115,31 @@ static const char * trace_event_get_name(TraceEvent *ev); /** * 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_vcpu_state: - * @vcpu: Target vCPU. - * @id: Event identifier (TraceEventID). - * @vcpu_id: Per-vCPU event identifier (TraceEventVCPUID). + * trace_event_get_state_backends: + * @id: Event identifier name. * - * Get the tracing state of an event (both static and dynamic) for the given - * vCPU. + * 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. * - * As a down side, you must always use an immediate #TraceEventID value. + * Returns: true if at least one backend has the event enabled and the event + * does not have the disabled property. */ -#define trace_event_get_vcpu_state(vcpu, id, vcpu_id) \ - ((id ##_ENABLED) && trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id)) +#define trace_event_get_state_backends(id) \ + ((id ##_ENABLED) && id ##_BACKEND_DSTATE()) /** * trace_event_get_state_static: @@ -160,39 +161,6 @@ static bool trace_event_get_state_static(TraceEvent *ev); */ static bool trace_event_get_state_dynamic(TraceEvent *ev); -/** - * trace_event_get_vcpu_state_dynamic: - * - * Get the dynamic tracing state of an event for the given vCPU. - */ -static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev); - -/** - * trace_event_set_state: - * - * Set the tracing state of an event (only if possible). - */ -#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) - -/** - * trace_event_set_vcpu_state: - * - * Set the tracing state of an event for the given vCPU (only if not disabled). - */ -#define trace_event_set_vcpu_state(vcpu, id, state) \ - do { \ - if ((id ##_ENABLED)) { \ - TraceEvent *_e = trace_event_id(id); \ - trace_event_set_vcpu_state_dynamic(vcpu, _e, state); \ - } \ - } while (0) - /** * trace_event_set_state_dynamic: * @@ -210,6 +178,9 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool state); * Set the dynamic tracing state of an event for the given vCPU. * * 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). */ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state); @@ -218,8 +189,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, /** * trace_init_backends: - * @file: Name of trace output file; may be NULL. - * Corresponds to commandline option "-trace file=...". * * Initialize the tracing backend. * @@ -229,21 +198,36 @@ bool trace_init_backends(void); /** * trace_init_file: - * @file: Name of trace output file; may be NULL. - * 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 - * output file, and a non-NULL file was passed. + * output file, and a file was specified with "-trace file=...". + */ +void trace_init_file(void); + +/** + * trace_init_vcpu: + * @vcpu: Added vCPU. + * + * Set initial dynamic event state for a hot-plugged vCPU. */ -void trace_init_file(const char *file); +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: + * @f: Where to send output. * * List all available events. */ -void trace_list_events(void); +void trace_list_events(FILE *f); /** * trace_enable_events: @@ -264,20 +248,17 @@ extern QemuOptsList qemu_trace_opts; * @optarg: A string argument of --trace command line argument * * Initialize tracing subsystem. - * - * Returns the filename to save trace to. It must be freed with g_free(). */ -char *trace_opt_parse(const char *optarg); +void trace_opt_parse(const char *optarg); /** - * trace_init_vcpu_events: + * trace_get_vcpu_event_count: * - * Re-synchronize initial event state with vCPUs (which can be created after - * trace_init_events()). + * Return the number of known vcpu-specific events */ -void trace_init_vcpu_events(void); +uint32_t trace_get_vcpu_event_count(void); -#include "trace/control-internal.h" +#include "control-internal.h" #endif /* TRACE__CONTROL_H */