babeltrace.git
5 years agoRename `init` methods to `initialize`
Francis Deslauriers [Thu, 26 Sep 2019 15:39:35 +0000 (11:39 -0400)] 
Rename `init` methods to `initialize`

We use the full word 'finalize' so why not use the full word
'initialize'.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I741e2406bf53a8da4b74a5335afcd7ec359727ea
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2098
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agolib: split real FC/field into single and double prec FC/field
Francis Deslauriers [Thu, 26 Sep 2019 20:13:22 +0000 (16:13 -0400)] 
lib: split real FC/field into single and double prec FC/field

This commit removes the BT_FIELD_CLASS_TYPE_REAL field class and the
corresponding fields and adds BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL
and BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL field classes and their
fields.

This seems like cleaner way to express the different types of floating
point representations and while keeping the door open for other
(smaller and/or larger) representations.

The test_field.py testcases for `_SinglePrecisionRealField` are
implemented using a default value of 52.0 which can be converted from
Python float(double precision) to C float(single precision) without loss
of precision. It's the best way I found to support the
`_TestNumericField` test cases without scattering specific conditions
for `_SinglePrecisionRealField`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I6057e1626b71fee5dce1c374bda3faf3451b5fef
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2099
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoFix: cli: don't log error when using help command with a plugin name
Simon Marchi [Thu, 26 Sep 2019 15:28:51 +0000 (11:28 -0400)] 
Fix: cli: don't log error when using help command with a plugin name

When using the help command with a plugin name, it works, but Babeltrace
logs an error:

    09-26 16:37:03.782 10054 10054 E CLI/CFG-CLI-ARGS plugin_comp_cls_names@babeltrace2-cfg-cli-args.c:189 Missing component class type (`source`, `filter`, or `sink`).

This is problematic, because this is a valid use of the command.
Logging an error is unnecessarily alarming.

The current code takes the argument (in our case, a plugin name such as
"ctf") and passes it through plugin_comp_cls_names.  The function can't
parse the string as a component class name, so logs the error mentioned
above.  The caller, bt_config_help_from_args, sees that the function has
failed, so falls back to assuming the string is a plugin name, which
then works correctly.

To avoid this, the sophisticated solution I chose was to look for an
unescaped dot in the argument.  If there's one, we treat it as a
component class name, if there isn't, we treat is as a plugin name.

Change-Id: I76b791e5d44436fdc5b10a3c10e3579a0783b04d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2101
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoFix: bt2: duplicate test name in test_field.py
Simon Marchi [Tue, 24 Sep 2019 19:20:06 +0000 (15:20 -0400)] 
Fix: bt2: duplicate test name in test_field.py

Flake8 reports:

    ./tests/bindings/python/bt2/test_field.py:2170:5: F811 redefinition of unused 'test_has_field_prop_true' from line 2166
    ./tests/bindings/python/bt2/test_field.py:2178:5: F811 redefinition of unused 'test_bool_op_true' from line 2174

I think that in both cases, the second instance was meant to be renamed
to `_false`.

Reported-by: flake8
Change-Id: I8b3143bb3f86982e220a6b516f028fca9e6e24ab
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2093

5 years agobt2: remove unused variable in UserMessageIteratorSeekNsFromOriginTestCase.test_seek_...
Simon Marchi [Tue, 24 Sep 2019 19:17:29 +0000 (15:17 -0400)] 
bt2: remove unused variable in UserMessageIteratorSeekNsFromOriginTestCase.test_seek_ns_from_origin

Flake8 reports:

    ./tests/bindings/python/bt2/test_message_iterator.py:790:9: F841 local variable 'msg' is assigned to but never used

Reported-by: flake8
Change-Id: I4be9bf2d1a86e4c5d538fd1d1461f6e2bbf2b763
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2092
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoFix: bt2: duplicate test name in _IntegerRangeTestCase
Simon Marchi [Tue, 24 Sep 2019 19:16:05 +0000 (15:16 -0400)] 
Fix: bt2: duplicate test name in _IntegerRangeTestCase

Flake8 reports:

    ./tests/bindings/python/bt2/test_integer_range_set.py:45:5: F811 redefinition of unused 'test_create_wrong_type_lower' from line 41

I think the issue is simply that the second instance should have `upper`
instead of `lower`.

Reported-by: flake8
Change-Id: Id03b801951b9ce64eb0264debdd8ed4c4e3a577e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2091

5 years agoFix: bt2: use of undefined variable in _VariantFieldClassWithSelectorTestCase.test_co...
Simon Marchi [Tue, 24 Sep 2019 19:04:07 +0000 (15:04 -0400)] 
Fix: bt2: use of undefined variable in _VariantFieldClassWithSelectorTestCase.test_const_append

Flake8 reports:

    ./tests/bindings/python/bt2/test_field_class.py:875:43: F821 undefined name 'str_field_class'

Fix it by defining the str_field_class variable (even though it won't
actually be used).

Reported-by: flake8
Change-Id: If17cef30ed24b6ec9d1ee25d3f6c94d491ffd8fd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2090

5 years agoFix: bt2: unused assignments in test_field_class.py
Simon Marchi [Tue, 24 Sep 2019 18:33:16 +0000 (14:33 -0400)] 
Fix: bt2: unused assignments in test_field_class.py

Fix these:

    ./tests/bindings/python/bt2/test_field_class.py:101:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:124:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:215:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:234:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:251:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:402:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:428:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:445:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:1183:9: F841 local variable 'field' is assigned to but never used
    ./tests/bindings/python/bt2/test_field_class.py:1222:9: F841 local variable 'field' is assigned to but never used

In all these cases, the assignment has no effect.  The original intent
was probably to do `field.value = ...`, so use that everywhere.

Reported-by: flake8
Change-Id: If28fab3d1a8facb0123ab3a2dc0b83062ebed38e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2089

5 years agobt2: print actual and expected lengths in _StaticArrayField._set_value error message
Simon Marchi [Tue, 24 Sep 2019 18:38:51 +0000 (14:38 -0400)] 
bt2: print actual and expected lengths in _StaticArrayField._set_value error message

I think it can help the user figure out what's wrong if we give the
lengths of the field and the passed value in the error message.

Change-Id: I94fb7ca04724d5d7af701df88aaedc195b1736fd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2088
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: ignore comparison to None flake8 warnings in test_value.py
Simon Marchi [Tue, 24 Sep 2019 18:17:38 +0000 (14:17 -0400)] 
bt2: ignore comparison to None flake8 warnings in test_value.py

Fix these:

    ./tests/bindings/python/bt2/test_value.py:485:36: E711 comparison to None should be 'if cond is None:'
    ./tests/bindings/python/bt2/test_value.py:488:35: E711 comparison to None should be 'if cond is not None:'
    ./tests/bindings/python/bt2/test_value.py:1177:36: E711 comparison to None should be 'if cond is None:'
    ./tests/bindings/python/bt2/test_value.py:1180:35: E711 comparison to None should be 'if cond is not None:'

In these tests, we specifically want to test that comparing (equal/not
equal) to None yields the expected result.

Reported-by: flake8
Change-Id: I47d96598a158b10116fc6a948d42ef61f608fb07
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2087

5 years agobt2: remove duplicate test test_create_from_vint in RealValueTestCase
Simon Marchi [Tue, 24 Sep 2019 16:34:51 +0000 (12:34 -0400)] 
bt2: remove duplicate test test_create_from_vint in RealValueTestCase

There are two tests named like this in RealValueTestCase.  The second
one looks right (it creates a Value from an int, then creates a
RealValue from that).  The first one looks like it should be called
"test_create_from_vfloat", as it tests creating a RealValue from another
RealValue, but we already have such a test case a bit lower.  So I think
it's fine to delete it.

Reported-by: flake8
Change-Id: I274b922c653675913f2346cbc67cbcd03cd5208f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2086
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: remove duplicated test test_setitem_none in ArrayValueTestCase
Simon Marchi [Tue, 24 Sep 2019 16:18:29 +0000 (12:18 -0400)] 
bt2: remove duplicated test test_setitem_none in ArrayValueTestCase

The two tests with that name are identical, so remove one.

Reported-by: flake8
Change-Id: Ibb63b6f548bceb81d6173dcc9619978e62d8828e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2085
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: rename test with conflicting name in test_trace.py
Simon Marchi [Tue, 24 Sep 2019 16:03:18 +0000 (12:03 -0400)] 
bt2: rename test with conflicting name in test_trace.py

The second test named `test_env_iter` seems to be testing iteration of a
const environment object, so rename it to `test_const_env_iter`.

Reported-by: flake8
Change-Id: I614756daa511b9c66b031328f11ad77053ab9fc5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2084
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoAdd setup.cfg with sensible flake8 configuration
Simon Marchi [Tue, 24 Sep 2019 16:01:28 +0000 (12:01 -0400)] 
Add setup.cfg with sensible flake8 configuration

This is a sensible config which allows to run "flake8 ." without having
too many useless warnings.

Note that the `per-file-ignores` config requires flake8 >= 3.7.

Ignore:

- E501, line too long, because we don't really care about that (black
  decides how it's formatted anyway).
- W503, line break before bbinary operator, because we don't really care
  about that (black decides how it's formatted anyway).

__init__.py contains some expectedly unused imports, so it seems cleaner
to disable that warning for the whole file, rather than putting a "noqa"
comment on each line.  Of course, we risk having a really unused import
in that file, but it doesn't contain much, so the risk is low.

Finally, exclude the Python tap directory, as it's not our code.

Change-Id: Iebdf274b91907fb31d4ebfa6ae4c8157de46467c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2083
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agolib: pass config object to message iterator init method, add can seek forward property
Simon Marchi [Wed, 18 Sep 2019 20:12:00 +0000 (16:12 -0400)] 
lib: pass config object to message iterator init method, add can seek forward property

This patch introduces a new bt_self_message_iterator_configuration
object that is passed to message iterator init methods.  The purpose of
this object is to hold options the message iterator can set at init time
but not later.

To verify that the user does not save a pointer to this object and try
to use it later, the object is frozen right after the init method
returns.

The object contains one option that we know we'll need,
`can_seek_forward`.  The corresponding functions to set it (on the
config object) and read it (from the self component port input message
iterator object) are also provided.  But because this patch already
contains a lot of boilerplate, the code that actually uses that option
will come in a following patch.

The Python bindings provide a simple wrapper around this new object.

Change-Id: Ibcd0df842fd154d3bafe3869b56f70aa3a72ceab
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2064
Tested-by: jenkins <jenkins@lttng.org>
5 years agoFix: tests: live: listen on python < 3.5 needs backlog parameter
Jonathan Rajotte [Wed, 25 Sep 2019 21:13:39 +0000 (17:13 -0400)] 
Fix: tests: live: listen on python < 3.5 needs backlog parameter

The backlog parameter is required on python version smaller then 3.5.

On sles12sp2:

 Traceback (most recent call last):
   File "/home/jenkins/workspace/babeltrace_master_slesbuild/arch/sles12sp2/build/std/conf/prod/src/babeltrace/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py", line 1447, in <module>
     args.port_filename, args.sessions, args.max_query_data_response_size
   File "/home/jenkins/workspace/babeltrace_master_slesbuild/arch/sles12sp2/build/std/conf/prod/src/babeltrace/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py", line 1232, in __init__
     self._listen()
   File "/home/jenkins/workspace/babeltrace_master_slesbuild/arch/sles12sp2/build/std/conf/prod/src/babeltrace/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py", line 1323, in _listen
     self._sock.listen()
 TypeError: listen() takes exactly one argument (0 given)

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ib923beb9eadf929714b3270aaa7a57ff6c52407e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2096
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agolib: pass config objects to component init methods
Simon Marchi [Tue, 17 Sep 2019 16:44:36 +0000 (12:44 -0400)] 
lib: pass config objects to component init methods

This patch introduces configuration objects that are passed to init
methods of components.  The goal is to make it possible to have
parameters that can be set during the component's init phase, and not
after.

At the moment, they are not used for anything, they are only there for
future use.  For that reason, we currently just pass the value NULL as
the config objects to the components.  This should be fine, since the
components should not do anything with the config objects for now.

Similarly, we have configuration Python objects passed to __init__
methods of _UserMessageIterator objects.  These configuration objects
are empty, but we can connect them with the corresponding SWIG pointer
once we actually add a method in them.

I added tests to verify that the config objects the components receive
have the right types.

Change-Id: If7568160e225c1eb8343eb212f8b4961f5472836
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2063
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: make it possible to remove a trace class or trace destruction listener
Simon Marchi [Fri, 20 Sep 2019 19:50:59 +0000 (15:50 -0400)] 
bt2: make it possible to remove a trace class or trace destruction listener

This patch adds the possibility to remove a previously added trace or
trace class destruction listener.  Calling
{_TraceClass,_Trace}.add_destruction_listener returns a
_ListenerHandle.  To remove the listener, the user must pass this handle
back to {_TraceClass,_Trace}.remove_destruction_listener.

Change-Id: I6020135c1e056658d941d2e022b171466c5df7b3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2077
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agobt2: make it work for Python 3.4
Simon Marchi [Mon, 23 Sep 2019 19:21:41 +0000 (15:21 -0400)] 
bt2: make it work for Python 3.4

The import system from Python 3.4 has some significant differences
compared to the one from Python 3.5 and later.  Notably, support for
circular references (which we use) was added in the later versions.

For example, trace.py and stream.py both import each other.  Trace
objects need Stream objects when listing streams in a trace, and Stream
objects need Trace objects when getting the containing trace of a
stream.

To make it work on Python 3.4, I think we need to break any circular
import chain that happen when "import bt2" is done.  It is fine to
import things later, once all the modules have been initialized.

To achieve this, I changed some

  from bt2 import foo as bt2_foo

to

  def _get_bt2_foo():
      from bt2 import foo as bt2_foo
      return bt2_foo

The users of bt2_foo in that file now need to use _get_bt2_foo() instead
of bt2_foo.  it is important that _get_bt2_foo doesn't get called during
the import of the module, otherwise, we come back to the initial
problem.  So in some cases, I have wrapped some calls to _get_bt2_foo in
properties, as was already done to break circular dependencies between
classes.

This is not enough though, as there is another behavior difference
between 3.4 and 3.5+, which I believe is also a consequence of the
circular import changes [1].  It is also related to the fact that we
delete submodule attributes from the bt2 module in our __init__.py.

With 3.5, it is still possible to do:

    from bt2 import value

after we've deleted the `value` attribute from bt2.  With Python 3.4, it
doesn't work.  I believe it is related to [1] in that Python 3.5+, when
processing a "from" import, searches in sys.modules if a simple getattr
on the module failed.

This is problematic for us, since we need the 'from bt2 import "foo"'
lines to work after the bt2 attributes have been deleted (to support the
changes described above).  The solution I've found is to not delete the
bt2 submodule attributes when using Python 3.4.

We delete those attributes simply to clean up the bt2 namespace and to
avoid exposing the internal organisation of the code.  I think it's
an acceptable trade-off to not do it when using Python 3.4, if it means
that it will actually work.

[1] https://bugs.python.org/issue17636

Change-Id: Ia6810972492a058f60c21e6f22afd43962f4f7a2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2082
Tested-by: jenkins <jenkins@lttng.org>
5 years agoUpdate project plugins's properties
Philippe Proulx [Mon, 16 Sep 2019 05:18:24 +0000 (01:18 -0400)] 
Update project plugins's properties

This patch updates various properties of the project's plugins. Those
properties are publicly visible through the API or with the CLI's `help`
command.

The updated properties are:

Descriptions:
    Updated to add details or normalize them.

Authors:
    All changed to `EfficiOS <https://www.efficios.com/>`. Keeping a
    specific up-to-date list of authors will be challenging in the
    future, especially with many contributors.

Help texts:
    Added to refer to specific manual pages.

    Maybe we can find a way to set a manual page's plain text as a
    component class's help text in the future, but in the meantime at
    least the user knows where to look for help.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I44d13a89039e433c06e1c527eb2be577fd471454
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2047
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoutils.sh: expand `${extra_details_args[@]}` conditionally
Philippe Proulx [Sat, 21 Sep 2019 16:07:58 +0000 (12:07 -0400)] 
utils.sh: expand `${extra_details_args[@]}` conditionally

When you call bt_diff_details_ctf_single() or
bt_diff_details_ctf_gen_single(), it is possible that you don't provide
any extra `sink.text.details` arguments. This makes
`${extra_details_args[@]}` empty.

`utils.sh` does

    set -u

to make Bash throw an error when a variable is undefined/unbound.

Starting from Bash 4.4 [1]:

> Using ${a[@]} or ${a[*]} with an array without any assigned elements
> when the nounset option is enabled no longer throws an unbound
> variable error.

In bt_diff_details_ctf_single() and bt_diff_details_ctf_gen_single(), we
use `"${extra_details_args[@]}"` directly: Bash < 4.4 throws an error if
the array is empty.

We don't get this error on CI nodes having Bash < 4.4 currently because
all the usages of bt_diff_details_ctf_single() and
bt_diff_details_ctf_gen_single() pass extra `sink.text.details`
arguments. However it is my understanding that they are optional.

This patch replaces

    "${extra_details_args[@]}"

with

    ${extra_details_args[@]+"${extra_details_args[@]}"}

so that `"${extra_details_args[@]}"` is only used when
`${extra_details_args[@]}` is defined. This works with any Bash version.

[1]: https://git.savannah.gnu.org/cgit/bash.git/tree/CHANGES?id=3ba697465bc74fab513a26dea700cc82e9f4724e#n878

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic74117607ac616f3e27968a6f8fb09d07fe7eb12
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2080
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agosink.text.details: add `with-data` initialization parameter
Philippe Proulx [Fri, 20 Sep 2019 09:52:33 +0000 (05:52 -0400)] 
sink.text.details: add `with-data` initialization parameter

This patch makes a `sink.text.details` component handle a new
`with-data` initialization parameter. This new parameter controls
whether or not the component writes data lines, as opposed to metadata
lines: anything that's not metadata is considered data, except for
message iterator inactivity messages.

This can be useful to inspect the metadata blocks of the received
messages without having all the message lines.

The new `default-without-data-without-metadata.expect` expectation file
is empty because, without data and without metadata, there's effectively
nothing to write.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I844073b2080df373501a9216d8041f4d6b799c08
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2076
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoAdd basic `sink.text.details` tests
Philippe Proulx [Fri, 20 Sep 2019 09:18:36 +0000 (05:18 -0400)] 
Add basic `sink.text.details` tests

This patch adds very basic `sink.text.details` tests to at least keep
track of the generated text's format. The tests test each initialization
parameter individually, and some combined with `compact=yes`.

As of this patch, all tests pass `with-stream-name=no` to initialize the
`sink.text.details` component because the `src.ctf.fs` component uses
absolute paths to set stream names and this is not compatible with
static expectation files.

Future tests should use a custom source to check how `sink.text.details`
writes the stream name property.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I79c4956e5d67dd922130443992de9daef2974f4e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2075
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agosink.text.details: don't write `:` after `Packet beginning` without ctx
Philippe Proulx [Fri, 20 Sep 2019 08:25:26 +0000 (04:25 -0400)] 
sink.text.details: don't write `:` after `Packet beginning` without ctx

This patch fixes packet beginning lines which look like:

    ...
        Stream (ID 0, Class ID 0)

    {Trace 0, Stream class ID 0, Stream ID 0}
    Packet beginning:

    {Trace 0, Stream class ID 0, Stream ID 0}
    ...

so that they become:

    ...
        Stream (ID 0, Class ID 0)

    {Trace 0, Stream class ID 0, Stream ID 0}
    Packet beginning

    {Trace 0, Stream class ID 0, Stream ID 0}
    ...

In other words, the `:` character following `Packet beginning` is
useless as there's no (packet context) data following.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4c75bc487c10fa2a4b39708d09d4089887ceabbd
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2074
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agosrc.ctf.fs: deterministically sort trace's DS file groups
Philippe Proulx [Sat, 21 Sep 2019 03:34:12 +0000 (23:34 -0400)] 
src.ctf.fs: deterministically sort trace's DS file groups

This patch makes a `src.ctf.fs` component deterministically sort its
trace's DS file groups. The order of the DS file group array directly
influences:

* The order of the output ports.
* Which DS file group gets which stream ID if the trace's packet headers
  do not contain a `stream_instance_id` field (automatic stream IDs).

It's important that, whatever the build or file system, the component
always assigns the same IDs to the same DS file group for a given trace.
This can help debugging and testing.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I105f44e7885a2974ace4d62abe0ee5384316b350
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2079
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoTests: src.ctf.lttng-live: add inverse ordering from relayd
Jonathan Rajotte [Tue, 13 Aug 2019 23:18:06 +0000 (19:18 -0400)] 
Tests: src.ctf.lttng-live: add inverse ordering from relayd

Validate that relayd side ordering does not have an influence on
determinism of trace decoding.

Change-Id: I37cf7f0d17616acb667339793d6624a7c67dfae3
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1916
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoAdd LTTng-independent `src.ctf.lttng-live` tests
Philippe Proulx [Mon, 29 Jul 2019 19:53:42 +0000 (15:53 -0400)] 
Add LTTng-independent `src.ctf.lttng-live` tests

This patch adds tests for `src.ctf.lttng-live`. It serves as a foundation
for future `src.ctf.lttng-live` tests.

Because `src.ctf.lttng-live` needs a running LTTng relay daemon to
connect to and because we don't want the Babeltrace tests to depend on
LTTng, the new `lttng_live_server.py` script mimics an LTTng relay
daemon. The script expects exact commands from an LTTng live viewer and
replies with the expected responses. It is mainly a scoped down
lttgn-relayd.

The faux server script accepts multiple arguments:

 positional arguments:
  SESSION (for each session)
    A session configuration. There is no space after
    comma.
    Format is:
    'NAME,ID,HOSTNAME,FREQ,CLIENTS,TRACEPATH[,TRACEPATH]....'

 optional arguments:
  --log-level {info,warning} (default: warning)
    The loglevel to be used for the server.

  --port-filename PORT_FILENAME (required)
    The final port file. This file is present when the server is ready to
    receive connection. This is used to as a synchronization point for
    the shell test script.

  --max-query-data-response-size MAX_QUERY_DATA_RESPONSE_SIZE (optional)
    The maximum size of control data response in bytes. This is used to force
    the client to perform multiple requests for the same packet.

The faux server bind to port 0 and get assigned a free port. This prevent
unforeseen interaction with the outside world

In the test script, `tests/plugins/src.ctf.lttng-live/test_live`, the
execution goes as follow:

1. It runs the faux server, passing two temporary file names, and making
   it a background job.

2. It waits for the second temporary file to contain anything.

3. It reads the port number from the second temporary file.

4. It runs:

       $ babeltrace2 -i lttng-live net://localhost:PORT/[valid path]

   where `PORT` is the faux server's port number.

5. It compares the output of 4. to an expected file generated from a
   template.

6. It removes the temporary files.

The faux server exits itself.

The current tests are:
  - test_list_sessions
    List 2 sessions including one with traces for multiple domains.
  - test_base
    Attach to the live server and read a standard ust trace with no discarded
    events.
  - test_multi_domains
    Attach and consume a multi-domain trace with discarded
    events.
  - test_rate_limited
    Attach and consume data from a multi packets ust session with no
    discarded events. Enforce a server side limit on the stream data
    requests size.
  - test_compare_to_ctf_fs
    Attach and consume a multi-domain trace with discarded
    events and compare it to the same trace read by src.ctf.fs.

Missing tests mostly concerns multiple traces under a same session
(per-pid) on listing and reading.

This test only runs if you have a Python interpreter (`HAVE_PYTHON`
Automake definition).

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I2919de3cdfa06eda6f4fcf118689571c13358246
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1915
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: field.py: raise ValueError when setting out of range value to Integer
Francis Deslauriers [Mon, 23 Sep 2019 19:25:36 +0000 (15:25 -0400)] 
bt2: field.py: raise ValueError when setting out of range value to Integer

This commit removes the use of `utils._check_int64()` and
`utils._check_uint64()` methods as the validity of the value is now
checked using the _check_range() method and the existing field class'
`_field_value_range` setter property.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib5b33ae5becc9f71b20b17ae0244b6e676b89f75
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2081
Tested-by: jenkins <jenkins@lttng.org>
5 years agobt2: remove unused import
Simon Marchi [Fri, 20 Sep 2019 20:51:19 +0000 (16:51 -0400)] 
bt2: remove unused import

trace_class.py doesn't need to import trace_class.

Change-Id: I792b742a6aecd9903f64815e4cf066d05d1ccc24
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2078
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoFix: muxer_upstream_msg_iters_can_all_seek_beginning(): init. `status`
Philippe Proulx [Fri, 20 Sep 2019 08:10:16 +0000 (04:10 -0400)] 
Fix: muxer_upstream_msg_iters_can_all_seek_beginning(): init. `status`

Detected by GCC:

    muxer.c: In function â€˜muxer_msg_iter_can_seek_beginning’:
    muxer.c:1541:9: error: â€˜status’ may be used uninitialized in this
    function [-Werror=maybe-uninitialized]
      return status;
             ^~~~~~
    muxer.c:1529:5: error: â€˜status’ may be used uninitialized in this
    function [-Werror=maybe-uninitialized]
      if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) {
         ^

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I55ad73aeb9595796bdcddff5ba4d2895d5f2314e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2073
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoflt.utils.muxer: remove `assume-absolute-clock-classes` param
Francis Deslauriers [Thu, 19 Sep 2019 19:06:58 +0000 (15:06 -0400)] 
flt.utils.muxer: remove `assume-absolute-clock-classes` param

It's a now a postcondition that all the messages of a given message
iterator have compatible clock classes. Thus the
`assume-absolute-clock-classes` parameter is useless as there is no more
need to force a muxer to accept possibly non-compatible clock classes
because we check that they are indeed all compatible.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1efcd99abfd1da1d9a4b7c9c6962f898446d31d1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2067
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agocli: make `--clock-force-correlate` use `force-clock-class-origin-unix-epoch`
Francis Deslauriers [Thu, 19 Sep 2019 21:39:07 +0000 (17:39 -0400)] 
cli: make `--clock-force-correlate` use `force-clock-class-origin-unix-epoch`

The flt.utils.muxer's `assume-absolute-clock-classes` parameter will be
removed in a subsequent commit.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I282576ad778eefd40e1d57266f3af2a880ceca47
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2071
Tested-by: jenkins <jenkins@lttng.org>
5 years agosrc.ctf.fs: add `force-clock-class-origin-unix-epoch` param
Francis Deslauriers [Thu, 19 Sep 2019 19:56:44 +0000 (15:56 -0400)] 
src.ctf.fs: add `force-clock-class-origin-unix-epoch` param

The `force-clock-class-origin-unix-epoch` initialization parameter makes
all the created clock classes have a Unix epoch origin. This is useful
to force the clock classes of multiple traces to be compatible even if
they are not inherently.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: If311081052e9be28ca5782ee684b4ef7bba66176
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2069
Tested-by: jenkins <jenkins@lttng.org>
5 years agobt2: print error causes in bt2._Error.__str__
Simon Marchi [Thu, 19 Sep 2019 21:13:58 +0000 (17:13 -0400)] 
bt2: print error causes in bt2._Error.__str__

When working on Python tests where a bt2._Error escapes the test, I very
often write the same thing to be able to visualize error causes:

    try:
        ... original code ...
    except bt2._Error as e:
        for c in e:
    print(c)
raise

By making bt2._Error.__str__ print the error causes, the causes will be
printed automatically when a test fails this way.

And from the point of view of a user of the bt2 package, I think it's
quite useful to get the error causes right away, rather than having to
write a snippet like the above.  As a user of the library, if a
bt2._Error escapes or if I print it, I'd be happy to get this very
precise information.  Also, not everyone might know from the start that
it's possible to print detailed causes, and the otherwise default
message is rather vague.  It just says for example "Failed to add
component to graph", without any other detail.  So I think we would do
users a service by printing the causes by default.

Change-Id: I6f8c72b8e358d6e664c47a1a43c9a81c91a76239
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2070
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agotests: utils.sh: add lttng-utils plugin to plugin path
Simon Marchi [Thu, 19 Sep 2019 23:58:20 +0000 (19:58 -0400)] 
tests: utils.sh: add lttng-utils plugin to plugin path

Change-Id: I41983a0c42ea2e41b385110e5e8ea003f9b24b3c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2072
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoCleanup: clock-snapshot.c: logically dead code
Francis Deslauriers [Mon, 16 Sep 2019 15:46:51 +0000 (11:46 -0400)] 
Cleanup: clock-snapshot.c: logically dead code

Coverity reported the following:
  CID 1401189 (#1 of 1): Logically dead code (DEADCODE)dead_error_begin:
  Execution cannot reach this statement: bt_clock_snapshot_recycle(c.

Reported-by: Coverity - 1401189 Logically dead code (DEADCODE)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I382a29cf5d825a9df06de61cbed7dcdf988de7d3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2053
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: test_dwarf.c: close() argument cannot be negative
Francis Deslauriers [Mon, 16 Sep 2019 14:46:31 +0000 (10:46 -0400)] 
Fix: test_dwarf.c: close() argument cannot be negative

Coverity reported the following:
  CID 1401801 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)8.
  negative_returns: fd is passed to a parameter that cannot be negative.

Reported-by: Coverity - Argument cannot be negative (NEGATIVE_RETURNS)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ibcdcfd54f5f711923e5a31544c86e82da3ec6226
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2048
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoCleanup: ctf-writer: field-wrapper.c: logically dead code
Francis Deslauriers [Mon, 16 Sep 2019 15:24:50 +0000 (11:24 -0400)] 
Cleanup: ctf-writer: field-wrapper.c: logically dead code

Coverity reported the following:
  CID 1401191 (#1 of 1): Logically dead code (DEADCODE)dead_error_begin:
  Execution cannot reach this statement: bt_ctf_field_wrapper_destroy.

Reported-by: Coverity - 1401191 Logically dead code (DEADCODE)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib468f8df4a11491b185ffa45c2db3bc4fc8fb045
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2051
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: ctf-writer: stream-class.c: Dereference after null check
Francis Deslauriers [Mon, 16 Sep 2019 14:54:45 +0000 (10:54 -0400)] 
Fix: ctf-writer: stream-class.c: Dereference after null check

Coverity reported the following:
  CID 1401231 (#1 of 1): Dereference after null check (FORWARD_NULL)8.
  var_deref_model: Passing null pointer ft_copy to
  bt_ctf_field_type_common_integer_set_mapped_clock_class_no_check_frozen,
  which dereferences it

Reported-by: Coverity - 1401231 Dereference after null check (FORWARD_NULL)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I32a15f0ff927c8b987e785a37596e9c56b628de5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2049
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: flt.lttng-utils.debug-info: bin-info.c: Dereferencing null pointer
Francis Deslauriers [Mon, 16 Sep 2019 14:59:37 +0000 (10:59 -0400)] 
Fix: flt.lttng-utils.debug-info: bin-info.c: Dereferencing null pointer

Coverity reported the following:
  CID 1401211 (#1 of 1): Dereference after null check (FORWARD_NULL)4.
  var_deref_op: Dereferencing null pointer bin.

Reported-by: Coverity - 1401211 Dereference after null check (FORWARD_NULL)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I66c3dc42305b1c14a5567141274249c6e6b10082
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2050
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: object-pool.c: dereferenced before null check
Francis Deslauriers [Mon, 16 Sep 2019 16:03:46 +0000 (12:03 -0400)] 
Fix: object-pool.c: dereferenced before null check

Coverity reported the following:
  CID 1401187 (#1 of 1): Dereference before null check
  (REVERSE_INULL)check_after_deref: Null-checking pool suggests that it
  may be null, but it has already been dereferenced on all paths leading
  to the check.

Add a `BT_ASSERT()` to ensure that `pool` is not null.

Reported-by: Coverity - 1401187 Dereference before null check (REVERSE_INULL)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie18fecdad17c1a42db914d2eb987f783a4523871
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2054
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoCleanup: packet-context-field.c: logically dead code
Francis Deslauriers [Mon, 16 Sep 2019 15:40:23 +0000 (11:40 -0400)] 
Cleanup: packet-context-field.c: logically dead code

Coverity reported the following:
  CID 1401199 (#1 of 1): Logically dead code (DEADCODE)dead_error_begin:
  Execution cannot reach this statement: bt_field_wrapper_destroy

Reported-by: Coverity - 1401199 Logically dead code (DEADCODE)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia53f46f998bcfb3a88f2d8a93343aa4c199a12ff
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2052
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: output non-LTTng CTF trace with same relative path as input
Simon Marchi [Mon, 9 Sep 2019 22:07:08 +0000 (18:07 -0400)] 
Fix: output non-LTTng CTF trace with same relative path as input

Commit

  73760435c5a4 ("cli: automatically detect sources for leftover arguments")

changed the behavior of the CLI when converting non-LTTng CTF traces
[1].  The intended behavior, prior to this commit, is to replicate in
the output directory the directory structure from the input directory.

So let's say we have CTF traces at `a/b/c1` and `a/b/c2` (metadata files
inside those directories) and we do:

    babeltrace2 a -c sink.ctf.fs -p 'path="out"'

We expect to have traces output in `out/b/c1` and `out/b/c2`.

Before the introduction of automatic source discovery, the src.ctf.fs
component would receive `a` as the input path, recurse to find the
traces, and set the name of each trace to be the path of the trace
relative to `a` (`b/c1` and `b/c2` in the example above).  The
sink.ctf.fs component would then use add the trace name to the
user-provided output path to build the output path of each trace.

Now, when used with automatic source discovery (and especially since
they have lost the ability to recurse), src.ctf.fs components receive
the direct path to each trace (one trace per component).  So, in the
example above, that is `a/b/c1` and `a/b/c2`.  Since they don't have
access to the top-level directory the user specified, they can no longer
compute the trace name that the sink.ctf.fs component so desperately
needs.

Currently (since 48881202c2ef ("ctf: make src.ctf.fs not recurse")), the
normalized path is passed as the trace name.  So we end up with the
absolute path of the input trace under the output directory.

To restore the original behavior, this patch makes the CLI (which has
access to the required information)  compute the trace name the same way
src.ctf.fs used to do, and pass it as the `trace-name` parameter to
src.ctf.fs components.  It only does so when the trace has a single
input directory.

[1] This behavior only affects non-LTTng CTF traces, because sink.ctf.fs
first tries to build the output path using certain environment fields
(which LTTng traces provide), and only falls back on the trace name if
the required fields are not present.  So for LTTng traces (or other
traces that have the required env fields), the trace name does not
matter.

Change-Id: Iaba02fbae856ac5ddc11724613457bcc0b5b4019
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2026
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agocli: don't include version.h in babeltrace2-cfg-cli-params-arg.c
Simon Marchi [Wed, 18 Sep 2019 13:51:12 +0000 (09:51 -0400)] 
cli: don't include version.h in babeltrace2-cfg-cli-params-arg.c

The only thing provided by version.h is the GIT_VERSION macro, which
this file doesn't use.  Because it includes that header file, it is
unnecessarily rebuilt after we do or amend a git commit.

Change-Id: Ic7526f09f62896d5dfc299f15205fe9982060c4d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2065
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: add `if __name__ == '__main__'` snippet to all tests
Simon Marchi [Tue, 17 Sep 2019 18:43:12 +0000 (14:43 -0400)] 
bt2: add `if __name__ == '__main__'` snippet to all tests

I find it useful to run a single test file.

Change-Id: I6387864abf246977b964e17b932beebdba8bc92c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2062
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agobt2: remove native_bt.d in `make clean`
Simon Marchi [Tue, 17 Sep 2019 15:34:15 +0000 (11:34 -0400)] 
bt2: remove native_bt.d in `make clean`

Change-Id: Ifedefce4d1d0f7ffad2fa9f32cb59d581750bb46
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2061
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoFix: ctf: assert that name is not NULL in warn_meaningless_field()
Jérémie Galarneau [Wed, 4 Sep 2019 16:13:39 +0000 (12:13 -0400)] 
Fix: ctf: assert that name is not NULL in warn_meaningless_field()

gcc 9.1 reports that warn_meaningless_field's `name` is sometimes
NULL when it is inlined in warn_meaningless_fields(), itself
inlined in ctf_trace_class_warn_meaningless_header_fields() at
line 131.

The the only call site using a `NULL` name will have
`fc->type == CTF_FIELD_CLASS_TYPE_STRUCT`.

Add a `BT_ASSERT(name)` to warn_meaningless_field() and a comment
indicating that `name` is guaranteed to be non-NULL whenever the field
class is not a structure.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I323b9f390f80dbd898a69664082fd07d5cc2fc86
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2000
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoctf: silence bogus warning in set_field_refs()
Jérémie Galarneau [Wed, 11 Sep 2019 14:57:15 +0000 (10:57 -0400)] 
ctf: silence bogus warning in set_field_refs()

gcc 9.1.0 warns that struct_fc my be used uninitialized. The code
flow doesn't allow this to happen, but this warning is annoying/scary
and easily fixed by initializing struct_fc to NULL.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib4c702dfc0ca4a29e387b384a1603bdf4634c599
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2028
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoctf: silence bogus warnings in create_relative_field_ref()
Jérémie Galarneau [Wed, 11 Sep 2019 14:54:48 +0000 (10:54 -0400)] 
ctf: silence bogus warnings in create_relative_field_ref()

gcc 9.1.0 warns that struct_fc and var_fc may be used uninitialized.
The code flow doesn't allow this to happen, but this warning is
annoying/scary and easily fixed by initializing both variables to
NULL.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I554affb70275f60eff08134f80b33bc4cefbc91f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2027
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agobt2: expose seek_ns_from_origin and can_seek_ns_from_origin
Simon Marchi [Mon, 9 Sep 2019 17:26:16 +0000 (13:26 -0400)] 
bt2: expose seek_ns_from_origin and can_seek_ns_from_origin

This patch makes the seek_ns_from_origin and can_seek_ns_from_origin
operations accessible in Python.  That means:

- A message iterator class implemented in Python can define the
  _user_seek_ns_from_origin and _user_can_seek_ns_from_origin
  methods to implement these operations.
- A message iterator class implemented in Python that has an upstream
  message iterator can call these operations on it using methods on that
  upstream message iterator object.

There is no big surprise in the patch, as everything has mostly been
modeled on seek_beginning/can_seek_beginning.

Change-Id: Ic726b64b4d7c24a59bab03df8a77cf8369bb5e5f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2020
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: test_message_iterator: use assertIs instead of assertTrue/assertFalse in can...
Simon Marchi [Mon, 9 Sep 2019 18:04:19 +0000 (14:04 -0400)] 
bt2: test_message_iterator: use assertIs instead of assertTrue/assertFalse in can seek tests

In these tests, we want to specifically check that the return values are
True or False, not any value that evaluates to True or False.

For example, we initialize can_seek_beginning to None, run
graph.run_once(), then do assertFalse(can_seek_beginning).  If, for some
reason, can_seek_beginning is still None, the test will wrongfully pass.

The same could happen if can_seek_beginning gets assigned some value
that evaluates to True (other than True itself) and we use
assertTrue(can_seek_beginning).

Instead, use assertIs, which checks that the value is specifically the
one and only True or the one and only False.

Change-Id: Idf94d350ecc06cdb6a38ca31b2d77804fbf57df7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2019
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agobt2: remove _GenericMessageIterator abstraction level
Simon Marchi [Mon, 9 Sep 2019 17:23:11 +0000 (13:23 -0400)] 
bt2: remove _GenericMessageIterator abstraction level

We used to have two message iterator types sharing a lot,
_OutputPortMessageIterator and _UserComponentInputPortMessageIterator,
so they shared some code in the name of _GenericMessageIterator.
_OutputPortMessageIterator is no more, so the _GenericMessageIterator
abstraction is not useful anymore.  Rename to
_UserComponentInputPortMessageIterator and remove all the templating.

Change-Id: If626aeac881ab2ca478a196a53047b4bcf3b7a65
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2018
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agobt2: make can_seek_beginning a method instead of a property
Simon Marchi [Mon, 9 Sep 2019 17:19:02 +0000 (13:19 -0400)] 
bt2: make can_seek_beginning a method instead of a property

_GenericMessageIterator.can_seek_beginning and
_UserMessageIterator._user_can_seek_beginning are currently properties.
We will add the equivalent for can_seek_ns_from_origin, but this one
requires a parameter (the ns_from_origin value), so it can't be a
property, it has to be a method.  For consistency, change the
can_seek_beginning ones to be methods.

Change-Id: Ic2c5b54908753dc7498fb1d0f94022301f766a15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2017
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agolib: remove END values from bt_message_iterator_seek_{beginning,ns_from_origin}_status
Simon Marchi [Mon, 9 Sep 2019 19:21:56 +0000 (15:21 -0400)] 
lib: remove END values from bt_message_iterator_seek_{beginning,ns_from_origin}_status

The corresponding status enumerations on the component class side:

- bt_component_class_message_iterator_seek_beginning_method_status
- bt_component_class_message_iterator_seek_ns_from_origin_method_status

don't include END, so it's not possible for
bt_self_component_port_input_message_iterator_seek_beginning or
bt_self_component_port_input_message_iterator_seek_ns_from_origin to
return END either.

Change-Id: I57a469d724f9605cd6a169459a39a7286f0e191b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2015
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agolib: make can_seek_beginning and can_seek_ns_from_origin methods return a status
Simon Marchi [Fri, 6 Sep 2019 19:50:51 +0000 (15:50 -0400)] 
lib: make can_seek_beginning and can_seek_ns_from_origin methods return a status

The current situation is problematic: calling any of these methods on a
message iterator can result in running some user code, which can fail
for various reasons (e.g. any Python exception being raised and
escaping).  It is not possible to inform the caller of such failure, as
the return type of these methods is bt_bool.  This must change.

This patch changes them to return a status, and return the result by an
output parameter.

If the method returns OK, it must have set the output parameter to
BT_TRUE or BT_FALSE.  If it returns another status, the output parameter
value is unused.

Change-Id: Iaa3dcc1494e2a0fcbdbb14283af3bf8504cd8ef5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2012
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: refactor test_message_iterator
Simon Marchi [Sun, 8 Sep 2019 21:26:09 +0000 (17:26 -0400)] 
bt2: refactor test_message_iterator

This patch tries to make test_message_iterator a bit easier to
understand and extend, since the following patches add various tests in
it.

- Split the test class in two, with "seek beginning" tests in their own
  class.
- Rename _setup_seek_beginning_test to _setup_seek_test, as we'll use it
  for seek ns from origin tests.
- Move _create_graph and _setup_seek_test to be top-level
  functions, they don't really benefit from being static methods.  Plus,
  we'll want to share them between the different test classes.
- Make _setup_seek_test take parameters for various optional methods to
  add to the message iterator class (for now, _user_seek_beginning and
  _user_can_seek_beginning).
- Make _setup_seek_test use _create_graph.
- Split test `test_can_seek_beginning` in three: one for when we have
  a _user_can_seek_beginning method, one for when we don't but have a
  _user_seek_beginning method, and the other one for when we have none
  of those.

Change-Id: Ib99965d60a406acde7c0b16f5fde30a268c84673
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2014
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: rename _FieldPath to _FieldPathConst
Simon Marchi [Mon, 16 Sep 2019 18:24:51 +0000 (14:24 -0400)] 
bt2: rename _FieldPath to _FieldPathConst

The Babeltrace API only returns const field_path objects, so from the
point of view of the user, it's always const.  Rename the Python object
to _FieldPathConst to reflect this.  If the API ever gives access to a
non-const version of field_path, then we can introduce a _FieldPath
type again.

Change-Id: I74a2889db48d570b4b6fbc28e43f98226dc5a053
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2055
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoUpdate manual pages for 2.0.0-rc1
Philippe Proulx [Mon, 12 Aug 2019 15:21:43 +0000 (11:21 -0400)] 
Update manual pages for 2.0.0-rc1

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I81b1a12efc1cfdb34084896d3fd4a4b05996530b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2046
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agotests: make UUIDs under data/ctf-traces/intersection unique
Simon Marchi [Tue, 10 Sep 2019 20:03:28 +0000 (16:03 -0400)] 
tests: make UUIDs under data/ctf-traces/intersection unique

Traces under data/ctf-traces/intersection currently share some UUID
values, even though they are different traces.  I presume it was not
really the initial intention (although it doesn't really matter when
handling them separately).  However, this prevents using them
simultaneously for testing, as they will get treated as part of the same
trace, when that's not what we want.

This patch assigns new, random UUIDs to all duplicated trace and clock
UUIDs.

Change-Id: I7b426640a787a70635162a3c8f1a6c7854072305
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2025
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoFix: fd-cache: Assertion failure if cache not allocated
Francis Deslauriers [Fri, 13 Sep 2019 15:21:46 +0000 (11:21 -0400)] 
Fix: fd-cache: Assertion failure if cache not allocated

Issue
=====
When initializing a `flt.lttng-utils.debug-info` message iterator,
errors may occur before the initialization of the iterator's
`bt_fd_cache`. If that occurs, the iterator is destroyed using the
`debug_info_msg_iter_destroy()` function which calls the
`bt_fd_cache_fini()` function. Leading to the `fdc->cache` being NULL
and thus triggering an assertion failure.

Solution
========
Change the `BT_ASSERT()` to an early return.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib6abd595f1c4365836cacd0357c7323f0b4c6385
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2044
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: plugin-so.c: Assert failure on short name file in plugin-path
Francis Deslauriers [Fri, 13 Sep 2019 21:38:12 +0000 (17:38 -0400)] 
Fix: plugin-so.c: Assert failure on short name file in plugin-path

Issue
=====
Running the following command:
  babeltrace2 --plugin-path=./ ~/lttng-traces/ref/block_rq
in a directory containing a two(or one) characters named file, Babeltrace
aborts with this assertion failure:
  bt_plugin_so_create_all_from_file@plugin-so.c:1527  Babeltrace 2 library precondition not satisfied; error is
  bt_plugin_so_create_all_from_file@plugin-so.c:1527  Path length is too short: path-length=3, min-length=4
  bt_plugin_so_create_all_from_file@plugin-so.c:1527  Aborting...

This problem can also be triggered by placing a single character file at
the root of the file system (e.g. /a) and using the `--plugin-path=/`
parameter.
The assertion failure occurs when trying to find plugins with names that
end with `.so` and `.la` files. This `BT_ASSERT_PRE()` is erroneous
because it asserts that every file tested have one of the right file
extensions when in fact all files of the `--plugin-path` directory are
tested.

Solution
========
Remove the assertion and add an early return if we find that the file
name can not contain any of the accepted suffices.

Drawback
========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib98afa3735a73c2dfabcd96aace9da4c03ae41ab
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2045
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agoFix: plugin.c: leak of `bt_plugin_set`
Francis Deslauriers [Mon, 9 Sep 2019 20:55:27 +0000 (16:55 -0400)] 
Fix: plugin.c: leak of `bt_plugin_set`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id9c8ac37298cda6675fbc57c4e2e76e4baf74999
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2021
Tested-by: jenkins <jenkins@lttng.org>
5 years agobt2: move _append_option to non-const versions of variant classes
Simon Marchi [Thu, 12 Sep 2019 15:22:05 +0000 (11:22 -0400)] 
bt2: move _append_option to non-const versions of variant classes

_append_option should not be available on const versions of variant
classes.  Move it to the non-const versions.

Change-Id: I9b3b9ce2c3cfa629a00f95396b2136384d75d1fa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2043
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: assign non-const version of field_class_variant_option_borrow_user_attributes...
Simon Marchi [Thu, 12 Sep 2019 15:17:37 +0000 (11:17 -0400)] 
bt2: assign non-const version of field_class_variant_option_borrow_user_attributes to _VariantFieldClassOption._borrow_user_attributes_ptr

Change-Id: Iddf8f0a22b922cad0b1c9290edac29a9e5e73514
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2042
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: field_class: rename range set Python class template to _range_set_pycls
Simon Marchi [Thu, 12 Sep 2019 15:12:57 +0000 (11:12 -0400)] 
bt2: field_class: rename range set Python class template to _range_set_pycls

For consistency, as this is the pattern used elsewhere.

Change-Id: Ifaaf82cab922da2c780d4af26580fa16974f7dcd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2041
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: allow getting self output port from user message iterator
Simon Marchi [Wed, 11 Sep 2019 20:07:53 +0000 (16:07 -0400)] 
bt2: allow getting self output port from user message iterator

Change-Id: Ibd5e9206bd4980f1e3e19b54fc41268232a27b81
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2031
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agolib: remove bt_self_port{,_input,_output}
Simon Marchi [Wed, 11 Sep 2019 15:43:19 +0000 (11:43 -0400)] 
lib: remove bt_self_port{,_input,_output}

They are equivalent to/redundant with

- bt_self_component_port
- bt_self_component_port_input
- bt_self_component_port_output

Change-Id: I2c466d829f2fecd3567aea195aa08045be9b6f53
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2030
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: template borrow_user_attributes method in _TraceClassConst, _StreamClassConst...
Simon Marchi [Wed, 11 Sep 2019 15:35:50 +0000 (11:35 -0400)] 
bt2: template borrow_user_attributes method in _TraceClassConst, _StreamClassConst and _ClockClassConst

Change-Id: I74fc9a490278930f980ed8994b98fd7af37c959b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2029
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: add `__hash__()` method on hashable fields
Francis Deslauriers [Wed, 11 Sep 2019 21:07:31 +0000 (17:07 -0400)] 
bt2: add `__hash__()` method on hashable fields

Implement the `__hash__()` method of selected fields so that they can be
used as keys in dictionaries. This commit only implements the
`__hash__()` method of _NumericFieldConst and _StringFieldConst fields
after considering the following facts:
  1. "[...] the implementation of hashable collections requires that a key’s
    hash value is immutable (if the object’s hash value changes, it will be
    in the wrong hash bucket)." [1],
  2. Python built-in types bool, int, float, and string are hashable,
      and sequences and dictionaries are not.

So I suggest that only const fields should be hashable as they are
immutable, and that Container fields (variant, static array, etc.) should not
be hashable (even if they are const) to be consistent with Python
built-in types.

[1]: https://docs.python.org/3/reference/datamodel.html?highlight=__hash__#object.__hash__

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3dc246802d628603a3f06ecd3a87b7e38b3f1e27
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2032
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoFix: src.ctf.lttng-live: no stream beginning/end messages
Francis Deslauriers [Tue, 10 Sep 2019 01:27:24 +0000 (21:27 -0400)] 
Fix: src.ctf.lttng-live: no stream beginning/end messages

Issue
=====
`src.ctf.lttng-live` components don't emit stream beginning and end
messages. This is due to the `bt_msg_iter::emit_stream_begin_msg` field
being set to false at allocation time.

Solution
========
Set it to true right after the allocation.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iae6b174e10070b32a877bb9ba7c1e637491ee15d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2022
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agobt2: Makefile: track dependencies of native_bt.c
Simon Marchi [Tue, 10 Sep 2019 15:08:43 +0000 (11:08 -0400)] 
bt2: Makefile: track dependencies of native_bt.c

Building native_bt.c involves including many .h files from include/.
Those dependencies are not tracked by the Makefile, which means that if
you build, modify a .h (which can be simply checking out a different
commit) and build again, native_bt.c won't be re-built (even though it
should).

SWIG has the same kind of features to make dependency tracking easy as
gcc.  The -MD switch generates a bt2/native_bt.d file containing a make
target with all files involved in generating bt2/native_bt.c.  All we
have to do is to include that file in our Makefile.  `-include` is used
so that it's not an error if the file does not exist (which happens the
first time you build).

Change-Id: Iedb187657d42770fa2caeadfa07079351af8a485
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2023
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: tests: Assert CC type, not if a subclass
Francis Deslauriers [Fri, 6 Sep 2019 20:27:21 +0000 (16:27 -0400)] 
bt2: tests: Assert CC type, not if a subclass

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I807e3a2946741263e2cd3cf0b48c4cddbf281632
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2010
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add `Const` suffix to non-user component-related classes and adapt tests
Francis Deslauriers [Fri, 6 Sep 2019 16:45:20 +0000 (12:45 -0400)] 
bt2: Add `Const` suffix to non-user component-related classes and adapt tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I2d6703707c55f1d420027cd83fa9124b83467938
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2009
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add `Const` suffix to `_*Port` classes and adapt tests
Francis Deslauriers [Fri, 6 Sep 2019 15:49:57 +0000 (11:49 -0400)] 
bt2: Add `Const` suffix to `_*Port` classes and adapt tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ic71e640abb206c249c63316af6ff536308291301
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2008
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add `Const` suffix to `_Connection` class and adapt tests
Francis Deslauriers [Fri, 6 Sep 2019 15:00:02 +0000 (11:00 -0400)] 
bt2: Add `Const` suffix to `_Connection` class and adapt tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I9f695ece01ba48a1fc7008b0ff2ac036fc6e0a7f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2007
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add remaining trace-ir `*Const` classes and adapt tests
Francis Deslauriers [Tue, 27 Aug 2019 19:23:15 +0000 (15:23 -0400)] 
bt2: Add remaining trace-ir `*Const` classes and adapt tests

Split Python classes into Const and Non-Const classes to mimic the type
safety offered by the C api. Const classes offer a read-only view of the
data. Non-Const classes subclass their respective Const classes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I82b10d48bc9183d9a6bdcc6006ef0a886f9def83
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1924
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add `_Clock*Const` classes and adapt tests
Francis Deslauriers [Fri, 30 Aug 2019 16:20:05 +0000 (12:20 -0400)] 
bt2: Add `_Clock*Const` classes and adapt tests

Split Python Clock Class related classes to mimic the type safety
offered by the C api. Const classes offer a read-only view of the data.
Non-Const classes subclass their respective Const classes.

Makes all `_ClockSnapshot` object Const

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I81e4643c80e6e94445ae0e4948279891416a38ca
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1996
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: Add `*ValueConst` classes and adapt tests
Francis Deslauriers [Tue, 27 Aug 2019 16:14:45 +0000 (12:14 -0400)] 
bt2: Add `*ValueConst` classes and adapt tests

Split Python Value classes to mimic the type safety offered by the C
api. Const classes offer a read-only view of the data. Non-Const classes
subclass their respective Const classes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I479db305a281063c7ee8aee2890c33c0b22e7153
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1983
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: field.py: add index check in `selected_option_index` setter of `_VariantField`
Francis Deslauriers [Thu, 5 Sep 2019 22:12:44 +0000 (18:12 -0400)] 
bt2: field.py: add index check in `selected_option_index` setter of `_VariantField`

Also, add corresponding test case.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia0b585adba02d71008f9f63298eb017db4a4fabb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2006
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: field.py: add `_count` method to `_VariantField`
Francis Deslauriers [Thu, 5 Sep 2019 22:10:54 +0000 (18:10 -0400)] 
bt2: field.py: add `_count` method to `_VariantField`

Also, add corresponding test case.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I536526aa0fa1c196056f35d6a74464b076e4b9d4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2005
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agolib: add non-const FC borrow functions for container FCs
Francis Deslauriers [Thu, 5 Sep 2019 16:48:32 +0000 (12:48 -0400)] 
lib: add non-const FC borrow functions for container FCs

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I015c3038d505873cf0bdf2ce0673f92d757aeb19
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2002
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agolib: add `bt_field_borrow_class()` function declaration
Francis Deslauriers [Thu, 5 Sep 2019 16:47:08 +0000 (12:47 -0400)] 
lib: add `bt_field_borrow_class()` function declaration

Also, fix the its definition by removing the `const`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I0ad6261e0890c7a9eab6241245bc99f532e714a9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2001
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
5 years agolib: fix can_seek_beginning method type cast
Simon Marchi [Mon, 9 Sep 2019 19:42:35 +0000 (15:42 -0400)] 
lib: fix can_seek_beginning method type cast

Use the right type for the cast.  It works right now because
can_seek_beginning and seek_beginning have the same signature, but
the can_seek_beginning signature is set to change very soon.

Change-Id: I9b51c1bba43fecd1d857578d28cae5b5ff058059
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: fix _seek_beginning -> _user_seek_beginning in comment
Simon Marchi [Mon, 9 Sep 2019 17:04:17 +0000 (13:04 -0400)] 
bt2: fix _seek_beginning -> _user_seek_beginning in comment

Change-Id: I93aaea82db86e1e8e37b49f5c26662c82337cb97
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
5 years agobt2: fix trivial typo
Simon Marchi [Mon, 9 Sep 2019 01:45:17 +0000 (21:45 -0400)] 
bt2: fix trivial typo

Change-Id: Iff1c9f8315625f63863763e1fbb35b86d6d54166
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
5 years agolib: make message iterator creation functions return a status
Simon Marchi [Thu, 5 Sep 2019 18:44:50 +0000 (14:44 -0400)] 
lib: make message iterator creation functions return a status

These two functions:

- bt_self_component_port_input_message_iterator_create_from_message_iterator
- bt_self_component_port_input_message_iterator_create_from_sink_component

call some user code at some point (the upstream message iterator's init
function), which can possibly fail (return ERROR).  However, they
currently just return the pointer to the created message iterator, no
status.  So on failure (NULL return value), the caller has to assume
that it translates to a MEMORY_ERROR, given that this is the semantic
for all creation functions that just return a pointer.

Therefore, change them to return a status, and return the pointer by
output parameter.

Wrappers for the Python bindings are necessary, because these functions
offer no guarantee about the value of the output pointer on failure.
But the argout typemap checks whether the pointer is NULL to know if the
function has failed or not.

A test is added in Python to check that if
_create_input_port_message_iterator (both in _UserMessageIterator and
_UserSinkComponent) fails, the error is propagated correctly.

Change-Id: I8151b7e9702d5210c28e2c4a9f323f1d990233ed
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2004
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agorename `babeltrace.trace-info` to `babeltrace.trace-infos`, `streams` to `stream...
Simon Marchi [Tue, 3 Sep 2019 19:28:20 +0000 (15:28 -0400)] 
rename `babeltrace.trace-info` to `babeltrace.trace-infos`, `streams` to `stream-infos`

Because the query response is a list of potentially multiple trace
infos, use the plural form for the object name.

Change-Id: I6b742b4993d1a1552c1d189c54759821d4fd069c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1999
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agocli: improve error logging in set_stream_intersections
Simon Marchi [Thu, 5 Sep 2019 16:29:21 +0000 (12:29 -0400)] 
cli: improve error logging in set_stream_intersections

I experienced some errors in set_stream_intersections, and found the
error messages to be very generic and non-helpful.  This patch makes the
function use BT_CLI_LOGE_APPEND_CAUSE when possible and produce more
precise error messages.

Change-Id: I4db2859f8f76de95de12c4139c621b068e22d3ba
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2003
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agobt2: pass all params to `babeltrace.trace-info` query when computing stream intersection
Simon Marchi [Tue, 3 Sep 2019 14:35:23 +0000 (10:35 -0400)] 
bt2: pass all params to `babeltrace.trace-info` query when computing stream intersection

TraceCollectionMessageIterator currently makes it mandatory to pass an
`inputs` parameter to source components when using the stream
intersection mode.  It then picks out that parameter and passes just by
itself to the `babeltrace.trace-info` query.

This is not right for two reasons:

1. The `babeltrace.trace-info` query should be executed with the same
   parameters as what the component will be created with.  This is because
   some parameters can influence the response of the query, such as
   `clock-class-offset-ns` for `src.ctf.fs`.
2. The `inputs` parameter is not mandatory.  It is a convention to which
   source component classes can adhere to work with auto source discovery,
   but it's not mandatory.  Stream intersection mode should work even with
   a source component class that doesn't use it.

A test is added, where a CTF trace is read using the stream intersection
mode, as well as a `clock-class-offset-s` parameter.  Without this
patch, the test would fail because the trimmer components would be
created with a range that doesn't consider the offset.  Therefore all
messages produced by the source (which have the offset applied) fall
outside the trimmers' ranges.  With this patch, the
`babeltrace.trace-info` query returns stream ranges with the offset
applied, so the trimmers have the correct ranges.

Change-Id: I79c86cafafe123c6d306d196d5dde71002b711f7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1998
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoctf: remove `intersection-range-ns` from `babeltrace.trace-info` query
Simon Marchi [Wed, 28 Aug 2019 20:31:12 +0000 (16:31 -0400)] 
ctf: remove `intersection-range-ns` from `babeltrace.trace-info` query

The `intersection-range-ns` field of the `src.ctf.fs` component class
response to the `babeltrace.trace-info` query is not essential, since it
can easily be computed from the stream ranges also in the response.
Remove it, and adjust users to compute the intersection themselves.

One user is the CLI and the other is the TraceCollectionMessageIterator
class in the Python bindings.

There is a small implementation detail change in
TraceCollectionMessageIterator.  Previously, we would do one
`babeltrace.trace-info` query per port.  With this patch, we pre-compute
the intersection range for each source component port and store it in a
port name to intersection mapping.  When we create the trimmers, we just look
up that value.

It results in less queries and avoids computing the intersections many
times.  It is also in line with how the CLI does.

Change-Id: Ic5ebded4d810ef992594941dde3316613909c98c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1994
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoctf: remove unnecessary assignment
Simon Marchi [Tue, 3 Sep 2019 19:19:17 +0000 (15:19 -0400)] 
ctf: remove unnecessary assignment

result is already set to NULL by the BT_VALUE_PUT_REF_AND_RESET just
above, so there is no need to set it again.

Change-Id: I9ab4839a8f9011fde846a0ee9cdb30d28786a362
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1997
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoctf: make src.ctf.fs handle a single trace
Simon Marchi [Wed, 28 Aug 2019 19:01:10 +0000 (15:01 -0400)] 
ctf: make src.ctf.fs handle a single trace

Now that traces with different UUIDs get grouped in different src.ctf.fs
instances, it's not (as) useful for one src.ctf.fs component to support
reading multiple traces at the same time.

This patch simplifies the src.ctf.fs component class to make it handle
only a single logical trace (which can actually be composed of multiple
traces with the same UUID).

Internally, it works the same way as before: we create one `struct
ctf_fs_trace` per input path.  We then merge all of them to a single
one, the one that has the most expansive metadata.

Change-Id: I5a395cac3c379dedc06d98ccffa02b3750a35173
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1993
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoctf: make src.ctf.fs not recurse
Simon Marchi [Wed, 28 Aug 2019 17:13:07 +0000 (13:13 -0400)] 
ctf: make src.ctf.fs not recurse

This patch makes the src.ctf.fs component class not recurse into the
directories passed as `inputs`.  This affects instantion of a new
component as well as `babeltrace.trace-info` queries.

Recursion is no longer needed, because it is handled by the automatic
source discovery feature at the CLI and TraceCollectionMessageIterator
levels.

This means that the elements of the `inputs` array must point directly
to traces, i.e. the directory that directly contains the `metadata`
file.

Providing an input path that does not point to such a directory is
unacceptable and will be met with an error of this class:

    CAUSED BY [src.ctf.fs: 'source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/fs-src/fs.c:1140)
      Path is not a CTF trace (does not contain a metadata file): `/home/smarchi/src/babeltrace/tests/data/ctf-traces/succeed/session-rotation`.

The bulk of the change is mostly in the
ctf_fs_component_create_ctf_fs_traces_one_root, which used to do the
recursion.  It now handles a single path, and is therefore renamed
ctf_fs_component_create_ctf_fs_traces_one_path.

Change-Id: Idb0bbf11f822c50f467fa4e4f661e65242ea78e2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1989
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
5 years agoctf: make src.ctf.fs group inputs by UUID in `babeltrace.support-info` query
Simon Marchi [Thu, 8 Aug 2019 19:22:02 +0000 (15:22 -0400)] 
ctf: make src.ctf.fs group inputs by UUID in `babeltrace.support-info` query

When replying to the `babeltrace.support-info` query, the src.ctf.fs component
class currently groups all recognized CTF inputs in a single `ctf`
group.  It then internally groups traces with the same UUID together to
process them as a single trace (to support LTTng's session rotation
feature).

This commit makes it group the inputs by UUID, which will naturally
assign all inputs beloning to one logical trace to one instance of
src.ctf.fs.  Input traces without UUID are not placed in a group,
meaning that they will have their own src.ctf.fs component.

This paves the way to simplifying src.ctf.fs to support only a single
(logical) trace.

I added a test CTF trace for this, `session-rotation`, which consists of
two traces with three rotation chunks each.  We therefore expect to have
two groups with three inputs each.

The new Python test checks the `babeltrace.support-info` query directly.
I also added a new .expect file for this new test trace, it will at
least verify that we have the right number of streams (which will be off
if the grouping doesn't work as intended).

Change-Id: I13374fff9bafa94c5d8f4b6bac1c64afadef7a46
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1844
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoctf: add internal ctf_metadata_decoder_get_trace_class_uuid()
Philippe Proulx [Wed, 10 Jul 2019 00:18:43 +0000 (20:18 -0400)] 
ctf: add internal ctf_metadata_decoder_get_trace_class_uuid()

This new internal function gets the trace class's UUID from the AST,
without having to create trace IR and CTF IR trace classes, which is a
much slower process (many allocations and checks).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I04d58c66a461219ca01bf120417d629d9a1b9d10
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1843
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoctf: refactor metadata decoder to always have an instance
Philippe Proulx [Tue, 9 Jul 2019 23:40:45 +0000 (19:40 -0400)] 
ctf: refactor metadata decoder to always have an instance

This patch changes the internal `ctf` plugin's metadata decoder API so
that you need to create a decoder instance to read properties instead of
calling ctf_metadata_decoder_packetized_file_stream_to_buf().

Now, you create a metadata decoder, you call
ctf_metadata_decoder_append_content() (similar to what was called
ctf_metadata_decoder_decode()), and then you can get the decoder's
current properties:

* ctf_metadata_decoder_get_ir_trace_class()
* ctf_metadata_decoder_borrow_ctf_trace_class()
* ctf_metadata_decoder_get_byte_order()
* ctf_metadata_decoder_get_uuid()
* ctf_metadata_decoder_get_text()

The decoder's configuration contains two new flags:

`create_trace_class`:
    Controls whether or not ctf_metadata_decoder_append_content()
    invokes the AST visitor to generate trace class objects.

    Trace classes are not needed, for example, for the `metadata-info`
    query.

`keep_plain_text`:
    Controls whether or not the decoder accumulates the metadata
    stream's plain text when you call
    ctf_metadata_decoder_append_content().

    This needs to be true to use ctf_metadata_decoder_get_text().

The goal of all this is to eventually add new metadata property getters
which do not need to create trace classes or to keep the metadata plain
text.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If1095da91aee0f446d7f5efcec765e5abbb2b30a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1842
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoAdd bt_common_append_file_content_to_g_string()
Philippe Proulx [Tue, 9 Jul 2019 23:40:59 +0000 (19:40 -0400)] 
Add bt_common_append_file_content_to_g_string()

This new function appends the content of a file (`FILE *`) to a
`GString *` object.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8552873d0c26baafe994e0294c3609f2a221c6e0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1841
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
5 years agoctf: use create + append/insert functions when possible
Simon Marchi [Thu, 29 Aug 2019 03:22:04 +0000 (23:22 -0400)] 
ctf: use create + append/insert functions when possible

Make the query code use the container value functions that create a new
empty map/array and append it to the container at the same time.  It
requires less lines of code, but also makes ownership management easier:
from the start the created container is owned by the parent container.
So there is no need to track it and free it on failure.

Change-Id: Ie0e81c67f50c721ef62e159f6f1d28380078ca86
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1995
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agoctf: remove ctf_fs_trace::name
Simon Marchi [Wed, 28 Aug 2019 18:30:57 +0000 (14:30 -0400)] 
ctf: remove ctf_fs_trace::name

Now that we don't report the name of CTF traces in
`babeltrace.trace-info`, it is no longer useful to invent a name for
each trace.  So remove the ctf_fs_trace::name field, and everything
related to it.

Note that the name set on the bt_trace (in set_trace_name) does not
depend on this field.

Change-Id: Ia1d3e917e7b1c553c0da0c8365cda9ec600c854b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1991
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
5 years agocli: remove unused path variable in set_stream_intersections
Simon Marchi [Wed, 28 Aug 2019 20:41:54 +0000 (16:41 -0400)] 
cli: remove unused path variable in set_stream_intersections

The `path` variable is used in the error message, but never set, so it
will always appear as "(unknown)".

In the future, it would be nice if the error message gave more info to
the user.  But right now, it is pointless to keep `path` there, so
remove it.

Change-Id: If55d8246dde8cffe1b584477643f105acaaa4792
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1992
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
This page took 0.05212 seconds and 4 git commands to generate.