Event notification: make sure contained event has a trace
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 18 May 2017 23:49:53 +0000 (19:49 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:43 +0000 (12:57 -0400)
Because we need to keep support for legacy CTF writer behaviours, we can
still create a "floating" event without its stream class attached to a
trace. Disallow the creation of an event notification with such an event
to provide the guarantee to filter and sink components that you can
always find the trace of an event notification's event.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/graph/notification/event.c

index 8e5d672493d8482f41a34d6ba96d90483d7a2e8e..c4474c158c6534189b4048e45327e3b917fb84b2 100644 (file)
@@ -34,6 +34,7 @@
 #include <babeltrace/graph/clock-class-priority-map-internal.h>
 #include <babeltrace/graph/notification-event-internal.h>
 #include <babeltrace/types.h>
+#include <stdbool.h>
 
 static
 void bt_notification_event_destroy(struct bt_object *obj)
@@ -120,6 +121,19 @@ end:
        return is_valid;
 }
 
+static
+bool event_has_trace(struct bt_ctf_event *event)
+{
+       struct bt_ctf_event_class *event_class;
+       struct bt_ctf_stream_class *stream_class;
+
+       event_class = bt_ctf_event_borrow_event_class(event);
+       assert(event_class);
+       stream_class = bt_ctf_event_class_borrow_stream_class(event_class);
+       assert(stream_class);
+       return bt_ctf_stream_class_borrow_trace(stream_class) != NULL;
+}
+
 struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
                struct bt_clock_class_priority_map *cc_prio_map)
 {
@@ -133,6 +147,10 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
                goto error;
        }
 
+       if (!event_has_trace(event)) {
+               goto error;
+       }
+
        notification = g_new0(struct bt_notification_event, 1);
        if (!notification) {
                goto error;
This page took 0.027982 seconds and 4 git commands to generate.