src.ctf.fs: always set the correct trace IR stream ID
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 12 May 2024 11:42:00 +0000 (07:42 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
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 <eeppeliteloop@gmail.com>
Change-Id: I3c6ea0a3cbd913017cd00c1c07c6c6bf83b8a534
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12771

src/plugins/ctf/fs-src/fs.cpp

index a1e5a5999bd9dbbe414e73b64a974d096184e3c6..97e1f34ef4a28c9c34ba8ac67a9bf00a00429c6d 100644 (file)
@@ -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_ds_file_group>(
-            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) {
This page took 0.024983 seconds and 4 git commands to generate.