lib: make auto-seek skip over packet messages without clock snapshots
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 5 May 2021 14:08:35 +0000 (10:08 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 Sep 2021 14:39:08 +0000 (10:39 -0400)
Trying to use a CTF trace with packets that don't have beginning clock
snapshots [1] with a trimmer component invokes the "auto-seek" seeking
mechanism provided by the lib, and leads to:

    $ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
    ...
    Babeltrace 2 library postcondition not satisfied.
    ------------------------------------------------------------------------
    Condition ID: `post:message-iterator-class-next-method:packet-message-has-default-clock-snapshot`.
    Function: bt_message_iterator_class_next_method().
    ------------------------------------------------------------------------
    Error is:
    Packet message has no default clock snapshot: addr=0x607000001fa0, type=PACKET_BEGINNING, is-frozen=0, graph-addr=0x612000001840, packet-is-frozen=1, packet-context-field-addr=(nil), packet-stream-addr=0x60d000001cb0, packet-stream-id=0, packet-stream-name="/home/simark/build/babeltrace/nvctf/channel0", packet-trace-class-addr=0x60d000001be0

The problem is with the auto_seek_handle_message function assuming that
all packet beginning messages have a clock snapshot.  Fix it by making
it check the relevant property in the stream class, and skip the message
if it doesn't have a clock snapshot.

Change it as well for packet end, discarded event and discarded packet
messages, although I did not test these cases.

[1] Like the trace from
    https://lists.lttng.org/pipermail/lttng-dev/2021-May/029955.html

Change-Id: I6be0ab013285c2a01125dbf27161d31e227250a8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5690
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/graph/iterator.c

index 796ade072d59c0c13b45758980a7e29b5af1fc47..fd49c27ef15ebb03511b65a65d68781f74a3b174 100644 (file)
@@ -1286,6 +1286,16 @@ int auto_seek_handle_message(
                const struct bt_message_packet *packet_msg =
                        (const void *) msg;
 
+               if (msg->type == BT_MESSAGE_TYPE_PACKET_BEGINNING
+                               && !packet_msg->packet->stream->class->packets_have_beginning_default_clock_snapshot) {
+                       goto skip_msg;
+               }
+
+               if (msg->type == BT_MESSAGE_TYPE_PACKET_END
+                               && !packet_msg->packet->stream->class->packets_have_end_default_clock_snapshot) {
+                       goto skip_msg;
+               }
+
                clk_snapshot = packet_msg->default_cs;
                BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
                        "packet-message-has-default-clock-snapshot",
@@ -1300,6 +1310,16 @@ int auto_seek_handle_message(
                struct bt_message_discarded_items *msg_disc_items =
                        (void *) msg;
 
+               if (msg->type == BT_MESSAGE_TYPE_DISCARDED_EVENTS &&
+                               !msg_disc_items->stream->class->discarded_events_have_default_clock_snapshots) {
+                       goto skip_msg;
+               }
+
+               if (msg->type == BT_MESSAGE_TYPE_DISCARDED_PACKETS &&
+                               !msg_disc_items->stream->class->discarded_packets_have_default_clock_snapshots) {
+                       goto skip_msg;
+               }
+
                BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
                        "discarded-events-packets-message-has-default-clock-snapshot",
                        msg_disc_items->default_begin_cs &&
This page took 0.025738 seconds and 4 git commands to generate.