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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 6 Jun 2019 21:19:12 +0000 (17:19 -0400)
commitafd452743c7fcc89246029f68055d6f251c857e6
tree3abecdb076d2000662143c94764e398bddb71d43
parent3f2f6b21fef5c6b6341419338a024c7ba6acc65a
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.026675 seconds and 4 git commands to generate.