diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-06-01 15:24:04 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2021-07-12 17:37:07 +0100 |
commit | c5cc58b176f23f6664d0e12e5956af4d904dcca4 (patch) | |
tree | 45741e904ba5308b6b504805e5fc81e09a1e1bc3 /trace/control.c | |
parent | 117856c3748dfda50351d1c0328486ede5f2646c (diff) | |
download | qemu-c5cc58b176f23f6664d0e12e5956af4d904dcca4.zip qemu-c5cc58b176f23f6664d0e12e5956af4d904dcca4.tar.gz qemu-c5cc58b176f23f6664d0e12e5956af4d904dcca4.tar.bz2 |
trace: add trace_event_iter_init_group
This allows to interate over an event group.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20210601132414.432430-4-kraxel@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace/control.c')
-rw-r--r-- | trace/control.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/trace/control.c b/trace/control.c index ed38e81..2c904b7 100644 --- a/trace/control.c +++ b/trace/control.c @@ -104,6 +104,7 @@ void trace_event_iter_init_all(TraceEventIter *iter) { iter->event = 0; iter->group = 0; + iter->group_id = -1; iter->pattern = NULL; } @@ -113,20 +114,32 @@ void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern) iter->pattern = pattern; } +void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id) +{ + trace_event_iter_init_all(iter); + iter->group_id = group_id; +} + TraceEvent *trace_event_iter_next(TraceEventIter *iter) { while (iter->group < nevent_groups && event_groups[iter->group].events[iter->event] != NULL) { TraceEvent *ev = event_groups[iter->group].events[iter->event]; + size_t group = iter->group; iter->event++; if (event_groups[iter->group].events[iter->event] == NULL) { iter->event = 0; iter->group++; } - if (!iter->pattern || - g_pattern_match_simple(iter->pattern, trace_event_get_name(ev))) { - return ev; + if (iter->pattern && + !g_pattern_match_simple(iter->pattern, trace_event_get_name(ev))) { + continue; + } + if (iter->group_id != -1 && + iter->group_id != group) { + continue; } + return ev; } return NULL; |