diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-06-01 15:24:03 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2021-07-12 17:37:07 +0100 |
commit | 117856c3748dfda50351d1c0328486ede5f2646c (patch) | |
tree | d8c7d94d85dc89e8c5bbcea24bf1051b0a22f40f /trace | |
parent | 2adf2164918e2dc74fef2cdd0257917aff488640 (diff) |
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>
Diffstat (limited to 'trace')
-rw-r--r-- | trace/control-target.c | 2 | ||||
-rw-r--r-- | trace/control.c | 16 | ||||
-rw-r--r-- | trace/control.h | 17 | ||||
-rw-r--r-- | trace/qmp.c | 6 | ||||
-rw-r--r-- | trace/simple.c | 2 |
5 files changed, 29 insertions, 14 deletions
diff --git a/trace/control-target.c b/trace/control-target.c index e293eeed7c..8418673c18 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -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) && diff --git a/trace/control.c b/trace/control.c index 4be38e1af2..ed38e813b2 100644 --- a/trace/control.c +++ b/trace/control.c @@ -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) && diff --git a/trace/control.h b/trace/control.h index 9522a7b318..ce40bd0405 100644 --- a/trace/control.h +++ b/trace/control.h @@ -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: diff --git a/trace/qmp.c b/trace/qmp.c index 85f81e47cc..3b4f4702b4 100644 --- a/trace/qmp.c +++ b/trace/qmp.c @@ -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))) { diff --git a/trace/simple.c b/trace/simple.c index 9cd2ed1fb3..97b6f85168 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -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); |