babeltrace:stable-2.0

Last commit made on 2019-08-07
Get this branch:
git clone -b stable-2.0 https://git.launchpad.net/babeltrace

Branch merges

Branch information

Name:
stable-2.0
Repository:
lp:babeltrace

Recent commits

c347a32... by Simon Marchi <email address hidden> on 2019-08-07

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 <email address hidden>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1834
Reviewed-by: Philippe Proulx <email address hidden>
Tested-by: jenkins <email address hidden>

01ed875... by .eepp on 2019-08-06

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 <email address hidden>
Reported-by: Jonathan Rajotte <email address hidden>
Change-Id: I24dd2482762c61e339ab0310fddee6c9aa69d438
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1833
Tested-by: jenkins <email address hidden>

7b89120... by .eepp on 2019-08-06

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 <email address hidden>
Change-Id: I15ccf573e0b7f5078d434852e915f90d685e65e1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1832
Tested-by: jenkins <email address hidden>

f6e305c... by .eepp on 2019-08-06

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 <email address hidden>
Change-Id: I454cdad039fab5b7d46e46762243f212c200f114
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1831
Tested-by: jenkins <email address hidden>

117d027... by .eepp on 2019-08-05

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 <email address hidden>
Change-Id: Id8ccfd7df4e4a8f0a39af386ed4ad13fe657f86a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1830
Reviewed-by: Simon Marchi <email address hidden>
Reviewed-by: Francis Deslauriers <email address hidden>

bbaccda... by .eepp on 2019-08-05

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 <email address hidden>
Change-Id: Ic89d9315f8bc1c3226a14955c9e6419462d5e588
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1829
Reviewed-by: Simon Marchi <email address hidden>
Reviewed-by: Francis Deslauriers <email address hidden>

5efafa1... by .eepp on 2019-08-05

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 <email address hidden>
Change-Id: I02aaae16215160cd861c2a76793adddf808202d6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1828
Reviewed-by: Simon Marchi <email address hidden>
Tested-by: jenkins <email address hidden>

dcf9ee1... by .eepp on 2019-08-05

lib: remove colander sink component class

This is not used anymore.

Signed-off-by: Philippe Proulx <email address hidden>
Change-Id: Ib0592d3adf02f82159e262184d92e6eaf67f2386
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1827
Tested-by: jenkins <email address hidden>
Reviewed-by: Francis Deslauriers <email address hidden>
Reviewed-by: Simon Marchi <email address hidden>

8d5247b... by .eepp on 2019-08-04

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 <email address hidden>
Change-Id: I6c27e6a18f9daa4a9d2e5f79058a94c926102da3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1817
Tested-by: jenkins <email address hidden>

e9e22c0... by .eepp on 2019-08-04

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 <email address hidden>
Change-Id: I3d587c730b4587d5381d07541d0d86ccff344858
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1822
Tested-by: jenkins <email address hidden>
Reviewed-by: Simon Marchi <email address hidden>