From 5c2e8153825684a8167b2be7a8ca888c51f923cb Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Wed, 26 Jun 2019 16:04:01 -0400 Subject: [PATCH] ctf: decoding: accommodate lttng-crash timestamp quirk See previous commit titled: src.ctf.fs: index: accommodate lttng-crash timestamp quirk for an explanation of the non-compliance of lttng-crash traces. How this commit fixes the decoding for the affected traces ========================================================== When about to emit a packet end message, check if the said packet is affected by the trace-crash non-compliance. If it's the case, omit to update the default_clock_snapshot to the `timestamp_end` of the packet. Signed-off-by: Francis Deslauriers Change-Id: If965a424afa160692c2ec148fc8f60d3d9ac1273 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1548 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/plugins/ctf/common/metadata/ctf-meta.h | 4 ++++ src/plugins/ctf/common/msg-iter/msg-iter.c | 22 +++++++++++++++++++--- src/plugins/ctf/fs-src/fs.c | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/plugins/ctf/common/metadata/ctf-meta.h b/src/plugins/ctf/common/metadata/ctf-meta.h index 5924346d..884fe69e 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta.h +++ b/src/plugins/ctf/common/metadata/ctf-meta.h @@ -310,6 +310,10 @@ struct ctf_trace_class { /* Weak, set during translation */ bt_trace_class *ir_tc; + + struct { + bool lttng_crash; + } quirks; }; static inline diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.c index 124a69d5..404119fa 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.c @@ -2529,13 +2529,29 @@ static 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; + } + } + + /* 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; } @@ -2545,7 +2561,7 @@ void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message) 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); diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index 6c362a32..8b6b54ea 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -2255,6 +2255,7 @@ int fix_packet_index_tracer_bugs(struct ctf_fs_component *ctf_fs) BT_LOGE_STR("Failed to fix lttng-crash timestamp quirks."); goto end; } + trace->metadata->tc->quirks.lttng_crash = true; } } end: -- 2.34.1