void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message)
{
bt_message *msg;
+ bool update_default_cs = true;
if (!notit->packet) {
return;
}
- /* Update default clock from packet's end time */
- if (notit->snapshots.end_clock != UINT64_C(-1)) {
+ /* Check if may be affected by lttng-crash timestamp_end quirk. */
+ if (G_UNLIKELY(notit->meta.tc->quirks.lttng_crash)) {
+ /*
+ * Check if the `timestamp_begin` field is non-zero but
+ * `timestamp_end` is zero. It means the trace is affected by
+ * the lttng-crash packet `timestamp_end` quirk and must be
+ * fixed up by omitting to update the default clock snapshot to
+ * the `timestamp_end` as is typically done.
+ */
+ if (notit->snapshots.beginning_clock != 0 &&
+ notit->snapshots.end_clock == 0) {
+ update_default_cs = false;
+ }
+ }
+
+ /*
+ * Check if may be affected by lttng event-after-packet `timestamp_end`
+ * quirk.
+ */
+ if (notit->meta.tc->quirks.lttng_event_after_packet) {
+ /*
+ * Check if `timestamp_end` is smaller then the current
+ * default_clock_snapshot (which is set to the last event
+ * decoded). It means the trace is affected by the lttng
+ * `event-after-packet` packet `timestamp_end` quirk and must
+ * be fixed up by omitting to update the default clock snapshot
+ * to the `timestamp_end` as is typically done.
+ */
+ if (notit->snapshots.end_clock < notit->default_clock_snapshot) {
+ update_default_cs = false;
+ }
+ }
+
+ /* Update default clock from packet's end time. */
+ if (notit->snapshots.end_clock != UINT64_C(-1) && update_default_cs) {
notit->default_clock_snapshot = notit->snapshots.end_clock;
}
BT_ASSERT(notit->snapshots.end_clock != UINT64_C(-1));
msg = bt_message_packet_end_create_with_default_clock_snapshot(
notit->msg_iter, notit->packet,
- notit->snapshots.end_clock);
+ notit->default_clock_snapshot);
} else {
msg = bt_message_packet_end_create(notit->msg_iter,
notit->packet);
}
static
-enum bt_msg_iter_status decode_until_state(
- struct bt_msg_iter *notit, enum state target_state_1,
- enum state target_state_2)
+enum bt_msg_iter_status decode_until_state( struct bt_msg_iter *notit,
+ enum state target_state_1, enum state target_state_2)
{
enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
return ret;
}
+static
+enum bt_msg_iter_status clock_snapshot_at_msg_iter_state(
+ struct bt_msg_iter *notit, enum state target_state_1,
+ enum state target_state_2, uint64_t *clock_snapshot)
+{
+ enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
+
+ BT_ASSERT(notit);
+ BT_ASSERT(clock_snapshot);
+ status = decode_until_state(notit, target_state_1, target_state_2);
+ if (status != BT_MSG_ITER_STATUS_OK) {
+ goto end;
+ }
+
+ *clock_snapshot = notit->default_clock_snapshot;
+end:
+ return status;
+}
+
+BT_HIDDEN
+enum bt_msg_iter_status bt_msg_iter_curr_packet_first_event_clock_snapshot(
+ struct bt_msg_iter *notit, uint64_t *first_clock_snapshot)
+{
+ return clock_snapshot_at_msg_iter_state(notit,
+ STATE_AFTER_EVENT_HEADER, -1, first_clock_snapshot);
+}
+
+BT_HIDDEN
+enum bt_msg_iter_status bt_msg_iter_curr_packet_last_event_clock_snapshot(
+ struct bt_msg_iter *notit, uint64_t *last_clock_snapshot)
+{
+ return clock_snapshot_at_msg_iter_state(notit,
+ STATE_EMIT_MSG_PACKET_END_SINGLE,
+ STATE_EMIT_MSG_PACKET_END_MULTI, last_clock_snapshot);
+}
+
BT_HIDDEN
enum bt_msg_iter_status bt_msg_iter_get_packet_properties(
struct bt_msg_iter *notit,