ctf: read packet sequence number from index
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 1 Nov 2019 19:17:46 +0000 (15:17 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 15 Nov 2019 18:08:11 +0000 (13:08 -0500)
Starting with version 1.1, the CTF index format includes a packet
sequence number.  Read it, if the index minor version is >=1.  The index
major version is already checked to always be 1 above in the code.

If the version is lower than that, store UINT64_MAX in the
packet_seq_num field of the ctf_fs_ds_index_entry structure.

This information will be used in a subsequent patch.

Change-Id: I7b94a94344b26638ae4b7cfc4659067bebc7e195
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/fs-src/data-stream-file.c
src/plugins/ctf/fs-src/fs.h

index b62ad693905d26743ec55dc640ce6524cfde4bb5..99ff70b1de7f0e17fccf8442bedb345fcfd0df49 100644 (file)
@@ -280,6 +280,24 @@ struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops = {
        .seek = medop_seek,
 };
 
+static
+struct ctf_fs_ds_index_entry *ctf_fs_ds_index_entry_create(
+               bt_self_component *self_comp, bt_logging_level log_level)
+{
+       struct ctf_fs_ds_index_entry *entry;
+
+       entry = g_new0(struct ctf_fs_ds_index_entry, 1);
+       if (!entry) {
+               BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to allocate a ctf_fs_ds_index_entry.");
+               goto end;
+       }
+
+       entry->packet_seq_num = UINT64_MAX;
+
+end:
+       return entry;
+}
+
 static
 int convert_cycles_to_ns(struct ctf_clock_class *clock_class,
                uint64_t cycles, int64_t *ns)
@@ -419,8 +437,11 @@ struct ctf_fs_ds_index *build_index_from_idx_file(
                        goto error;
                }
 
-               index_entry = g_new0(struct ctf_fs_ds_index_entry, 1);
+               index_entry = ctf_fs_ds_index_entry_create(
+                       ds_file->self_comp, ds_file->log_level);
                if (!index_entry) {
+                       BT_COMP_LOGE_APPEND_CAUSE(ds_file->self_comp,
+                               "Failed to create a ctf_fs_ds_index_entry.");
                        goto error;
                }
 
@@ -465,6 +486,10 @@ struct ctf_fs_ds_index *build_index_from_idx_file(
                        goto error;
                }
 
+               if (version_minor >= 1) {
+                       index_entry->packet_seq_num = be64toh(file_index->packet_seq_num);
+               }
+
                total_packets_size += packet_size;
                file_pos += file_index_entry_size;
 
@@ -621,9 +646,11 @@ struct ctf_fs_ds_index *build_index_from_stream_file(
                        goto error;
                }
 
-               index_entry = g_new0(struct ctf_fs_ds_index_entry, 1);
+               index_entry = ctf_fs_ds_index_entry_create(
+                       ds_file->self_comp, ds_file->log_level);
                if (!index_entry) {
-                       BT_COMP_LOGE_STR("Failed to allocate a new index entry.");
+                       BT_COMP_LOGE_APPEND_CAUSE(ds_file->self_comp,
+                               "Failed to create a ctf_fs_ds_index_entry.");
                        goto error;
                }
 
index a6594b1c234ab603e9998349cf0ec794ccac55e6..78faded2a0c59c1e66ea283e3cff62b9487f5ba0 100644 (file)
@@ -129,6 +129,11 @@ struct ctf_fs_ds_index_entry {
         * (in ns since EPOCH).
         */
        int64_t timestamp_begin_ns, timestamp_end_ns;
+
+       /*
+        * Packet sequence number, or UINT64_MAX if not present in the index.
+        */
+       uint64_t packet_seq_num;
 };
 
 struct ctf_fs_ds_index {
This page took 0.027198 seconds and 4 git commands to generate.