src.ctf.fs: support no packet beg/end CS and no discarded events/packets
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 3 Jun 2019 19:48:06 +0000 (15:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 13 Jun 2019 21:24:21 +0000 (17:24 -0400)
commit32476570edb2c77d9447b2a36db8a78ef6acd202
tree4c9138abaa3451a1b56fb1fd5d0677605333c3ff
parent34f2b0fbb8193aa7c11e7835b045e70d3087140d
src.ctf.fs: support no packet beg/end CS and no discarded events/packets

This patch makes `src.ctf.fs` support CTF traces where a packet context
field class has or does not have the `timestamp_begin`, `timestamp_end`,
`events_discarded`, and `packet_seq_num` members. The corresponding
trace IR stream class's properties are set accordingly.

This fixes a bug having those base conditions:

1. Stream class has a default clock class.

2. Packet context's `timestamp_begin` and `timestamp_end` members
   are missing.

Then:

a) Because of 1., it was mandatory to set the default clock snapshot of
   packet beginning and end messages. It was also mandatory to set the
   default clock snapshots of discarded events/packets messages.

b) Because we didn't have the packet beginning and end times (because of
   2.), we used 0 for the first packet's beginning default clock
   snapshot.

c) Because CTF uses the packet beginning/end times to set the discarded
   events ranges, and because of b), we also used 0 as a discarded
   events message's beginning default clock snapshot if the events were
   discarded during the first packet.

0 is wrong for both b) and c): it's not 0, we just don't know the value.
It is wrong to tell a downstream component that events were possibly
discarded from 0 to another time because we just don't know those times.

I'm adding two test traces to make this code covered:

`no-packet-context`:
    No packet context at all, which means no packet beginning/end times,
    no discarded events, and no discarded packets.

`ev-disc-no-ts-begin-end`:
    A packet context with an `events_discarded` member, but without the
    `timestamp_begin` and `timestamp_end` members.

    In this case, when there's a discarded events message, events are
    known to have been discarded contextually, between two other
    messages with a default clock snapshot, but not at a specific time.

    `sink.text.pretty` prints:

        WARNING: Tracer discarded 17 events (unknown time range) in
        trace "ev-disc-no-ts-begin-end" (no UUID) within stream
        "/path/to/babeltrace/tests/ctf-traces/succeed/ev-disc-no-ts-begin-end/stream"
        (stream class ID: 0, stream ID: 0).

    while Babeltrace 1.5 prints:

        [warning] Tracer discarded 17 events between
        [19:00:00.000000000] and [19:00:00.000000000] in trace UUID
        0000000000000000, at path:
        "tests/ctf-traces/succeed/ev-disc-no-ts-begin-end", within
        stream id 0, at relative path: "stream". You should consider
        recording a new trace with larger buffers or with fewer events
        enabled.

    which is not exact.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ieebf679a67bd0089e48708372caf934cc27573dc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1368
Tested-by: jenkins
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
plugins/ctf/common/metadata/Makefile.am
plugins/ctf/common/metadata/ctf-meta-translate.c
plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c [new file with mode: 0644]
plugins/ctf/common/metadata/ctf-meta-visitors.h
plugins/ctf/common/metadata/ctf-meta.h
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/msg-iter/msg-iter.c
tests/ctf-traces/succeed/ev-disc-no-ts-begin-end/metadata [new file with mode: 0644]
tests/ctf-traces/succeed/ev-disc-no-ts-begin-end/stream [new file with mode: 0644]
tests/ctf-traces/succeed/no-packet-context/metadata [new file with mode: 0644]
tests/ctf-traces/succeed/no-packet-context/stream [new file with mode: 0644]
This page took 0.027032 seconds and 4 git commands to generate.