add end of stream notification
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Sep 2016 22:23:56 +0000 (18:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
14 files changed:
converter/babeltrace.c
include/Makefile.am
include/babeltrace/plugin/notification/notification.h
include/babeltrace/plugin/notification/schema.h
include/babeltrace/plugin/notification/stream-internal.h [new file with mode: 0644]
include/babeltrace/plugin/notification/stream.h [new file with mode: 0644]
lib/plugin-system/notification/Makefile.am
lib/plugin-system/notification/packet.c
lib/plugin-system/notification/stream.c [new file with mode: 0644]
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/fs/data-stream.c
plugins/ctf/fs/fs.c
plugins/ctf/fs/fs.h
plugins/text/text.c

index e563c0a4fd6b18c98d101ba5ed1d989f02739a12..5b381bf6cd1f575f728bdbd820ddb9fca28838d3 100644 (file)
@@ -255,7 +255,7 @@ int main(int argc, char **argv)
                        component_factory, "ctf", BT_COMPONENT_TYPE_SOURCE,
                        "fs");
        if (!source_class) {
-               fprintf(stderr, "Could not find ctf-fs output component class. Aborting...\n");
+               fprintf(stderr, "Could not find ctf-fs source component class. Aborting...\n");
                ret = -1;
                goto end;
        }
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
        sink_class = bt_component_factory_get_component_class(component_factory,
                        "text", BT_COMPONENT_TYPE_SINK, "text");
        if (!sink_class) {
-               fprintf(stderr, "Could not find text output component class. Aborting...\n");
+               fprintf(stderr, "Could not find text sink component class. Aborting...\n");
                ret = -1;
                goto end;
        }
index 76e077223a12dda2e9beb2602d65fdf4d89c3435..5ae1cc30300135a9ada93eb7e552d79072c7ad94 100644 (file)
@@ -51,7 +51,8 @@ babeltraceplugininclude_HEADERS = \
        babeltrace/plugin/notification/event.h \
        babeltrace/plugin/notification/iterator.h \
        babeltrace/plugin/notification/packet.h \
-       babeltrace/plugin/notification/schema.h
+       babeltrace/plugin/notification/schema.h \
+       babeltrace/plugin/notification/stream.h
 
 noinst_HEADERS = \
        babeltrace/align.h \
@@ -122,4 +123,5 @@ noinst_HEADERS = \
        babeltrace/plugin/notification/event-internal.h \
        babeltrace/plugin/notification/iterator-internal.h \
        babeltrace/plugin/notification/notification-internal.h \
-       babeltrace/plugin/notification/packet-internal.h
+       babeltrace/plugin/notification/packet-internal.h \
+       babeltrace/plugin/notification/stream-internal.h
index 5557f919b3ac3723d495871fefb687094fcd05b5..4636f229126f6f14386637aa7c38af0c1cc5a7b4 100644 (file)
@@ -54,17 +54,20 @@ enum bt_notification_type {
        /** End of stream packet notification, see packet.h */
        BT_NOTIFICATION_TYPE_PACKET_END = 3,
 
+       /** End of stream packet notification, see stream.h */
+       BT_NOTIFICATION_TYPE_STREAM_END = 4,
+
        /** New trace notification, see model.h */
-       BT_NOTIFICATION_TYPE_NEW_TRACE = 4,
+       BT_NOTIFICATION_TYPE_NEW_TRACE = 5,
 
        /** New stream class notification, see model.h */
-       BT_NOTIFICATION_TYPE_NEW_STREAM_CLASS = 5,
+       BT_NOTIFICATION_TYPE_NEW_STREAM_CLASS = 6,
 
        /** New event class notification, see model.h */
-       BT_NOTIFICATION_TYPE_NEW_EVENT_CLASS = 6,
+       BT_NOTIFICATION_TYPE_NEW_EVENT_CLASS = 7,
 
        /** End of trace notification, see eot.h */
-       BT_NOTIFICATION_TYPE_END_OF_TRACE = 7,
+       BT_NOTIFICATION_TYPE_END_OF_TRACE = 8,
 
        BT_NOTIFICATION_TYPE_NR, /* Not part of ABI. */
 };
index 96b161a0ab45b8c10a2e7c01931fbe41acf42f6e..5d7b6425f3e39b1fa8932ea53a289e7ea4ae56e6 100644 (file)
@@ -36,7 +36,6 @@ struct bt_ctf_trace;
 struct bt_ctf_stream_class;
 struct bt_ctf_event_class;
 
-
 /* BT_NOTIFICATION_TYPE_NEW_TRACE */
 /**
  * Create a new trace notification.
diff --git a/include/babeltrace/plugin/notification/stream-internal.h b/include/babeltrace/plugin/notification/stream-internal.h
new file mode 100644 (file)
index 0000000..73e2fd6
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef BABELTRACE_PLUGIN_NOTIFICATION_STREAM_INTERNAL_H
+#define BABELTRACE_PLUGIN_NOTIFICATION_STREAM_INTERNAL_H
+
+/*
+ * BabelTrace - Stream-related Notifications
+ *
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-ir/packet.h>
+#include <babeltrace/plugin/notification/notification-internal.h>
+
+struct bt_notification_stream_end {
+       struct bt_notification parent;
+       struct bt_ctf_stream *stream;
+};
+
+#endif /* BABELTRACE_PLUGIN_NOTIFICATION_STREAM_INTERNAL_H */
diff --git a/include/babeltrace/plugin/notification/stream.h b/include/babeltrace/plugin/notification/stream.h
new file mode 100644 (file)
index 0000000..6f07925
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef BABELTRACE_PLUGIN_NOTIFICATION_STREAM_H
+#define BABELTRACE_PLUGIN_NOTIFICATION_STREAM_H
+
+/*
+ * BabelTrace - Plug-in Stream-related Notifications
+ *
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/plugin/notification/notification.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*** BT_NOTIFICATION_TYPE_STREAM_END ***/
+struct bt_notification *bt_notification_stream_end_create(
+               struct bt_ctf_stream *stream);
+struct bt_ctf_stream *bt_notification_stream_end_get_stream(
+               struct bt_notification *notification);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_NOTIFICATION_STREAM_H */
index 1271c6eb501ac2c67ad4ac38b114e0d18acf3b0d..12cdbf1215f97ee2bdc3c77bf5717f1b22a3db4e 100644 (file)
@@ -6,4 +6,5 @@ noinst_LTLIBRARIES = libplugin-system-notification.la
 libplugin_system_notification_la_SOURCES = \
        notification.c \
        packet.c \
-       event.c
+       event.c \
+       stream.c
index 0b6649a9686e6f2b072cb18777917f55e49dc1f2..112f0f788d354bc78bc04d35a99f386bb1863bf0 100644 (file)
@@ -28,7 +28,7 @@
 #include <babeltrace/plugin/notification/packet-internal.h>
 
 static
-void bt_notification_start_packet_destroy(struct bt_object *obj)
+void bt_notification_packet_start_destroy(struct bt_object *obj)
 {
        struct bt_notification_packet_start *notification =
                        (struct bt_notification_packet_start *) obj;
@@ -38,7 +38,7 @@ void bt_notification_start_packet_destroy(struct bt_object *obj)
 }
 
 static
-void bt_notification_end_packet_destroy(struct bt_object *obj)
+void bt_notification_packet_end_destroy(struct bt_object *obj)
 {
        struct bt_notification_packet_end *notification =
                        (struct bt_notification_packet_end *) obj;
@@ -59,7 +59,7 @@ struct bt_notification *bt_notification_packet_start_create(
        notification = g_new0(struct bt_notification_packet_start, 1);
        bt_notification_init(&notification->parent,
                        BT_NOTIFICATION_TYPE_PACKET_START,
-                       bt_notification_start_packet_destroy);
+                       bt_notification_packet_start_destroy);
        notification->packet = bt_get(packet);
        return &notification->parent;
 error:
@@ -88,7 +88,7 @@ struct bt_notification *bt_notification_packet_end_create(
        notification = g_new0(struct bt_notification_packet_end, 1);
        bt_notification_init(&notification->parent,
                        BT_NOTIFICATION_TYPE_PACKET_END,
-                       bt_notification_end_packet_destroy);
+                       bt_notification_packet_end_destroy);
        notification->packet = bt_get(packet);
        return &notification->parent;
 error:
diff --git a/lib/plugin-system/notification/stream.c b/lib/plugin-system/notification/stream.c
new file mode 100644 (file)
index 0000000..bc0b1b7
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Babeltrace Plug-in Stream-related Notifications
+ *
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/compiler.h>
+#include <babeltrace/plugin/notification/stream-internal.h>
+
+static
+void bt_notification_stream_end_destroy(struct bt_object *obj)
+{
+       struct bt_notification_stream_end *notification =
+                       (struct bt_notification_stream_end *) obj;
+
+       BT_PUT(notification->stream);
+       g_free(notification);
+}
+
+struct bt_notification *bt_notification_stream_end_create(
+               struct bt_ctf_stream *stream)
+{
+       struct bt_notification_stream_end *notification;
+
+       if (!stream) {
+               goto error;
+       }
+
+       notification = g_new0(struct bt_notification_stream_end, 1);
+       bt_notification_init(&notification->parent,
+                       BT_NOTIFICATION_TYPE_STREAM_END,
+                       bt_notification_stream_end_destroy);
+       notification->stream = bt_get(stream);
+       return &notification->parent;
+error:
+       return NULL;
+}
+
+struct bt_ctf_packet *bt_notification_stream_end_get_stream(
+               struct bt_notification *notification)
+{
+       struct bt_notification_stream_end *stream_end;
+
+       stream_end = container_of(notification,
+                       struct bt_notification_stream_end, parent);
+       return bt_get(stream_end->stream);
+}
index ee4cd2be3acd2d4cd02ce5357a3b382d64bf7270..5de812b026bd36ecab472b36d1246e4231c8900a 100644 (file)
@@ -1735,6 +1735,28 @@ end:
        BT_PUT(event);
 }
 
+static
+void notify_eos(struct bt_ctf_notif_iter *notit,
+               struct bt_notification **notification)
+{
+       struct bt_ctf_event *event;
+       struct bt_notification *ret = NULL;
+
+       /* Create event */
+       event = create_event(notit);
+       if (!event) {
+               goto end;
+       }
+
+       ret = bt_notification_stream_end_create(event);
+       if (!ret) {
+               goto end;
+       }
+       *notification = ret;
+end:
+       BT_PUT(event);
+}
+
 struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
                size_t max_request_sz,
                struct bt_ctf_notif_iter_medium_ops medops,
index 64152ed2e1c5e5cd11c60cfe087b65991935c39c..704e4f647a39d6180b8d02fd051893be6fbfba27 100644 (file)
@@ -330,6 +330,11 @@ enum bt_notification_iterator_status ctf_fs_data_stream_get_next_notification(
        struct ctf_fs_stream *stream = g_ptr_array_index(
                        ctf_fs->data_stream.streams, 0);
 
+       if (stream->end_reached) {
+               status = BT_CTF_NOTIF_ITER_STATUS_EOF;
+               goto end;
+       }
+
        status = bt_ctf_notif_iter_get_next_notification(stream->notif_iter,
                        notification);
        if (status != BT_CTF_NOTIF_ITER_STATUS_OK &&
@@ -337,12 +342,21 @@ enum bt_notification_iterator_status ctf_fs_data_stream_get_next_notification(
                goto end;
        }
 
+       /* Should be handled in bt_ctf_notif_iter_get_next_notification. */
+       if (status == BT_CTF_NOTIF_ITER_STATUS_EOF) {
+               *notification = bt_notification_stream_end_create(
+                               stream->stream);
+               if (!*notification) {
+                       status = BT_CTF_NOTIF_ITER_STATUS_ERROR;
+               }
+               status = BT_CTF_NOTIF_ITER_STATUS_OK;
+               stream->end_reached = true;
+       }
 end:
        switch (status) {
        case BT_CTF_NOTIF_ITER_STATUS_EOF:
-               /* Not an error, send end of stream notification. */
-               /* Subsequent calls to "next" should return BT_NOTIFICATION_STATUS_END */
-               /* TODO */
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_END;
+               break;
        case BT_CTF_NOTIF_ITER_STATUS_OK:
                ret = BT_NOTIFICATION_ITERATOR_STATUS_OK;
                break;
@@ -356,6 +370,7 @@ end:
        case BT_CTF_NOTIF_ITER_STATUS_INVAL:
                /* No argument provided by the user, so don't return INVAL. */
        case BT_CTF_NOTIF_ITER_STATUS_ERROR:
+       default:
                ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
                break;
        }
index ba550f2f973f4f5c480b63612e52e6bb4e3a5993..cf00fddd9986c2aa288d0b2e222d0d65342f3a1b 100644 (file)
@@ -86,7 +86,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_next(
        bt_put(ctf_fs->current_notification);
        ctf_fs->current_notification = notification;
 end:
-       return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+       return ret;
 }
 
 static
@@ -137,7 +137,6 @@ enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
        if (ret) {
                goto error;
        }
-
 end:
        return ret;
 error:
@@ -240,7 +239,6 @@ enum bt_component_status ctf_fs_init(struct bt_component *source,
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
-
 end:
        return ret;
 error:
index 31c868270922b1663b3263b88a03654d70c88699..f3d442e466bbf7e33d6be8c8822c394b3b6ebaec 100644 (file)
@@ -63,6 +63,7 @@ struct ctf_fs_stream {
        size_t mmap_len;
        off_t mmap_offset;
        off_t request_offset;
+       bool end_reached;
 };
 
 struct ctf_fs_data_stream {
index 40bc1c5ea6b54f69c1a0211b16deafa8643b3182..9d72e3a1ed76a0b0765f66f2c33c9c3e1e35f3de 100644 (file)
@@ -72,25 +72,23 @@ const char *loglevel_str [] = {
 };
 
 struct text_options {
-       bool opt_print_all_field_names : 1;
-       bool opt_print_scope_field_names : 1;
-       bool opt_print_header_field_names : 1;
-       bool opt_print_context_field_names : 1;
-       bool opt_print_payload_field_names : 1;
-       bool opt_print_all_fields : 1;
-       bool opt_print_trace_field : 1;
-       bool opt_print_trace_domain_field : 1;
-       bool opt_print_trace_procname_field : 1;
-       bool opt_print_trace_vpid_field : 1;
-       bool opt_print_trace_hostname_field : 1;
-       bool opt_print_trace_default_fields : 1;
-       bool opt_print_loglevel_field : 1;
-       bool opt_print_emf_field : 1;
-       bool opt_print_delta_field : 1;
+       bool print_scope_field_names : 1;
+       bool print_header_field_names : 1;
+       bool print_context_field_names : 1;
+       bool print_payload_field_names : 1;
+       bool print_delta_field : 1;
+       bool print_loglevel_field : 1;
+       bool print_trace_field : 1;
+       bool print_trace_domain_field : 1;
+       bool print_trace_procname_field : 1;
+       bool print_trace_vpid_field : 1;
+       bool print_trace_hostname_field : 1;
+       bool no_size_limit : 1;
 };
 
 struct text_component {
        struct text_options options;
+       FILE *out, *err;
 };
 
 static
@@ -124,7 +122,10 @@ enum bt_component_status handle_notification(struct bt_component *component,
                puts("</packet>");
                break;
        case BT_NOTIFICATION_TYPE_EVENT:
-               puts("<event>");
+               puts("\t<event>");
+               break;
+       case BT_NOTIFICATION_TYPE_STREAM_END:
+               puts("</stream>");
                break;
        default:
                puts("Unhandled notification type");
@@ -160,6 +161,9 @@ enum bt_component_status text_component_init(
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
+
+       text->out = stdout;
+       text->err = stderr;
 end:
        return ret;
 error:
This page took 0.033775 seconds and 4 git commands to generate.