#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)
ctf_fs->trace_path = g_string_new(path);
if (!ctf_fs->trace_path) {
+ BT_PUT(value);
goto error;
}
+ bt_put(value);
+
+ value = bt_value_map_get(params, "offset-s");
+ if (value) {
+ int64_t offset;
+
+ if (!bt_value_is_integer(value)) {
+ fprintf(stderr,
+ "offset-s should be an integer\n");
+ goto error;
+ }
+ ret = bt_value_integer_get(value, &offset);
+ if (ret != BT_VALUE_STATUS_OK) {
+ fprintf(stderr,
+ "Failed to get offset-s value\n");
+ goto error;
+ }
+ ctf_fs->options.clock_offset = offset;
+ bt_put(value);
+ }
+
+ value = bt_value_map_get(params, "offset-ns");
+ if (value) {
+ int64_t offset;
+
+ if (!bt_value_is_integer(value)) {
+ fprintf(stderr,
+ "offset-ns should be an integer\n");
+ goto error;
+ }
+ ret = bt_value_integer_get(value, &offset);
+ if (ret != BT_VALUE_STATUS_OK) {
+ fprintf(stderr,
+ "Failed to get offset-ns value\n");
+ goto error;
+ }
+ ctf_fs->options.clock_offset_ns = offset;
+ bt_put(value);
+ }
+
ctf_fs->error_fp = stderr;
ctf_fs->page_size = (size_t) getpagesize();
goto error;
}
+ ret = create_cc_prio_map(ctf_fs);
+ if (ret) {
+ goto error;
+ }
+
ret = create_ports(ctf_fs);
if (ret) {
goto error;
ctf_fs_destroy_data(ctf_fs);
ctf_fs = NULL;
end:
- BT_PUT(value);
return ctf_fs;
}