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;
}
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;
}
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 \
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
/** 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. */
};
struct bt_ctf_stream_class;
struct bt_ctf_event_class;
-
/* BT_NOTIFICATION_TYPE_NEW_TRACE */
/**
* Create a new trace notification.
--- /dev/null
+#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 */
--- /dev/null
+#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 */
libplugin_system_notification_la_SOURCES = \
notification.c \
packet.c \
- event.c
+ event.c \
+ stream.c
#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;
}
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;
notification = g_new0(struct bt_notification_packet_start, 1);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_PACKET_START,
- bt_notification_start_packet_destroy);
+ bt_notification_packet_start_destroy);
notification->packet = bt_get(packet);
return ¬ification->parent;
error:
notification = g_new0(struct bt_notification_packet_end, 1);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_PACKET_END,
- bt_notification_end_packet_destroy);
+ bt_notification_packet_end_destroy);
notification->packet = bt_get(packet);
return ¬ification->parent;
error:
--- /dev/null
+/*
+ * 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(¬ification->parent,
+ BT_NOTIFICATION_TYPE_STREAM_END,
+ bt_notification_stream_end_destroy);
+ notification->stream = bt_get(stream);
+ return ¬ification->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);
+}
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,
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 &&
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;
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;
}
bt_put(ctf_fs->current_notification);
ctf_fs->current_notification = notification;
end:
- return BT_NOTIFICATION_ITERATOR_STATUS_OK;
+ return ret;
}
static
if (ret) {
goto error;
}
-
end:
return ret;
error:
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
-
end:
return ret;
error:
size_t mmap_len;
off_t mmap_offset;
off_t request_offset;
+ bool end_reached;
};
struct ctf_fs_data_stream {
};
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
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");
if (ret != BT_COMPONENT_STATUS_OK) {
goto error;
}
+
+ text->out = stdout;
+ text->err = stderr;
end:
return ret;
error: