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>
const struct bt_message_packet *packet_msg =
(const void *) msg;
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",
clk_snapshot = packet_msg->default_cs;
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"packet-message-has-default-clock-snapshot",
struct bt_message_discarded_items *msg_disc_items =
(void *) msg;
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 &&
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"discarded-events-packets-message-has-default-clock-snapshot",
msg_disc_items->default_begin_cs &&