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>
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.
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.
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.
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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 [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 [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>
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:
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>
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 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 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.
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 [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 [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>
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>
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>
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 [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 [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.
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 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 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>
Philippe Proulx [Fri, 16 Aug 2019 03:04:06 +0000 (23:04 -0400)]
cli: make --plugin-path and --omit-{system,home}-plugin-path global opts
This patch makes the `--plugin-path`, `--omit-system-plugin-path`, and
`--omit-home-plugin-path` options global options, in that you must
specify them before the command's name.
This change exists because those three options were handled by all five
commands anyway, so there was a lot of code redundancy.
Tests are adapted accordingly. Everything about those three options in
`test_convert_args` is removed as they will never be part of the
`--run-args` output now.