diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2016-10-04 14:35:42 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-10-12 09:35:53 +0200 |
commit | 6a1b0f3aea09142cb8989ccffb3b74bb8808a00f (patch) | |
tree | e92e911b9783cdff602181b1c5d9e6089c23eba1 /trace/control.h | |
parent | 170f75ad80115c509d3bedfcbbf4a8237ff6f771 (diff) |
trace: add trace event iterator APIs
Currently methods which want to iterate over trace events,
do so using the trace_event_count() and trace_event_id()
methods. This leaks the concept of a single ID enum to
the callers. There is an alternative trace_event_pattern()
method which can be used in an iteration context, but its
design is stateless, so is not easy to expand it in the
future.
This defines a formal iterator API will provide a future-
proof way of iterating over events.
The iterator is also able to apply a pattern match filter
to events, further removing the need for the pattern
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: LluĂs Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1475588159-30598-4-git-send-email-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace/control.h')
-rw-r--r-- | trace/control.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/trace/control.h b/trace/control.h index a22d11242e..36d7cd23ed 100644 --- a/trace/control.h +++ b/trace/control.h @@ -13,6 +13,10 @@ #include "qemu-common.h" #include "trace/generated-events.h" +typedef struct TraceEventIter { + size_t event; + const char *pattern; +} TraceEventIter; /** * TraceEventID: @@ -25,6 +29,29 @@ */ enum TraceEventID; + +/** + * trace_event_iter_init: + * @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 + * with non-matching names. + */ +void trace_event_iter_init(TraceEventIter *iter, const char *pattern); + +/** + * 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); + /** * trace_event_id: * @id: Event identifier. |