Validate CTF semantics in selected CTF IR functions
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 18 May 2017 23:52:41 +0000 (19:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:44 +0000 (12:57 -0400)
commite011d2c1930972adc9b85f2c4067c62c207fc4ff
tree058cd08dac22c8d3e40062a91c6a2d7b34402e02
parenta68c0f97106c1b5ef70ec92a3e88e5e830a8b31f
Validate CTF semantics in selected CTF IR functions

Before this patch, the semantics suggested by the CTF specification are
not validated in CTF IR itself. For example, the library does not
enforce that, if there's more than one stream class contained in a given
trace, its packet header field type's `stream_id` field must exist
(which also means that the packet header field type must be set).

When you add a stream class to a trace created by a CTF writer object
(implicit when you call bt_ctf_writer_create_stream(), for example), we
proceed to automatically map selected field types to the stream class's
clock if it's set. Those fields are:

* Packet context field type: `timestamp_begin`
* Packet context field type: `timestamp_end`
* Event header field type: `timestamp`

If those fields are not mapped to a clock class, and if there's no
current stream class's clock, then the whole
bt_ctf_trace_add_stream_class() function fails.

Those mappings are needed to make a valid CTF trace. The field types
cannot be mapped at stream class creation time because the user can
override the packet context and event header field types and still have
those fields without a mapping. To make this use case more easy in CTF
writer context, the mapping is always done automatically in
bt_ctf_trace_add_stream_class().

This has the side effect that this sequence of operations is not valid
anymore:

1. Create a trace.
2. Create a default stream class with bt_ctf_trace_add_stream_class().
3. Add the default stream class (2) to the created trace (1).

Because bt_ctf_trace_add_stream_class() creates an initial packet
context field type which contains the `timestamp_begin` and
`timestamp_end` fields, and because those fields are only valid at
bt_ctf_trace_add_stream_class() call time when they are mapped to a
clock class, and because we're not in CTF writer context, then they are
not automatically mapped. This is why, in non CTF writer mode (graph
mode), the user should prefer bt_ctf_stream_class_create_empty(), or
manually get the `timestamp_begin` and `timestamp_end` field types and
map them to a clock class which is also part of the trace in which to
add the stream class.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/stream-class-internal.h
lib/ctf-ir/field-types.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/trace.c
tests/lib/test_ctf_writer.c
This page took 0.025479 seconds and 4 git commands to generate.