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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Simon Marchi [Wed, 28 Aug 2019 17:44:20 +0000 (13:44 -0400)]
ctf: remove unused fields from `babeltrace.trace-info` query
The response of the src.ctf.fs component class to the
`babeltrace.trace-info` query object contains a few fields that are not
used at the moment. Remove them, before somebody uses them, making us
stuck with them for eternity.
The removed fields are:
- stream class ids
- stream ids
- stream paths
- trace path
- trace range-ns
- trace name
The field `intersection-range-ns` will be removed in a separate patch.
Change-Id: Iee673acbb766cd951e758b5186eabb6fc058b442
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1990
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Simon Marchi [Tue, 27 Aug 2019 05:00:24 +0000 (01:00 -0400)]
tests: fix 'expected 2 blank lines, found 1' warning in utils.py
This is not very important, but I'm fixing warnings anyway. Black
is fine with this change (it doesn't revert it).
Change-Id: I8e8cf58407d6309756c193d29d3447e9b16df63c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1982
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 27 Aug 2019 04:58:32 +0000 (00:58 -0400)]
bt2: add missing bt2 import in interrupter.py
Fix this:
./src/bindings/python/bt2/bt2/interrupter.py:34:19: F821 undefined name 'bt2'
Change-Id: I84d39d8ced0d75c3a1d9218a43c701f9f653d247
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1981
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 27 Aug 2019 04:57:30 +0000 (00:57 -0400)]
python: fix all "do not use bare 'except'" warnings
I wasn't sure why that mattered, but I found this explanation pretty
good:
https://help.semmle.com/wiki/pages/viewpage.action?pageId=
29394005
In short, we don't want to catch KeyboardInterrupt and SystemExit.
Change-Id: I0ee20f45ac715a0477c867960cfaea511518171f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1980
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 27 Aug 2019 04:54:49 +0000 (00:54 -0400)]
python: fix all 'imported but unused' warnings
Fix all instances of this warning (code F401) found in the repo by
flake8.
Change-Id: I49dc56715d7f23a8779b7bcaf819ee2c90523a6f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1979
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 27 Aug 2019 04:50:06 +0000 (00:50 -0400)]
python: fix all 'is assigned to but never used' warnings
Fix all instances of this warning (code F841) found in the repo by
flake8. In one instance (in test_plugin.py), I added an assertion to
use the variable. In all others, I considered the variable not useful
and removed it.
Change-Id: I95c282a610d0e3b8adf7cee40ce5229744e8ebc0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1978
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 26 Aug 2019 20:52:33 +0000 (16:52 -0400)]
autodisc: don't accept NULL values for `support-info` query `group` key
It is not necessary to support that, and it doesn't help much in
implementing component classes. To keep the support-info protocol a bit
simpler, let's make it mandatory that if you have a `group` key, it must
be a string.
Change-Id: I45aa0a6fb57727d73d9fea48fbebc04dc9c0d5f5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1977
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 26 Aug 2019 20:24:21 +0000 (16:24 -0400)]
autodisc: improve logging
Improve the logging in the support_info_query_all_sources function:
- Include the group after a successful query
- Include the group when announcing the winner
- Format messages according to our standard, "message: key=value, ...".
Change-Id: I9833ea63314cde912c1da56d6ed2483f34783f17
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1976
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Aug 2019 22:31:15 +0000 (18:31 -0400)]
bt2: make ComponentSpec take a component class object
... rather than a plugin and component class name. It can be a user
component class:
class MySource(bt2._UserSourceComponent, ...):
...
spec = bt2.ComponentSpec(MySource)
or a component class from a plugin:
cc = bt2.find_plugin('my_plugin').source_component_classes['cerfeuil']
spec = bt2.ComponentSpec(cc)
This is a bit more general compared to taking a plugin name and a
component class name, since it allows passing an component class that
does not come from a plugin. It also allows the user to use component
classes from plugins in non-standard locations, by looking up plugins
manually with bt2.find_plugins_in_path.
For convenience, there is a new static method
bt2.ComponentSpec.from_named_plugin_and_component_class that creates a
ComponentSpec from a plugin and component class names.
Change-Id: I39e3fec6bbc7e7a9ba375065c9318b61b1791e35
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1890
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Simon Marchi [Mon, 26 Aug 2019 20:26:33 +0000 (16:26 -0400)]
autodisc: cast when assigning to different enum type
Gets rid of these warnings with clang:
/home/smarchi/src/babeltrace/src/autodisc/autodisc.c:766:13: warning: implicit conversion from enumeration type 'auto_source_discovery_internal_status' (aka 'enum auto_source_discovery_internal_status') to different enumeration type 'auto_source_discovery_status' (aka 'enum auto_source_discovery_status') [-Wenum-conversion]
status = internal_status;
~ ^~~~~~~~~~~~~~~
/home/smarchi/src/babeltrace/src/autodisc/autodisc.c:778:13: warning: implicit conversion from enumeration type 'auto_source_discovery_internal_status' (aka 'enum auto_source_discovery_internal_status') to different enumeration type 'auto_source_discovery_status' (aka 'enum auto_source_discovery_status') [-Wenum-conversion]
status = internal_status;
~ ^~~~~~~~~~~~~~~
Change-Id: Id4cdaaf20da1789e604d346ff2c08239352eb381
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1975
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Simon Marchi [Tue, 20 Aug 2019 00:56:26 +0000 (20:56 -0400)]
autodisc: make it possible to interrupt auto source discovery
It is currently not possible to interrupt babeltrace2 while it is doing
auto source discovery. However, it can be a quite long process that the
user might want to interrupt using ctrl-C. This patch makes it possible
to do that.
An interrupter object is taken by the auto source discovery code and
passed all the way to support_info_query_all_sources. In the CLI, the
global `the_interrupter` object, which is set on sigint, is passed.
Because support_info_query_all_sources (and other internal functions)
can now return a few different values (success with a match, success
without a match, error and interrupted), I changed it to return an enum
type. The entry point of auto source discovery,
auto_discover_source_components, can now return "interrupted" as well.
However, since that function doesn't return "no match", I didn't want to
make it use the same return type as support_info_query_all_sources. I
therefore made an "internal" and public version of the status enum.
With this patch, there is no way to interrupt an auto source discovery
started from Python.
Change-Id: I0040c7fab1887c4e05decd0659fa8ff3c85a16a1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1972
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Simon Marchi [Tue, 20 Aug 2019 01:54:07 +0000 (21:54 -0400)]
Make bitfield.h C++-friendly
This patch changes bitfield.h to be usable in C++11.
It will probably never be compiled as C++ in the context of
babeltrace, but this is just to keep things sync'ed across projects.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ib0fa31ee08d0f691841f96676556d2aa9fcd2426
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1965
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 19 Aug 2019 14:46:55 +0000 (10:46 -0400)]
trimmer: make filter.utils.trimmer append error causes
Change-Id: I6e4f291a8194691faa78b9e497b7563ec32eb7eb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1967
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Sat, 17 Aug 2019 05:24:46 +0000 (01:24 -0400)]
bt2: make _create_event_message's parent parameter mandatory
The `parent` parameter of _create_event_message currently has the None
default value. However, None is never a valid value, as parent must
either be a Stream or a Packet. Having a None default value makes it
look like the parameter is optional, but is actually always required.
Therefore, remove the None default value from the parameter.
Change-Id: Id0f8d64006ca25281529fc6bb3b9912365799f44
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1962
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 13 Aug 2019 15:56:18 +0000 (11:56 -0400)]
ctf: make src.ctf.fs append error causes
This patch makes the src.ctf.fs plugin code append error causes whenever
an error status is returned.
A few new macros are added to comp-logging.h to support that.
Some functions are called both in component context and component class
context. When appending error causes, we need to call the
function/macro for the right context. My solution to this is to pass
both bt_self_component and bt_self_component_class pointers, but expect
only one of them to be set. The new macro
BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE takes care of calling the right
function for whichever is set.
Change-Id: I8d54f463d9a13066abdc140ef41f374e4daed303
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1966
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Sat, 17 Aug 2019 23:29:42 +0000 (19:29 -0400)]
Fix: cli: check return value of bt_value_array_append_string_element
Found by coverity.
Change-Id: I7830920e70457d8281f57f4447d81fe194399821
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1963
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 21 Aug 2019 23:47:32 +0000 (19:47 -0400)]
Fix: ctf: fix possible use-after-free in ctf_fs_component_create
The error path destroys the ctf_fs_component, but doesn't reset the
variable, so we return a pointer to free'd memory. We should be
returning NULL in the error case. Fix it by assigning to NULL after
destroying the ctf_fs_component.
Change-Id: Ib7afd03009dc646460f77fae331920307229220a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1973
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Sat, 17 Aug 2019 04:45:52 +0000 (00:45 -0400)]
Fix: cli: replace remaining log level `V` (verbose) -> `T` (trace)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0649be8f1121ee145163c026847f1117d965b728
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1958
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 23 Aug 2019 18:38:03 +0000 (11:38 -0700)]
Fix: sink.ctf.fs: dereference before NULL check
CID
1404550 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking tsdl suggests that it may be null,
but it has already been dereferenced on all paths leading to the
check.
Reported-by: Coverity - Dereference before null check (REVERSE_INULL)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I7566cbd74529e93587079d163bb1691e420f723f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1974
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Wed, 21 Aug 2019 17:09:32 +0000 (10:09 -0700)]
Fix: autodisc: possible use-after-free
Reported-by: scan-build: Memory error Use-after-free
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Icfb8a6640a096369d51ba1c04ce43d043af7af59
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1971
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 20 Aug 2019 03:33:12 +0000 (23:33 -0400)]
Fix: sink.utils.counter: possible NULL pointer dereference
If the null check at line 148 is true, the `counter` pointer might be
used will be used while being NULL by the
`destroy_private_counter_data()` function.
scan-build report:
Access to field 'msg_iter' results in a dereference of a null pointer
(loaded from variable 'counter')
Reported-by: scan-build - Logic error Dereference of null pointer
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I50bb981433ef3f5083613b36bbef54743cddb4c2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1970
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Francis Deslauriers [Tue, 20 Aug 2019 03:28:33 +0000 (23:28 -0400)]
sink.ctf.fs: cleanup: duplicated `:` in log statements
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id0cc8d4ee400e3615e4a3e231c56c5d7315f7605
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1969
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Francis Deslauriers [Tue, 20 Aug 2019 03:21:57 +0000 (23:21 -0400)]
Fix: sink.ctf.fs: possible use-after-free
Issue
=====
We might use of `trace` pointer after freeing it in the error path.
Solution
========
Move the `fclose()` call (and surroundings) before the `end` label as
the `fh` pointer is only initialized after the only possible `goto end`.
Reported-by: scan-build - Use of memory after it is freed
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8f346b45a76ce976019931f9c63c20dd18a88d86
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1968
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Sun, 18 Aug 2019 16:42:35 +0000 (12:42 -0400)]
lib: make g++ happy with plugin-dev.h macros
g++ doesn't like the syntax used for assigning structures in the plugin
macros:
/tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:599:3: error: expected primary-expression before ‘.’ token
.value._attr_name = _x, \
^
/tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:871:2: note: in expansion of macro ‘__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE’
__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD, _id, _comp_class_id, source, _x)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:1356:2: note: in expansion of macro ‘BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID’
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
can.cpp:829:1: note: in expansion of macro ‘BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD’
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(CANSource, can_iter_init);
^
Changing
.value._attr_name = _x
to
.value = { ._attr_name = _x }
makes it work. There are a few instances of this, I changed all I found.
Built-tested with gcc 7.4.0 and clang-9, and verified that a plugin compiled
with g++ 7.4.0 works.
Change-Id: I17cb4edf1082003dc0bb9d0fae906c391daf3da4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1964
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 16 Aug 2019 03:05:13 +0000 (23:05 -0400)]
bt2: don't show warning when query method raises a non-error exception
I noticed that when a Python query raised bt2.UnknownObject, we show
this warning:
W BT2-PY component_class_query@native_bt_component_class.i.h:802 Failed to call Python class's _bt_query_from_native() method: py-cls-addr=0x6190001090a0
In my opinion, a query returning "unknown object" is part of the normal
course of operation, and we should not show a warning. So, only show it
when the exception gets translated to a status < 0. Also, append an
error cause while at it in case of error.
Change-Id: I079f67b74df881ab000c6e223667ca72dcd52713
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1952
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Sat, 17 Aug 2019 00:02:33 +0000 (20:02 -0400)]
bt_common_parse_lttng_live_url(): don't accept `net://RDHOST/host/TGTHOST`
This patch makes the bt_common_parse_lttng_live_url() function not
accept LTTng live URLs with the form:
net[4]://RDHOST[:RDPORT]/host/TGTHOST
This was previously accepted for the session listing feature, but in
fact the `babeltrace` program (Babeltrace 1) only accepts this form:
net[4]://RDHOST[:RDPORT]
and the list of URLs that the `babeltrace2` program prints with the
first form is invalid.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I68a804c69ec557ed9cc77c9020afbbe2f79a7c43
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1961
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 16 Aug 2019 23:41:46 +0000 (19:41 -0400)]
src.ctf.lttng-live: return unsigned integers in `sessions` query object
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1a0f505ee17f5657395d358dfcaa09fdc8e2afa1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1960
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 16 Aug 2019 22:06:41 +0000 (18:06 -0400)]
Fix: pass `inputs` parameter to implicit `src.ctf.lttng-live`, not `url`
Since the `src.ctf.lttng-live` component class started to handle the
`babeltrace.support-info` query object, its component accepts the
`inputs` array parameter, not the `url` string parameter.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5d74a16c50ba16518a12be9064afd604c456e3fb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1959
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 15 Aug 2019 04:00:15 +0000 (00:00 -0400)]
cli: allow map values in --params arguments
This patch makes it possible to use map values in --params arguments.
For example:
--params 'a={hi="mlady",mapping={tete="epaule",genou="orteil"}}'
The chosen syntax uses curly braces to delimit the map. It uses an
equal sign between the key an value, to be consistent with the syntax of
the implicit map at the top-level of `--params` values.
Speaking of which: it's not done in this patch, but it should be
possible to make the new function a bit more generic and re-use it for
parsing the top-level dict of `--params` values.
Change-Id: I1400ff6a2cf6c9132a9c5dd731a462f43225146b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1936
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 15 Aug 2019 15:17:11 +0000 (11:17 -0400)]
tests: add tests for CLI params parsing
Add tests that checks various forms of valid parameters passed to the
CLI.
Change-Id: I81eb0ceefb6e4326fa001febbecfee5c66ad18c1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1943
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 15 Aug 2019 00:06:21 +0000 (20:06 -0400)]
cli: exit with error if a plugin fails to load
The CLI is currently permissive when plugins fails to load, it will
display an error but carry on. To make it easier for users to catch
configuration and programming problems, this patch changes that be
strict. If a plugin fails to load (for example, Python syntax error),
the CLI stops and the error is reported to the user.
If this ever becomes a problem (a user would like to carry on even
though some plugin fails to load), we can add a switch like
`--ignore-plugin-loading-error` to have a permissive mode.
Change-Id: Ic89d4e044ecdc34a6e169309479e17bb947ae637
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1937
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 14 Aug 2019 20:47:26 +0000 (16:47 -0400)]
cli: set log levels earlier
The problem this patch is aiming to solve is that the effective log
level is not set when executing bt_config_convert_from_args. For
example, bt_python_bindings_bt2_log_level is still NONE, only to be set
later. So if Python plugin fails to be imported during the auto source
discovery phase, nothing will be logged, making debugging quite
difficult. Any argument passed (top level --log-level, --debug or
--verbose) won't help because they will take effect later, when we call
set_auto_log_levels.
This patch moves the call to set_auto_log_levels earlier, as soon as we
know what the default log level will be. For all commands but
`convert`, it is after we are done parsing the top-level arguments. The
default log level will be the most verbose any --debug, --verbose or
--log-level argument passed.
With the `convert` command, it is possible to pass --debug and
--verbose, with the same effect as the top-level equivalents. So for
this command, we call set_auto_log_levels just after parsing its
arguments.
The --debug argument sets the log level to TRACE and the --verbose
argument sets it to INFO. If more than one of --debug, --verbose and
--log-level are specified, the most verbose level of all specified
arguments is chosen.
Note that the --log-level argument of the convert command is not the
same as the top-level's --log-level argument. The argument of the
convert command sets the --log-level of a specific component or
auto-source-discovery input.
The behavior of the environment variables LIBBABELTRACE2_INIT_LOG_LEVEL,
BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL and
BABELTRACE_PYTHON_BT2_LOG_LEVEL is kept. If they are specified, they
force the log level of the corresponding subsystem, overriding the
log level specified on the command line.
Change-Id: I9ac558737df4789fc8f5bd8d0240887b3b11b295
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1935
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 14 Aug 2019 17:49:51 +0000 (13:49 -0400)]
cli: return if bt_plugin_find_all_from_dir fails in load_dynamic_plugins
If the call to bt_plugin_find_all_from_dir in load_dynamic_plugins
returns an error (a negative status code), we currently continue
execution as if nothing happened.
This patch makes it so that we exit the loop and report the error to the
caller.
Change-Id: Ib22813b92fe06156cde1681c55651a294cd67909
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1934
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 15 Aug 2019 15:56:14 +0000 (11:56 -0400)]
Fix: lib: increment refcount of bt_value_null when copying it
Value copy functions must return a new reference. This is not done for
bt_value_null_copy, which causes refcount imbalance when a null value
gets copied. A bug caused by this can be triggered with:
$ git:(
3e3535450850) ✗ LIBBABELTRACE2_INIT_LOG_LEVEL=W ~/build/babeltrace/src/cli/babeltrace2 -c src.ctf.fs --params='yo=null,madame=null,la=null'
...
08-15 11:58:25.070 2757 2757 W LIB/VALUE bt_value_null_instance_release_func@value.c:72 Releasing the null value singleton: addr=0x7f070e1fc8e0
08-15 11:58:25.070 2757 2757 F LIB/VALUE bt_object_put_ref@object.h:367 Babeltrace 2 library precondition not satisfied; error is:
08-15 11:58:25.070 2757 2757 F LIB/VALUE bt_object_put_ref@object.h:367 Decrementing a reference count set to 0: addr=0x7f070e1fc8e0, ref-count=0
08-15 11:58:25.070 2757 2757 F LIB/VALUE bt_object_put_ref@object.h:367 Aborting...
Change-Id: I338e6700201892cbe582719bf349041f316d78d8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1942
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 15 Aug 2019 15:24:24 +0000 (11:24 -0400)]
Fix: cli: increment bt_value_null ref count when returning null value
The ini_parse_value function returns a new reference to a value.
When return a null value, it needs to acquire a new reference to
bt_value_null to account for that.
A crash can be triggered because of this bug with:
$ LIBBABELTRACE2_INIT_LOG_LEVEL=W ~/build/babeltrace/src/cli/babeltrace2 -c src.ctf.fs --params='yo=null,madame=null,la=null'
08-15 11:27:23.947 8793 8793 W LIB/VALUE bt_value_null_instance_release_func@value.c:72 Releasing the null value singleton: addr=0x7fb46d3038e0
08-15 11:27:23.947 8793 8793 F LIB/VALUE bt_object_put_ref@object.h:367 Babeltrace 2 library precondition not satisfied; error is:
08-15 11:27:23.947 8793 8793 F LIB/VALUE bt_object_put_ref@object.h:367 Decrementing a reference count set to 0: addr=0x7fb46d3038e0, ref-count=0
08-15 11:27:23.947 8793 8793 F LIB/VALUE bt_object_put_ref@object.h:367 Aborting...
Change-Id: I6748fd9d8a7ba89728f0e4ddb9ea62bf423fdc91
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1941
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 16 Aug 2019 18:24:27 +0000 (14:24 -0400)]
Fix: field-class.c: dereference before `NULL` check
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaf80ac22f38e3a9dc5d09a69ac5729ece7cdd2f3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1957
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 16 Aug 2019 15:43:58 +0000 (11:43 -0400)]
Tests: ctf: add basic `metadata-info` query test
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1dcd08a024581a078c163cb09a3372bf2a7ce35f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1955
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Fri, 16 Aug 2019 15:43:00 +0000 (11:43 -0400)]
bt2: add `StringValue.__contains__()` method
This is useful to use the `in` Python operator like we do with regular
Python `str` objects:
if 'my_env_var' in env_string_value:
...
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8f7f5c02d71bc089e14c3b8f2ffa81045a9e8f15
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1954
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 16 Aug 2019 16:30:01 +0000 (12:30 -0400)]
cli: "Babeltrace configuration" -> "Babeltrace CLI configuration"
Make it clear that it's the configuration of the CLI program.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I972a8555f3f0bd8e7f97191a241df50d75349251
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1956
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 16 Aug 2019 03:24:12 +0000 (23:24 -0400)]
cli: `convert` command: do not allow more than one sink component
It's a nonsense to allow more than one component sink because, starting
from the muxer's single output port, there's a chain of components until
it reaches a sink. We don't have any tee filter, so we can't have more
than one sink: the second one won't get connected.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibec54ae29b64bb0fb8637f1b37131f05abc53b77
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1953
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
This page took 0.049158 seconds and 4 git commands to generate.