lib: add discarded events message
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Feb 2019 20:54:47 +0000 (15:54 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
This patch implements the "discarded events" message API. You can create
such a message to communicate that events were discarded at the source
level.

This message conveys redundant information considering the "discarded
event counter" property of a packet object. However, this property will
be removed before 2.0-rc1, and the discarded event message will be the
only way to indicate discarded events. The rationale behind this is that
the beginning and end times of the packet object do not represent a
stream activity time range (this is indicated by stream activity
beginning and end messages now); they are used for discarded event and
packet counter time ranges (when using multiple packets). To make this
less confusing, discarded events and packets are or will be their own
messages. For the time being, both the properties and the messages
coexist.

There are two ways to create a discarded events message:

bt_message_discarded_events_create():
    Create a message using a stream of which the class has no default
    clock class. This indicates that a number of events were discarded
    at this point within the message flow.

bt_message_discarded_events_create_with_default_clock_snapshots():
    Create a message using a stream of which the class has a default
    clock class. In this case, you must pass the beginning and end clock
    snapshot raw values which delimit the time range when events were
    discarded by the tracer.

    Within the message flow, the beginning time must be greater than or
    equal to the previous message's time (depending on its type). The
    end time can be greater than the next message's time. For example,
    the `ctf` plugin sources will push such a message following a packet
    end message, and the time range will be said packet end message's
    packet's end time to the next packet's end time.

By default, the message indicates that "a number" of events were
discarded. In other words, bt_message_discarded_events_get_count()
returns `BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE`. To be more accurate,
use bt_message_discarded_events_set_count() to set a specific discarded
event count.

The implementation deals with "discarded items" message objects because
the same code will be used to implement the discarded packets message
API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/Makefile.am
include/babeltrace/babeltrace.h
include/babeltrace/graph/message-const.h
include/babeltrace/graph/message-discarded-events-const.h [new file with mode: 0644]
include/babeltrace/graph/message-discarded-events.h [new file with mode: 0644]
include/babeltrace/graph/message-discarded-items-internal.h [new file with mode: 0644]
include/babeltrace/graph/message-internal.h
lib/graph/message/Makefile.am
lib/graph/message/discarded-items.c [new file with mode: 0644]
lib/graph/message/message.c
lib/lib-logging.c

index 4ed311a894de21f5502712ecdbbe57a6fe31e685..81437113de9e941d4a7b743b23b70e2af1b68689 100644 (file)
@@ -168,6 +168,8 @@ babeltracegraphinclude_HEADERS = \
        babeltrace/graph/graph-const.h \
        babeltrace/graph/graph.h \
        babeltrace/graph/message-const.h \
+       babeltrace/graph/message-discarded-events-const.h \
+       babeltrace/graph/message-discarded-events.h \
        babeltrace/graph/message-event-const.h \
        babeltrace/graph/message-event.h \
        babeltrace/graph/message-inactivity-const.h \
@@ -278,6 +280,7 @@ noinst_HEADERS = \
        babeltrace/graph/component-source-internal.h \
        babeltrace/graph/connection-internal.h \
        babeltrace/graph/graph-internal.h \
+       babeltrace/graph/message-discarded-items-internal.h \
        babeltrace/graph/message-event-internal.h \
        babeltrace/graph/message-inactivity-internal.h \
        babeltrace/graph/message-internal.h \
index 253bd960567cd77e36d041502c47b9a03d541cf4..913b4da7d88452dbb4ff2ea3c0931fee36e72f36 100644 (file)
 #include <babeltrace/graph/graph-const.h>
 #include <babeltrace/graph/graph.h>
 #include <babeltrace/graph/message-const.h>
+#include <babeltrace/graph/message-discarded-events-const.h>
+#include <babeltrace/graph/message-discarded-events.h>
 #include <babeltrace/graph/message-event-const.h>
 #include <babeltrace/graph/message-event.h>
 #include <babeltrace/graph/message-inactivity-const.h>
 #include <babeltrace/graph/message-packet-end-const.h>
 #include <babeltrace/graph/message-packet-end.h>
 #include <babeltrace/graph/message-stream-activity-beginning.h>
+#include <babeltrace/graph/message-stream-activity-const.h>
 #include <babeltrace/graph/message-stream-activity-end.h>
 #include <babeltrace/graph/message-stream-beginning-const.h>
 #include <babeltrace/graph/message-stream-beginning.h>
index 5085192ace3c5db4188dce329a6a775598a192ac..2e859f54c97dc218dd5bbaddec2df9b1b630a3e0 100644 (file)
@@ -43,6 +43,7 @@ typedef enum bt_message_type {
        BT_MESSAGE_TYPE_PACKET_END = 5,
        BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING = 6,
        BT_MESSAGE_TYPE_STREAM_ACTIVITY_END = 7,
+       BT_MESSAGE_TYPE_DISCARDED_EVENTS = 8,
 } bt_message_type;
 
 /**
diff --git a/include/babeltrace/graph/message-discarded-events-const.h b/include/babeltrace/graph/message-discarded-events-const.h
new file mode 100644 (file)
index 0000000..221667f
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@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.
+ */
+
+/* For bt_message, bt_clock_snapshot, bt_stream */
+#include <babeltrace/types.h>
+
+/* For bt_clock_snapshot_state */
+#include <babeltrace/trace-ir/clock-snapshot-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_clock_snapshot_state
+bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
+               const bt_message *msg, const bt_clock_snapshot **snapshot);
+
+extern bt_clock_snapshot_state
+bt_message_discarded_events_borrow_default_end_clock_snapshot_const(
+               const bt_message *msg, const bt_clock_snapshot **snapshot);
+
+extern const bt_stream *
+bt_message_discarded_events_borrow_stream_const(const bt_message *message);
+
+extern bt_property_availability bt_message_discarded_events_get_count(
+               const bt_message *message, uint64_t *count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H */
diff --git a/include/babeltrace/graph/message-discarded-events.h b/include/babeltrace/graph/message-discarded-events.h
new file mode 100644 (file)
index 0000000..787691d
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_stream */
+#include <babeltrace/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message *bt_message_discarded_events_create(
+               bt_self_message_iterator *message_iterator,
+               bt_stream *stream);
+
+extern bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
+               bt_self_message_iterator *message_iterator,
+               bt_stream *stream, uint64_t beginning_raw_value,
+               uint64_t end_raw_value);
+
+extern bt_stream *bt_message_discarded_events_borrow_stream(
+               bt_message *message);
+
+extern void bt_message_discarded_events_set_count(bt_message *message,
+               uint64_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H */
diff --git a/include/babeltrace/graph/message-discarded-items-internal.h b/include/babeltrace/graph/message-discarded-items-internal.h
new file mode 100644 (file)
index 0000000..3bd8941
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@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 <glib.h>
+#include <babeltrace/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace/trace-ir/stream-internal.h>
+#include <babeltrace/property-internal.h>
+#include <babeltrace/graph/message-const.h>
+
+struct bt_message_discarded_items {
+       struct bt_message parent;
+       struct bt_stream *stream;
+       struct bt_clock_snapshot *default_begin_cs;
+       struct bt_clock_snapshot *default_end_cs;
+       struct bt_property_uint count;
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H */
index 8c17ef9ea008865c46f125945c874cc0de606151..af68723805127820ee12deed52f5e472e09279c7 100644 (file)
@@ -128,6 +128,8 @@ const char *bt_message_type_string(enum bt_message_type type)
                return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING";
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
                return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_END";
+       case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+               return "BT_MESSAGE_TYPE_DISCARDED_EVENTS";
        default:
                return "(unknown)";
        }
index 20f6a00010fe1f7269fa03ff9a5cb2286a0bc167..9e2039b44329838c737b3d0046d8c3a9dde73401 100644 (file)
@@ -6,4 +6,5 @@ libgraph_message_la_SOURCES = \
        event.c \
        stream.c \
        inactivity.c \
-       stream-activity.c
+       stream-activity.c \
+       discarded-items.c
diff --git a/lib/graph/message/discarded-items.c b/lib/graph/message/discarded-items.c
new file mode 100644 (file)
index 0000000..c0e76e3
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@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.
+ */
+
+#define BT_LOG_TAG "MSG-DISCARDED-ITEMS"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/trace-ir/clock-class.h>
+#include <babeltrace/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace/trace-ir/stream-class-internal.h>
+#include <babeltrace/trace-ir/stream-internal.h>
+#include <babeltrace/property-internal.h>
+#include <babeltrace/graph/message-internal.h>
+#include <babeltrace/graph/message-discarded-items-internal.h>
+#include <babeltrace/graph/message-discarded-events.h>
+#include <babeltrace/graph/message-discarded-events-const.h>
+
+static
+void destroy_discarded_items_message(struct bt_object *obj)
+{
+       struct bt_message_discarded_items *message = (void *) obj;
+
+       BT_LIB_LOGD("Destroying discarded items message: %!+n", message);
+       BT_LIB_LOGD("Putting stream: %!+s", message->stream);
+       BT_OBJECT_PUT_REF_AND_RESET(message->stream);
+
+       if (message->default_begin_cs) {
+               bt_clock_snapshot_recycle(message->default_begin_cs);
+               message->default_begin_cs = NULL;
+       }
+
+       if (message->default_end_cs) {
+               bt_clock_snapshot_recycle(message->default_end_cs);
+               message->default_end_cs = NULL;
+       }
+
+       g_free(message);
+}
+
+static inline
+struct bt_message *create_discarded_items_message(
+               struct bt_self_message_iterator *self_msg_iter,
+               enum bt_message_type type, struct bt_stream *stream,
+               bool with_cs,
+               uint64_t beginning_raw_value, uint64_t end_raw_value)
+{
+       struct bt_message_discarded_items *message;
+       struct bt_stream_class *stream_class;
+
+       BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator");
+       BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+       stream_class = bt_stream_borrow_class(stream);
+       BT_ASSERT(stream_class);
+       BT_LIB_LOGD("Creating discarded items message object: "
+               "type=%s, %![stream-]+s, %![sc-]+S, with-cs=%d, "
+               "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64,
+               bt_message_type_string(type), stream, stream_class,
+               with_cs, beginning_raw_value, end_raw_value);
+       message = g_new0(struct bt_message_discarded_items, 1);
+       if (!message) {
+               BT_LOGE_STR("Failed to allocate one discarded items message.");
+               goto error;
+       }
+
+       bt_message_init(&message->parent, type,
+               destroy_discarded_items_message, NULL);
+       message->stream = stream;
+       bt_object_get_no_null_check(message->stream);
+
+       if (with_cs) {
+               message->default_begin_cs = bt_clock_snapshot_create(
+                       stream_class->default_clock_class);
+               if (!message->default_begin_cs) {
+                       goto error;
+               }
+
+               bt_clock_snapshot_set_raw_value(message->default_begin_cs,
+                       beginning_raw_value);
+
+               message->default_end_cs = bt_clock_snapshot_create(
+                       stream_class->default_clock_class);
+               if (!message->default_end_cs) {
+                       goto error;
+               }
+
+               bt_clock_snapshot_set_raw_value(message->default_end_cs,
+                       end_raw_value);
+       }
+
+       bt_property_uint_init(&message->count,
+               BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE, 0);
+       BT_LIB_LOGD("Created discarded items message object: "
+               "%![msg-]+n, %![stream-]+s, %![sc-]+S", message,
+               stream, stream_class);
+
+       return (void *) &message->parent;
+
+error:
+       return NULL;
+}
+
+static inline
+struct bt_stream *borrow_discarded_items_message_stream(
+               struct bt_message *message)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) message;
+
+       BT_ASSERT(message);
+       return disc_items_msg->stream;
+}
+
+static inline
+void set_discarded_items_message_count(struct bt_message *message,
+               uint64_t count)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) message;
+
+       BT_ASSERT(message);
+       BT_ASSERT_PRE_HOT(message, "Message", ": %!+n", message);
+       bt_property_uint_set(&disc_items_msg->count, count);
+}
+
+static inline
+enum bt_property_availability get_discarded_items_message_count(
+               const struct bt_message *message, uint64_t *count)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) message;
+
+       BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
+       BT_ASSERT(message);
+       *count = disc_items_msg->count.value;
+       return disc_items_msg->count.base.avail;
+}
+
+static inline
+enum bt_clock_snapshot_state
+borrow_discarded_items_message_default_beginning_clock_snapshot_const(
+               const struct bt_message *message,
+               const struct bt_clock_snapshot **snapshot)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) message;
+
+       BT_ASSERT(message);
+       BT_ASSERT_PRE(disc_items_msg->stream->class->default_clock_class,
+               "Message's stream's class has no default clock class: "
+               "%![msg-]+n, %![sc-]+S",
+               message, disc_items_msg->stream->class);
+       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
+       *snapshot = disc_items_msg->default_begin_cs;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
+}
+
+static inline
+enum bt_clock_snapshot_state
+borrow_discarded_items_message_default_end_clock_snapshot_const(
+               const struct bt_message *message,
+               const struct bt_clock_snapshot **snapshot)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) message;
+
+       BT_ASSERT(message);
+       BT_ASSERT_PRE(disc_items_msg->stream->class->default_clock_class,
+               "Message's stream's class has no default clock class: "
+               "%![msg-]+n, %![sc-]+S",
+               message, disc_items_msg->stream->class);
+       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
+       *snapshot = disc_items_msg->default_end_cs;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
+}
+
+struct bt_message *bt_message_discarded_events_create(
+               struct bt_self_message_iterator *message_iterator,
+               struct bt_stream *stream)
+{
+       return create_discarded_items_message(message_iterator,
+               BT_MESSAGE_TYPE_DISCARDED_EVENTS, stream,
+               false, 0, 0);
+}
+
+struct bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
+               struct bt_self_message_iterator *message_iterator,
+               struct bt_stream *stream, uint64_t beginning_raw_value,
+               uint64_t end_raw_value)
+{
+       return create_discarded_items_message(message_iterator,
+               BT_MESSAGE_TYPE_DISCARDED_EVENTS, stream,
+               true, beginning_raw_value, end_raw_value);
+}
+
+struct bt_stream *bt_message_discarded_events_borrow_stream(
+               struct bt_message *message)
+{
+       BT_ASSERT_PRE_NON_NULL(message, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       return borrow_discarded_items_message_stream(message);
+}
+
+void bt_message_discarded_events_set_count(struct bt_message *message,
+               uint64_t count)
+{
+       BT_ASSERT_PRE_NON_NULL(message, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       set_discarded_items_message_count(message, count);
+}
+
+enum bt_clock_snapshot_state
+bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
+               const struct bt_message *msg,
+               const struct bt_clock_snapshot **snapshot)
+{
+       BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       return borrow_discarded_items_message_default_beginning_clock_snapshot_const(
+               msg, snapshot);
+}
+
+enum bt_clock_snapshot_state
+bt_message_discarded_events_borrow_default_end_clock_snapshot_const(
+               const struct bt_message *msg,
+               const struct bt_clock_snapshot **snapshot)
+{
+       BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       return borrow_discarded_items_message_default_end_clock_snapshot_const(
+               msg, snapshot);
+}
+
+const struct bt_stream *
+bt_message_discarded_events_borrow_stream_const(const struct bt_message *message)
+{
+       return (void *) bt_message_discarded_events_borrow_stream(
+               (void *) message);
+}
+
+enum bt_property_availability bt_message_discarded_events_get_count(
+               const struct bt_message *message, uint64_t *count)
+{
+       BT_ASSERT_PRE_NON_NULL(message, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       return get_discarded_items_message_count(message, count);
+}
index f258eb1ed78d8162ed2f04ac34b1bb660bd758f4..989e0e44f11abc682fe2ee9860914aa46022811b 100644 (file)
@@ -36,7 +36,7 @@ void bt_message_init(struct bt_message *message,
                bt_object_release_func release,
                struct bt_graph *graph)
 {
-       BT_ASSERT(type >= 0 && type <= BT_MESSAGE_TYPE_STREAM_ACTIVITY_END);
+       BT_ASSERT(type >= 0 && type <= BT_MESSAGE_TYPE_DISCARDED_EVENTS);
        message->type = type;
        bt_object_init_shared(&message->base, release);
        message->graph = graph;
index 096428e1de4d268bbc261c0402e8261d55660348..0c6865759316dc73aae5e804e7adbf49ec873e68 100644 (file)
@@ -68,6 +68,7 @@
 #include <babeltrace/graph/message-packet-internal.h>
 #include <babeltrace/graph/message-stream-internal.h>
 #include <babeltrace/graph/message-stream-activity-internal.h>
+#include <babeltrace/graph/message-discarded-items-internal.h>
 #include <babeltrace/graph/port-internal.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/plugin/plugin-so-internal.h>
@@ -965,6 +966,36 @@ static inline void format_message(char **buf_ch, bool extended,
 
                break;
        }
+       case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+       {
+               const struct bt_message_discarded_items *msg_disc_items =
+                       (const void *) msg;
+
+               if (msg_disc_items->stream) {
+                       SET_TMP_PREFIX("stream-");
+                       format_stream(buf_ch, true, tmp_prefix,
+                               msg_disc_items->stream);
+               }
+
+               if (msg_disc_items->default_begin_cs) {
+                       SET_TMP_PREFIX("default-begin-cs-");
+                       format_clock_snapshot(buf_ch, true, tmp_prefix,
+                               msg_disc_items->default_begin_cs);
+               }
+
+               if (msg_disc_items->default_end_cs) {
+                       SET_TMP_PREFIX("default-end-cs-");
+                       format_clock_snapshot(buf_ch, true, tmp_prefix,
+                               msg_disc_items->default_end_cs);
+               }
+
+               if (msg_disc_items->count.base.avail) {
+                       BUF_APPEND(", %scount=%" PRIu64,
+                               PRFIELD(msg_disc_items->count.value));
+               }
+
+               break;
+       }
        default:
                break;
        }
This page took 0.035125 seconds and 4 git commands to generate.