mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-26 21:10:42 +00:00
trace: iter init tweaks
Rename trace_event_iter_init() to trace_event_iter_init_pattern(), add trace_event_iter_init_all() for interating over all events. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20210601132414.432430-3-kraxel@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2adf216491
commit
117856c374
@ -1804,7 +1804,7 @@ void info_trace_events_completion(ReadLineState *rs, int nb_args, const char *st
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
char *pattern = g_strdup_printf("%s*", str);
|
||||
trace_event_iter_init(&iter, pattern);
|
||||
trace_event_iter_init_pattern(&iter, pattern);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
readline_add_completion(rs, trace_event_get_name(ev));
|
||||
}
|
||||
@ -1822,7 +1822,7 @@ void trace_event_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
char *pattern = g_strdup_printf("%s*", str);
|
||||
trace_event_iter_init(&iter, pattern);
|
||||
trace_event_iter_init_pattern(&iter, pattern);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
readline_add_completion(rs, trace_event_get_name(ev));
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void trace_init_vcpu(CPUState *vcpu)
|
||||
{
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
trace_event_iter_init(&iter, NULL);
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (trace_event_is_vcpu(ev) &&
|
||||
trace_event_get_state_static(ev) &&
|
||||
|
@ -91,7 +91,7 @@ TraceEvent *trace_event_name(const char *name)
|
||||
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
trace_event_iter_init(&iter, NULL);
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (strcmp(trace_event_get_name(ev), name) == 0) {
|
||||
return ev;
|
||||
@ -100,10 +100,16 @@ TraceEvent *trace_event_name(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void trace_event_iter_init(TraceEventIter *iter, const char *pattern)
|
||||
void trace_event_iter_init_all(TraceEventIter *iter)
|
||||
{
|
||||
iter->event = 0;
|
||||
iter->group = 0;
|
||||
iter->pattern = NULL;
|
||||
}
|
||||
|
||||
void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern)
|
||||
{
|
||||
trace_event_iter_init_all(iter);
|
||||
iter->pattern = pattern;
|
||||
}
|
||||
|
||||
@ -130,7 +136,7 @@ void trace_list_events(FILE *f)
|
||||
{
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
trace_event_iter_init(&iter, NULL);
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
fprintf(f, "%s\n", trace_event_get_name(ev));
|
||||
}
|
||||
@ -150,7 +156,7 @@ static void do_trace_enable_events(const char *line_buf)
|
||||
TraceEvent *ev;
|
||||
bool is_pattern = trace_event_is_pattern(line_ptr);
|
||||
|
||||
trace_event_iter_init(&iter, line_ptr);
|
||||
trace_event_iter_init_pattern(&iter, line_ptr);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (!trace_event_get_state_static(ev)) {
|
||||
if (!is_pattern) {
|
||||
@ -256,7 +262,7 @@ void trace_fini_vcpu(CPUState *vcpu)
|
||||
|
||||
trace_guest_cpu_exit(vcpu);
|
||||
|
||||
trace_event_iter_init(&iter, NULL);
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (trace_event_is_vcpu(ev) &&
|
||||
trace_event_get_state_static(ev) &&
|
||||
|
@ -20,15 +20,24 @@ typedef struct TraceEventIter {
|
||||
|
||||
|
||||
/**
|
||||
* trace_event_iter_init:
|
||||
* trace_event_iter_init_all:
|
||||
* @iter: the event iterator struct
|
||||
* @pattern: optional pattern to filter events on name
|
||||
*
|
||||
* Initialize the event iterator struct @iter,
|
||||
* optionally using @pattern to filter out events
|
||||
* 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
|
||||
* with non-matching names.
|
||||
*/
|
||||
void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
|
||||
void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
|
||||
|
||||
/**
|
||||
* trace_event_iter_next:
|
||||
|
@ -55,7 +55,7 @@ static bool check_events(bool has_vcpu, bool ignore_unavailable, bool is_pattern
|
||||
/* error for unavailable events */
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
trace_event_iter_init(&iter, name);
|
||||
trace_event_iter_init_pattern(&iter, name);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (!ignore_unavailable && !trace_event_get_state_static(ev)) {
|
||||
error_setg(errp, "event \"%s\" is disabled", trace_event_get_name(ev));
|
||||
@ -90,7 +90,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
|
||||
}
|
||||
|
||||
/* Get states (all errors checked above) */
|
||||
trace_event_iter_init(&iter, name);
|
||||
trace_event_iter_init_pattern(&iter, name);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
TraceEventInfo *value;
|
||||
bool is_vcpu = trace_event_is_vcpu(ev);
|
||||
@ -153,7 +153,7 @@ void qmp_trace_event_set_state(const char *name, bool enable,
|
||||
}
|
||||
|
||||
/* Apply changes (all errors checked above) */
|
||||
trace_event_iter_init(&iter, name);
|
||||
trace_event_iter_init_pattern(&iter, name);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
if (!trace_event_get_state_static(ev) ||
|
||||
(has_vcpu && !trace_event_is_vcpu(ev))) {
|
||||
|
@ -286,7 +286,7 @@ static int st_write_event_mapping(void)
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
|
||||
trace_event_iter_init(&iter, NULL);
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
uint64_t id = trace_event_get_id(ev);
|
||||
const char *name = trace_event_get_name(ev);
|
||||
|
Loading…
Reference in New Issue
Block a user