From 0982a26d7f4ad134fbef954f87d0fd5d7bb60af4 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 25 Apr 2017 21:53:25 -0400 Subject: [PATCH] ctf: bt_ctf_notif_iter_get_next_notification(): require CC prio. map MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since bt_notification_event_create() freezes its clock class priority map, pass which clock class priority map to use each time you call bt_ctf_notif_iter_get_next_notification(). In ctf.fs, it's always the same because all the clock classes are known when the trace object is created. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- plugins/ctf/common/notif-iter/notif-iter.c | 13 ++++--------- plugins/ctf/common/notif-iter/notif-iter.h | 6 +++--- plugins/ctf/fs/data-stream.c | 7 +++++-- plugins/ctf/fs/fs.h | 1 + 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index f6fe230c..bb629b18 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -162,9 +162,6 @@ struct bt_ctf_notif_iter { struct bt_ctf_event_class *event_class; } meta; - /* Clock class priority map (owned by this) */ - struct bt_clock_class_priority_map *cc_prio_map; - /* Current packet (NULL if not created yet) */ struct bt_ctf_packet *packet; @@ -2193,6 +2190,7 @@ void notify_end_of_packet(struct bt_ctf_notif_iter *notit, static void notify_event(struct bt_ctf_notif_iter *notit, + struct bt_clock_class_priority_map *cc_prio_map, struct bt_notification **notification) { struct bt_ctf_event *event; @@ -2204,7 +2202,7 @@ void notify_event(struct bt_ctf_notif_iter *notit, goto end; } - ret = bt_notification_event_create(event, notit->cc_prio_map); + ret = bt_notification_event_create(event, cc_prio_map); if (!ret) { goto end; } @@ -2312,7 +2310,6 @@ end: BT_HIDDEN struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, - struct bt_clock_class_priority_map *cc_prio_map, size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops, void *data, FILE *err_stream) @@ -2337,7 +2334,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, }; assert(trace); - assert(cc_prio_map); assert(medops.request_bytes); assert(medops.get_stream); notit = g_new0(struct bt_ctf_notif_iter, 1); @@ -2356,7 +2352,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, PERR("Failed to initialize stream clock states\n"); goto error; } - notit->cc_prio_map = bt_get(cc_prio_map); notit->meta.trace = bt_get(trace); notit->medium.medops = medops; notit->medium.max_request_sz = max_request_sz; @@ -2400,7 +2395,6 @@ error: void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit) { - BT_PUT(notit->cc_prio_map); BT_PUT(notit->meta.trace); BT_PUT(notit->meta.stream_class); BT_PUT(notit->meta.event_class); @@ -2432,6 +2426,7 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit) enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( struct bt_ctf_notif_iter *notit, + struct bt_clock_class_priority_map *cc_prio_map, struct bt_notification **notification) { enum bt_ctf_notif_iter_status status = BT_CTF_NOTIF_ITER_STATUS_OK; @@ -2461,7 +2456,7 @@ enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( goto end; case STATE_EMIT_NOTIF_EVENT: PDBG("Emitting event notification\n"); - notify_event(notit, notification); + notify_event(notit, cc_prio_map, notification); if (!*notification) { status = BT_CTF_NOTIF_ITER_STATUS_ERROR; } diff --git a/plugins/ctf/common/notif-iter/notif-iter.h b/plugins/ctf/common/notif-iter/notif-iter.h index b8b91c5e..90a53bae 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.h +++ b/plugins/ctf/common/notif-iter/notif-iter.h @@ -234,8 +234,6 @@ struct bt_ctf_notif_iter_notif_event { * incremented. * * @param trace Trace to read - * @param cc_prio_map Clock class priority map to use when - * creating the event notifications * @param max_request_sz Maximum buffer size, in bytes, to * request to * bt_ctf_notif_iter_medium_ops::request_bytes() @@ -248,7 +246,6 @@ struct bt_ctf_notif_iter_notif_event { */ BT_HIDDEN struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace, - struct bt_clock_class_priority_map *cc_prio_map, size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops, void *medops_data, FILE *err_stream); @@ -275,6 +272,8 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notif_iter); * call this function again, until another status is returned. * * @param notif_iter CTF notification iterator + * @param cc_prio_map Clock class priority map to use when + * creating an event notification * @param notification Returned notification if the function's * return value is #BT_CTF_NOTIF_ITER_STATUS_OK * @returns One of #bt_ctf_notif_iter_status values @@ -282,6 +281,7 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notif_iter); BT_HIDDEN enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification( struct bt_ctf_notif_iter *notit, + struct bt_clock_class_priority_map *cc_prio_map, struct bt_notification **notification); #endif /* CTF_NOTIF_ITER_H */ diff --git a/plugins/ctf/fs/data-stream.c b/plugins/ctf/fs/data-stream.c index 70bdf5a8..38843d7b 100644 --- a/plugins/ctf/fs/data-stream.c +++ b/plugins/ctf/fs/data-stream.c @@ -363,6 +363,7 @@ struct ctf_fs_stream *ctf_fs_stream_create( goto error; } + stream->cc_prio_map = bt_get(ctf_fs->cc_prio_map); g_string_assign(stream->file->path, path); ret = ctf_fs_file_open(ctf_fs, stream->file, "rb"); if (ret) { @@ -370,7 +371,7 @@ struct ctf_fs_stream *ctf_fs_stream_create( } stream->notif_iter = bt_ctf_notif_iter_create(ctf_fs->metadata->trace, - ctf_fs->cc_prio_map, ctf_fs->page_size, medops, stream, + ctf_fs->page_size, medops, stream, ctf_fs->error_fp); if (!stream->notif_iter) { goto error; @@ -397,6 +398,8 @@ void ctf_fs_stream_destroy(struct ctf_fs_stream *stream) return; } + bt_put(stream->cc_prio_map); + if (stream->file) { ctf_fs_file_destroy(stream->file); } @@ -432,7 +435,7 @@ struct bt_notification_iterator_next_return ctf_fs_stream_next( } notif_iter_status = bt_ctf_notif_iter_get_next_notification(stream->notif_iter, - &ret.notification); + stream->cc_prio_map, &ret.notification); if (notif_iter_status != BT_CTF_NOTIF_ITER_STATUS_OK && notif_iter_status != BT_CTF_NOTIF_ITER_STATUS_EOF) { goto translate_status; diff --git a/plugins/ctf/fs/fs.h b/plugins/ctf/fs/fs.h index 0e286f17..836c106c 100644 --- a/plugins/ctf/fs/fs.h +++ b/plugins/ctf/fs/fs.h @@ -57,6 +57,7 @@ struct ctf_fs_metadata { struct ctf_fs_stream { struct ctf_fs_file *file; struct bt_ctf_stream *stream; + struct bt_clock_class_priority_map *cc_prio_map; struct bt_ctf_notif_iter *notif_iter; /* A stream is assumed to be indexed. */ struct index index; -- 2.34.1