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>
#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
#include <babeltrace/types.h>
static
void bt_notification_event_destroy(struct bt_object *obj)
static
void bt_notification_event_destroy(struct bt_object *obj)
+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)
{
struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
struct bt_clock_class_priority_map *cc_prio_map)
{
+ if (!event_has_trace(event)) {
+ goto error;
+ }
+
notification = g_new0(struct bt_notification_event, 1);
if (!notification) {
goto error;
notification = g_new0(struct bt_notification_event, 1);
if (!notification) {
goto error;