From ed3039e4f1abcc78367b60ce40512ee8d3949144 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 5 May 2021 10:08:35 -0400 Subject: [PATCH] lib: make auto-seek skip over packet messages without clock snapshots 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/5690 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/lib/graph/iterator.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 796ade07..fd49c27e 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -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 && -- 2.34.1