Philippe Proulx [Wed, 14 Aug 2019 00:08:57 +0000 (20:08 -0400)]
bt2: rename `_Field.field_class` -> `_Field.cls`
This makes it match what we have for the class of an event object, the
class of a stream object, and the class of a trace object (`cls`
properties).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5dd6f837a7f79b05ca933cd30bd281da2fbe5728
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1919
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 23:35:12 +0000 (19:35 -0400)]
bt2: add bit array field class and field support
This patch adds bit array field class and field support to the Python
bindings.
A bit array field class has a `length` property (number of bits in the
array).
As of this patch, a bit array field is not a Python sequence. It could
become in the future however. The way to access a bit array field's
value is the `value_as_integer` property which simply wraps the
corresponding library functions.
A bit array field is not considered a numeric field. Its _spec_eq()
method only compares if the other object is also a bit array fields.
I did not implement the __bool__() operator because it will need to
satisfy the Python sequence protocol (length is not 0, which in fact is
always the case with a bit array field), should we decide as such in the
future. I implemented the __len__() operator however which is
straightforward.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2e90e1444151bf5169a8df70c53664096cceb6c4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1918
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 13 Aug 2019 23:09:25 +0000 (19:09 -0400)]
sink.ctf.fs: write bit array field classes and fields
This patch makes a `sink.ctf.fs` component handle bit array field classes
and fields. Because CTF 1.8 has no bit array field class type, it makes a
best effort and translates it to an unsigned integer field class with
a hexadecimal base.
When a `src.ctf.fs` component reads a trace generated by `sink.ctf.fs`
where the input trace IR contained bit array field classes, the
corresponding unsigned integer field classes will stay unsigned integer
field classes; the source component has no way to determine if the
metadata describes a bit array field class or a genuine unsigned integer
field class. However, the CTF 1.8 to CTF 1.8 scenario will always be
unambiguous because a `src.ctf.fs` component never creates bit array
field classes.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6375723d8513b06f984dc27f88d3d9b668191d21
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1911
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 22:57:41 +0000 (18:57 -0400)]
sink.text.details: print bit array field classes and fields
The component prints bit array fields as unsigned integer fields with a
forced hexadecimal base.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If97e1f05161377c6f8fa3d56e87ad2cc10cb32e2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1910
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 22:49:14 +0000 (18:49 -0400)]
sink.text.pretty: print bit array fields
The compoent prints bit array fields as an unsigned integer (hexadecimal
base).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I89b9cadb4b8f0d87d3d547450232321010852e98
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1909
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 22:43:18 +0000 (18:43 -0400)]
flt.lttng-utils.debug-info: copy bit array field class and field objects
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iffb2083c21e57229e506577ab214cf6d8fc2da46
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1908
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 21:34:02 +0000 (17:34 -0400)]
lib: add bit array field class and field types
This patch adds the bit array field class (FC) and field to the
available library types.
A bit array field is a simple array of bits. As opposed to integer
fields, a bit array field has no sign: it does not contain a quantity.
Such a field can be used to hold CPU register values, for example, or an
array of flags which is typically read and written as a (small) unsigned
integer.
CTF 2 will very likely have such a type, so Babeltrace 2.0 will be
ready.
You create a bit array FC with bt_field_class_bit_array_create(). This
function expects a length parameter which must be in the [1, 64] range
as of this version. The length is the number of bits in the array. You
can get the length of a bit array with
bt_field_class_bit_array_get_length().
You can set the value of a bit array field with
bt_field_bit_array_set_value_as_integer(). This function accepts an
unsigned integer and conceptually sets all the bits of the array
accordingly, where the _first_ bit of the array is the LSB of the value.
In other words, should there be a bit accessor (by index), getting the
value of bit 0 would return the LSB of that unsigned integer:
0 1 1 0 1 1 0 1
^ MSB: bit 7 ^ LSB: bit 0
Unsigned integer value: 0x6d
As such, you can get the value of the bit array with
bt_field_bit_array_get_value_as_integer(). Again, the value of bit 0 is
the LSB of the returned unsigned integer.
I chose to apply a mask to the received value in
bt_field_bit_array_set_value_as_integer() to ensure that there's no set
bit outside the bit array's range. This is to lessen the user's burden
instead of a having a precondition assertion. This in turns guarantees
that bt_field_bit_array_get_value_as_integer() always returns a value
without superfluous set bit. If this automatic masking becomes a
performance issue in the future, then we can add another function which
expects the user to do it (with a precondition assertion).
This patch does not adapt existing plugins and the Python bindings to
use and wrap the new bit array FC and field; this work is reserved for
subsequent patches.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8ba4d111df275962cfa9f2c4f754f83a1de40e29
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1907
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Tue, 13 Aug 2019 15:58:10 +0000 (11:58 -0400)]
bt2: add option field class and field support
This patch adds option field class and field support to the Python
bindings.
You can create an option field class with
_TraceClass.create_option_field_class(). This method requires the
optional field class and also accepts an optional selector field class
(just like the library's equivalent bt_field_class_option_create()
function).
An option field class only has the `field_class` (the optional field
class) and `selector_field_path` (can be `None`) properties.
An option field is similar to a variant field:
* You can use the `has_field` property to set whether or not the option
field has an optional field.
* You can access the optional field with the `field` property, which
returns `None` when the option field has no field.
* The __bool__() operator of an option field is the equivalent of the
`has_field` property.
* You can use the `value` property (write only, like
`_VariantField.value`) to assign a value to the optional field. This
property also sets `has_field` to `True` so it's always safe to use.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I90aa9ef2dbcb7422ee25aaeb191a18fd9fa4998b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1902
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 13 Aug 2019 00:16:09 +0000 (20:16 -0400)]
sink.ctf.fs: write option field classes and fields
This patch makes a `sink.ctf.fs` component handle option field classes
and fields. Because CTF 1.8 has no option field class type, it makes a
best effort and translates it to a variant field class with two
options:
* An empty structure field class (option field contains nothing).
* The optional field class itself.
The tag field class is always generated before the variant field class
and is an 8-bit unsigned enumeration field class.
For example, a `sink.ctf.fs` component would translate an optional
string field class to:
/*
* This enumeration field class and the following variant field
* class were a trace IR option field class.
*/
enum : integer { size = 8; align = 8; } {
none = 0,
content = 1,
} __module_name_tag;
variant <__module_name_tag> {
struct { } none;
string { encoding = UTF8; } content;
} module_name;
When a `src.ctf.fs` component reads a trace generated by `sink.ctf.fs`
where the input trace IR contained option field classes, the
corresponding variant field classes will stay variant field classes; the
source component has no way to determine if the metadata describes an
option field class or a genuine variant field class. However, the CTF
1.8 to CTF 1.8 scenario will always be unambiguous because a
`src.ctf.fs` component never creates option field classes.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib83e011f73795d70cd8545f55ea87e0bf10b68bc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1901
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Wed, 14 Aug 2019 00:15:01 +0000 (20:15 -0400)]
sink.text.details: use write_none_prop_value() for empty array fields
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6d6eb3575f0fa4f77096d1def57d46b5e5c40b48
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1917
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 22:25:17 +0000 (18:25 -0400)]
sink.text.details: print option field classes and fields
The component prints `None` when there's no current optional field.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaa0634ce6806508fa8b07fc70e0e021af9363b8d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1900
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 22:15:04 +0000 (18:15 -0400)]
sink.text.pretty: print option fields
The component prints `<none>` when there's no current optional field,
and does the same as a variant field otherwise (printing the optional
field's value between `{` and `}`).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I7a42ca31d68562fa0994945b32dbb2935aa92ee4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1899
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 22:11:31 +0000 (18:11 -0400)]
flt.lttng-utils.debug-info: copy option field class and field objects
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3451d3071655b4759c365adf9ff9c0ddd53425ba
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1898
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 21:09:38 +0000 (17:09 -0400)]
lib: add option field class and field types
This patch adds the option field class (FC) and field to the available
library types.
An option field can contain or not another field. It is very similar to
a variant field in that it's a choice between two things.
CTF 2 will very likely have such a type, so Babeltrace 2.0 will be
ready.
Like a variant FC, an option FC can have a selector which must be a
reachable boolean FC.
When you create an option with bt_field_class_option_create(), you pass
the optional FC, which becomes frozen on success.
You can borrow the optional FC of an option FC with
bt_field_class_option_borrow_field_class_const(). If the option FC has a
selector FC, you can borrow the computed selector field path with
bt_field_class_option_borrow_selector_field_path_const().
To set whether or not an option field contains a field, call
bt_field_option_set_has_field(). You must call this function even if the
option field contains no field (with `BT_FALSE`) because field objects
are pooled and not reset for each message in production mode (similar to
how you must initially call bt_field_string_clear() before you call
bt_field_string_append()). Once you have called
bt_field_option_set_has_field() with `BT_TRUE`, you can borrow the
optional field with bt_field_option_borrow_field() to fill it.
On the const side, you can borrow an option field's optional field with
bt_field_option_borrow_field_const(). This function returns `NULL` if
the option field does not contain a field.
This patch also adds the
`BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT` field path item type.
Such a field path item means the current field of an option field.
This patch does not adapt existing plugins and the Python bindings to
use and wrap the new option FC and field; this work is reserved
for subsequent patches.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie76312a53affe8343dd058bd4c38cd9a6074c4d7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1897
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 12 Aug 2019 02:04:08 +0000 (22:04 -0400)]
bt2: add boolean field class and field support
This patch adds boolean field class and field support to the Python
bindings.
A boolean field class has no properties.
A boolean field is a numeric field (like Python's `bool` is a numeric
type). The `BoolFieldTestCase` test case inherits `_TestNumericField`,
making sure the field behaves more or less like the Python `bool` type.
`BoolFieldTestCase` is very similar to `BoolValueTestCase`.
Just like `BoolValue` objects, you can set the value of a `BoolField`
object from a `bool` or `BoolField` object.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib6d0723d69709b7f3b459ba173eb7cbea5d8c435
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1896
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 16:03:55 +0000 (12:03 -0400)]
sink.ctf.fs: write boolean field classes and fields
This patch makes a `sink.ctf.fs` component handle boolean field classes
and fields. Because CTF 1.8 has no boolean field class type, it makes a
best effort and translates it to an 8-bit unsigned integer field class.
A boolean field is written as an 8-bit unsigned integer field having the
value 0 (false) or 1 (true).
When a `src.ctf.fs` component reads a trace generated by `sink.ctf.fs`
where the input trace IR contained boolean field classes, the 8-bit
unsigned integer field classes will stay integer field classes; the
source component has no way to determine if the metadata describes a
boolean field class or a genuine integer field class. However, the CTF
1.8 to CTF 1.8 scenario will always be unambiguous because a
`src.ctf.fs` component never creates boolean field classes.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6be5967c2312bdb0e67be7db14ab663912872403
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1895
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 15:50:05 +0000 (11:50 -0400)]
sink.text.details: print boolean field classes and fields
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4f533f5682928d667fb26553bf9ca659135df0d3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1894
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 15:42:52 +0000 (11:42 -0400)]
sink.text.pretty: print boolean fields
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I7fe169bbd23d87af117acff5f1697a7a326b7e2c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1893
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 15:31:38 +0000 (11:31 -0400)]
flt.lttng-utils.debug-info: copy boolean field class and field objects
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaa66e2fc34740d249f014a3a7ec18006e74a2472
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1892
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 15:20:14 +0000 (11:20 -0400)]
lib: add boolean field class and field types
This patch adds the boolean field class and field to the available
library types. They are analogous to the boolean value object which
already exists.
CTF 2 will very likely have such a type, so Babeltrace 2.0 will be
ready.
This patch does not adapt existing plugins and the Python bindings to
use and wrap the new boolean field class and field; this work is
reserved for subsequent patches.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I90874f214757ad67d5eecaad5bd8297b8610c001
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1891
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Francis Deslauriers [Tue, 13 Aug 2019 16:47:10 +0000 (12:47 -0400)]
bt2: cleanup: Remove unused `_StreamClass` id setter
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iabd929f239e54e81e8424d366e7bc7689b342c2a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1904
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Tue, 13 Aug 2019 16:23:59 +0000 (12:23 -0400)]
bt2: cleanup: Remove unused `_StreamClassIterator` class
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I527c35015f5fb75dbcb55850932e0e0950d3b0ea
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1903
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 13 Aug 2019 19:30:15 +0000 (15:30 -0400)]
tests: return 0 instead of None for unknown file in test component class support-info query
I noticed some spurious warnings while running
TestAutoDiscoverSourceComponentSpecsGrouping.test_grouping (shortened
for brevity):
unexpected result type: component-class-name=source.test.TestSourceExt, input=/home/smarchi/src/babeltrace/tests/data/auto-source-discovery/grouping/bt_plugin_test.py, input-type=file, expected-types=REAL,MAP,SIGNED_INTEGER, actual-type=NULL
Indeed, the _query method of TestSourceExt fails to return a value (so
it returns None) if it doesn't know the file. This is not on purpose in
this test, so fix it.
Change-Id: I303c78dae4a518c62573263aa7a3afafd0c61ed7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1906
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Jonathan Rajotte [Tue, 13 Aug 2019 22:34:20 +0000 (18:34 -0400)]
bt_uuid_compare: return actual comparison
Previous implementation resulted in non-equal uuid_a being flagged as
smaller than uuid_b even when it was actually bigger.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I00dfe935f21514d78bd586bb52729c5e147c8a36
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1912
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jonathan Rajotte [Tue, 13 Aug 2019 18:20:34 +0000 (14:20 -0400)]
sink.ctf.fs: isa_length is now architecture_bit_width
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I30cac20017f7508ed170b936a7b90ebc2916b913
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1905
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Jonathan Rajotte [Tue, 13 Aug 2019 22:50:09 +0000 (18:50 -0400)]
src.ctf.lttng-live: consider youngest only when timestamp is smaller
When the timestamps are equals perform further comparison.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Id7567019177ab2e2d4ad1ab1e8840aa07f9ba471
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1913
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jonathan Rajotte [Tue, 13 Aug 2019 22:51:32 +0000 (18:51 -0400)]
Use uuid as first comparison criteria
This is most important in the message ordering reproducibility against
multiple sources where some might populate the trace name and some don't.
A good example of a source not populating the trace name is lttng-live.
It facilitates the testing of lttng-live source plugin since it is
possible to compare it to the src.ctf.fs plugin directly.
Philippe adds: there's a trace UUID property in a CTF metadata stream,
but no trace name property. The trace name is entirely up to the
specific CTF source component class. Therefore it's safer to use the
UUID to distinguish unique traces.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I39f3c513e27bffd51ca02b089c097ac406e3316e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1914
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Mon, 12 Aug 2019 22:07:09 +0000 (18:07 -0400)]
src.ctf.lttng-live: cleanup: rename functions and variables
Use term "youngest" whenever possible to signify our current best
candidate.
Rename `lttng_live_iterator_next_on_stream()` ->
`lttng_live_iterator_next_msg_on_stream()` to signify that it's
returning a message.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I7dcfccda30c87662209ac87e3bcda31699d3ea44
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1889
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Mon, 12 Aug 2019 21:35:01 +0000 (17:35 -0400)]
Fix: src.ctf.lttng-live: missing ordering within traces and streams
Issue
=====
Sorting of messages with the same timestamps are different from the
messages sorted by the a `flt.utils.muxer` component. This is caused by
the fact that we are not sorting messages within sessions and traces
but only across the different session currently handled by the
component.
Indeed, we need to sort messages at across three locations in the code
to ensure proper ordering: sessions, traces, and streams.
Solution
========
Handle messages with the same timestamps at each of these three
locations using the `common_muxing_compare_messages()` function.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iadc66f3b6a12f34522f6364b3f47f15eefa87930
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1888
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 12 Aug 2019 03:01:00 +0000 (23:01 -0400)]
bt2: `TraceCollectionMessageIterator`: find greatest MIP version
This patch makes the `TraceCollectionMessageIterator` object use
bt2.get_greatest_operative_mip_version() to find the greatest operative
MIP version of all the components to create, including the stream
intersection `flt.utils.trimmer` components, and then use the result to
create the graph with bt2.Graph().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id9024a2343d0e99384ae62bd77754912a4267dac
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1881
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 06:36:41 +0000 (02:36 -0400)]
cli: find greatest operative MIP version to create `run` command's graph
This patch makes the CLI's `run` command use
bt_get_greatest_operative_mip_version() to find the greatest operative
MIP version of all the components to create, including the stream
intersection `flt.utils.trimmer` components, and then use the result to
create the graph with bt_graph_create().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2e791ac9c8806457fa850d0dad72ea3ab6912f08
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1879
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 03:24:13 +0000 (23:24 -0400)]
lib: bt_graph_create(): accept MIP version
This patch makes bt_graph_create() accept the message interchange
protocol (MIP) version with which to configure the graph.
This MIP version will usually come from
bt_get_greatest_operative_mip_version() or bt_get_maximal_mip_version().
The components can access the configured MIP version with
bt_self_component_get_graph_mip_version().
As of this patch the only possible MIP version is 0. bt_graph_create()
does not accept a MIP version that is greater than
bt_get_maximal_mip_version() because almost all the library functions
need to know the configured MIP version to behave accordingly, should
the semantics change in the future.
In Python, Graph.__init__() accepts a `mip_version` parameter which
defaults to 0. A Python component can get the configured MIP version of
its operating graph with the `_UserComponent._graph_mip_version`
property.
All the sites where bt_graph_create() is called pass 0 to it. This is
correct for tests as we always control the component classes and
initialization parameters, so we know that 0 is always supported by
them. The locations where bt_get_greatest_operative_mip_version() must
be used are the CLI and `bt2.TraceCollectionMessageIterator`. Those
sites will be addressed by subsequent patches.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I324a317922a8caa5557043ae02b97e58fc91d92d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1878
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 11 Aug 2019 02:38:39 +0000 (22:38 -0400)]
bt2: add bt2.get_{greatest_operative,maximal}_mip_version()
Those new functions wrap bt_get_greatest_operative_mip_version() and
bt_get_maximal_mip_version().
bt2.get_greatest_operative_mip_version() excepts a list of
`bt2.ComponentDescriptor` objects. The function builds a component
descriptor set (bt_component_descriptor_set_create()) and adds the
corresponding component descriptors to it and then calls
bt_get_greatest_operative_mip_version().
bt_get_greatest_operative_mip_version() translates
`BT_GET_OPERATIVE_MIP_VERSION_STATUS_NO_MATCH` into `None`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaeb36b976f3c651fa82a86de2e835f782d682299
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1877
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 21:19:46 +0000 (17:19 -0400)]
bt2: add "get supported MIP versions" method support
This patch makes the `bt2` package wrap the library's "get supported MIP
versions" component class method.
In a Python component class, it is expected that the optional
_user_get_supported_mip_versions() method returns either a
`bt2.UnsignedIntegerRangeSet` object or what such an object needs to be
constructed. In other words, the method can return, for example:
return [0, 1, (3, 5)]
Like in the library, the default _user_get_supported_mip_versions()
returns 0 (only protocol 0 supported):
def _user_get_supported_mip_versions(cls, params, obj, log_level):
return [0]
_bt_get_supported_mip_versions_from_native() returns a new reference on
this unsigned integer range set. Then, the native
component_class_get_supported_mip_versions() copies the ranges from the
returned range set to the range set to fill. I believe this makes
_user_get_supported_mip_versions() easier to use than receiving a range
set object and filling it like it's done in C.
The feature is not tested in this patch because the "get supported MIP
versions" method is not used within the library.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9e0c6f0fcac23d2224401c1fb1c258f061642767
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1875
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sat, 10 Aug 2019 19:46:37 +0000 (15:46 -0400)]
bt2: _IntegerRangeSet.add(): make it possible to add a single value
This patch makes it possible to do:
my_range_set.add(23)
which is the equivalent of:
my_range_set.add((23, 23))
It also makes it possible to do:
bt2.SignedIntegerRangeSet(-17)
bt2.UnsignedIntegerRangeSet(17)
which is the equivalent of:
bt2.SignedIntegerRangeSet(-17, -17)
bt2.UnsignedIntegerRangeSet(17, 17)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I44bf1a257422fb9e74835a300eeda948a8e5d067
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1874
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 18:53:32 +0000 (14:53 -0400)]
bt2: add `ComponentDescriptor` class and test
The goal of a `ComponentDescriptor` object is to eventually be used
within an array of descriptors passed to a function which computes an
effective message interchange protocol version with the help of version
support component class methods.
I choose not to wrap the `bt_component_descriptor_set` API as this is
so simple and will be used at a single location.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifef9b4fb0a7cf0278dbf8bed2d18d0b47934a272
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1873
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 22:40:50 +0000 (18:40 -0400)]
lib: add bt_get_{greatest_operative,maximal}_mip_version() functions
This patch adds the bt_get_greatest_operative_mip_version() and
bt_get_maximal_mip_version() functions.
The bt_get_greatest_operative_mip_version() accepts a set of component
descriptors and returns, on success, the (greatest) operative message
interchange protocol (MIP) version for all those descriptors.
bt_get_greatest_operative_mip_version() can fail if any component class's "get
supported MIP versions" fails. It can also return
`BT_GET_OPERATIVE_MIP_VERSION_STATUS_NO_MATCH` if any component
descriptor does not support MIP version 0, the only MIP version
currently supported by the the library.
bt_get_maximal_mip_version() returns the maximal MIP version supported
by the library (currently 0).
The purpose of both functions is to be used eventually to create a graph
of which all the components and the library itself operate using a
specific MIP. You can use bt_get_greatest_operative_mip_version() to find the
greatest compatible MIP version to be used by that set of component
descriptors, or you can use bt_get_maximal_mip_version() to get the
greatest MIP version possible for that library.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If3875b3d76ddca2b4d58a18a829394eadb3bcd39
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1872
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 22:27:55 +0000 (18:27 -0400)]
Fix: {graph,query-executor}.h: missing `STATUS_` before `MEMORY_ERROR`
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I24307beb9896b754f13c0d887ef3ed03ee6596b2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1871
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 19:18:17 +0000 (15:18 -0400)]
lib: add "get supported MIP versions" method support
This patch adds a new optional method to component classes: get
supported message interchange protocol (MIP) versions.
As of this patch, you can set the "get supported MIP versions" method of
a component class, but it's not used.
The "message interchange protocol" term is very long so I chose to use
the acronym "mip" in the API. The API documentation will make this more
clear.
The method is considered a "class method"; no component exists yet when
calling it (like the query method). The method receives the component
class, the initialization parameters, the initalization method custom
data, and an existing, empty unsigned integer range set. The method's
purpose is to fill this integer range set with all the MIP versions it
supports depending on the initialization configuration. This makes it
possible to support specific MIP versions based on an input path or URI,
for example.
It is a postcondition that the method adds at least one MIP version to
the unsigned integer range set.
The "get supported MIP versions" method is optional: not implementing it
corresponds to adding [0, 0] to the unsigned integer range set. This
makes it possible to implement a component class of which the instance
operates according to the MIP protocol of Babeltrace 2.0.
The "get supported MIP versions" method can fail, but it cannot return
a "try again" status.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib26ec9e90b47a3d3e51cc56465a264de9d02b97c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1870
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 18:56:34 +0000 (14:56 -0400)]
lib: graph.c: add missing `enum` and `const` keywords
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I87eb15507f671073d3bea4d2dbb0d8dea2a63f85
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1869
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 10 Aug 2019 18:52:21 +0000 (14:52 -0400)]
lib: add component descriptor set API
This patch adds an API to the library to create an empty set of
component descriptors and to add descriptors to it.
A component descriptor contains:
* A component class.
* Component initialization parameters.
* Component initialization custom data.
The motivation is to eventually be able to get an effective/compatible
message interchange protocol version number from such a set.
As of this patch, the API is available, but it's not used anywhere.
A component descriptor set is a shared object.
You add a component descriptor to a component descriptor set with
bt_component_descriptor_set_add_descriptor(). Internally, the descriptor
gets appended to one of the source, filter, or sink descriptor array to
eventually have bt_component_descriptor_get_*_descriptor_count() and
bt_component_descriptor_set_borrow_*_descriptor_by_index_const()
functions if needed.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I337d4c596bd988b20849700daf9747a3f188450d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1868
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Mon, 12 Aug 2019 19:46:05 +0000 (15:46 -0400)]
bt2: py_plugin.py: cache `_PluginInfo` objects
This patch makes _try_load_plugin_module() cache the `_PluginInfo`
objects it creates. The cache, `_plugin_infos`, maps a Python plugin
absolute path to a `_PluginInfo` object.
This avoids loading the Python module twice, which can create problems,
for example destroying component classes earlier than expected when the
new module replaces the old one in `sys.modules`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I55397a1d5e65de1f6495dccc23e1134bd1127631
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1887
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Aug 2019 18:59:13 +0000 (14:59 -0400)]
bt2: remove unused imports
I ran flake8 and removed unused import warnings in all files, except
__init__.py, where the imports are present but not used in that file on
purpose.
Change-Id: Ib422a25b042eb1ba0a68e5c254947b5cfe3b7398
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1886
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Aug 2019 18:37:58 +0000 (14:37 -0400)]
bt2: raise an exception if an AutoSourceComponentSpec produces no component
We don't do anything special at the moment if an AutoSourceComponentSpec
passed to TraceCollectionMessageIterator produces no component. The
created graph will have no source component and the message iterator
will produce no message:
In [5]: list(bt2.TraceCollectionMessageIterator('/yomadame'))
08-12 14:43:03.938 20284 20284 W CLI-CFG-SRC-AUTO-DISC auto_discover_source_components@autodisc.c:755 No trace was found based on input `/yomadame`.
Out[5]: []
This patch changes the behavior to be a bit more strict. If any
AutoSourceComponentSpec passed to TraceCollectionMessageIterator ends up
producing no component, an exception is raised. In the following example, the
directory `/home/smarchi/lttng-traces` does contain some valid traces, and
therefore produces some components, whereas the string `/yomadame` does not
produce any.
In [2]: bt2.TraceCollectionMessageIterator(['/home/smarchi/lttng-traces', '/yomadame'])
08-12 14:45:06.433 24428 24428 W CLI-CFG-SRC-AUTO-DISC auto_discover_source_components@autodisc.c:755 No trace was found based on input `/yomadame`.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-2-
107461e1b36b> in <module>
----> 1 bt2.TraceCollectionMessageIterator(['/home/smarchi/lttng-traces', '/yomadame'])
~/build/babeltrace/src/bindings/python/bt2/build/build_lib/bt2/trace_collection_message_iterator.py in __init__(self, source_component_specs, filter_component_specs, stream_intersection_mode, begin, end, plugin_set)
292 ]
293 self._src_comp_specs += _auto_discover_source_component_specs(
--> 294 auto_src_comp_specs, plugin_set
295 )
296
~/build/babeltrace/src/bindings/python/bt2/build/build_lib/bt2/trace_collection_message_iterator.py in _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set)
194
195 msg = 'Some auto source component specs did not produce any component: ' + ', '.join(unused_inputs)
--> 196 raise RuntimeError(msg)
197
198 return comp_specs
RuntimeError: Some auto source component specs did not produce any component: /yomadame
Change-Id: I6c6df9fad18915e294559948812a8213596affdf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1885
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Aug 2019 17:43:32 +0000 (13:43 -0400)]
tests: remove bt_diff_cli_sorted from utils.sh
This function is not used anymore.
Change-Id: Iebca03d9193a4da20bb7a4511345c39bf62d31b0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1884
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Aug 2019 16:25:59 +0000 (12:25 -0400)]
tests: use os.pathsep when appending to BABELTRACE_PLUGIN_PATH
On Windows, we expect BABELTRACE_PLUGIN_PATH entries to be separated
with ';', not ':' (like PATH). Python conveniently provides an
OS-dependent definition for this.
Change-Id: Ie53af04e933258963b8495c72e7607a623e83ddb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1883
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Aug 2019 16:13:58 +0000 (12:13 -0400)]
cli: mention path separator for Windows in comment
This function uses bt_common_append_plugin_path_dirs, which uses
G_SEARCHPATH_SEPARATOR to split up paths. G_SEARCHPATH_SEPARATOR is ';'
on Windows.
Change-Id: If2a88d5cd138d0e1ab186e1e33fda9bb3ceaec5a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1882
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Sun, 11 Aug 2019 15:33:40 +0000 (11:33 -0400)]
test_plugin.py: do not search in user/system directories for tests
In `test_plugin.py`, make bt2.find_plugin() not search in user and
system directories so that it needs to find the specific plugin in the
test's search path (given by `BABELTRACE_PLUGIN_PATH`) or fail.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9bad521d079ce602fa152d9e24ab6b145e8edce9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1880
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Sun, 11 Aug 2019 02:31:41 +0000 (22:31 -0400)]
Fix: bt2: replace bt2.CreationError instances with bt2._MemoryError
Commit
4acc866e8298 ("bt2: rename CreationError to MemoryError, handle it in and out of Python bindings")
removed bt2.CreationError in favor of bt2.MemoryError (now
bt2._MemoryError). However, some usages of bt2.CreationError were
introduced afterwards, probably by patches that were in the pipeline.
Replace them with bt2._MemoryError.
Change-Id: Id3cb6542e507b1e41c165ca61df21069d72fb44f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1867
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 5 Aug 2019 18:45:38 +0000 (14:45 -0400)]
bt2: add auto source discovery support to TraceCollectionMessageIterator
This patch makes TraceCollectionMessageIterator capable of automatically
detecting source components from given input strings, similar to how the
command line interface does.
A new type AutoSourceComponentSpec is introduced. The user can
instantiate this type, passing a mandatory input string (equivalent to a
non-option argument on the CLI). The user can then pass instances of
AutoSourceComponentSpec in the source_component_specs list when creating
a TraceCollectionMessageIterator. In
TraceCollectionMessageIterator.__init_, we run the automatic source
algorithm on all inputs passed through AutoSourceComponentSpec
objects. We create ComponentSpec from the results of the auto discovery
and append them to the source component spec list. The rest of the
TraceCollectionMessageIterator then works as before.
The user can attach params and log levels to AutoSourceComponentSpec
inputs. The semantic for those is the same as for the CLI. There is
also an `obj` parameter, allowing to pass an arbitrary Python object.
The semantic for this one is the same as the log level: if an
auto-discovered component comes from multiple inputs, it will receive
the obj of the last input that contributed to getting it instantiated
that has a non-None `obj`.
For convenience, some shorthands when creating a
TraceCollectionMessageIterator are equivalent to using an
AutoSourceComponentSpec. For example, these three forms are equivalent:
- TraceCollectionMessageIterator('foo')
- TraceCollectionMessageIterator(AutoSourceComponentSpec('foo'))
- TraceCollectionMessageIterator([AutoSourceComponentSpec('foo')])
Implementation details
----------------------
New test cases are added to test the new feature. They are based on
the corresponding CLI tests, in that they test equivalent scenarios
(same inputs, expecting the same results).
In order for TraceCollectionMessageIterator to find the test plugin
(both bt_plugin_test.py files), the only way I found was to amend
BABELTRACE_PLUGIN_PATH for the duration of the test.
Change-Id: I0e1100d850c920723861609cfa14707f8c669892
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1826
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 9 Aug 2019 21:57:56 +0000 (17:57 -0400)]
tests: move auto source discovery test artifacts
These test artifacts will soon be used to test the auto source discovery
feature in the Python bindings, so move them out of the `cli` directory.
Change-Id: Ia6763a42657c988442436e088fbf0e96de5baf49
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1865
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 5 Aug 2019 15:05:08 +0000 (11:05 -0400)]
Move autodisc to its own convenience library
Since we'll want to make TraceCollectionMessageIterator have an
automatic source discovery feature, like the CLI has, move the auto
discovery code to its own library, which doesn't have any dependency on
the CLI.
To avoid dependencies on the CLI, here are the changes done to the auto
discovery code:
- To avoid depending on cli_query, use a simplified version,
simple_query, included in the auto discovery code. It doesn't handle
retrying if the status is TRY_AGAIN, as it is not very likely that a
babeltrace2.support-info query implementation will need to do that, as
we want them to be very fast (we can always revisit it in the future).
- Avoid using BT_CLI_LOGE_APPEND_CAUSE, replace with the new
BT_AUTODISC_LOGE_AND_APPEND.
- Don't use require_loaded_plugins, get_loaded_plugins_count and
borrow_loaded_plugin, as those are CLI-specific. Instead, the caller of
auto_discover_source_components must provide an array of plugins.
- plugin_restrict, used to filter down to a single plugin by name, is
removed. Instead, it is the caller's responsibility to pass a single
plugin to `plugins` if it wants to restrict the search to a single
plugin.
A side effect of moving the code is that a warning is now printed by
default when no input is found from non-option argument. I think this
is desirable to have this warning printed, so I have opted to update the
test case to expect it.
Change-Id: Id4009976430126d926eac46ff044365a6b2bc006
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1825
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 9 Aug 2019 21:17:35 +0000 (17:17 -0400)]
tests: make auto-source-discovery-{log_level,params} tests use sink.text.details
For the same rationale as the previous patch, change how the test
component classes for test_auto_source_discovery_params and
test_auto_source_discovery_log_level report what they receive from a
print to stdout to stream name.
Change-Id: I62405ccd1fbdbe708fbec5dacc52894d4060dfb0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1864
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 9 Aug 2019 20:08:37 +0000 (16:08 -0400)]
tests: make auto-source-discovery-grouping test use sink.text.details
This patch changes the way that test component classes for the auto
source discovery grouping CLI test reports the inputs passed to each
instantiated component.
Currently, they print to stdout the input names
in the components' __init__. That is then check by the test script
(test_auto_source_discovery_grouping). The
TraceCollectionMessageIterator class in the Python bindings will soon
have the capability to automatically discover source components.
However, it's not practical to use the same test method in Python.
To facilitate this, make the test component classes report the inputs
they receive by sending a stream beginning message, where the stream
name contains the input names. The eventual Python test will be able to
inspect the stream name to validate that the right inputs were passed to
each component.
Since the information is now passed in messages, the
test_auto_source_discovery_grouping test now uses the details sink.
Change-Id: Ie5c12e390f5b68fb50a6d18c53463860fb7a1c99
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1863
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 8 Aug 2019 17:58:47 +0000 (13:58 -0400)]
tests: print executed CLI command line in bt_cli
When debugging a test, it is often useful to have the complete
CLI command line executed, so we can copy paste it and reproduce
the failure by hand.
This patch makes bt_cli echo the executed CLI command line to
stderr, such that it will show up when running one test by hand and in
the test logs when running "make check".
This allows simplifying bt_diff: we no longer have to pass the
CLI arguments to have them included in the error message, since
the full CLI command line will typically be printed just above.
Change-Id: I64f8c80f648d06319efe4e7544447183ba8069cc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1839
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 8 Aug 2019 15:50:46 +0000 (11:50 -0400)]
tests: make bt_diff check a single file pair
bt_diff currently accepts 4 file arguments:
- stdout expected
- stdout actual
- stderr expected
- stderr actual
To allow for more flexibility, change it to check a single pair. Tests
that need to check for both stdout and stderr will need to call it
twice.
Change-Id: I400d251e77931a3a457214fabdc59f4c56be7ce1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1838
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 8 Aug 2019 15:09:11 +0000 (11:09 -0400)]
tests: add bt_cli util function
Add a function that simply runs the CLI, redirecting stdout and
stderr to the specified files. This will allow more flexible tests than
the existing "diff" function.
Change-Id: I8319c4a74a0baa3b40afb871bfb0605ac81c3270
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1837
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Sat, 10 Aug 2019 18:48:23 +0000 (14:48 -0400)]
m4/pprint.m4: check that the terminal supports at least 8 colors
Checking for 8 colors is enough here and makes rudimentary terminals
have colors in the report.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icf49c3f24aa3546a81a52f4627b9f39ab88f929c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1866
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 9 Aug 2019 20:35:54 +0000 (16:35 -0400)]
Fix: flt.utils.muxer: Explicit null dereferenced
Fixes coverity #
1404006
ID
1404006 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
18. var_deref_op: Dereferencing null pointer *muxer_upstream_msg_iter
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I055200226ab13653b219a084f38a2dd9bb16664b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1859
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 9 Aug 2019 20:30:09 +0000 (16:30 -0400)]
Fix: muxer: check for MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE in validate_new_stream_clock_class
There is a problem currently when trying to send multiple streams that
don't have a clock class (which is a supported use case) to a muxer
instance.
The first time we enter validate_new_stream_clock_class without a clock
class, we set the expectation to
MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE. The second time we enter
without a clock class, we wrongfully go to the error case. We are
missing a check for MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE, which
is the expected and valid case. This patch adds it.
Also, the error message is erroneous. If we are in that situation, we
expect a stream class _without_ a clock class, but are met with a stream
class _with_ a clock class. Fix that at the same time.
Change-Id: Iea692578498ea87a33ecba5d2fd54b2980056cd0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1862
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Fri, 9 Aug 2019 20:52:42 +0000 (16:52 -0400)]
Tests: flt.utils.muxer: run `black` on bt_plugin_muxer_test.py
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I83faf79c295130976aa741af080e59253a3083f7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1860
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 9 Aug 2019 18:40:23 +0000 (14:40 -0400)]
src.ctf.lttng-live: use `common_muxing_compare_messages()` to break TS ties
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I2dc0087d995ea06e7ac9c11e4e5cd54958e932aa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1848
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Fri, 9 Aug 2019 17:14:34 +0000 (13:14 -0400)]
Add message compare common func/library; make flt.utils.muxer use it
Change-Id: I8efe1e22fa7badd1328eb46f35315bb40936c46a
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1847
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 9 Aug 2019 21:24:59 +0000 (17:24 -0400)]
logging/log.h: always write the source file name and line number
We don't need to protect our source file names and line numbers in the
logs of a production build, so always write them.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I837dd0cfc4cf3279aa26f813f3ebae2b7f4d4d55
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1861
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 9 Aug 2019 19:01:32 +0000 (15:01 -0400)]
Fix: tests: flt.utils.muxer: missing '../' in path to utils.sh
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia4b6d3275ea7d81a9fce770f34be700fe8c99e48
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1849
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 9 Aug 2019 19:11:52 +0000 (15:11 -0400)]
Fix: visitor-generate-ir.c: dereference after `NULL` check
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8b0e43d57b8a4bdfb39632216b2090e2f13af6c4
Philippe Proulx [Fri, 9 Aug 2019 19:09:32 +0000 (15:09 -0400)]
Fix: plugin-so.c: dereference after `NULL` check
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I44f05edbeec6541b6b65f1f5ead55511d1085a0e
Philippe Proulx [Fri, 9 Aug 2019 19:06:37 +0000 (15:06 -0400)]
Fix: plugin-so.c: dereference before `NULL` check
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I36ae818417b9f9902a561641e83d6e24837be462
Philippe Proulx [Fri, 9 Aug 2019 19:04:48 +0000 (15:04 -0400)]
Fix: common.c: logically dead code
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib870cf62d6028bb26259d448e5dbee59dacb9759
Philippe Proulx [Fri, 9 Aug 2019 19:03:24 +0000 (15:03 -0400)]
Fix: cli/babeltrace2.c: logically dead code
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icc8f3d6736cc086a18764d8c671683c226404e25
Philippe Proulx [Fri, 9 Aug 2019 19:00:35 +0000 (15:00 -0400)]
Fix: dmesg.c: deference before `NULL` check
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I841e1434341037ddf482445464c3fd428f08edd7
Philippe Proulx [Fri, 9 Aug 2019 18:57:00 +0000 (14:57 -0400)]
Fix: translate-trace-ir-to-ctf-ir.c: dereference after `NULL` check
We only need to call must_protect_variant_option_name() when the tag
field class is not created by the component (`fc->tag_is_before`).
Furthermore, the local `must_protect` variable is not used, so the
corresponding must_protect_variant_option_name() parameter is not
either. They are both removed. Because the
must_protect_variant_option_name() function actually sets the name of
the option to use (protecting it or not), it's renamed to
maybe_protect_variant_option_name().
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ieccc0bcddc5570f473d4303f7cc470a56af65a9e
Philippe Proulx [Fri, 9 Aug 2019 18:44:44 +0000 (14:44 -0400)]
Fix: argpar.c: logically dead code
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id67092bcdb0a0ebf7aa29186668457596c177ca6
Philippe Proulx [Fri, 9 Aug 2019 18:42:53 +0000 (14:42 -0400)]
Fix: babeltrace2-cfg-cli-args.c: uninitialized pointer read
Found by Coverity Scan.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaf8c35247a61562ab745b734d523831f2ea68be8
Francis Deslauriers [Thu, 8 Aug 2019 17:17:40 +0000 (13:17 -0400)]
Fix: src.ctf.lttng-live: omitting stream end on stream hang up
Issue
=====
When receiving a LTTNG_VIEWER_INDEX_HUP request status, a
`src.ctf.lttng-live` component quickly removes the associated stream
iterator and move on to the next request without sending the stream end
message to properly close the stream. This breaks the guarantee that
stream end messages are always present.
Solution
========
Whenever we receive an HUP status from the server, we trigger the
`bt_msg_iter` code to hit an BT_MSG_ITER_MEDIUM_STATUS_EOF so it
generates the stream end message that closes the stream.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I89924ee95b35ca62c103651ad44c9eaf71f6df53
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1840
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 9 Aug 2019 13:44:51 +0000 (09:44 -0400)]
Fix: muxer.c: compare_events(): initialize `ret` to 0
GCC complains when this `ret` is not initialized:
muxer.c: In function ‘compare_events’:
muxer.c:993:9: error: ‘ret’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
return ret;
It reaches `return ret` with an uninitialized `ret` when all the tests
fail to find a difference (which can happen).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib0541150173dbc845ba5784abfc5e131412d2663
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1846
Tested-by: jenkins <jenkins@lttng.org>
Jérémie Galarneau [Thu, 8 Aug 2019 04:45:56 +0000 (00:45 -0400)]
src.ctf.lttng-live fix: remove overly strict check for session name
The live component checks that the path of a stream contains a
session's name. While this check works when interacting with pre-2.11
peers, there is no reason for a session's name to necessarily be in a
stream's path.
The LTTng relay daemon, as of 2.11, now expresses its path relative to
a session's output path, the session's name no longer appears in a
stream's path.
There are no comments explaining the reason for this check and it is
not present in babeltrace 1.5.x. Hence, it appears safe to remove it.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic5499976ed45f1f4ae17056b9e881a8455898a44
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1845
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Fri, 19 Jul 2019 21:46:35 +0000 (17:46 -0400)]
Tests: flt.utils.muxer: add message ordering tests
* Add a test that checks the basic ordering of messages based on
timestamps.
* Add a test that checks the basic ordering of messages with the same
timestamps but different trace name, stream class id, or stream id.
* Add tests that check the ordering of messages with the same timestamps
and types.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I217119a00828288d0a2471c26b387a670e62608a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1726
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Wed, 17 Jul 2019 22:23:35 +0000 (18:23 -0400)]
flt.utils.muxer: deterministically order messages of same timestamps
Issue
=====
The ordering of messages with the exact same timestamp is runtime
dependent. It is causing flakiness in tests using a `sink.text.details`
sink component where such differences in ordering is checked.
Note: It's common to have messages with the same timestamps because that
messages with no clock snapshot are assumed to happen at the same time
that of the previous message.
Solution
========
We need to order messages deterministically even when timestamps are the
same. This commit adds functions to order, in a predictable manner,
messages that have the same timestamp (or no timestamp at all) so that
they are sorted in the same way every time a trace is read.
With this commit:
* We first try to sort the messages by their trace name, stream class
id, or stream id,
* If not possible, we check if the messages have different types and if
they do, we sort them using the following scheme:
SB < PB < EV < DE < MI < PE < DP < SE
* If they are of the same type, we sort them comparing their properties.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id6fc1fe8b19d02ec1804e54255a73c64820d1e13
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1719
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Thu, 8 Aug 2019 02:21:02 +0000 (22:21 -0400)]
Fix: extra '%' causes babeltrace2 to abort() in logging code
An extra '%' in a TRACE logging statement causes
bt_common_custom_vsnprintf() to interpret '!' as a conversion
specifier. This causes handle_conversion_specifier_bt() to invoke
abort().
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia077616ea84559dfc3abb57d6404d06a6e9b7baf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1836
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 7 Aug 2019 03:48:44 +0000 (23:48 -0400)]
Fix: bt2: use unsigned iteration variable
This fixes the following compiler diagnostic (gcc 9.1.0):
bt2/native_bt.c: In function ‘_wrap_field_class_enumeration_unsigned_get_mapping_labels_for_value’:
bt2/native_bt.c:9387:25: error: comparison of integer expressions of different signedness: ‘int’ and ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
9387 | for (int i = 0; i < *arg4; i++) {
| ^
Change-Id: I543c61d64c0cf7b42cb242bdbb7b71cbf67dbe48
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1834
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 6 Aug 2019 16:49:54 +0000 (12:49 -0400)]
Fix: `ctf` plugin: msg-iter.c: do not switch packet twice
Issue
=====
In read_packet_header_begin_state(), bt_msg_iter_switch_packet() is
called systematically at the beginning of the state. However,
buf_ensure_available_bits() can fail below (the medium can return
`BT_MSG_ITER_MEDIUM_STATUS_AGAIN`), and read_packet_header_begin_state()
will be called again next time, calling bt_msg_iter_switch_packet()
twice for the same packet.
One of the problems of calling bt_msg_iter_switch_packet() twice is
that, the first time, the current snapshots are copied to the previous
snapshots and the current snapshots are reset; the second time, the
current (reset) snapshots are copied to the previous snapshots. This
shatters the whole snapshot states. Because the medium installed by
`src.ctf.lttng-live` can return `BT_MSG_ITER_MEDIUM_STATUS_AGAIN`, all
the messages that depend on the previous snapshots, like the discarded
events/packets messages, are wrong.
Solution
========
In `msg-iter.c`, add a new `STATE_SWITCH_PACKET` state which is
dedicated to doing what bt_msg_iter_switch_packet() used to do. Once it
completes, the next state is `STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN`.
read_packet_header_begin_state() does not switch packets itself now (the
`STATE_SWITCH_PACKET` state already occured at this point), so it can
safely occur twice.
Known drawbacks
===============
There's one more state to handle per packet, but this have a significant
performance hit.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reported-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I24dd2482762c61e339ab0310fddee6c9aa69d438
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1833
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 6 Aug 2019 16:47:26 +0000 (12:47 -0400)]
src.ctf.lttng-live: `live_viewer_connection`: make `obj` first member
This fixes a leak. The `bt_object` member must always be the first
because the internal API casts any `void *` parameter to `bt_object *`.
The object API was not getting the correct reference count here.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I15ccf573e0b7f5078d434852e915f90d685e65e1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1832
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 6 Aug 2019 00:31:35 +0000 (20:31 -0400)]
lib, bt2: make query method receive custom data
Just like a component class initialization method can receive custom
user data (`init_method_data`) along with generic parameters, this patch
makes this possible for a query operation.
Library changes
===============
On the library side, this patch introduces the new
bt_query_executor_create_with_method_data() function which is like
bt_query_executor_create(), but accepts a `void *` user data parameter.
Internally, bt_query_executor_create() calls
bt_query_executor_create_with_method_data() with `NULL` as the
`method_data` parameter.
The component class query method type is changed to:
typedef bt_component_class_query_method_status
(*bt_component_class_*_query_method)(
bt_self_component_class_* *comp_class,
bt_private_query_executor *query_executor,
const char *object, const bt_value *params,
void *method_data, const bt_value **result);
The component class is guaranteed, for a given query executor, to always
being passed the same `method_data` value to its query method.
Python bindings changes
=======================
QueryExecutor.__init__() accepts a new, optional `method_obj` parameter
which defaults to `None`.
`None` gets translated to `NULL` as the `method_data` parameter, and
vice versa when a Python query method is called from the native part.
QueryExecutor.__init__() validates that you can only pass a Python
method object when the component class you query is a Python component
class.
Because you build the query executor and then make a query operation in
two steps, a Python reference to the method object must exist as long as
the query executor exists. This patch makes it reside within the Python
query executor wrapper (`_method_obj` attribute) as there's no way
currently to lose the Python wrapper and retrieve it through a library
call. If this becomes possible in the future, then we can introduce
query executor destruction listeners and add one from the Python
bindings to put the `PyObject *` reference when the query executor is
destroyed. A new test checks this
(test_query_with_method_obj_del_ref()), deleting the test's reference
between the query executor's construction and the actual query
operation. I tried without making the query executor keep a strong
reference and the test causes a segmentation fault, as expected, which
shows that the test is valuable.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I454cdad039fab5b7d46e46762243f212c200f114
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1831
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 5 Aug 2019 22:01:09 +0000 (18:01 -0400)]
Add bt_graph_add_simple_sink_component() tests
As of this patch, the tests are basic and only check that the statuses
returned by the user functions are correctly translated and returned by
bt_graph_run_once(). The user initialization function status is not
returned by bt_graph_add_simple_sink_component() because the
initialization function is called within the sink component's "graph is
configured" method.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id8ccfd7df4e4a8f0a39af386ed4ad13fe657f86a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1830
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 5 Aug 2019 21:57:27 +0000 (17:57 -0400)]
Fix: src/lib/graph/graph.h: do not override `comp_status` value
This made, for example, bt_graph_run() return
`BT_GRAPH_RUN_STATUS_ERROR` when the sink component's "graph is
configured" method returned
`BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR`,
therefore not percolating the correct status.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic89d9315f8bc1c3226a14955c9e6419462d5e588
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1829
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Philippe Proulx [Mon, 5 Aug 2019 20:15:32 +0000 (16:15 -0400)]
lib: add bt_graph_add_simple_sink_component()
This patch adds bt_graph_add_simple_sink_component(), an easy way to add
a simple sink component which has a single message iterator iterating a
single input port named `in` and which calls user-provided functions at
specific locations.
This makes it possible to create a sink component without having to:
* Create a sink component class with initialization, "graph is
configured", "consume", and finalization methods.
* Create an input port in the component class's initialization method.
* Create an input port message iterator in the component class's "graph
is configured" method.
* Put the input port message iterator's reference in the component
class's finalization method.
The goal of this new function is to make it easy to get messages at the
sink endpoint of a graph, just like we used to do with the output port
message iterator concept (but the graph model is honored now). The user
must still call bt_graph_run() or bt_graph_run_once() to make her
consume function (see details below) called: the added simple sink
component is not special in any way.
bt_graph_add_simple_sink_component() receives three function pointers
(and custom user data):
Initialize (optional):
Called after the simple sink component creates the input port
message iterator in the "graph is configured" method.
The user function receives the message iterator to perform any
initial task.
Consume:
Called for each "consume" method call of the simple sink component.
The user function receives the message iterator and can get the next
messages with bt_self_component_port_input_message_iterator_next()
as usual.
Finalize (optional):
Called when the simple sink component is finalized.
The message iterator is not available at this point.
I'm not wrapping this one in Python because it's so easy to replicate
with our bindings:
class _SimpleSink:
def __init__(self, params, consume_cb):
self._consume_cb = consume_cb
self._add_input_port('in')
def _user_graph_is_configured(self):
self._msg_iter = self._create_input_port_message_iterator(
self._input_ports['in']
)
def _consume(self):
self._consume_cb(self._msg_iter)
def _mein_consume(msg_iter):
...
...
graph.add_component(_SimpleSink, 'simple', _mein_consume)
...
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I02aaae16215160cd861c2a76793adddf808202d6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1828
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 5 Aug 2019 20:35:56 +0000 (16:35 -0400)]
lib: remove colander sink component class
This is not used anymore.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib0592d3adf02f82159e262184d92e6eaf67f2386
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1827
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 4 Aug 2019 04:24:06 +0000 (00:24 -0400)]
cli, tests: rename "leftover" terms to "non-option"
"Leftover" is a popt term, and we don't use popt anymore. Arguments
which are not options are not leftover anymore: they are treated within
the same loop as option arguments, and their position relative to option
arguments are important, so we simply call them "non-option arguments".
Note that "non-option" is also a term that getopt(1) and getopt(3) use.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6c27e6a18f9daa4a9d2e5f79058a94c926102da3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1817
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sun, 4 Aug 2019 14:07:18 +0000 (10:07 -0400)]
test_try_again_many_times(): use three times `None`'s ref count
100,000 iterations was arbitrary anyway, so let's just depend on the
initial reference count of `None` and iterate three times that since
this is the object we want to avoid destroy.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3d587c730b4587d5381d07541d0d86ccff344858
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1822
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sun, 4 Aug 2019 14:04:03 +0000 (10:04 -0400)]
lib: remove output port message iterator
The output port message iterator concept was not a good idea in the
beginning: it breaks the graph model, making it possible to iterate a
disconnected output port (which is weird from the component's
perspective), blocking the graph (user cannot call bt_graph_run()), and
forcing the graph not to contain any sink component. This looks and
feels like a hack.
For the C part, a subsequent patch should implement an easy way to add a
simple sink component to a graph based on a simple callback and custom
user data instead of going through the inconvenience of creating a sink
component class, setting the methods manually, creating an input port
message iterator once the graph is configured, etc.
For the Python part, we'll focus on `TraceCollectionMessageIterator` to
replace `_OutputPortMessageIterator`. `TraceCollectionMessageIterator`
should cover most of the use cases and is easier to use: you don't need
to set up your graph, add your own `flt.utils.muxer`, etc.
For more advanced use cases in Python, it's always possible to create a
"proxy sink component", just like `TraceCollectionMessageIterator` does
internally, to get full control on the input port message iterator.
To adapt the current tests, `TestOutputPortMessageIterator` in
`utils.py` can be used like an output port message iterator. Such an
iterator cannot seek however, so `test_message_iterator.py` needed
special treatments to make the eventual input port message iterator
seek.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I92d432fb33d35ae3c0262b723cdfeae82c6633c9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1821
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sun, 4 Aug 2019 05:13:15 +0000 (01:13 -0400)]
bt2: make `TraceCollectionMessageIterator` not use an output port msg iter
Because there's a plan to drop the output port message iterator concept
altogether, make `TraceCollectionMessageIterator` not use any output
port message iterator.
Instead, a `TraceCollectionMessageIterator` instance adds a proxy sink
component (`_TraceCollectionMessageIteratorProxySink`) to its graph,
connecting it to the last filter component in the chain, and sharing
with it a list having a single item.
When the sink consumes a message from its upstream message iterator, it
places it in the shared list as the first item.
TraceCollectionMessageIterator.__next__() is changed so that it calls
Graph.run_once() to make the proxy sink consume, and then reads the
consumed message from the shared list.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4b561837a9c23d3d758ea089193cfdabf99fc27e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1820
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sun, 4 Aug 2019 05:11:03 +0000 (01:11 -0400)]
bt2: wrap bt_graph_run_once() (Graph.run_once())
As opposed to Graph.run() which simply returns `None` when it's finished
running, Graph.run_once() needs a way to indicate that the whole graph
is finished. In that case, the method raises `bt2.Stop`. Otherwise,
Graph.run_once() returns `None`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8c5908b7b1a265486534a3ec01c9eb813c2cde7c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1819
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sun, 4 Aug 2019 05:09:28 +0000 (01:09 -0400)]
lib: rename bt_graph_consume() -> bt_graph_run_once()
While bt_graph_run() makes the graph run until the end,
bt_graph_run_once() makes it run a single time, that is, a single sink's
(next in the queue) "consume" operation.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I65dc06c93425d5b5aa1f9e31edf3e22bbeaf77f0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1818
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 3 Aug 2019 18:36:42 +0000 (14:36 -0400)]
bt2: pass custom Python object to Python component's __init__()
Just like you can pass custom data (`void *`) to the initialization
function of a component class written in C with the
bt_graph_add_*_component_with_init_method_data() functions, this patch
makes it possible to pass any Python object to the __init__() method of
a component class written in Python with the Graph.add_component()
method.
This patch installs a mechanism to share Python data between a Python
graph user and the methods of a Python component without relying on
`nonlocal`, global variables, or other such hacks. This data can be as
simple as an integer and as complex as a database connection, for
example.
The __init__() method of a Python component used to look like:
def __init__(self, params):
...
It's now:
def __init__(self, params, obj):
...
When you pass any Python object to Graph.add_component() as its `obj`
parameter, the Python component's __init__() method eventually receives
it.
Graph.add_component() ensures that the component class to instantiate is
a Python component class if `obj` is not `None`.
Internally, `None` gets converted to `NULL` as the `init_method_data`
parameter of the bt_graph_add_*_component_with_init_method_data()
functions, and then `NULL` gets converted back to `Py_None` in
component_class_init().
Now there is the risk that you call
bt_graph_add_*_component_with_init_method_data() in C with a Python
component class and pass a non-`NULL`, non-`PyObject *`
`init_method_data` parameter. However I consider an insignificant
drawback as you're not supposed to use the `init_method_data` with a
component class you don't know.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib879ece9e423b3495b9449ca73674082020865c5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1815
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Sat, 3 Aug 2019 18:29:27 +0000 (14:29 -0400)]
bt2: remove BT CC entry from global HT in _UserComponentType.__del__()
The global `bt_cc_ptr_to_py_cls` hash table maps BT component class
pointers to Python component classes (`PyObject *`) for component
classes created in Python. The key and value are weak references.
When the Python side calls native_bt.bt2_component_class_*_create() with
a Python component class, an entry is added to `bt_cc_ptr_to_py_cls` on
success. This works most of the time because all Python classes are
normally destroyed when the interpreter is finalized, but there could be
issues with specific/unusual import patterns.
To avoid potential issues, remove an entry from `bt_cc_ptr_to_py_cls` in
_UserComponentType.__del__(), where a strong BT component class
reference is finally released.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I450a1c6f179f352e758b9e3e5cac8f4711aa3c88
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1816
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Sun, 4 Aug 2019 15:00:22 +0000 (11:00 -0400)]
cli: free auto_source_discovery_result::original_input_indices
This field is never freed, causing a memory leak.
Change-Id: I8d118226c2b491ae6ac3237250ab6ce3928e8ac2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1824
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Sun, 4 Aug 2019 14:58:58 +0000 (10:58 -0400)]
cli: free leftover_params and leftover_loglevels
They are never freed, causing a memory leak.
Change-Id: I66e12face4e83ecf98c780e8f20b97b9669e04b0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1823
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 1 Aug 2019 22:43:31 +0000 (18:43 -0400)]
cli: apply log levels (`--log-level` option) to leftovers
It is currently not possible to apply --log-level after a leftover.
This patch proposes a way to allow it and to deal with the ambiguity
that it poses.
In the simple case, we have:
babeltrace2 my-traces --log-level=TRACE
All source components auto-discovered from the `my-traces` leftover will
have the TRACE log level.
If we have more than one leftover, but _no_ cross-leftover grouping,
then it is also intuitive:
babeltrace2 my-traces-1 --log-level=TRACE my-traces-2 --log-level=DEBUG
... all source components discovered from `my-traces-1` will have log
level TRACE and all source components discovered from `my-traces-2` will
have log level DEBUG.
It becomes less obvious when components are given inputs coming from
multiple leftovers (because of the auto-discovery grouping feature):
which log level do they receive? For example, if the following line:
babeltrace2 my-traces-1 --log-level=TRACE my-traces-2 --log-level=DEBUG
leads to these components getting instantiated, with these inputs:
* Source component X with inputs `my-traces-1/x` and `my-traces-2/x`.
* Source component Y with input `my-traces-1/y`
In this case, each component receives (on the `run` command line) the
log level options of all leftovers that contributed to its inputs, in
the same order as they are provided on the command line. The resulting
`run` command line for the example above could therefore look like:
... --component x:src.my.comp --log-level=TRACE --log-level=DEBUG \
--component y:src.my.comp --log-level=TRACE
resulting in these effective log levels:
* Source component X: log level DEBUG
* Source component Y: log level TRACE
Change-Id: I5e1bf9e1b4dd139ff7900d81b302a1eda72fb37f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1810
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 31 Jul 2019 21:40:56 +0000 (17:40 -0400)]
cli: apply parameters (`--params` option) to leftovers
It is currently not possible to apply --params after a leftover.
This patch proposes a way to allow it and to deal with the ambiguity
that it poses.
In the simple case, we have:
babeltrace2 my-traces --params=foo=2
All source components auto-discovered from the `my-traces` leftover will
receive the `foo=2` parameter.
If we have more than one leftover, but _no_ cross-leftover grouping,
then it is also intuitive:
babeltrace2 my-traces-1 --params=foo=2 my-traces-2 --params=bar=3
... all source components discovered from `my-traces-1` will receive
`foo=2` and all source components discovered from `my-traces-2` will
receive `bar=3`.
It becomes less obvious when components are given inputs coming from
multiple leftovers (because of the auto-discovery grouping feature):
which parameters do they receive? For example, if the following line:
babeltrace2 my-traces-1 --params=foo=2,bar=3 my-traces-2 --params=foo=4
leads to these components getting instantiated, with these inputs:
* Source component X with inputs `my-traces-1/x` and `my-traces-2/x`.
* Source component Y with input `my-traces-1/y`
In this case, each component receives the parameters of all leftovers
that contributed to its inputs, in the same order as they are provided
on the command line. The resulting `run` command line for the example
above could therefore look like:
... --component x:src.my.comp --params=foo=2,bar=3 --params=foo=4 \
--component y:src.my.comp --params=foo=2,bar=3
resulting in these parameters being passed to the components:
* Source component X receives parameters `foo=4,bar=3`
* Source component Y receives parameters `foo=2,bar=3`
Implementation details
----------------------
The auto discovery mechanism now returns, for each result, which
input from the passed `inputs` array contributed to that result.
This allows us, for the component that we create from a given result, to
get the parameters from the leftovers that have contributed to it.
Change-Id: Ic048e4e137c2e1f93b6da13a62629343500cb75a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1809
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.053594 seconds and 4 git commands to generate.