babeltrace.git
8 years agoir: refactor FT validation and resolving
Philippe Proulx [Mon, 8 Feb 2016 07:21:40 +0000 (02:21 -0500)] 
ir: refactor FT validation and resolving

This patch refactors the CTF IR field type validation and the
resolving of variant/sequence field types.

First, validation is completely decoupled from the objects
containing the field types. In other words, validation does not
know the exact event class, stream class, or trace in which the
field types to validate are or are supposed to be. Only field types
are given to the validation function, which is isolated in its
own file.

To make the life of the resolving engine easier, all scopes are
deep-copied before reaching it. This is done during the validation
process. This ensures that no two field types in the whole
hierarchy refer to the same object in memory. This greatly simplifies
the resolving process, while adding insignificant overhead since
this is only done once. The copies do not replace the original types
until we are sure that the object to be validated (event class, stream
class, or trace) is valid and will be frozen. When it is the case, a
valid flag is set, which avoids validating the object again in the
future when calling the same function. If the object is not valid,
then the copies of its field types are discarded, and the function
fails.

Validation is done at three important places:

  * bt_ctf_event_create(): when creating an event, because we don't
    want the user to obtain an event linked to an invalid event
    class. It is possible to create an event from an even class
    which has a parent stream class which has no parent trace. In
    this case, no variant/sequence field type in all the field types
    of the stream class and event class can be resolved to the
    trace packet header field type.
  * bt_ctf_stream_class_add_event_class(): when adding an event class
    to a stream class AND when the stream class has a parent trace,
    because in this case the whole hierarchy exists and everything
    is frozen, so it makes sense that everything in there should be
    valid. If the stream class has no parent trace yet, then the
    validation will be done when adding it to a trace using the
    following function. This is because the added event class could
    contain a variant/sequence field type which resolves to a field
    type of the trace packet header field type, contained in the trace
    object.
  * bt_ctf_trace_add_stream_class(): when adding a stream class to
    a trace, because in this case both the trace and the stream
    class will be frozen, and hence they should be valid because they
    cannot be changed anymore.

The test_ctf_writer test is updated here to follow those changes. Since
the field types can be copied when calling one of the above functions,
we cannot create a field out of an original field type and then compare
its address to a field obtained from the created event or stream: we must
put the original field types and obtain the new ones from the event class
or stream class. The contents of field types are compared using
bt_ctf_field_type_compare() instead.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: allow to set variant FT's tag FT even when frozen
Philippe Proulx [Mon, 8 Feb 2016 07:14:51 +0000 (02:14 -0500)] 
ir: allow to set variant FT's tag FT even when frozen

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: add internal bt_ctf_field_path_clear()
Philippe Proulx [Mon, 8 Feb 2016 07:11:20 +0000 (02:11 -0500)] 
ir: add internal bt_ctf_field_path_clear()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: validate field types on field creation
Philippe Proulx [Mon, 8 Feb 2016 07:05:35 +0000 (02:05 -0500)] 
ir: validate field types on field creation

This patch removes the validation that is done when adding
fields to structure/variant field types, and when creating
array/sequence field types with specific element types. This
is needed because a variant with an unset tag type may be
created and thus exist in any of those compound types. This
variant will be resolved when the time comes.

A valid field type is still required when creating a concrete
field out of it and when serializing it.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agovalues: fix indentation
Philippe Proulx [Thu, 4 Feb 2016 22:11:41 +0000 (17:11 -0500)] 
values: fix indentation

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoref.h: fix doc
Philippe Proulx [Thu, 4 Feb 2016 18:22:27 +0000 (13:22 -0500)] 
ref.h: fix doc

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agovalues: add `_empty` prefix when relevant
Philippe Proulx [Thu, 4 Feb 2016 08:11:07 +0000 (03:11 -0500)] 
values: add `_empty` prefix when relevant

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoBT_MOVE(): call bt_put(_dst)
Philippe Proulx [Mon, 1 Feb 2016 13:21:00 +0000 (08:21 -0500)] 
BT_MOVE(): call bt_put(_dst)

It makes no semantical sense to move a reference from a variable
to another without first putting the destination, if it has one.
Otherwise this would be a lost reference, unless it was moved
elsewhere or put manually using bt_put() previously, which is why
BT_MOVE() should always be used for move semantics and BT_PUT() is
preferred to bt_put() to avoid this situation.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: bt_ctf_field_type_floating_point_copy(): set self references
Philippe Proulx [Sat, 30 Jan 2016 06:22:57 +0000 (01:22 -0500)] 
Fix: bt_ctf_field_type_floating_point_copy(): set self references

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoAdd bt_ctf_field_type_compare(): field type deep comparison
Philippe Proulx [Sat, 30 Jan 2016 06:19:01 +0000 (01:19 -0500)] 
Add bt_ctf_field_type_compare(): field type deep comparison

The new bt_ctf_field_type_compare() function compares two field
types recursively.

The tag field type of variant field types are not compared; only
the tag strings are compared.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: event-types-internal.h: fix comment
Philippe Proulx [Sat, 30 Jan 2016 06:29:39 +0000 (01:29 -0500)] 
ir: event-types-internal.h: fix comment

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: add user byte order to integer/float types
Philippe Proulx [Sat, 30 Jan 2016 06:27:18 +0000 (01:27 -0500)] 
ir: add user byte order to integer/float types

The `byte_order` field of an integer/float field type gets
replaced by `BIG_ENDIAN` or `LITTLE_ENDIAN` if it's set to
0 (native) once the type becomes the descendant of a
trace. However, once this is set, there is no way to know
that the user intended this field type's byte order to be
native. The metadata string, for example, will never contain
a byte order set to `native` with this behaviour.

This patch adds a `user_byte_order` field to the internal
integer and floating point number field type structures. This
field is the one set by and returned to the user using the
CTF IR API. Internally, the declaration's `byte_order` field
is still used for caching the resolved byte order.

This patch also modifies bt_ctf_stream_class_set_byte_order()
so that it cannot fail. This is an internal, hidden function
which should not be called with invalid parameters. Assertions
are inserted to verify this.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agotest_ctf_writer.c: assert() unchecked return values
Philippe Proulx [Sat, 30 Jan 2016 05:56:30 +0000 (00:56 -0500)] 
test_ctf_writer.c: assert() unchecked return values

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoir: bt_ctf_stream_class_set_byte_order(): EC is already frozen
Philippe Proulx [Fri, 31 Jul 2015 18:22:25 +0000 (14:22 -0400)] 
ir: bt_ctf_stream_class_set_byte_order(): EC is already frozen

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPython bindings: remove unnecessary semi-colons
Jérémie Galarneau [Wed, 17 Feb 2016 03:36:24 +0000 (22:36 -0500)] 
Python bindings: remove unnecessary semi-colons

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPython bindings: missing error check in Clock precision setter
Jérémie Galarneau [Wed, 17 Feb 2016 03:27:21 +0000 (22:27 -0500)] 
Python bindings: missing error check in Clock precision setter

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPython bindings: accomodate API changes introduced for negative time
Jérémie Galarneau [Wed, 17 Feb 2016 03:26:26 +0000 (22:26 -0500)] 
Python bindings: accomodate API changes introduced for negative time

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoRemove stale comment from event destructor
Jérémie Galarneau [Mon, 15 Feb 2016 19:46:11 +0000 (14:46 -0500)] 
Remove stale comment from event destructor

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoHandle negative time and offset from Epoch
Mathieu Desnoyers [Tue, 9 Feb 2016 18:27:24 +0000 (13:27 -0500)] 
Handle negative time and offset from Epoch

Handle cases where a trace have a negative offset from Epoch.
If Epoch is arbitrary (e.g. embedded system starting at 0, without any
network access), the "0" can be used as correlation point between
various components, and some components could start before the
correlation point. Therefore, especially in traces where the time is
meant to be shown in nanoseconds or cycles from the correlation point,
it also makes sense to have a negative time value.

It introduces API-breaking changes in the C and Python APIs, since we
need to be able to return negative time values, which were previously
used as errors (-1ULL).

The --offset and --offset-ns command line parameters can now take
negative offset (seconds and nanoseconds) values too.

The [sec.ns] format is used as fallback so we don't attempt to pass
a negative time value to POSIX time-formatting APIs.

This also fixes an inaccurate return value in an error path of
bt_ctf_event_populate_event_header().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: CTF parser: accept signed constant literals
Mathieu Desnoyers [Tue, 9 Feb 2016 18:27:23 +0000 (13:27 -0500)] 
Fix: CTF parser: accept signed constant literals

Those are inaccurately rejected by the parser due to this bug. This
affects environment variables and loglevel values.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: out-of-bound memory access
Mathieu Desnoyers [Tue, 9 Feb 2016 18:27:22 +0000 (13:27 -0500)] 
Fix: out-of-bound memory access

We need to check for end of stream before updating the current packet
index, else we access memory beyond the last stream packet index array
element. This fixes valgrind errors which appear at commit

480ef05 Support ctf index version 1.1

due to change of the element size, but actually caused by commit

2654fe9 Fix: events discarded timing inaccuracy

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix out-of-tree tests: seek tests can't find traces
Jérémie Galarneau [Wed, 10 Feb 2016 16:25:33 +0000 (11:25 -0500)] 
Fix out-of-tree tests: seek tests can't find traces

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoTests: Fix test plans and do not skip on fail
Michael Jeanson [Mon, 25 Jan 2016 21:00:41 +0000 (16:00 -0500)] 
Tests: Fix test plans and do not skip on fail

Use fixed count test plans in all tests and make sure we do not skip
some tests on initialisation failures.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: Check return value of fpathconf
Michael Jeanson [Fri, 4 Dec 2015 22:03:12 +0000 (17:03 -0500)] 
Fix: Check return value of fpathconf

Current glibc has a bug in fpathconf(fd, _PC_NAME_MAX) where it will
fail with a 32bit userland on a 64bit kernel and where the filesystem
has a large block count, see glibc bug #18675.

In any case, we should check this return value because on a failure we
we don't allocate enough memory for dirent and then overflow on the
readdir_r call.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: BABELTRACE_HAVE_LIBC_UUID misspelled as BT_HAVE_LIBC_UUID
Michael Jeanson [Thu, 5 Nov 2015 17:52:37 +0000 (12:52 -0500)] 
Fix: BABELTRACE_HAVE_LIBC_UUID misspelled as BT_HAVE_LIBC_UUID

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: check for socket lib before function checks
Michael Jeanson [Tue, 9 Feb 2016 23:50:22 +0000 (18:50 -0500)] 
Fix: check for socket lib before function checks

On platforms that require extra libraries to link socket apps,
running this macro before the function checks will lead to
socket functions being correctly detected.

Signed-off by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPort: Add OSX libuuid compat
Michael Jeanson [Thu, 5 Nov 2015 17:51:55 +0000 (12:51 -0500)] 
Port: Add OSX libuuid compat

OSX has the libuuid symbols built in the system libraries.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPort: Add OSX mman.h compat
Michael Jeanson [Thu, 5 Nov 2015 17:51:54 +0000 (12:51 -0500)] 
Port: Add OSX mman.h compat

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoPort: Add OSX endian.h compat
Alexis Martin [Thu, 5 Nov 2015 17:51:53 +0000 (12:51 -0500)] 
Port: Add OSX endian.h compat

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoCleanup: remove unused label 'end'
Michael Jeanson [Thu, 15 Oct 2015 20:40:22 +0000 (16:40 -0400)] 
Cleanup: remove unused label 'end'

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoFix: Wrong variable checked for allocation failure
Jérémie Galarneau [Tue, 26 Jan 2016 20:45:38 +0000 (15:45 -0500)] 
Fix: Wrong variable checked for allocation failure

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoImplement new CTF-IR reference counting scheme
Jérémie Galarneau [Tue, 19 Jan 2016 18:40:30 +0000 (13:40 -0500)] 
Implement new CTF-IR reference counting scheme

See doc/ref-counting.md for the rationale and description of this
architecture change.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoUse bt_put instead of bt_ctf_field_put as release callback
Jérémie Galarneau [Tue, 19 Jan 2016 18:39:37 +0000 (13:39 -0500)] 
Use bt_put instead of bt_ctf_field_put as release callback

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoClean-up bt_put() implementation
Jérémie Galarneau [Tue, 19 Jan 2016 18:24:12 +0000 (13:24 -0500)] 
Clean-up bt_put() implementation

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoObject: Acquire reference to parent on first acquired reference
Jérémie Galarneau [Tue, 19 Jan 2016 18:22:59 +0000 (13:22 -0500)] 
Object: Acquire reference to parent on first acquired reference

See doc/ref-counting.md

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoTests: Add CTF-IR reference counting test
Jérémie Galarneau [Tue, 5 Jan 2016 23:07:05 +0000 (18:07 -0500)] 
Tests: Add CTF-IR reference counting test

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoReturn pointer when using bt_get()
Jérémie Galarneau [Mon, 30 Nov 2015 14:03:04 +0000 (09:03 -0500)] 
Return pointer when using bt_get()

bt_get() now returns the pointer it was passed to replace code
of the form:

bt_get(my_thingy);
another_object->thingy = my_thingy;

to the shorter form

another_object->thingy = bt_get(my_thingy);

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoAdd internal bt_object reference count accessor
Jérémie Galarneau [Mon, 30 Nov 2015 14:01:16 +0000 (09:01 -0500)] 
Add internal bt_object reference count accessor

This accessor is added to facilitate the testing and validation
of the bt_object reference counting and aggregation mechanism.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoDocs: Document reference counting scheme implemented by Object
Jérémie Galarneau [Mon, 23 Nov 2015 23:25:38 +0000 (18:25 -0500)] 
Docs: Document reference counting scheme implemented by Object

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoAdd parented object memory management to the Object interface
Jérémie Galarneau [Mon, 23 Nov 2015 23:14:10 +0000 (18:14 -0500)] 
Add parented object memory management to the Object interface

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 years agoDo not use g_list_free_full
Jonathan Rajotte [Mon, 4 Jan 2016 22:04:23 +0000 (17:04 -0500)] 
Do not use g_list_free_full

Babeltrace supports glib all the way back to 2.22 and g_list_free_full
was introduced in 2.28.0 (and backported to 2.27.2).

The replacement is equivalent to the behaviour offered by a modern glib.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoUpdate version to 2.0.0-pre
Jérémie Galarneau [Wed, 4 Nov 2015 21:33:52 +0000 (16:33 -0500)] 
Update version to 2.0.0-pre

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoOnly compare "bison -y" to the basename of YACC variable
Jonathan Rajotte [Thu, 22 Oct 2015 21:07:02 +0000 (17:07 -0400)] 
Only compare "bison -y" to the basename of YACC variable

In the event that the YACC variable is set to a full path
this test fail even if it should not.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPython bindings: work around Python 3.5 behaviour change
Jérémie Galarneau [Tue, 27 Oct 2015 20:10:03 +0000 (16:10 -0400)] 
Python bindings: work around Python 3.5 behaviour change

Python 3.5 changes the StopIteration exception clearing behaviour
when a generator finishes its iteration. This causes the
interpreter to errounously consider SWIG clean-up functions as
having "set an error".

This hack explicitly allocates and cleans up struct bt_iter_pos
instead of relying on SWIG auto-generated code which manages
the lifetime of temporary objects.

An investigation of the cause of this change is under way, but
at least this makes the bindings usable on Python 3.5 which is
being rolled-out in some distros.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoOutput a warning if packets are lost
Julien Desfossez [Thu, 20 Aug 2015 01:19:58 +0000 (21:19 -0400)] 
Output a warning if packets are lost

Depends on the packet_seq_num fields available in the CTF index v1.1
(produced by LTTng 2.8).
Same limitation as the events discarded information: if a stream is
split in multiple files, the counters might not report the appropriate
information for now.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoClean-up: Use memset() to initialize packet_index
Jérémie Galarneau [Mon, 26 Oct 2015 16:11:30 +0000 (12:11 -0400)] 
Clean-up: Use memset() to initialize packet_index

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoSupport ctf index version 1.1
Julien Desfossez [Thu, 20 Aug 2015 01:19:57 +0000 (21:19 -0400)] 
Support ctf index version 1.1

Produced by LTTng as of 2.8 (no compatibility breakage with 1.0)

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoCleanup: Don't hardcode include paths unnecessarily
Jérémie Galarneau [Sat, 17 Oct 2015 19:19:05 +0000 (15:19 -0400)] 
Cleanup: Don't hardcode include paths unnecessarily

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: include ctf-scanner-symbols.h to prefix yy_* symbols
Jérémie Galarneau [Sat, 17 Oct 2015 19:18:40 +0000 (15:18 -0400)] 
Fix: include ctf-scanner-symbols.h to prefix yy_* symbols

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: missing includes break the out-of-tree build
Jérémie Galarneau [Fri, 16 Oct 2015 19:31:28 +0000 (15:31 -0400)] 
Fix: missing includes break the out-of-tree build

Addresses out-of-tree build breakage introduced by
commit 3842465694945829d76452ff83924aa0103c6293

Reported-by: Nathan Lynch <Nathan_Lynch@mentor.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: memstream compat layer requires use of babeltrace_close_memstream
Mathieu Desnoyers [Thu, 15 Oct 2015 16:08:48 +0000 (12:08 -0400)] 
Fix: memstream compat layer requires use of babeltrace_close_memstream

In compatibility mode, the babeltrace compat layer around memstream
copies the file content into the buffer only at close.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agocompat send no SIGPIPE: multithread-safe
Mathieu Desnoyers [Thu, 15 Oct 2015 16:07:46 +0000 (12:07 -0400)] 
compat send no SIGPIPE: multithread-safe

The current implementation of the no-SIGPIPE send in the compatibility
layer has side-effects on multithreaded processes due to use of
sigaction(). Although multithread-safety is not strictly needed since
Babeltrace is single-threaded for now, there is no reason to keep this
limitation deeply rooted in a compatibility layer.

Use the multithreaded-safe algorithm to catch SIGPIPE implemented in
LTTng-UST for the write() system call for platforms that do not have
MSG_NOSIGNAL. It was originally implented in LTTng-UST as part of the
ring buffer wakeup. This is a re-implementation of this same algorithm
under MIT license. It uses signal masks and sigtimedwait.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: truncated value in fgetc() usage
Jérémie Galarneau [Thu, 15 Oct 2015 17:43:06 +0000 (13:43 -0400)] 
Fix: truncated value in fgetc() usage

Reported by Coverity Scan:
CID 1327417:  API usage errors  (CHAR_IO)
Assigning the return value of "fgetc" to char "c" truncates
its value.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: handle EINTR return value for bt_posix_fallocate
Mathieu Desnoyers [Tue, 13 Oct 2015 20:04:23 +0000 (16:04 -0400)] 
Fix: handle EINTR return value for bt_posix_fallocate

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoConfigure: Add missing checks
Michael Jeanson [Tue, 13 Oct 2015 19:29:58 +0000 (15:29 -0400)] 
Configure: Add missing checks

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoImplement bt_getline
Mathieu Desnoyers [Tue, 13 Oct 2015 18:56:44 +0000 (14:56 -0400)] 
Implement bt_getline

Implement our own getline to remove dependency from glibc 2.10+ and to
increase portability to other operating systems.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: initialize getline linesize argument to 0
Mathieu Desnoyers [Tue, 13 Oct 2015 18:44:05 +0000 (14:44 -0400)] 
Fix: initialize getline linesize argument to 0

It works by accident because getline() reallocates based on the initial
pointer, but doing this falls into a blind spot of the Linux man pages.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: warning, may be used uninitialized
Michael Jeanson [Fri, 9 Oct 2015 21:16:37 +0000 (17:16 -0400)] 
Fix: warning, may be used uninitialized

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Replace dirent->d_type by stat S_ISREG
Michael Jeanson [Fri, 9 Oct 2015 20:19:40 +0000 (16:19 -0400)] 
Port: Replace dirent->d_type by stat S_ISREG

dirent->d_type is Linux specific while 'stat' is part of POSIX

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Include config.h globally trough DEFAULT_INCLUDES
Michael Jeanson [Fri, 9 Oct 2015 19:50:25 +0000 (15:50 -0400)] 
Port: Include config.h globally trough DEFAULT_INCLUDES

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add compat for dirfd
Michael Jeanson [Fri, 9 Oct 2015 16:24:20 +0000 (12:24 -0400)] 
Port: Add compat for dirfd

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add compat for mkdtemp
Michael Jeanson [Fri, 9 Oct 2015 16:15:12 +0000 (12:15 -0400)] 
Port: Add compat for mkdtemp

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add compat for strnlen and strndup
Michael Jeanson [Fri, 9 Oct 2015 16:01:46 +0000 (12:01 -0400)] 
Port: Add compat for strnlen and strndup

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Use bash to run tests
Michael Jeanson [Tue, 6 Oct 2015 20:30:12 +0000 (16:30 -0400)] 
Port: Use bash to run tests

The Solaris base shell does not support subshells with $()

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Implement faccessat wrapper
Mathieu Desnoyers [Thu, 1 Oct 2015 20:26:20 +0000 (16:26 -0400)] 
Port: Implement faccessat wrapper

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: implement posix_fallocate wrapper
Jérémie Galarneau [Thu, 1 Oct 2015 19:53:47 +0000 (15:53 -0400)] 
Port: implement posix_fallocate wrapper

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Set required compiler flags to use pthreads
Michael Jeanson [Wed, 7 Oct 2015 19:35:46 +0000 (15:35 -0400)] 
Port: Set required compiler flags to use pthreads

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add configure check for __attribute__ support
Michael Jeanson [Wed, 7 Oct 2015 19:33:34 +0000 (15:33 -0400)] 
Port: Add configure check for __attribute__ support

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: cleanup and portability fix to configure.ac
Michael Jeanson [Wed, 7 Oct 2015 19:23:18 +0000 (15:23 -0400)] 
Port: cleanup and portability fix to configure.ac

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add support for linkers with no support for 'no-as-needed'
Alexis Martin [Thu, 1 Oct 2015 20:12:25 +0000 (16:12 -0400)] 
Port: Add support for linkers with no support for 'no-as-needed'

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add compat for platforms with no MSG_NOSIGNAL or SO_NOSIGPIPE
Michael Jeanson [Mon, 28 Sep 2015 15:53:19 +0000 (11:53 -0400)] 
Port: Add compat for platforms with no MSG_NOSIGNAL or SO_NOSIGPIPE

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add AX_LIB_SOCKET_NSL macro to configure.ac
Michael Jeanson [Mon, 28 Sep 2015 15:42:50 +0000 (11:42 -0400)] 
Port: Add AX_LIB_SOCKET_NSL macro to configure.ac

This is required on platforms that need extra libraries to
link socket programs.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Replace bzero() by memset()
Michael Jeanson [Mon, 28 Sep 2015 14:50:54 +0000 (10:50 -0400)] 
Port: Replace bzero() by memset()

bzero() was deprecated in POSIX 2001 and removed from POSIX 2008,
while memset() is part of standard C.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add dummy.c to libcompat
Michael Jeanson [Mon, 28 Sep 2015 14:26:50 +0000 (10:26 -0400)] 
Port: Add dummy.c to libcompat

The BSD 'ar' command won't accept an empty file list, add a dummy c file.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: uname can return a positive value on success
Michael Jeanson [Mon, 28 Sep 2015 14:17:23 +0000 (10:17 -0400)] 
Port: uname can return a positive value on success

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Replace NAME_MAX by MAXNAMLEN
Michael Jeanson [Mon, 28 Sep 2015 14:13:27 +0000 (10:13 -0400)] 
Port: Replace NAME_MAX by MAXNAMLEN

MAXNAMLEN is defined on Linux, Solaris and BSD

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoChange UUID API prefix from babeltrace_ to bt_
Jérémie Galarneau [Tue, 13 Oct 2015 20:36:56 +0000 (16:36 -0400)] 
Change UUID API prefix from babeltrace_ to bt_

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add Solaris libuuid compat
Michael Jeanson [Mon, 28 Sep 2015 12:26:00 +0000 (08:26 -0400)] 
Port: Add Solaris libuuid compat

Solaris libuuid lack const qualifiers, add compat functions.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: Add Solaris endian.h compat
Michael Jeanson [Tue, 6 Oct 2015 16:09:02 +0000 (12:09 -0400)] 
Port: Add Solaris endian.h compat

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoPort: make bootstrap script work on most shell
Michael Jeanson [Tue, 6 Oct 2015 16:08:00 +0000 (12:08 -0400)] 
Port: make bootstrap script work on most shell

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: babeltrace-log packet seek
Mathieu Desnoyers [Tue, 13 Oct 2015 16:06:26 +0000 (12:06 -0400)] 
Fix: babeltrace-log packet seek

Packet seek has been removed from ctf helper headers somewhere around
Babeltrace 1.1. Since then, babeltrace-log is broken when it needs to
output a file larger than the fixed-sized packet (WRITE_PACKET_LEN
currently defined as (getpagesize() * 8 * CHAR_BIT).

Correctly handle the non-zero return values on ctf_align_pos() and
ctf_move_pos() on the dummy position copy, which are used to validate
whether we need to switch packet or not. Also add an initial packet seek
at the beginning of the file.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: posix_fallocate() returns int > 0 on errors
Michael Jeanson [Tue, 13 Oct 2015 16:13:11 +0000 (12:13 -0400)] 
Fix: posix_fallocate() returns int > 0 on errors

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoConfigure: add check for type
Jonathan Rajotte [Mon, 23 Feb 2015 20:50:38 +0000 (15:50 -0500)] 
Configure: add check for type

Based on autoscan report:

configure.ac: warning: missing AC_TYPE_INT16_T wanted by: formats/ctf/types/integer.c:111
configure.ac: warning: missing AC_TYPE_INT32_T wanted by: formats/ctf/types/integer.c:120
configure.ac: warning: missing AC_TYPE_INT64_T wanted by: lib/trace-collection.c:111
configure.ac: warning: missing AC_TYPE_INT8_T wanted by: formats/ctf/types/integer.c:103
configure.ac: warning: missing AC_TYPE_OFF_T wanted by: formats/ctf/ctf.c:863
configure.ac: warning: missing AC_TYPE_SSIZE_T wanted by: lib/iterator.c:51
configure.ac: warning: missing AC_TYPE_UINT16_T wanted by: formats/ctf/types/integer.c:71
configure.ac: warning: missing AC_TYPE_UINT32_T wanted by: converter/babeltrace-log.c:127
configure.ac: warning: missing AC_TYPE_UINT64_T wanted by: lib/iterator.c:52
configure.ac: warning: missing AC_TYPE_UINT8_T wanted by: converter/babeltrace-log.c:141

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoConfigure: add check on headers
Jonathan Rajotte [Mon, 23 Feb 2015 20:50:37 +0000 (15:50 -0500)] 
Configure: add check on headers

Based on autoscan report:

configure.ac: warning: missing AC_CHECK_HEADERS([fcntl.h]) wanted by: lib/context.c:44
configure.ac: warning: missing AC_CHECK_HEADERS([limits.h]) wanted by: include/babeltrace/compat/limits.h:26
configure.ac: warning: missing AC_CHECK_HEADERS([netdb.h]) wanted by: formats/lttng-live/lttng-live-comm.c:27
configure.ac: warning: missing AC_CHECK_HEADERS([netinet/in.h]) wanted by: formats/lttng-live/lttng-live-comm.c:26
configure.ac: warning: missing AC_CHECK_HEADERS([stddef.h]) wanted by: include/babeltrace/compiler.h:28
configure.ac: warning: missing AC_CHECK_HEADERS([sys/socket.h]) wanted by: formats/lttng-live/lttng-live-comm.c:24

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoConfigure: add missing check for used funcs
Jonathan Rajotte [Mon, 23 Feb 2015 20:50:36 +0000 (15:50 -0500)] 
Configure: add missing check for used funcs

Based on autoscan report:
configure.ac: warning: missing AC_CHECK_FUNCS([ftruncate]) wanted by: formats/ctf/writer/writer.c:237
configure.ac: warning: missing AC_CHECK_FUNCS([gethostbyname]) wanted by: formats/lttng-live/lttng-live-comm.c:122
configure.ac: warning: missing AC_CHECK_FUNCS([localtime_r]) wanted by: formats/ctf/ctf.c:341
configure.ac: warning: missing AC_CHECK_FUNCS([memset]) wanted by: converter/babeltrace-log.c:228
configure.ac: warning: missing AC_CHECK_FUNCS([mkdir]) wanted by: converter/babeltrace-log.c:404
configure.ac: warning: missing AC_CHECK_FUNCS([rmdir]) wanted by: converter/babeltrace-log.c:467
configure.ac: warning: missing AC_CHECK_FUNCS([setenv]) wanted by: include/babeltrace/compat/utc.h:71
configure.ac: warning: missing AC_CHECK_FUNCS([socket]) wanted by: formats/lttng-live/lttng-live-comm.c:129
configure.ac: warning: missing AC_CHECK_FUNCS([strchr]) wanted by: converter/babeltrace-log.c:244
configure.ac: warning: missing AC_CHECK_FUNCS([strdup]) wanted by: converter/babeltrace.c:701
configure.ac: warning: missing AC_CHECK_FUNCS([strerror]) wanted by: formats/ctf/ctf.c:682
configure.ac: warning: missing AC_CHECK_FUNCS([strndup]) wanted by: formats/lttng-live/lttng-live-comm.c:280
configure.ac: warning: missing AC_CHECK_FUNCS([strrchr]) wanted by: converter/babeltrace-log.c:334
configure.ac: warning: missing AC_CHECK_FUNCS([strtoull]) wanted by: converter/babeltrace.c:354
configure.ac: warning: missing AC_CHECK_FUNCS([tzset]) wanted by: include/babeltrace/compat/utc.h:72

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: add compat for glib < 2.32
Michael Jeanson [Tue, 22 Sep 2015 18:46:07 +0000 (14:46 -0400)] 
Fix: add compat for glib < 2.32

A dependency on glib >= 2.32 was introduced in this commit:

commit 347829f5b1eaf79a540f4623f7ae5ee4e9e3d4c7
Author: Philippe Proulx <eeppeliteloop@gmail.com>
Date:   Thu Mar 12 16:14:31 2015 -0400

    Add basic object system

To stay compatible with SLES11, keep our dependency on 2.22 and add a
compatibility header.

Fixes #890

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: make check in OOT build with absolute path
Michael Jeanson [Fri, 4 Sep 2015 21:23:12 +0000 (17:23 -0400)] 
Fix: make check in OOT build with absolute path

The previous patch fixed the out of tree build when the configure script
was called with a path relative to the builddir but still failed when
the path was absolute. This works with both.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: make check in out of tree build
Michael Jeanson [Thu, 3 Sep 2015 18:13:21 +0000 (14:13 -0400)] 
Fix: make check in out of tree build

Use the tracefiles from the source dir when running make check in an out
of tree builddir.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: 32bit values index_major/minor used as 64bit
Michael Jeanson [Tue, 18 Aug 2015 19:39:41 +0000 (15:39 -0400)] 
Fix: 32bit values index_major/minor used as 64bit

This patch fixes compiler warnings on big endian architectures where
be64toh() is a nop and returns the original type.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoHide the packet_seq_num field
Julien Desfossez [Mon, 3 Aug 2015 15:35:38 +0000 (11:35 -0400)] 
Hide the packet_seq_num field

The packet_seq_num is a new field in LTTng 2.8 that should be hidden
from the ctf-text output as it is not really relevant for the users of
the text output.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add bt_ctf_field_type_sequence/array_set_element_type()
Philippe Proulx [Fri, 31 Jul 2015 14:11:58 +0000 (10:11 -0400)] 
ir: add bt_ctf_field_type_sequence/array_set_element_type()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: do not cache variant type's alignment
Philippe Proulx [Tue, 28 Jul 2015 19:09:06 +0000 (15:09 -0400)] 
ir: do not cache variant type's alignment

A variant type's alignment will always be 0
any way, so this caching step is not needed.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoFix: test_ctf_writer: assert() without side effects
Philippe Proulx [Thu, 30 Jul 2015 20:42:32 +0000 (16:42 -0400)] 
Fix: test_ctf_writer: assert() without side effects

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: empty structures are legal in CTF
Philippe Proulx [Thu, 30 Jul 2015 19:31:38 +0000 (15:31 -0400)] 
ir: empty structures are legal in CTF

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add field instance type ID helpers
Philippe Proulx [Mon, 27 Jul 2015 13:02:25 +0000 (09:02 -0400)] 
ir: add field instance type ID helpers

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add bt_ctf_field_get_type_id()
Philippe Proulx [Mon, 27 Jul 2015 12:49:09 +0000 (08:49 -0400)] 
ir: add bt_ctf_field_get_type_id()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add field type ID helpers
Philippe Proulx [Mon, 27 Jul 2015 12:56:02 +0000 (08:56 -0400)] 
ir: add field type ID helpers

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoUnify reference counting using a common bt_object base
Jérémie Galarneau [Thu, 30 Jul 2015 04:16:27 +0000 (00:16 -0400)] 
Unify reference counting using a common bt_object base

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add bt_ctf_trace_get_stream_class_by_id()
Philippe Proulx [Mon, 27 Jul 2015 13:13:46 +0000 (09:13 -0400)] 
ir: add bt_ctf_trace_get_stream_class_by_id()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 years agoir: add internal field path getters
Philippe Proulx [Mon, 27 Jul 2015 12:40:33 +0000 (08:40 -0400)] 
ir: add internal field path getters

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.046249 seconds and 4 git commands to generate.