#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/graph/notification-internal.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#ifdef __cplusplus
extern "C" {
struct bt_notification_event {
struct bt_notification parent;
struct bt_ctf_event *event;
+ struct bt_clock_class_priority_map *cc_prio_map;
};
#ifdef __cplusplus
struct bt_notification;
struct bt_ctf_event;
+struct bt_clock_class_priority_map;
/***BT_NOTIFICATION_TYPE_EVENT ***/
/**
* @see #bt_notification_type
*/
extern struct bt_notification *bt_notification_event_create(
- struct bt_ctf_event *event);
+ struct bt_ctf_event *event,
+ struct bt_clock_class_priority_map *clock_class_priority_map);
/**
* Get an event notification's event.
extern struct bt_ctf_event *bt_notification_event_get_event(
struct bt_notification *notification);
+extern struct bt_clock_class_priority_map *
+bt_notification_event_get_clock_class_priority_map(
+ struct bt_notification *notification);
+
#ifdef __cplusplus
}
#endif
*/
#include <babeltrace/compiler.h>
+#include <babeltrace/ctf-ir/event.h>
+#include <babeltrace/ctf-ir/event-class.h>
+#include <babeltrace/ctf-ir/stream-class.h>
+#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/notification-event-internal.h>
static
(struct bt_notification_event *) obj;
BT_PUT(notification->event);
+ BT_PUT(notification->cc_prio_map);
g_free(notification);
}
-struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event)
+static
+bool validate_clock_classes(struct bt_notification_event *notif)
+{
+ /*
+ * For each clock class found in the event's trace, get the
+ * event's clock value for this clock class, and if it exists,
+ * make sure that this clock class has a priority in the
+ * notification's clock class priority map.
+ */
+ bool is_valid = true;
+ int ret;
+ int count;
+ size_t i;
+ struct bt_ctf_event_class *event_class = NULL;
+ struct bt_ctf_stream_class *stream_class = NULL;
+ struct bt_ctf_trace *trace = NULL;
+ uint64_t prio;
+
+ event_class = bt_ctf_event_get_class(notif->event);
+ assert(event_class);
+ stream_class = bt_ctf_event_class_get_stream_class(event_class);
+ assert(stream_class);
+ trace = bt_ctf_stream_class_get_trace(stream_class);
+ assert(trace);
+ count = bt_ctf_trace_get_clock_class_count(trace);
+ assert(count >= 0);
+
+ for (i = 0; i < count; i++) {
+ struct bt_ctf_clock_class *clock_class =
+ bt_ctf_trace_get_clock_class(trace, i);
+
+ assert(clock_class);
+ ret = bt_clock_class_priority_map_get_clock_class_priority(
+ notif->cc_prio_map, clock_class, &prio);
+ bt_put(clock_class);
+ if (ret) {
+ is_valid = false;
+ goto end;
+ }
+ }
+
+end:
+ bt_put(trace);
+ bt_put(stream_class);
+ bt_put(event_class);
+ return is_valid;
+}
+
+struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
+ struct bt_clock_class_priority_map *cc_prio_map)
{
struct bt_notification_event *notification;
- if (!event) {
+ if (!event || !cc_prio_map) {
goto error;
}
BT_NOTIFICATION_TYPE_EVENT,
bt_notification_event_destroy);
notification->event = bt_get(event);
+ notification->cc_prio_map = bt_get(cc_prio_map);
+
+ if (!validate_clock_classes(notification)) {
+ bt_put(notification);
+ goto error;
+ }
+
return ¬ification->parent;
error:
return NULL;
end:
return event;
}
+
+extern struct bt_clock_class_priority_map *
+bt_notification_event_get_clock_class_priority_map(
+ struct bt_notification *notification)
+{
+ struct bt_clock_class_priority_map *cc_prio_map = NULL;
+ struct bt_notification_event *event_notification;
+
+ if (bt_notification_get_type(notification) !=
+ BT_NOTIFICATION_TYPE_EVENT) {
+ goto end;
+ }
+
+ event_notification = container_of(notification,
+ struct bt_notification_event, parent);
+ cc_prio_map = bt_get(event_notification->cc_prio_map);
+end:
+ return cc_prio_map;
+}
#include <babeltrace/graph/notification-packet.h>
#include <babeltrace/graph/notification-event.h>
#include <babeltrace/graph/notification-stream.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/ref.h>
#include <glib.h>
struct bt_ctf_event_class *event_class;
} meta;
+ /* Clock class priority map (owned by this) */
+ struct bt_clock_class_priority_map *cc_prio_map;
+
/* Current packet (NULL if not created yet) */
struct bt_ctf_packet *packet;
goto end;
}
- ret = bt_notification_event_create(event);
+ ret = bt_notification_event_create(event, notit->cc_prio_map);
if (!ret) {
goto end;
}
BT_HIDDEN
struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
+ struct bt_clock_class_priority_map *cc_prio_map,
size_t max_request_sz,
struct bt_ctf_notif_iter_medium_ops medops,
void *data, FILE *err_stream)
};
assert(trace);
+ assert(cc_prio_map);
assert(medops.request_bytes);
assert(medops.get_stream);
notit = g_new0(struct bt_ctf_notif_iter, 1);
PERR("Failed to initialize stream clock states\n");
goto error;
}
+ notit->cc_prio_map = bt_get(cc_prio_map);
notit->meta.trace = bt_get(trace);
notit->medium.medops = medops;
notit->medium.max_request_sz = max_request_sz;
void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit)
{
+ BT_PUT(notit->cc_prio_map);
BT_PUT(notit->meta.trace);
BT_PUT(notit->meta.stream_class);
BT_PUT(notit->meta.event_class);
#include <babeltrace/ctf-ir/trace.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/event.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/babeltrace-internal.h>
/**
* incremented.
*
* @param trace Trace to read
+ * @param cc_prio_map Clock class priority map to use when
+ * creating the event notifications
* @param max_request_sz Maximum buffer size, in bytes, to
* request to
* bt_ctf_notif_iter_medium_ops::request_bytes()
*/
BT_HIDDEN
struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
+ struct bt_clock_class_priority_map *cc_prio_map,
size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops,
void *medops_data, FILE *err_stream);
}
stream->notif_iter = bt_ctf_notif_iter_create(ctf_fs->metadata->trace,
- ctf_fs->page_size, medops, stream, ctf_fs->error_fp);
+ ctf_fs->cc_prio_map, ctf_fs->page_size, medops, stream,
+ ctf_fs->error_fp);
if (!stream->notif_iter) {
goto error;
}
#include <babeltrace/graph/private-notification-iterator.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/notification-iterator.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#include <plugins-common.h>
#include <glib.h>
#include <assert.h>
g_free(ctf_fs->metadata);
}
+ bt_put(ctf_fs->cc_prio_map);
g_free(ctf_fs);
}
return ret;
}
+static
+int create_cc_prio_map(struct ctf_fs_component *ctf_fs)
+{
+ int ret = 0;
+ size_t i;
+ int count;
+
+ assert(ctf_fs);
+ ctf_fs->cc_prio_map = bt_clock_class_priority_map_create();
+ if (!ctf_fs->cc_prio_map) {
+ ret = -1;
+ goto end;
+ }
+
+ count = bt_ctf_trace_get_clock_class_count(ctf_fs->metadata->trace);
+ assert(count >= 0);
+
+ for (i = 0; i < count; i++) {
+ struct bt_ctf_clock_class *clock_class =
+ bt_ctf_trace_get_clock_class(ctf_fs->metadata->trace,
+ i);
+
+ assert(clock_class);
+ ret = bt_clock_class_priority_map_add_clock_class(
+ ctf_fs->cc_prio_map, clock_class, 0);
+ BT_PUT(clock_class);
+
+ if (ret) {
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
static
struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp,
struct bt_value *params)
goto error;
}
+ ret = create_cc_prio_map(ctf_fs);
+ if (ret) {
+ goto error;
+ }
+
ret = create_ports(ctf_fs);
if (ret) {
goto error;
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/graph/component.h>
+#include <babeltrace/graph/clock-class-priority-map.h>
#include "data-stream.h"
#define CTF_FS_COMPONENT_DESCRIPTION \
size_t page_size;
struct ctf_fs_component_options options;
struct ctf_fs_metadata *metadata;
+ struct bt_clock_class_priority_map *cc_prio_map;
/* Array of struct ctf_fs_port_data *, owned by this */
GPtrArray *port_data;