2011-08-31 22:31:03 +04:00
|
|
|
/*
|
|
|
|
* Interface for configuring and controlling the state of tracing events.
|
|
|
|
*
|
2016-02-25 19:43:38 +03:00
|
|
|
* Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
|
2011-08-31 22:31:03 +04:00
|
|
|
*
|
2013-03-05 17:47:38 +04:00
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2011-08-31 22:31:03 +04:00
|
|
|
*/
|
|
|
|
|
2013-03-05 17:47:38 +04:00
|
|
|
#ifndef TRACE__CONTROL_H
|
|
|
|
#define TRACE__CONTROL_H
|
2011-08-31 22:31:03 +04:00
|
|
|
|
2016-10-04 16:35:55 +03:00
|
|
|
#include "event-internal.h"
|
2011-08-31 22:31:18 +04:00
|
|
|
|
2016-10-04 16:35:42 +03:00
|
|
|
typedef struct TraceEventIter {
|
2021-06-01 16:24:04 +03:00
|
|
|
/* iter state */
|
2016-10-04 16:35:42 +03:00
|
|
|
size_t event;
|
2016-10-04 16:35:52 +03:00
|
|
|
size_t group;
|
2021-06-01 16:24:04 +03:00
|
|
|
/* filter conditions */
|
|
|
|
size_t group_id;
|
2016-10-04 16:35:42 +03:00
|
|
|
const char *pattern;
|
|
|
|
} TraceEventIter;
|
2011-08-31 22:31:18 +04:00
|
|
|
|
2016-10-04 16:35:42 +03:00
|
|
|
|
|
|
|
/**
|
2021-06-01 16:24:03 +03:00
|
|
|
* trace_event_iter_init_all:
|
2016-10-04 16:35:42 +03:00
|
|
|
* @iter: the event iterator struct
|
|
|
|
*
|
|
|
|
* Initialize the event iterator struct @iter,
|
2021-06-01 16:24:03 +03:00
|
|
|
* for all events.
|
|
|
|
*/
|
|
|
|
void trace_event_iter_init_all(TraceEventIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_iter_init_pattern:
|
|
|
|
* @iter: the event iterator struct
|
|
|
|
* @pattern: pattern to filter events on name
|
|
|
|
*
|
|
|
|
* Initialize the event iterator struct @iter,
|
|
|
|
* using @pattern to filter out events
|
2016-10-04 16:35:42 +03:00
|
|
|
* with non-matching names.
|
|
|
|
*/
|
2021-06-01 16:24:03 +03:00
|
|
|
void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
|
2016-10-04 16:35:42 +03:00
|
|
|
|
2021-06-01 16:24:04 +03:00
|
|
|
/**
|
|
|
|
* trace_event_iter_init_group:
|
|
|
|
* @iter: the event iterator struct
|
|
|
|
* @group_id: group_id to filter events by group.
|
|
|
|
*
|
|
|
|
* 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);
|
|
|
|
|
2016-10-04 16:35:42 +03:00
|
|
|
/**
|
|
|
|
* trace_event_iter_next:
|
|
|
|
* @iter: the event iterator struct
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
TraceEvent *trace_event_iter_next(TraceEventIter *iter);
|
|
|
|
|
2013-03-05 17:47:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_name:
|
|
|
|
* @id: Event name.
|
|
|
|
*
|
|
|
|
* Search an event by its name.
|
|
|
|
*
|
|
|
|
* Returns: pointer to #TraceEvent or NULL if not found.
|
|
|
|
*/
|
|
|
|
TraceEvent *trace_event_name(const char *name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_is_pattern:
|
|
|
|
*
|
|
|
|
* Whether the given string is an event name pattern.
|
|
|
|
*/
|
|
|
|
static bool trace_event_is_pattern(const char *str);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_get_id:
|
|
|
|
*
|
|
|
|
* Get the identifier of an event.
|
|
|
|
*/
|
2016-10-04 16:35:49 +03:00
|
|
|
static uint32_t trace_event_get_id(TraceEvent *ev);
|
2013-03-05 17:47:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_get_name:
|
2011-08-31 22:31:18 +04:00
|
|
|
*
|
2013-03-05 17:47:38 +04:00
|
|
|
* Get the name of an event.
|
2011-08-31 22:31:18 +04:00
|
|
|
*/
|
2013-03-05 17:47:38 +04:00
|
|
|
static const char * trace_event_get_name(TraceEvent *ev);
|
2011-08-31 22:31:03 +04:00
|
|
|
|
2013-03-05 17:47:38 +04:00
|
|
|
/**
|
|
|
|
* trace_event_get_state:
|
2016-10-04 16:35:49 +03:00
|
|
|
* @id: Event identifier name.
|
2013-03-05 17:47:38 +04:00
|
|
|
*
|
2017-07-31 17:07:18 +03:00
|
|
|
* Get the tracing state of an event, both static and the QEMU dynamic state.
|
2013-03-05 17:47:38 +04:00
|
|
|
*
|
|
|
|
* If the event has the disabled property, the check will have no performance
|
|
|
|
* impact.
|
|
|
|
*/
|
|
|
|
#define trace_event_get_state(id) \
|
2015-10-28 09:06:27 +03:00
|
|
|
((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
|
2013-03-05 17:47:38 +04:00
|
|
|
|
2017-07-31 17:07:18 +03:00
|
|
|
/**
|
|
|
|
* 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())
|
|
|
|
|
2013-03-05 17:47:38 +04:00
|
|
|
/**
|
|
|
|
* trace_event_get_state_static:
|
|
|
|
* @id: Event identifier.
|
|
|
|
*
|
|
|
|
* Get the static tracing state of an event.
|
|
|
|
*
|
|
|
|
* Use the define 'TRACE_${EVENT_NAME}_ENABLED' for compile-time checks (it will
|
|
|
|
* be set to 1 or 0 according to the presence of the disabled property).
|
|
|
|
*/
|
|
|
|
static bool trace_event_get_state_static(TraceEvent *ev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_get_state_dynamic:
|
|
|
|
*
|
|
|
|
* Get the dynamic tracing state of an event.
|
2016-07-11 13:53:41 +03:00
|
|
|
*
|
|
|
|
* If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
|
2013-03-05 17:47:38 +04:00
|
|
|
*/
|
|
|
|
static bool trace_event_get_state_dynamic(TraceEvent *ev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_event_set_state_dynamic:
|
|
|
|
*
|
|
|
|
* Set the dynamic tracing state of an event.
|
|
|
|
*
|
2016-07-11 13:53:41 +03:00
|
|
|
* If the event has the 'vcpu' property, sets the state on all vCPUs.
|
|
|
|
*
|
2013-03-05 17:47:38 +04:00
|
|
|
* Pre-condition: trace_event_get_state_static(ev) == true
|
|
|
|
*/
|
2016-07-11 13:53:41 +03:00
|
|
|
void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
|
|
|
|
|
2013-03-05 17:47:38 +04:00
|
|
|
/**
|
2014-05-27 17:02:14 +04:00
|
|
|
* trace_init_backends:
|
2011-08-31 22:31:03 +04:00
|
|
|
*
|
2013-03-05 17:47:38 +04:00
|
|
|
* Initialize the tracing backend.
|
|
|
|
*
|
2014-05-27 17:02:14 +04:00
|
|
|
* Returns: Whether the backends could be successfully initialized.
|
2011-08-31 22:31:31 +04:00
|
|
|
*/
|
2016-01-07 16:55:24 +03:00
|
|
|
bool trace_init_backends(void);
|
2016-01-07 16:55:23 +03:00
|
|
|
|
2016-01-07 16:55:24 +03:00
|
|
|
/**
|
|
|
|
* trace_init_file:
|
|
|
|
*
|
|
|
|
* Record the name of the output file for the tracing backend.
|
|
|
|
* Exits if no selected backend does not support specifying the
|
2020-11-02 14:58:41 +03:00
|
|
|
* output file, and a file was specified with "-trace file=...".
|
2016-01-07 16:55:24 +03:00
|
|
|
*/
|
2020-11-02 14:58:41 +03:00
|
|
|
void trace_init_file(void);
|
2016-01-07 16:55:24 +03:00
|
|
|
|
2016-01-07 16:55:27 +03:00
|
|
|
/**
|
|
|
|
* trace_list_events:
|
2020-11-26 00:52:45 +03:00
|
|
|
* @f: Where to send output.
|
2016-01-07 16:55:27 +03:00
|
|
|
*
|
|
|
|
* List all available events.
|
|
|
|
*/
|
2020-11-26 00:52:45 +03:00
|
|
|
void trace_list_events(FILE *f);
|
2016-01-07 16:55:27 +03:00
|
|
|
|
2016-01-07 16:55:26 +03:00
|
|
|
/**
|
|
|
|
* trace_enable_events:
|
|
|
|
* @line_buf: A string with a glob pattern of events to be enabled or,
|
|
|
|
* if the string starts with '-', disabled.
|
|
|
|
*
|
|
|
|
* Enable or disable matching events.
|
|
|
|
*/
|
|
|
|
void trace_enable_events(const char *line_buf);
|
|
|
|
|
2016-06-17 17:44:10 +03:00
|
|
|
/**
|
|
|
|
* Definition of QEMU options describing trace subsystem configuration
|
|
|
|
*/
|
|
|
|
extern QemuOptsList qemu_trace_opts;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trace_opt_parse:
|
|
|
|
* @optarg: A string argument of --trace command line argument
|
|
|
|
*
|
|
|
|
* Initialize tracing subsystem.
|
|
|
|
*/
|
2020-11-02 14:58:41 +03:00
|
|
|
void trace_opt_parse(const char *optarg);
|
2013-03-05 17:47:38 +04:00
|
|
|
|
2016-10-04 16:35:53 +03:00
|
|
|
/**
|
|
|
|
* trace_get_vcpu_event_count:
|
|
|
|
*
|
|
|
|
* Return the number of known vcpu-specific events
|
|
|
|
*/
|
|
|
|
uint32_t trace_get_vcpu_event_count(void);
|
|
|
|
|
2016-07-11 13:53:41 +03:00
|
|
|
|
2018-05-03 22:50:28 +03:00
|
|
|
#include "control-internal.h"
|
2013-03-05 17:47:38 +04:00
|
|
|
|
2016-06-29 16:29:06 +03:00
|
|
|
#endif /* TRACE__CONTROL_H */
|