aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trace/control.c19
-rw-r--r--trace/control.h13
2 files changed, 29 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;
diff --git a/trace/control.h b/trace/control.h
index ce40bd0..23b8393 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -13,8 +13,11 @@
#include "event-internal.h"
typedef struct TraceEventIter {
+ /* iter state */
size_t event;
size_t group;
+ /* filter conditions */
+ size_t group_id;
const char *pattern;
} TraceEventIter;
@@ -40,6 +43,16 @@ void trace_event_iter_init_all(TraceEventIter *iter);
void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
/**
+ * 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);
+
+/**
* trace_event_iter_next:
* @iter: the event iterator struct
*