From 529a1450584b1c469ca4d7b248a043ba732d33bf Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sun, 12 May 2024 07:42:00 -0400 Subject: [PATCH] src.ctf.fs: always set the correct trace IR stream ID In add_ds_file_to_ds_file_group(), we don't use the original CTF data stream ID to set the trace IR stream ID whenever the beginning timestamp is missing. The comment says: if (begin_ns == -1) { /* * No beginning timestamp to sort the stream files * within a stream file group, so consider that this * file must be the only one within its group. */ stream_instance_id.reset(); } This might be true, but there's no need to reset the data stream ID. Then during data stream decoding, the trace IR stream ID always matches the CTF IR data stream ID (if any), which enables some further checks. Furthermore, a trace which goes from `src.ctf.fs` to `sink.ctf.fs` will keep its original data stream IDs. Signed-off-by: Philippe Proulx Change-Id: I3c6ea0a3cbd913017cd00c1c07c6c6bf83b8a534 Reviewed-on: https://review.lttng.org/c/babeltrace/+/12771 --- src/plugins/ctf/fs-src/fs.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/plugins/ctf/fs-src/fs.cpp b/src/plugins/ctf/fs-src/fs.cpp index a1e5a599..97e1f34e 100644 --- a/src/plugins/ctf/fs-src/fs.cpp +++ b/src/plugins/ctf/fs-src/fs.cpp @@ -367,16 +367,7 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const return -1; } - if (begin_ns == -1) { - /* - * No beginning timestamp to sort the stream files - * within a stream file group, so consider that this - * file must be the only one within its group. - */ - stream_instance_id.reset(); - } - - if (!stream_instance_id) { + if (!stream_instance_id || begin_ns == -1) { /* * No stream instance ID or no beginning timestamp: * create a unique stream file group for this stream @@ -385,13 +376,12 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const * group. */ ctf_fs_trace->ds_file_groups.emplace_back(bt2s::make_unique( - ctf_fs_trace, *sc, UINT64_C(-1), std::move(*index))); + ctf_fs_trace, *sc, stream_instance_id ? *stream_instance_id : UINT64_C(-1), + std::move(*index))); ctf_fs_trace->ds_file_groups.back()->insert_ds_file_info_sorted(std::move(ds_file_info)); return 0; } - BT_ASSERT(begin_ns != -1); - /* Find an existing stream file group with this ID */ ctf_fs_ds_file_group *ds_file_group = NULL; for (const auto& candidate : ctf_fs_trace->ds_file_groups) { -- 2.34.1