Fix: fail when reading 0 byte event

Rather than looping forever.

Fixes #685

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: fix typo

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Parse CTF indexes

If a trace file has an associated index (same filename and .idx suffix
in the "index" folder), we open it and use it instead of generating
the index at open.
The index folder is not mandatory and can be destroyed without any
problem.

To use with LTTng, make sure you have lttng-tools commit :
50adc26400482c07210afcda8ef1d3322f75871d
Mon Nov 25 15:32:38 2013 -0500
Rename LTTng index in CTF index

Versions between commit 309167d2a6f59d0c8cbf64eb23ba912cdea76a34 and
this commit have a different index format that will never be merged in
Babeltrace, so if you have traces recorded between this period of
time, just remove the index directory.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: add stricter checks on packet boundaries

Fixes #699

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: string packet boundary handling, bits vs bytes

Fixes #684

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: clarify end of packet error

Fixes #686

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: reversed logic in packet vs content size

As described in CTF section 5.2

"If the packet size field is missing, the whole stream only contains a
single packet. If the content size field is missing, the packet is
filled (no padding). The content and packet sizes include all headers."

Here is the correct semantic:

* Content size and packet size are available:

  Packet is filled with data up to content size, and then with padding
  up to packet size.

* Content size available, no packet size field:

  The stream has a single packet. It is filled up to content size, and
  the rest is padding.

* Packet size available, no content size field:

  Packet filled completely, no padding.

Fixes #683

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: test for less than 1 byte packets

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: uncheck null pointer

Found by coverity:

** CID 1132647:  Dereference null return value  (NULL_RETURNS)
/formats/ctf/ctf.c: 1852 in ctf_open_file_stream_read()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: check packet index len

Found by coverity:

** CID 1132646:  Untrusted value as argument  (TAINTED_SCALAR)
/formats/ctf/ctf.c: 1715 in import_stream_packet_inde)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: test content size vs headers len

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Handle the inactive streams

When content_size == 0, just set the timestamp_end of the packet and
reinsert the stream in the heap.
This is required to handle the beacons of inactivity generated in
LTTng live trace streaming.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Handle packets containing only a header

In live streaming with LTTng, if we do a stop and then a destroy, we
receive a packet that contains only a header. With this patch, we will
ask for a new packet when we see this case.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Handle empty streams on iterator init

In live trace streaming, we can create an iterator with inactive
streams. This patch allows inactive streams to be considered as valid.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: floats should set content size in tmp definition

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: do not duplicate code in float fix

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: read/write mode check

It's on the "prot" field, not flags. Moreover, it needs to be done with
a == / != comparison, not a mask.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Live viewer

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Begin lttng-live input plugin

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fixes in babeltrace core to support non-CTF traces

Since we will have an effort soon to cleanup the Babeltrace plugin
mechanism, this patch adds just the bits required in Babeltrace to not
crash if a non-ctf is opened.
That way, an input plugin can just implement the open_trace callback and
process its input trace.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>