Fix: src.ctf.fs: do not use trace IR objects in queries
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 27 Mar 2019 00:44:59 +0000 (20:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
Issue
=====
We try to create a `bt_stream` object from a translated CTF IR stream
class object (to `bt_stream_class`) systematically in
create_ds_file_groups(), but this path is also taken by the `trace-info`
query which needs DS file groups, but does not need trace IR objects
(and cannot have them because there's no self component object in this
case).

Also there's a bug in build_index_from_stream_file() where the index is
not built because of a wrong status code check.

The result is that `trace-info` query does not work.

Solution
========
Only use CTF IR objects in the queries. Therefore, only create a
`bt_stream` object for the DS file group if the CTF IR stream class was
translated (this only happens when there's an available self component).

Fix the status code check issue in build_index_from_stream_file().

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/fs.c
plugins/ctf/fs-src/fs.h
plugins/ctf/fs-src/query.c

index bafa80de5a6378fd8c783aa99123e232d070e880..e1041151e6aa094108ce4a9fc86612a456b6cebd 100644 (file)
@@ -611,7 +611,7 @@ struct ctf_fs_ds_index *build_index_from_stream_file(
                }
        } while (iter_status == BT_MSG_ITER_STATUS_OK);
 
-       if (iter_status != BT_MSG_ITER_STATUS_EOF) {
+       if (iter_status != BT_MSG_ITER_STATUS_OK) {
                goto error;
        }
 
index 901c495635dc94edd9e47f780533d17e9eb4d5be..e20a2ec7412d0e584889cc69e23547b9bf279d14 100644 (file)
@@ -511,14 +511,13 @@ void ctf_fs_ds_file_group_destroy(struct ctf_fs_ds_file_group *ds_file_group)
        }
 
        bt_stream_put_ref(ds_file_group->stream);
-       bt_stream_class_put_ref(ds_file_group->stream_class);
        g_free(ds_file_group);
 }
 
 static
 struct ctf_fs_ds_file_group *ctf_fs_ds_file_group_create(
                struct ctf_fs_trace *ctf_fs_trace,
-               bt_stream_class *stream_class,
+               struct ctf_stream_class *sc,
                uint64_t stream_instance_id)
 {
        struct ctf_fs_ds_file_group *ds_file_group;
@@ -535,9 +534,8 @@ struct ctf_fs_ds_file_group *ctf_fs_ds_file_group_create(
        }
 
        ds_file_group->stream_id = stream_instance_id;
-       BT_ASSERT(stream_class);
-       ds_file_group->stream_class = stream_class;
-       bt_stream_class_get_ref(ds_file_group->stream_class);
+       BT_ASSERT(sc);
+       ds_file_group->sc = sc;
        ds_file_group->ctf_fs_trace = ctf_fs_trace;
        goto end;
 
@@ -612,7 +610,6 @@ static
 int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
                const char *path)
 {
-       bt_stream_class *stream_class = NULL;
        int64_t stream_instance_id = -1;
        int64_t begin_ns = -1;
        struct ctf_fs_ds_file_group *ds_file_group = NULL;
@@ -648,8 +645,6 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
        sc = ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc,
                props.stream_class_id);
        BT_ASSERT(sc);
-       stream_class = sc->ir_sc;
-       BT_ASSERT(stream_class);
        stream_instance_id = props.data_stream_id;
 
        if (props.snapshots.beginning_clock != UINT64_C(-1)) {
@@ -690,7 +685,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
                 * group.
                 */
                ds_file_group = ctf_fs_ds_file_group_create(ctf_fs_trace,
-                       stream_class, stream_instance_id);
+                       sc, UINT64_C(-1));
                if (!ds_file_group) {
                        goto error;
                }
@@ -715,7 +710,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
                ds_file_group = g_ptr_array_index(
                        ctf_fs_trace->ds_file_groups, i);
 
-               if (ds_file_group->stream_class == stream_class &&
+               if (ds_file_group->sc == sc &&
                                ds_file_group->stream_id ==
                                stream_instance_id) {
                        break;
@@ -726,7 +721,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
 
        if (!ds_file_group) {
                ds_file_group = ctf_fs_ds_file_group_create(ctf_fs_trace,
-                       stream_class, stream_instance_id);
+                       sc, stream_instance_id);
                if (!ds_file_group) {
                        goto error;
                }
@@ -860,19 +855,25 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
                        goto error;
                }
 
-               if (ds_file_group->stream_id == UINT64_C(-1)) {
-                       /* No stream ID: use 0 */
-                       ds_file_group->stream = bt_stream_create_with_id(
-                               ds_file_group->stream_class,
-                               ctf_fs_trace->trace,
-                               ctf_fs_trace->next_stream_id);
-                       ctf_fs_trace->next_stream_id++;
+               if (ds_file_group->sc->ir_sc) {
+                       BT_ASSERT(ctf_fs_trace->trace);
+
+                       if (ds_file_group->stream_id == UINT64_C(-1)) {
+                               /* No stream ID: use 0 */
+                               ds_file_group->stream = bt_stream_create_with_id(
+                                       ds_file_group->sc->ir_sc,
+                                       ctf_fs_trace->trace,
+                                       ctf_fs_trace->next_stream_id);
+                               ctf_fs_trace->next_stream_id++;
+                       } else {
+                               /* Specific stream ID */
+                               ds_file_group->stream = bt_stream_create_with_id(
+                                       ds_file_group->sc->ir_sc,
+                                       ctf_fs_trace->trace,
+                                       (uint64_t) ds_file_group->stream_id);
+                       }
                } else {
-                       /* Specific stream ID */
-                       ds_file_group->stream = bt_stream_create_with_id(
-                               ds_file_group->stream_class,
-                               ctf_fs_trace->trace,
-                               (uint64_t) ds_file_group->stream_id);
+                       ds_file_group->stream = NULL;
                }
 
                if (!ds_file_group->stream) {
index 694b18480c8053d2796203bc499c8b32502c059b..40060c6a017d1dee1fce57d936dfd38b2d3310f9 100644 (file)
@@ -114,7 +114,7 @@ struct ctf_fs_ds_file_group {
        GPtrArray *ds_file_infos;
 
        /* Owned by this */
-       bt_stream_class *stream_class;
+       struct ctf_stream_class *sc;
 
        /* Owned by this */
        bt_stream *stream;
index 8dcc492ee8cdbfa6099d306cb94e2e0a7da2e2fb..0e2fb991b088eb57215bf306e9b2e94b163a33ba 100644 (file)
@@ -226,36 +226,22 @@ end:
 }
 
 static
-int add_stream_ids(bt_value *info, const bt_stream *stream)
+int add_stream_ids(bt_value *info, struct ctf_fs_ds_file_group *ds_file_group)
 {
        int ret = 0;
-       int64_t stream_class_id, stream_instance_id;
        bt_value_status status;
-       const bt_stream_class *stream_class = NULL;
 
-       stream_instance_id = bt_stream_get_id(stream);
-       if (stream_instance_id != -1) {
+       if (ds_file_group->stream_id != UINT64_C(-1)) {
                status = bt_value_map_insert_integer_entry(info, "id",
-                               stream_instance_id);
+                       (int64_t) ds_file_group->stream_id);
                if (status != BT_VALUE_STATUS_OK) {
                        ret = -1;
                        goto end;
                }
        }
 
-       stream_class = bt_stream_borrow_class_const(stream);
-       if (!stream_class) {
-               ret = -1;
-               goto end;
-       }
-
-       stream_class_id = bt_stream_class_get_id(stream_class);
-       if (stream_class_id == -1) {
-               ret = -1;
-               goto end;
-       }
-
-       status = bt_value_map_insert_integer_entry(info, "class-id", stream_class_id);
+       status = bt_value_map_insert_integer_entry(info, "class-id",
+               (int64_t) ds_file_group->sc->id);
        if (status != BT_VALUE_STATUS_OK) {
                ret = -1;
                goto end;
@@ -286,8 +272,8 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group,
        for (file_idx = 0; file_idx < group->ds_file_infos->len; file_idx++) {
                int64_t file_begin_epoch, file_end_epoch;
                struct ctf_fs_ds_file_info *info =
-                               g_ptr_array_index(group->ds_file_infos,
-                                       file_idx);
+                       g_ptr_array_index(group->ds_file_infos,
+                               file_idx);
 
                if (!info->index || info->index->entries->len == 0) {
                        BT_LOGW("Cannot determine range of unindexed stream file \'%s\'",
@@ -331,7 +317,7 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group,
                goto end;
        }
 
-       ret = add_stream_ids(group_info, group->stream);
+       ret = add_stream_ids(group_info, group);
        if (ret) {
                goto end;
        }
This page took 0.029547 seconds and 4 git commands to generate.