- int ret = 0;
- uint64_t i;
- bt_logging_level log_level = ctf_fs->log_level;
- GPtrArray *paths = NULL;
- GPtrArray *traces;
- const char *trace_name;
-
- BT_ASSERT(bt_value_get_type(paths_value) == BT_VALUE_TYPE_ARRAY);
- BT_ASSERT(!bt_value_array_is_empty(paths_value));
-
- traces = g_ptr_array_new_with_free_func(ctf_fs_trace_destroy_notifier);
- if (!traces) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Failed to allocate a GPtrArray.");
- goto error;
- }
-
- paths = g_ptr_array_new_with_free_func(g_free);
- if (!paths) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Failed to allocate a GPtrArray.");
- goto error;
- }
-
- trace_name = trace_name_value ? bt_value_string_get(trace_name_value) : NULL;
-
- /*
- * Create a sorted array of the paths, to make the execution of this
- * component deterministic.
- */
- for (i = 0; i < bt_value_array_get_length(paths_value); i++) {
- const bt_value *path_value =
- bt_value_array_borrow_element_by_index_const(paths_value, i);
- const char *input = bt_value_string_get(path_value);
- gchar *input_copy;
-
- input_copy = g_strdup(input);
- if (!input_copy) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Failed to copy a string.");
- goto error;
- }
-
- g_ptr_array_add(paths, input_copy);
- }
-
- g_ptr_array_sort(paths, compare_strings);
-
- /* Create a separate ctf_fs_trace object for each path. */
- for (i = 0; i < paths->len; i++) {
- const char *path = (const char *) g_ptr_array_index(paths, i);
-
- ret = ctf_fs_component_create_ctf_fs_trace_one_path(ctf_fs,
- path, trace_name, traces, self_comp, self_comp_class);
- if (ret) {
- goto end;
- }
- }
-
- if (traces->len > 1) {
- struct ctf_fs_trace *first_trace = (struct ctf_fs_trace *) traces->pdata[0];
- const uint8_t *first_trace_uuid = first_trace->metadata->tc->uuid;
- struct ctf_fs_trace *trace;
-
- /*
- * We have more than one trace, they must all share the same
- * UUID, verify that.
- */
- for (i = 0; i < traces->len; i++) {
- struct ctf_fs_trace *this_trace =
- (struct ctf_fs_trace *) traces->pdata[i];
- const uint8_t *this_trace_uuid = this_trace->metadata->tc->uuid;
-
- if (!this_trace->metadata->tc->is_uuid_set) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Multiple traces given, but a trace does not have a UUID: path=%s",
- this_trace->path->str);
- goto error;
- }
-
- if (bt_uuid_compare(first_trace_uuid, this_trace_uuid) != 0) {
- char first_trace_uuid_str[BT_UUID_STR_LEN + 1];
- char this_trace_uuid_str[BT_UUID_STR_LEN + 1];
-
- bt_uuid_to_str(first_trace_uuid, first_trace_uuid_str);
- bt_uuid_to_str(this_trace_uuid, this_trace_uuid_str);
-
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Multiple traces given, but UUIDs don't match: "
- "first-trace-uuid=%s, first-trace-path=%s, "
- "trace-uuid=%s, trace-path=%s",
- first_trace_uuid_str, first_trace->path->str,
- this_trace_uuid_str, this_trace->path->str);
- goto error;
- }
- }
-
- ret = merge_ctf_fs_traces((struct ctf_fs_trace **) traces->pdata,
- traces->len, &trace);
- if (ret) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Failed to merge traces with the same UUID.");
- goto error;
- }
-
- ctf_fs->trace = trace;
- } else {
- /* Just one trace, it may or may not have a UUID, both are fine. */
- ctf_fs->trace = (ctf_fs_trace *) traces->pdata[0];
- traces->pdata[0] = NULL;
- }
-
- ret = fix_packet_index_tracer_bugs(ctf_fs, self_comp, self_comp_class);
- if (ret) {
- BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
- "Failed to fix packet index tracer bugs.");
- }
-
- /*
- * Sort data stream file groups by first data stream file info
- * path to get a deterministic order. This order influences the
- * order of the output ports. It also influences the order of
- * the automatic stream IDs if the trace's packet headers do not
- * contain a `stream_instance_id` field, in which case the data
- * stream file to stream ID association is always the same,
- * whatever the build and the system.
- *
- * Having a deterministic order here can help debugging and
- * testing.
- */
- g_ptr_array_sort(ctf_fs->trace->ds_file_groups,
- compare_ds_file_groups_by_first_path);
- goto end;
+ int ret = 0;
+ uint64_t i;
+ GPtrArray *paths = NULL;
+ GPtrArray *traces;
+ const char *trace_name;
+
+ BT_ASSERT(bt_value_get_type(paths_value) == BT_VALUE_TYPE_ARRAY);
+ BT_ASSERT(!bt_value_array_is_empty(paths_value));
+
+ traces = g_ptr_array_new_with_free_func(ctf_fs_trace_destroy_notifier);
+ if (!traces) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger, "Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ paths = g_ptr_array_new_with_free_func(g_free);
+ if (!paths) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger, "Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ trace_name = trace_name_value ? bt_value_string_get(trace_name_value) : NULL;
+
+ /*
+ * Create a sorted array of the paths, to make the execution of this
+ * component deterministic.
+ */
+ for (i = 0; i < bt_value_array_get_length(paths_value); i++) {
+ const bt_value *path_value = bt_value_array_borrow_element_by_index_const(paths_value, i);
+ const char *input = bt_value_string_get(path_value);
+ gchar *input_copy;
+
+ input_copy = g_strdup(input);
+ if (!input_copy) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger, "Failed to copy a string.");
+ goto error;
+ }
+
+ g_ptr_array_add(paths, input_copy);
+ }
+
+ g_ptr_array_sort(paths, compare_strings);
+
+ /* Create a separate ctf_fs_trace object for each path. */
+ for (i = 0; i < paths->len; i++) {
+ const char *path = (const char *) g_ptr_array_index(paths, i);
+
+ ret = ctf_fs_component_create_ctf_fs_trace_one_path(ctf_fs, path, trace_name, traces,
+ selfComp);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ if (traces->len > 1) {
+ struct ctf_fs_trace *first_trace = (struct ctf_fs_trace *) traces->pdata[0];
+ const uint8_t *first_trace_uuid = first_trace->metadata->tc->uuid;
+ struct ctf_fs_trace *trace;
+
+ /*
+ * We have more than one trace, they must all share the same
+ * UUID, verify that.
+ */
+ for (i = 0; i < traces->len; i++) {
+ struct ctf_fs_trace *this_trace = (struct ctf_fs_trace *) traces->pdata[i];
+ const uint8_t *this_trace_uuid = this_trace->metadata->tc->uuid;
+
+ if (!this_trace->metadata->tc->is_uuid_set) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(
+ ctf_fs->logger,
+ "Multiple traces given, but a trace does not have a UUID: path={}",
+ this_trace->path->str);
+ goto error;
+ }
+
+ if (bt_uuid_compare(first_trace_uuid, this_trace_uuid) != 0) {
+ char first_trace_uuid_str[BT_UUID_STR_LEN + 1];
+ char this_trace_uuid_str[BT_UUID_STR_LEN + 1];
+
+ bt_uuid_to_str(first_trace_uuid, first_trace_uuid_str);
+ bt_uuid_to_str(this_trace_uuid, this_trace_uuid_str);
+
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger,
+ "Multiple traces given, but UUIDs don't match: "
+ "first-trace-uuid={}, first-trace-path={}, "
+ "trace-uuid={}, trace-path={}",
+ first_trace_uuid_str, first_trace->path->str,
+ this_trace_uuid_str, this_trace->path->str);
+ goto error;
+ }
+ }
+
+ ret = merge_ctf_fs_traces((struct ctf_fs_trace **) traces->pdata, traces->len, &trace);
+ if (ret) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger,
+ "Failed to merge traces with the same UUID.");
+ goto error;
+ }
+
+ ctf_fs->trace = trace;
+ } else {
+ /* Just one trace, it may or may not have a UUID, both are fine. */
+ ctf_fs->trace = (ctf_fs_trace *) traces->pdata[0];
+ traces->pdata[0] = NULL;
+ }
+
+ ret = fix_packet_index_tracer_bugs(ctf_fs->trace);
+ if (ret) {
+ BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger, "Failed to fix packet index tracer bugs.");
+ }
+
+ /*
+ * Sort data stream file groups by first data stream file info
+ * path to get a deterministic order. This order influences the
+ * order of the output ports. It also influences the order of
+ * the automatic stream IDs if the trace's packet headers do not
+ * contain a `stream_instance_id` field, in which case the data
+ * stream file to stream ID association is always the same,
+ * whatever the build and the system.
+ *
+ * Having a deterministic order here can help debugging and
+ * testing.
+ */
+ g_ptr_array_sort(ctf_fs->trace->ds_file_groups, compare_ds_file_groups_by_first_path);
+ goto end;