ctf: decoding: accommodate lttng-crash timestamp quirk
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 26 Jun 2019 20:04:01 +0000 (16:04 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 16 Aug 2019 15:35:50 +0000 (11:35 -0400)
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 <francis.deslauriers@efficios.com>
Change-Id: If965a424afa160692c2ec148fc8f60d3d9ac1273
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1548
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/common/metadata/ctf-meta.h
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/fs-src/fs.c

index 5924346d7e30c1fccba5b0a3769b6c349fad1ef1..884fe69ebfdf166e4230648080bdba2e44ad551c 100644 (file)
@@ -310,6 +310,10 @@ struct ctf_trace_class {
 
        /* Weak, set during translation */
        bt_trace_class *ir_tc;
+
+       struct {
+               bool lttng_crash;
+       } quirks;
 };
 
 static inline
index 124a69d531484210bf0a5532cda24611bca253ab..404119facf12950926482e184bb50f475f0b65df 100644 (file)
@@ -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);
index 6c362a32faf398801fea801544721065ebfae7c9..8b6b54ea70f52e618bd0d14205df819c3bf0ad8b 100644 (file)
@@ -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:
This page took 0.027278 seconds and 4 git commands to generate.