From 413bc2c417a706e7e2cc331077421e89e36daea0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 5 Sep 2016 15:36:49 -0400 Subject: [PATCH] Init ctf fs data and metadata streams MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- .../plugin/notification/iterator-internal.h | 1 + .../babeltrace/plugin/notification/iterator.h | 3 +++ lib/plugin-system/iterator.c | 9 +++++++ plugins/ctf/fs/data-stream.c | 2 +- plugins/ctf/fs/data-stream.h | 24 ++++--------------- plugins/ctf/fs/file.c | 2 +- plugins/ctf/fs/fs.c | 13 ++++++---- plugins/ctf/fs/fs.h | 1 + plugins/ctf/fs/metadata.c | 2 +- plugins/ctf/fs/metadata.h | 2 +- 10 files changed, 32 insertions(+), 27 deletions(-) diff --git a/include/babeltrace/plugin/notification/iterator-internal.h b/include/babeltrace/plugin/notification/iterator-internal.h index dd6ba450..b56d86c7 100644 --- a/include/babeltrace/plugin/notification/iterator-internal.h +++ b/include/babeltrace/plugin/notification/iterator-internal.h @@ -33,6 +33,7 @@ struct bt_notification_iterator { struct bt_object base; + struct bt_component *component; bt_notification_iterator_get_cb get; bt_notification_iterator_next_cb next; void *user_data; diff --git a/include/babeltrace/plugin/notification/iterator.h b/include/babeltrace/plugin/notification/iterator.h index 7729cb5e..5558aa7f 100644 --- a/include/babeltrace/plugin/notification/iterator.h +++ b/include/babeltrace/plugin/notification/iterator.h @@ -119,6 +119,9 @@ extern enum bt_notification_iterator_status *bt_notification_iterator_seek( struct bt_notification_iterator *iterator, int whence, int64_t time); +extern struct bt_component *bt_notification_iterator_get_component( + struct bt_notification_iterator *iterator); + #ifdef __cplusplus } #endif diff --git a/lib/plugin-system/iterator.c b/lib/plugin-system/iterator.c index 6a40ba70..06fea4aa 100644 --- a/lib/plugin-system/iterator.c +++ b/lib/plugin-system/iterator.c @@ -45,6 +45,7 @@ void bt_notification_iterator_destroy(struct bt_object *obj) if (iterator->user_destroy) { iterator->user_destroy(iterator); } + BT_PUT(iterator->component); g_free(iterator); } @@ -64,6 +65,7 @@ struct bt_notification_iterator *bt_notification_iterator_create( goto end; } + iterator->component = bt_get(component); bt_object_init(iterator, bt_notification_iterator_destroy); end: return iterator; @@ -158,3 +160,10 @@ bt_notification_iterator_set_private_data( end: return ret; } + +struct bt_component *bt_notification_iterator_get_component( + struct bt_notification_iterator *iterator) +{ + return bt_get(iterator->component); +} + diff --git a/plugins/ctf/fs/data-stream.c b/plugins/ctf/fs/data-stream.c index 6fba603a..b29c40a0 100644 --- a/plugins/ctf/fs/data-stream.c +++ b/plugins/ctf/fs/data-stream.c @@ -327,7 +327,7 @@ end: return ret; } -void ctf_fs_data_stream_deinit(struct ctf_fs_data_stream *data_stream) +void ctf_fs_data_stream_fini(struct ctf_fs_data_stream *data_stream) { g_ptr_array_free(data_stream->streams, TRUE); } diff --git a/plugins/ctf/fs/data-stream.h b/plugins/ctf/fs/data-stream.h index d8f67466..60a46e16 100644 --- a/plugins/ctf/fs/data-stream.h +++ b/plugins/ctf/fs/data-stream.h @@ -28,35 +28,21 @@ #include #include -#include "ctf-notif-iter/ctf-notif-iter.h" - -struct ctf_fs_stream { - struct ctf_fs_file *file; - struct bt_ctf_stream *stream; - struct bt_ctf_notif_iter *notif_iter; - void *mmap_addr; - size_t mmap_len; - off_t mmap_offset; - off_t request_offset; -}; - -struct ctf_fs_data_stream { - GPtrArray *streams; -}; +#include "../common/notif-iter/notif-iter.h" BT_HIDDEN -int ctf_fs_data_stream_init(struct ctf_fs *ctf_fs, +int ctf_fs_data_stream_init(struct ctf_fs_component *ctf_fs, struct ctf_fs_data_stream *data_stream); BT_HIDDEN -void ctf_fs_data_stream_deinit(struct ctf_fs_data_stream *data_stream); +void ctf_fs_data_stream_fini(struct ctf_fs_data_stream *data_stream); BT_HIDDEN -int ctf_fs_data_stream_open_streams(struct ctf_fs *ctf_fs); +int ctf_fs_data_stream_open_streams(struct ctf_fs_component *ctf_fs); BT_HIDDEN int ctf_fs_data_stream_get_next_notification( - struct ctf_fs *ctf_fs, + struct ctf_fs_component *ctf_fs, struct bt_ctf_notif_iter_notif **notification); #endif /* CTF_FS_DATA_STREAM_H */ diff --git a/plugins/ctf/fs/file.c b/plugins/ctf/fs/file.c index 1d31bcfc..54b11a67 100644 --- a/plugins/ctf/fs/file.c +++ b/plugins/ctf/fs/file.c @@ -89,7 +89,7 @@ int ctf_fs_file_open(struct ctf_fs_component *ctf_fs, struct ctf_fs_file *file, PDBG("Opening file \"%s\" with mode \"%s\"\n", file->path->str, mode); file->fp = fopen(file->path->str, mode); if (!file->fp) { - PERR("Cannot open file \"%s\" with mode \"%s\": %s", + PERR("Cannot open file \"%s\" with mode \"%s\": %s\n", file->path->str, mode, strerror(errno)); goto error; } diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 9019543e..6c7f2030 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -32,6 +32,8 @@ #include #include #include "fs.h" +#include "metadata.h" +#include "data-stream.h" static bool ctf_fs_debug; @@ -67,8 +69,8 @@ static enum bt_component_status ctf_fs_iterator_init(struct bt_component *source, struct bt_notification_iterator *it) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; struct ctf_fs_iterator *ctf_it; + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; assert(source && it); ctf_it = g_new0(struct ctf_fs_iterator, 1); @@ -112,8 +114,8 @@ void ctf_fs_destroy_data(struct ctf_fs_component *component) g_string_free(component->trace_path, TRUE); } -// ctf_fs_metadata_fini(&component->metadata); -// ctf_fs_data_stream_fini(&component->data_stream); + ctf_fs_metadata_fini(&component->metadata); + ctf_fs_data_stream_fini(&component->data_stream); g_free(component); } @@ -156,7 +158,9 @@ struct ctf_fs_component *ctf_fs_create(struct bt_value *params) ctf_fs->error_fp = stderr; ctf_fs->page_size = (size_t) getpagesize(); - + ctf_fs_data_stream_init(ctf_fs, &ctf_fs->data_stream); + ctf_fs_metadata_set_trace(ctf_fs); + ctf_fs_data_stream_open_streams(ctf_fs); end: return ctf_fs; error: @@ -194,6 +198,7 @@ enum bt_component_status ctf_fs_init(struct bt_component *source, if (ret != BT_COMPONENT_STATUS_OK) { goto error; } + end: return ret; error: diff --git a/plugins/ctf/fs/fs.h b/plugins/ctf/fs/fs.h index ff97b7a2..7a67b48a 100644 --- a/plugins/ctf/fs/fs.h +++ b/plugins/ctf/fs/fs.h @@ -78,6 +78,7 @@ struct ctf_fs_component { GString *trace_path; FILE *error_fp; size_t page_size; + struct bt_notification *last_notif; struct ctf_fs_metadata metadata; struct ctf_fs_data_stream data_stream; struct ctf_fs_component_options options; diff --git a/plugins/ctf/fs/metadata.c b/plugins/ctf/fs/metadata.c index 967452f9..38283680 100644 --- a/plugins/ctf/fs/metadata.c +++ b/plugins/ctf/fs/metadata.c @@ -393,7 +393,7 @@ int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata) return 0; } -void ctf_fs_metadata_deinit(struct ctf_fs_metadata *metadata) +void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata) { if (metadata->text) { free(metadata->text); diff --git a/plugins/ctf/fs/metadata.h b/plugins/ctf/fs/metadata.h index eeccf848..7ed7f069 100644 --- a/plugins/ctf/fs/metadata.h +++ b/plugins/ctf/fs/metadata.h @@ -35,7 +35,7 @@ BT_HIDDEN int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata); BT_HIDDEN -void ctf_fs_metadata_deinit(struct ctf_fs_metadata *metadata); +void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata); BT_HIDDEN void ctf_fs_metadata_set_trace(struct ctf_fs_component *ctf_fs); -- 2.34.1