deliverable/babeltrace.git
4 years agoinclude: add missing files to dist tarball C009-19 babeltrace_trace_merging
Simon Marchi [Thu, 2 May 2019 18:36:57 +0000 (14:36 -0400)] 
include: add missing files to dist tarball

When making a tarball (make dist) and trying to build from it, it fails
because of missing header files.  This patch adds all the necessary
headers to the dist tarball to make "./configure && make" from the
tarball succeed.

Change-Id: I89051cb060e911eac154ef1726034e905b49b085
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agotests: update EXTRA_DIST of Python bindings
Simon Marchi [Thu, 2 May 2019 18:18:07 +0000 (14:18 -0400)] 
tests: update EXTRA_DIST of Python bindings

This list is out of date, causing "make dist" to fail.

Sync the list of distributed files with the actual files.

Change-Id: Iedef7411c691689eb6a0505b4ea29d0f319f6860
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agotests: remove non-existent files from EXTRA_DIST
Simon Marchi [Thu, 2 May 2019 18:29:10 +0000 (14:29 -0400)] 
tests: remove non-existent files from EXTRA_DIST

These files were removed in commit

    e8bacbe2bd42 ("Remove stale trace-ir test files")

... so they should be removed from EXTRA_DIST as well.  Currently, it
causes a "make dist" failure:

  make[4]: *** No rule to make target 'test_trace.py', needed by 'distdir'.  Stop.

The tests/lib/trace-ir directory is currently not very useful, as it
contains no tests at all, so we could remove it in theory.  But I
presume we'll add something in there in not too long, so I think we can
leave it there.

Change-Id: Iec44efd7c52e84b35a5a55206055b5d63635fbe1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agobt2: Add wrapper for bt_plugin_get_version
Simon Marchi [Wed, 1 May 2019 22:00:50 +0000 (18:00 -0400)] 
bt2: Add wrapper for bt_plugin_get_version

There is a subtle bug with our use of the "char **OUT" typemap for the
bt_plugin_get_version function.

THe SWIG wrapper does this:

    char *temp_value5;
    arg5 = &temp_value5;

The initial content of temp_value5 is unknown, assume that it points to
unreadable memory.  If the call to bt_plugin_get_version returns
PROPERTY_AVAILABILITY_NOT_AVAILABLE, the value of temp_value5 is
unchanged (but really, it could be anything, again we should assume it
points to unreadable memory).  However, the epilogue of the typemap will
still try to transform the C string to a Python str object.  Doing so
will cause a crash when trying to read the C string.

The fix is to make our own wrapper to bt_plugin_get_version, which
guarantees that if it returns PROPERTY_AVAILABILITY_NOT_AVAILABLE, it
will force the value of the output parameter to be NULL (which is
handled by the epilogue and transformed to None).

Setting the temporary variable to an invalid but non-zero pointer value
((void *) 1) makes this bug consistently reproducible and not rely on
random memory contents.  I suggest we keep it there, in order to quickly
find other instances of this bug in the future.

Change-Id: Idd12ca4c4d4d732b841c1e12420e46e6a5a25874
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1221
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoAdd git-review config
Michael Jeanson [Tue, 30 Apr 2019 15:10:10 +0000 (11:10 -0400)] 
Add git-review config

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Iece6807efd73611d1a2767c3284fbe6f9f72256c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1023
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: bt2: enum-conversion warning in native_bt_component_class.i
Francis Deslauriers [Wed, 1 May 2019 22:44:44 +0000 (18:44 -0400)] 
Fix: bt2: enum-conversion warning in native_bt_component_class.i

clang warns about the following enumeration conversion.
  bt2/native_bt_wrap.c:3896:12: warning: implicit conversion from
  enumeration type 'enum bt_message_iterator_status' to different
  enumeration type 'enum bt_self_message_iterator_status'
  [-Wenum-conversion]
                  status = BT_MESSAGE_ITERATOR_STATUS_END;
                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bt2/native_bt_wrap.c:3898:12: warning: implicit conversion from
  enumeration type 'enum bt_message_iterator_status' to different
  enumeration type 'enum bt_self_message_iterator_status'
  [-Wenum-conversion]
                  status = BT_MESSAGE_ITERATOR_STATUS_AGAIN;
                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bt2/native_bt_wrap.c:3901:12: warning: implicit conversion from
  enumeration type 'enum bt_message_iterator_status' to different
  enumeration type 'enum bt_self_message_iterator_status'
  [-Wenum-conversion]
                  status = BT_MESSAGE_ITERATOR_STATUS_ERROR;
                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bt2/native_bt_wrap.c:4513:43: warning: implicit conversion from
  enumeration type 'enum bt_message_iterator_status' to different
  enumeration type 'bt_self_message_iterator_status' (aka 'enum
  bt_self_message_iterator_status') [-Wenum-conversion]
          bt_self_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
                                          ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bt2/native_bt_wrap.c:4678:43: warning: implicit conversion from
  enumeration type 'enum bt_message_iterator_status' to different
  enumeration type 'bt_self_message_iterator_status' (aka 'enum
  bt_self_message_iterator_status') [-Wenum-conversion]
          bt_self_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
                                        ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Icb3bc0141cdd9f35a5a42420bb48167c12e70df0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1183
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
4 years agoFix: bt2: int-to-pointer-cast warnings in SWIG utils functions
Francis Deslauriers [Wed, 1 May 2019 18:19:05 +0000 (14:19 -0400)] 
Fix: bt2: int-to-pointer-cast warnings in SWIG utils functions

  bt2/native_bt_wrap.c: In function ‘bt_py3_component_class_query’:
  bt2/native_bt_wrap.c:4453:12: warning: cast to pointer from integer of
    different size [-Wint-to-pointer-cast]
      *result = (void *) PyLong_AsUnsignedLongLong(py_results_addr);
                 ^
  bt2/native_bt_wrap.c: In function ‘bt_py3_component_class_message_iterator_next’:
  bt2/native_bt_wrap.c:4697:3: warning: cast to pointer from integer of
    different size [-Wint-to-pointer-cast]
      (const bt_message *) PyLong_AsUnsignedLongLong(
      ^
  python-plugin-provider.c: In function ‘bt_plugin_from_python_plugin_info’:
  python-plugin-provider.c:341:18: warning: cast to pointer from integer of
    different size [-Wint-to-pointer-cast]
       comp_class = (bt_component_class *)

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I44d15e5d072d993776539eddae5f3e37c6161cac
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1162
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agosink.ctf.fs: set_field_refs(): make `fc` `const` as `fc_type` depends on it
Philippe Proulx [Wed, 1 May 2019 20:58:09 +0000 (16:58 -0400)] 
sink.ctf.fs: set_field_refs(): make `fc` `const` as `fc_type` depends on it

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9b0a0eb3fc41d9181205cb4f3f33334b90a3b712

4 years agoFix: sink.ctf.fs: do not keep different `tgt_fc_type` as `tgt_fc` changes
Philippe Proulx [Wed, 1 May 2019 20:56:03 +0000 (16:56 -0400)] 
Fix: sink.ctf.fs: do not keep different `tgt_fc_type` as `tgt_fc` changes

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie79306f50018d7f5ca0971e6c9a2410378a4ccc7

4 years agolib: bt_graph_{consume,run}(): add unlikely() to unlikely condition
Philippe Proulx [Wed, 1 May 2019 20:40:05 +0000 (16:40 -0400)] 
lib: bt_graph_{consume,run}(): add unlikely() to unlikely condition

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I37badc4c15fbde16940150854cae1e31305953f1

4 years agosrc.ctf.fs: compute stream range using entire file info group
Francis Deslauriers [Tue, 30 Apr 2019 23:01:17 +0000 (19:01 -0400)] 
src.ctf.fs: compute stream range using entire file info group

Given that index entries are sorted within their file info structure and
that file info structures are sorted by time within the file info group,
we can simply compute the range of the stream by using the absolute
first index entry and the absolute last index entry of the entire file
info group.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I5b13451d72a4b1aeb9f31140ebfb025e2d712d7e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1128
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: update bindings to make test_plugins pass
Simon Marchi [Tue, 30 Apr 2019 20:30:32 +0000 (16:30 -0400)] 
bt2: update bindings to make test_plugins pass

This patch updates the necessary stuff in the bindings to make
test_plugins pass.

One new test is added, test_find_file, which tests passing the path to a
plugin shared object to bt2.find_plugins.

Change-Id: Ie2ac6e830fb18d8839d2879567509cd2f6abbd81
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1087
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
4 years agobt2: update bindings to make test_component pass
Simon Marchi [Wed, 1 May 2019 18:09:13 +0000 (14:09 -0400)] 
bt2: update bindings to make test_component pass

This patch updates component.py such that the test_component test
passes.

With the API, it is no longer possible to obtain the graph from a
component, so things related to this are removed from both files.

Change-Id: I3ab0e6aaaa8ec1ad7378abb78072e6e130e1c2a4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1085
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: update bindings to make test_component_class pass
Simon Marchi [Wed, 1 May 2019 15:30:28 +0000 (11:30 -0400)] 
bt2: update bindings to make test_component_class pass

This patch updates the binding with the goal of making
test_component_class pass.

Besides the obviously needed changes to the component class code, there
are a bunch of changes to things around it (component, graph), just
enough to make the test run.

One notable change is the _SharedObject._release method, used to make the
Python object stop manage the reference it currently owns.

Another functional change is how the component classes _query method
reports that it's not implemented.  Currently, it default to return the
NotImplemented object.  Instead, I made it raise a NotImplementedError.
Returning NotImplemented is useful if the caller has an alternative to
try when the method is not implemented.  In our case, there is nothing
to do if the specific class doesn't implement _query.  The exception is
caught in bt_py3_component_class_query, where other types of exceptions
need to be handled anyway.

Some changes are required to the library, to be able to get a specific
component class type from a specific component (e.g. a
bt_component_class_source from a bt_component_source).

Change-Id: I895817bc996c21b6a9c6d57605cc64f9ff61dfcc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1083
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: Add functions to borrow specialized component classes from specialized components
Simon Marchi [Wed, 1 May 2019 14:17:33 +0000 (10:17 -0400)] 
lib: Add functions to borrow specialized component classes from specialized components

The API currently contains a function to obtain a 'bt_component_class *'
from a 'bt_component *'.  This patch adds functions to obtain a
specialized component class from a specialized component.  For example,
a 'bt_component_class_source *' from a 'bt_component_source *'.

Change-Id: Ide192c7759f630adbc884def2e5c462ce2b8f973
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1161
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: update value.py, make test_value pass
Simon Marchi [Fri, 26 Apr 2019 19:41:24 +0000 (15:41 -0400)] 
bt2: update value.py, make test_value pass

This patch updates value.py to match the current API.

The only known thing missing (to be done later) is to split classes in
their const and non-const variants (e.g. BoolValue and BoolValueConst),
where the methods that can modify values are only present on the
non-const versions.

The test is largely unchanged, except for the removal of things related
to frozen values.

Change-Id: I6424b0e6208ffe2cbe5e60fdd08579326abff29a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1022
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: update object model
Simon Marchi [Mon, 29 Apr 2019 16:12:36 +0000 (12:12 -0400)] 
bt2: update object model

This patch updates the Babeltrace Python object model (what all
Babeltrace Python objects inherit from) to match the current status of
the API.

We have both Shared and Unique objects.  Both types have a _ptr
member, a SWIG Python object wrapping a typed pointer (e.g. pointer to
struct bt_value).

A Shared object type is defined by inheriting from _SharedObject.  It
wraps and owns a reference to a Babeltrace object that is reference
counted.  The reference count is dropped when the Python object gets
deleted.  The _SharedObject base class defines two class methods,
_get_ref and _put_ref, which must be implemented by subclasses.  These
implementations must respectively get and put a reference of the
specialized pointer (_ptr) they wrap.

A Unique object type is defined by inheriting from _UniqueObject.  It is
not refcounted.  Rather, it is wholly owned by another object (the
owner) that is itself refcounted.  A Unique object, in the Babeltrace
API, is destroyed when its parent is destroyed.  There is therefore a
risk that someone would keep a (Python) reference to a unique object
that got destroyed, because its parent got destroyed, resulting in some
use-after-free bug.  To avoid this, we make it so that when a Python
object representing a Babeltrace Unique object is created, that Python
object obtains a reference on the owner Shared object.  When the Unique
Python object is destroyed, the reference on the Shared parent is
dropped.

The concepts of Freezable and Private objects don't exist anymore, so
they are removed.  I have also removed the _PrivateConnection class,
since it won't be needed in the end and inherited from _PrivateObject.
For other classes representing Babeltrace concepts, I have made them
inherit the object type they'll need to inherit in the end (when all the
Python bindings will be fixed), even though none of these classes is
functional at the moment.

Change-Id: I9ab743dd7a28407913945648c1d74c467550df14
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1021
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: string format warnings on 32 bits
Francis Deslauriers [Wed, 1 May 2019 15:40:16 +0000 (11:40 -0400)] 
Fix: string format warnings on 32 bits

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I49fdb170642bfd0c7326719f42973863af41c8e7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1141
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: unused-function warnings in lib/graph/iterator.c
Francis Deslauriers [Tue, 30 Apr 2019 15:36:43 +0000 (11:36 -0400)] 
Fix: unused-function warnings in lib/graph/iterator.c

clang warnings:
  iterator.c:87:6: error: unused function '_set_self_comp_port_input_msg_iterator_state' [-Werror,-Wunused-function]
  void _set_self_comp_port_input_msg_iterator_state(
       ^
  iterator.c:885:6: error: unused function '_set_iterator_state_after_seeking' [-Werror,-Wunused-function]
  void _set_iterator_state_after_seeking(
       ^

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia409f1dd696cdfed58de23aad926c4effdc26307
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1034
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: may-uninitialized warning in trace-ir-metadata-field-class-copy.c
Francis Deslauriers [Tue, 30 Apr 2019 15:30:44 +0000 (11:30 -0400)] 
Fix: may-uninitialized warning in trace-ir-metadata-field-class-copy.c

GCC warning:
  In file included from ../../../include/babeltrace/common-internal.h:30:0,
                   from trace-ir-metadata-field-class-copy.c:31:
  trace-ir-metadata-field-class-copy.c: In function ‘copy_field_class_content_internal’:
  ../../../include/babeltrace/trace-ir/field-class-const.h:196:3: error:
  ‘out_tag_field_class’ may be used uninitialized in this function
  [-Werror=maybe-uninitialized]
     bt_field_class_put_ref(_var);  \
     ^~~~~~~~~~~~~~~~~~~~~~
  trace-ir-metadata-field-class-copy.c:421:18: note: ‘out_tag_field_class’ was declared here
    bt_field_class *out_tag_field_class;

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I73c6057f9795b153f95c1287f3f3f8e529328fbf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1033
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: maybe-uninitialized warnings in translate-trace-ir-to-ctf-ir.c
Francis Deslauriers [Tue, 30 Apr 2019 15:28:48 +0000 (11:28 -0400)] 
Fix: maybe-uninitialized warnings in translate-trace-ir-to-ctf-ir.c

GCC warning example:
  translate-trace-ir-to-ctf-ir.c:929:14: error: ‘struct_fc’ may be used
  uninitialized in this function [-Werror=maybe-uninitialized]
       named_fc = fs_sink_ctf_field_class_struct_borrow_member_by_index(
       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       struct_fc, i);
       ~~~~~~~~~~~~~

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I24ba8095f26cec640e0a24473b4fee05d1c404af
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1032
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: maybe-uninitialized warning in create_relative_field_ref()
Francis Deslauriers [Tue, 30 Apr 2019 15:24:11 +0000 (11:24 -0400)] 
Fix: maybe-uninitialized warning in create_relative_field_ref()

  translate-trace-ir-to-ctf-ir.c: In function ‘resolve_field_class’:
  translate-trace-ir-to-ctf-ir.c:302:6: error: ‘tgt_fc_name’ may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
       g_string_assign(tgt_field_ref,
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         tgt_fc_name);
         ~~~~~~~~~~~~
  translate-trace-ir-to-ctf-ir.c:177:14: note: ‘tgt_fc_name’ was declared here
    const char *tgt_fc_name;

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8d3398a852bf3ca412bb479eae72a81a3959d220
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1031
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: unused-variable warnings in lib/graph/iterator.c
Francis Deslauriers [Tue, 30 Apr 2019 15:21:06 +0000 (11:21 -0400)] 
Fix: unused-variable warnings in lib/graph/iterator.c

GCC warnings:
  make[3]: Entering directory '/home/frdeso/projets/babeltrace/optimalize/lib/graph'
    CC       iterator.lo
  iterator.c: In function ‘_set_iterator_state_after_seeking’:
  iterator.c:889:59: error: variable ‘new_state’ set but not used [-Werror=unused-but-set-variable]
    enum bt_self_component_port_input_message_iterator_state new_state = 0;
                                                             ^~~~~~~~~
  iterator.c: In function ‘find_message_ge_ns_from_origin’:
  iterator.c:1159:59: error: unused variable ‘init_state’ [-Werror=unused-variable]
    enum bt_self_component_port_input_message_iterator_state init_state =

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia14a89f330198e4109af14f755aeed3378912256
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1030
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: maybe-uninitialized warning in bt_ctf_stream_flush()
Francis Deslauriers [Tue, 30 Apr 2019 15:15:27 +0000 (11:15 -0400)] 
Fix: maybe-uninitialized warning in bt_ctf_stream_flush()

GCC warning:
  In file included from ../../include/babeltrace/ctf-writer/fields-internal.h:41:0,
                   from ../../include/babeltrace/ctf-writer/field-wrapper-internal.h:26,
                   from ../../include/babeltrace/ctf-writer/event-internal.h:37,
                   from stream.c:32:
  stream.c: In function ‘bt_ctf_stream_flush’:
  ../../include/babeltrace/ctfser-internal.h:568:36: error:
  ‘packet_context_offset_bits’ may be used uninitialized in this function
  [-Werror=maybe-uninitialized]
    ctfser->offset_in_cur_packet_bits = offset_bits;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
  stream.c:1608:11: note: ‘packet_context_offset_bits’ was declared here
    uint64_t packet_context_offset_bits;

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia7457b1a444290ba1a71459bfaf707812227899c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1029
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: unused-variable warnings in bt_X_freeze() when not in DEV_MODE
Francis Deslauriers [Tue, 30 Apr 2019 15:13:35 +0000 (11:13 -0400)] 
Fix: unused-variable warnings in bt_X_freeze() when not in DEV_MODE

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Idf9e91b2abd9b2720343917c2d3ffdf207f82735
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1028
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: src.ctf.fs: metadata-info: sanitize `path` param
Francis Deslauriers [Tue, 30 Apr 2019 17:51:03 +0000 (13:51 -0400)] 
Fix: src.ctf.fs: metadata-info: sanitize `path` param

Issue
=====
Omitting to pass the mandatory `path` parameter to the `metadata-info`
query results in a BT_ASSERT() failure when calling
bt_value_get_string(), or a NULL pointer dereference in non-DEV_MODE.

Similarly, setting the `path` to a non-string value would also result in
a BT_ASSERT() failure, or a invalid memory access in non-DEV_MODE

Solution
========
Confirm that the `path` parameter is present and is of the string type and
print error messages accordingly it's not.

Known drawbacks
===============
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8182de2797c375262d77a4a8961bedb4c5ef9578
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1081
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: flt.lttng-utils.debug-info: extra colon in `bin` member
Francis Deslauriers [Wed, 1 May 2019 02:07:38 +0000 (22:07 -0400)] 
Fix: flt.lttng-utils.debug-info: extra colon in `bin` member

There is an extra ':' character in the `bin` member of the `debug-info`
field.

Example of the issue from the tests:
   debug_info = { bin = "libhello_so:+0x15a6", func = "bar+0xa9", src =
   "libhello.c:13" }

The "libhello_so:+0x15a6" will now be printed "libhello_so+0x15a6".

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie7c4ea54e534eeb8a1bdd503760b791a01aa9594
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1129
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agodebug info: Skip test that depends on Python bindings
Simon Marchi [Tue, 30 Apr 2019 22:29:01 +0000 (18:29 -0400)] 
debug info: Skip test that depends on Python bindings

This test depends on the Python bindings, which don't work right now.
Skip it, so that it doesn't cause a "make check" failure while we are
repairing the bindings.

Change-Id: I8e9b1092e2794875b249b060581f4305be640a88
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1126
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobabeltrace: Remove leftovers
Simon Marchi [Tue, 30 Apr 2019 22:00:43 +0000 (18:00 -0400)] 
babeltrace: Remove leftovers

It seems like these files should have been removed when removing the
babeltrace Python bindings in commit

    1c81bd8895c0 ("Remove babeltrace 1 Python bindings and tests")

Right now, the test causes a "make check" failure, because it tries to
import the babeltrace Python package, which no longer exists.

Change-Id: Ied4871ec23444776fca601b6f78b583ef8137c81
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1125
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agodoc: Make python bindings doc build
Simon Marchi [Tue, 30 Apr 2019 21:52:12 +0000 (17:52 -0400)] 
doc: Make python bindings doc build

Babeltrace 1 Python bindings (the babeltrace package) were removed in
commit

    1c81bd8895c0 ("Remove babeltrace 1 Python bindings and tests")

However, the Python doc still references it.  It tries to import it to
get the version, and therefore fails to build.  Update it to import the
bt2 package instead.

Change-Id: I656a89ad83069f6794abf4c775a14fb9be2ecba0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1124
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agopython-plugin-provider: Make it build
Simon Marchi [Mon, 8 Apr 2019 16:53:56 +0000 (12:53 -0400)] 
python-plugin-provider: Make it build

This patch fixes building with --enable-python-plugins.

One problem is that the python plugin provider uses some
functions coming from the internal headers of the lib, which use some
logging functions that are internal to the lib, but not included by
those internal headers.  Trying to add the relevant include file
(lib-logging-internal.h) conflicts with python-plugin-provider's own
logger.

python-plugin-provider doesn't really need to have its own logger.  Even
though it is built as a separate shared object (so that we can package
it separately), it can be considered as internal to the library (and
that's why it includes some internal lib headers).  Therefore, the
easiest way to fix this is to get rid of its logger and make the lib
header files that use lib logging include the required header file
(lib-logging-internal.h).

This requires the python-plugin-provider shared object to access a few
additional symbols not currently exposed by libbabeltrace, which
requires the removal of a few BT_HIDDEN.

I have also included fixes to the python-plugin-provider which I have
on hand.  However, it won't work until the Python bindings are up and
running, so I have marked it as skipped.

Change-Id: I9b46d91fc635d670fef2e4d3c8b32203ec34443f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1101
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoRemove clock_class_priority_map.py
Simon Marchi [Mon, 29 Apr 2019 21:03:44 +0000 (17:03 -0400)] 
Remove clock_class_priority_map.py

This concept no longer exists in the BT api, and therefore this file
won't be needed anymore.

Change-Id: Ib298f5463ee701be3a0a5b3d4b37b6e7ecf8d5b3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452469
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: headers: make static inline upcasts compatible with C++
Philippe Proulx [Sat, 27 Apr 2019 21:04:45 +0000 (17:04 -0400)] 
Fix: headers: make static inline upcasts compatible with C++

Issue
=====
There are many static inline functions which upcast a pointer from its
original type to another one known to be a parent. The functions upcast
with `(void *)` or `(const void *)`. While this works in C, it does not
in C++, which is more strict:

    In file included from install/include/babeltrace/babeltrace.h:75,
                     from test.cpp:1:

    install/include/babeltrace/trace-ir/field-class-const.h: In function
    ‘const bt_field_class_enumeration_mapping*
    bt_field_class_unsigned_enumeration_mapping_as_mapping_const(const
    bt_field_class_unsigned_enumeration_mapping*)’:

    install/include/babeltrace/trace-ir/field-class-const.h:100:9:
    error: invalid conversion from ‘const void*’ to ‘const
    bt_field_class_enumeration_mapping*’ [-fpermissive]

      return (const void *) mapping;

Solution
========
Use the new __BT_UPCAST() and __BT_UPCAST_CONST() macros to upcast
within headers. Those macros are defined in `babeltrace/types.h`. We use
static_cast<>() in C++ with the specific destination type, going through
`void *` or `const void *` to keep the same address.

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaac8e55635eb2f358a546c32bd886a484f5ebfeb
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452302
Reviewed-by: Simon Marchi <simon.marchi@polymtl.ca>
4 years agoFix: headers: add missing end of `extern "C"` curly brackets (for C++)
Philippe Proulx [Sat, 27 Apr 2019 21:03:50 +0000 (17:03 -0400)] 
Fix: headers: add missing end of `extern "C"` curly brackets (for C++)

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5f6277ce3075f26bec6507b7b26977d33aea858f
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452301
Reviewed-by: Simon Marchi <simon.marchi@polymtl.ca>
4 years agoFix: include/Makefile.am: add missing `babeltrace/ctf-writer/object.h`
Philippe Proulx [Sat, 27 Apr 2019 20:06:06 +0000 (16:06 -0400)] 
Fix: include/Makefile.am: add missing `babeltrace/ctf-writer/object.h`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I29700d6c62b0ebd910b6a6715ab7edbc2126168f

4 years agobt2: Rename files to use singular form
Simon Marchi [Fri, 26 Apr 2019 19:26:51 +0000 (15:26 -0400)] 
bt2: Rename files to use singular form

I am mildly annoyed that most Python files use the singular form of the
concept they are related too (component.py, event.py) but others use the
plural form (fields.py, values.py).

Change this to consistently use the singular.

Change-Id: I1a33c47ec45ef3359025e0a66f01eaefc09fecdf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452257
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: Mass clock_value -> clock_snapshot rename
Simon Marchi [Fri, 26 Apr 2019 19:08:33 +0000 (15:08 -0400)] 
bt2: Mass clock_value -> clock_snapshot rename

The clock_value concept has been renamed to clock_snapshot.  Do a mass
rename in the bt2 Python bindings and the associated tests.

Change-Id: I2b275f554c20a12a0f1891c4deed0046e4d3e8e6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452254
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: Mass field_types -> field_class rename
Simon Marchi [Wed, 3 Apr 2019 15:30:40 +0000 (11:30 -0400)] 
bt2: Mass field_types -> field_class rename

The concept of field_type has been renamed to field_class.  This patch
does a mostly mechanical rename across the Python bindings and their
tests.

Change-Id: I3c2a870262e3cfeddaec7d3565eb635a4c70d131
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452253
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: Mass notification -> message rename
Simon Marchi [Tue, 2 Apr 2019 18:03:30 +0000 (14:03 -0400)] 
bt2: Mass notification -> message rename

As the "notification" concept has been renamed to "message", I decided
to do a mass rename (including renaming files).  It's quite
straightforward and will reduce a little bit the noise in further
patches.

The changes were done mostly mechanically, but I verified them to make
sure it didn't go too wild (like changing "notifier" to "msgier", which
we wouldn't want).

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I6e6dec1234864400a2570a4726c32a1398cf42c0
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452232
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobt2: Sync native_bt_field_class.i with field-class-const.h
Simon Marchi [Fri, 26 Apr 2019 14:18:55 +0000 (10:18 -0400)] 
bt2: Sync native_bt_field_class.i with field-class-const.h

Commit

    2d97b62eea05 ("lib: have dedicated, unique unsigned and signed enum FC mapping objects")

Changed some declarations in field-class-const.h without doing the
corresponding changes in native_bt_field_class.i.  I am now seeing this
build error:

    bt2/native_bt_wrap.c: In function ‘_wrap_field_class_unsigned_enumeration_borrow_mapping_by_index_const’:
    bt2/native_bt_wrap.c:11087:3: error: unknown type name ‘bt_field_class_unsigned_enumeration_mapping_ranges’; did you mean ‘bt_field_class_unsigned_enumeration_mapping’?
       bt_field_class_unsigned_enumeration_mapping_ranges **arg4 = (bt_field_class_unsigned_enumeration_mapping_ranges **) 0 ;
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       bt_field_class_unsigned_enumeration_mapping

Change-Id: I897749a6a7fe5bd1c3c16b1ea9625820e77f112b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452225
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: have dedicated, unique unsigned and signed enum FC mapping objects
Philippe Proulx [Wed, 24 Apr 2019 05:00:45 +0000 (01:00 -0400)] 
lib: have dedicated, unique unsigned and signed enum FC mapping objects

This patch makes the enumeration field class mapping API aligned with
the structure field class member and variant field class option APIs. In
other words, a signed or an unsigned enumeration field class mapping is
now a dedicated type. An enumeration field class mapping object is
unique and always belongs to its parent field class.

bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const() and
bt_field_class_signed_enumeration_borrow_mapping_by_index_const() now
return borrowed enumeration field class mapping objects.

You can use
bt_field_class_unsigned_enumeration_mapping_as_mapping_const() to change
a signed or unsigned enumeration field class mapping into a generic
enumeration field class mapping. The API for a generic enumeration field
class mapping is:

    const char *bt_field_class_enumeration_mapping_get_label(
        const bt_field_class_enumeration_mapping *mapping);

    uint64_t bt_field_class_enumeration_mapping_get_range_count(
        const bt_field_class_enumeration_mapping *mapping);

You cannot create an enumeration field class mapping object: you still
map a name to a specific range with
bt_field_class_unsigned_enumeration_map_range() and
bt_field_class_signed_enumeration_map_range().

This patch also makes the `flt.lttng-utils.debug-info` and `sink.ctf.fs`
component classes use the updated API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iba5da648ca69ec0ca0c5df09a9f383dd4b1e3972
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/451996

4 years agotests/bindings/python: Mark all tests as skipped
Simon Marchi [Wed, 3 Apr 2019 18:08:18 +0000 (14:08 -0400)] 
tests/bindings/python: Mark all tests as skipped

This patch makes us skip all the Python bindings tests.  The goal is for
these commands to run with success (even though they doesn't actually test
anything):

    $ tests/bindings/python/bt2/test_python_bt2
    $ tests/bindings/python/babeltrace/test_python_babeltrace

The strategy will be to gradually fix the bindings and their tests, and
gradually remove those skip annotations.  At any point, we should be
able to run the testsuite with success, ensuring that we don't regress.

After this patch, "make check" is clean for me, with python bindings
enabled (--enable-python-bindings).

I am not sure what is still relevant in the python/babeltrace
directory, I suppose the ctf writer stuff still is.  I think we can sort
this out later.

Change-Id: I1169c255c0c7c29fa5de75a358c02c4cd57aae20
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452155
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobindings/python/bt2: Make the bt2 package importable
Simon Marchi [Thu, 25 Apr 2019 21:10:31 +0000 (17:10 -0400)] 
bindings/python/bt2: Make the bt2 package importable

This patch changes the minimum necessary to make the bt2 package
importable.  In other words, for this command to succeed:

    $ tests/utils/test_python_bt2_env python3 -c "import bt2"

In some cases, I've replaced some references to concepts that don't
exist with the new concepts (e.g. some NOTIFICATION_TYPE_* to
MESSAGE_TYPE_*).  In other cases, (e.g. fields.py and field_types.py),
it was easier to remove the code, knowing we'll add it back when
tackling the tests that require these files.

After this milestone, we'll be able to at least run some tests that
import the bt2 package, so we'll be able to make sure we don't regress
things while we fix others.

Change-Id: I930d5a4dd129777cb40c607670e27002bb727e39
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452154
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: Fix function name to match declaration
Simon Marchi [Thu, 25 Apr 2019 20:48:17 +0000 (16:48 -0400)] 
lib: Fix function name to match declaration

Commit

  c4cae502570e ("lib: Fix function name to match declaration")

used an erroneous name for a function definition, this patches fixes it.

Change-Id: I4190b60c9f6db62bf6b50fd095c402494d596a27
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452153
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoAdd env wrapper to facilitate importing the in-tree python bindings
Simon Marchi [Mon, 1 Apr 2019 19:46:57 +0000 (15:46 -0400)] 
Add env wrapper to facilitate importing the in-tree python bindings

The test_python_bt2 script sets up a special environment for running the
Python bindings tests.  Crucially, it sets up PYTHONPATH so we are able
to "import bt2" from a Python interpreter.  It can be difficult to
reproduce this environment exactly in an interactive shell, or when
trying to run a single test.

This patch introduces test_python_bt2_env, which can be used to run a
command in the same environment.  This command can be anything from a
single test run to a sub-shell.

Also, we expect that many Babeltrace tests will test some non-Python
features using Python, for convenience.  These tests will also need to
run in the right environment to be able to import the bt2 Python
package.  Therefore, I think it makes sense to put it under tests/utils.

Once the bindings and their tests work better, we should make
the test_python_bt2 script use test_python_bt2_env, to avoid the duplication, but
for now I prefer to leave it as-is.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I4e1655614756d638ef6bb9a4426719d4b754aa4b
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452152
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agobindings/python/bt2: Make the bt2 Python bindings build
Simon Marchi [Mon, 22 Apr 2019 15:17:23 +0000 (11:17 -0400)] 
bindings/python/bt2: Make the bt2 Python bindings build

This patch is just a little bit more than the bare minimum to make the
Python bindings build (that is, configure with --enable-python-bindings
and build).  It consists of sync'ing the .i SWIG interface definition
files with the corresponding headers.  It's possible that the interfaces
are incomplete, in which case they'll be adjusted in the a later pass.
For example, output parameters are currently not named in a way that
match the type maps.

For simplicity, I have included at the same time some other changes to
the .i files, such as adjusting the typemap definitions (in
native_bt.i).  The helper functions (such as at the bottom of
native_bt_componentclass.i) are also changed to the "final" form they
have on my development branch.  Even though these are not immediatly used,
they need to be changed for the bindings to build.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I87a438a692690639f956b214f878df65885ed78c

4 years agolib: Make bt_value_null a const pointer
Simon Marchi [Wed, 3 Apr 2019 16:08:11 +0000 (12:08 -0400)] 
lib: Make bt_value_null a const pointer

We probably don't want anything to change the value of this pointer,
which points to the only instance of BT_VALUE_TYPE_NULL,
bt_value_null_instance.  Therefore, declare it as a constant value.

It also helps a little bit the Python bindings: if we copy the
declaration verbatim to the .i file, without const, bt_value_null is
available through the special "cvar" global object (and can be
modified!).  With const, it becomes read-only, so can be accessed
directly as native_bt.value_null.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoctf: Add dash to stream name suffixes
Simon Marchi [Thu, 25 Apr 2019 15:00:02 +0000 (11:00 -0400)] 
ctf: Add dash to stream name suffixes

We add numerical suffixes to stream names, if needed, to make them
unique. For trace directories, we do something similar and decided to
format these suffixes with a dash to avoid confusion if the original
name ends with a number.  This patch does the same thing but for stream
names.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I3041fe98bbeb3c122d06e5fa54449ed6e55017bd
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452110
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoctf: Use environment fields provided by LTTng to make output trace path
Simon Marchi [Tue, 23 Apr 2019 13:32:58 +0000 (09:32 -0400)] 
ctf: Use environment fields provided by LTTng to make output trace path

Starting with version 2.11, the LTTng tracer includes in the trace
environment all the information necessary to rebuild the output path
that it itself uses when outputting traces.  This lets us recreate an
output path similar to what LTTng does when outputting ctf traces (with
the exception that we also add a level with the hostname, which LTTng
doesn't).

If the trace does not come from LTTng, or comes from LTTng < 2.11, we
keep using the same strategy: use a trace path based on the trace name,
which is itself based on the original directory.

This feature will especially be useful in conjunction with session
rotation: since the input trace is actually composed of multiple
traces/chunks, the trace name would otherwise be based on one particular
of these chunks.  With the environment values, we can recreate a path
that describes correctly the trace as a whole.  The output path is then
similar to what one would have been output by LTTng, if one had not used
the session rotation feature in the first place.

Change-Id: I03c0569869561ec11873b808c47d30196889cb36
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/451942
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agocli: put space after comma between array elements
Philippe Proulx [Thu, 25 Apr 2019 00:55:47 +0000 (20:55 -0400)] 
cli: put space after comma between array elements

This is more readable when looking at the output of `--run-args`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I75a4622fb2f2c864f4af1599c18044bb696c3307

4 years agoFix: test_convert_args: fix malformed test line
Philippe Proulx [Thu, 25 Apr 2019 00:50:39 +0000 (20:50 -0400)] 
Fix: test_convert_args: fix malformed test line

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia164a1703d12f0e3caff9e9d6fcd9a5c6deb58fd

4 years agotest_convert_args: test multiple leftover arguments
Philippe Proulx [Thu, 25 Apr 2019 00:38:13 +0000 (20:38 -0400)] 
test_convert_args: test multiple leftover arguments

When `babeltrace convert` is given multiple leftover arguments:

    babeltrace /path/to/trace1 /path/to/trace2 /path/to/trace3

it configures a single `src.ctf.fs` component with a `paths` array
parameter containing the three paths.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0c19c730bc276dba7160b9efcb72dc8077c078f5

4 years agoFix: test_convert_args: fix expected arguments
Philippe Proulx [Thu, 25 Apr 2019 00:34:12 +0000 (20:34 -0400)] 
Fix: test_convert_args: fix expected arguments

Changes:

* `src.ctf.fs` paths are given as an array now.

* What used to be `params=...` is now two arguments: `--params ...`.

* There's a new default parameter when instantiating a
  `src.ctf.lttng-live` component: `session-not-found-action="end"`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic08db60b280ca9babb1ddc21829392d14a0d3fd3

4 years agocli: mimic behavior of BT1 when trying to attach to live session
Francis Deslauriers [Wed, 24 Apr 2019 20:13:07 +0000 (16:13 -0400)] 
cli: mimic behavior of BT1 when trying to attach to live session

In Babeltrace 1, when trying to attach to a LTTng live session the
`babeltrace` command would exit with status 0 (SUCCESS) if it
successfully connected to the relay daemon _even if_ it did not find the
requested session.

To mimic the behavior of BT1, we set the `session-not-found-action`
parameter to "end". This makes the message iterator of an lttng-live
component return a END status if the requested session is not found
on the relay daemon and makes the cli return gracefully with SUCCESS.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3b3810f97c090d102fd30902fda37434f62d5c01

4 years agoplugins/ctf/fs-src: Session rotation support: merge traces with same uuid
Simon Marchi [Tue, 16 Apr 2019 20:16:01 +0000 (16:16 -0400)] 
plugins/ctf/fs-src: Session rotation support: merge traces with same uuid

This patch makes the src.ctf.fs component merge traces that have the
same UUID, with the intent of supporting traces output by LTTng's
session rotation feature.

When using this feature of LTTng, the user ends up with multiple traces
that are independent (with their own metadata and data files), except
for the fact that they share the same trace uuid.  The goal of this
patch is to make Babeltrace realize this and make all those traces
appear as a single trace.

The approach taken is to scan the search paths (passed as parameter to
the component) as usual and create a ctf_fs_trace for each found trace.
We then go over the list of traces in the component and merge those
having the same UUID.

Merging traces consists of merging corresponding data stream file groups
(ctf_fs_ds_file_group structs).  Two ctf_fs_ds_file_group structs are
corresponding if they have the same stream_id (aka stream_instance_id in
CTF) and stream class id.

Merging two ctf_fs_ds_file_group structs consists of merging their list
of ctf_fs_ds_file_info structs, making sure to keep the resulting list
sorted by begin timestamp.

Since the trace-info query also uses create_ctf_fs_traces, its behavior
is updated as expected.  Doing a trace-info on a directory containing
multiple traces with the same UUID will result in a single trace with
multiple files per stream.  A little drawback/inconsistency that will be
address later is that the trace object in the output has a single
"path", which is set to the path of one of the original traces.
Ideally, it should have also have a list of paths and list all the
paths of the "physical" traces that form this "logical" trace.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ib290cf08119f9be4344057b2544b4627eea3f450

4 years agocli, plugins/ctf/fs-src: Make src.ctf.fs accept multiple root paths
Simon Marchi [Tue, 23 Apr 2019 16:03:29 +0000 (12:03 -0400)] 
cli, plugins/ctf/fs-src: Make src.ctf.fs accept multiple root paths

A following patch will make it possible to process multiple traces that
share the same UUID as a single trace.  One requirement is to be able to
do this event when passing multiple arguments, like:

    babeltrace path1 path2 ...

With the current code, this instantiates two src.ctf.fs components, and
therefore makes it impossible to do this merging by UUID.

This patch therefore changes the design so that we only instantiate a
single src.ctf.fs component and pass an array with the paths.

We also need to make the trace-info query support receiving multiple
paths.  One reason is that in general, we want trace-info queries to
support the same parameters as the components.  A more pragmatic reason
is that it will need to do the same kind of UUID-merging anyway.  I
therefore made the trace-info query re-use more of the code used by the
component to locate and create the ctf_fs_trace list.  One difference
between the two usages is that in the case of the query, we don't want
to create IR streams or component ports.  I moved those outside of the
shared code path and made the component do that as a separate step.

One notable change in babeltrace.c is in set_stream_intersections.
We previously extracted the "path" parameter from the component creation
parameter, to make the query parameters.  Instead, we now directly pass
the component creation parameters to the query.  The idea is the same as
above, we want to pass the same parameters to the trace-info query as
what will be used to create the component, since it might alter how the
traces will be open, and therefore the results.

So in practice the changes boil down to:

- babeltrace-cfg-cli-args.c: Make it possible to serialize bt_value of
  type BT_VALUE_TYPE_ARRAY, so we can build the list of paths in a
  bt_value array, then serialize it to send it to "babeltrace run".
  Make it instantiate a single ctf component, this even simplifies the
  code a little bit.
- fs.c: Accept "paths" parameter with a list of paths, rather than
  "path" with a single path, iterate on that list to find traces and
  create trace objects just as before.  Separate creation or IR streams
  and component ports from the ctf_fs_trace creation.
- query.c: Re-use more of fs.c's functions to locate and create
  ctf_fs_trace objects.

There are no functional changes intended, except if you are the kind of
person to pass params by hand to the src.ctf.fs component.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Make append_parameter_to_args accept a bt_value value
Simon Marchi [Tue, 23 Apr 2019 15:16:00 +0000 (11:16 -0400)] 
cli: Make append_parameter_to_args accept a bt_value value

append_parameter_to_args is used to append a --params=KEY=VALUE argument
to a list of arguments.  It currently assumes that VALUE is a simple
string.  We will want to generalize this to support arrays (in the form
of a bt_value of type array).  This patch does a bit of refactoring in
preparation of that, making append_parameter_to_args accept a value of
type bt_value* instead of const char*.

append_string_parameter_to_args is introduced as a wrapper, for those
spots that still want to pass a simple string value.  It converts the
string to a temporary bt_value of type string.

No functional changes intended.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Remove support for --key and --value arguments
Simon Marchi [Tue, 9 Apr 2019 23:00:33 +0000 (19:00 -0400)] 
cli: Remove support for --key and --value arguments

There are currently two ways of passing parameters to the current
component on the Babeltrace command line:

  --params=KEY=VALUE
  --key KEY --value VALUE

The method with --params is more versatile, as VALUE can have different
types (string, number, bool).  The value in the --key/--value method is
always converted to a string.

This patch removes the less-versatile --key/--value way, in order to
keep only --params.

I have remove or updated references to --key/--value in man pages.  The
only remaining mention of --key/--value that I know of is in
babeltrace-log.c, which I was told is going to disappear anyway, so I
have left it.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Support arrays in parameters
Simon Marchi [Tue, 23 Apr 2019 14:14:08 +0000 (10:14 -0400)] 
cli: Support arrays in parameters

This patch adds support for arrays in the parameters one can pass to
components on the Babeltrace command line.  For example:

  --params="value=[1,2,\"Hello\"]"

When we are starting to parse a value and the token is a '[', we start
parsing it as an array.  We accept comma-separated values until we reach
the matching ']'. The code should be pretty self-explanatory/commented.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Adjust integer range check, replace magic numbers with constants
Simon Marchi [Tue, 23 Apr 2019 14:03:34 +0000 (10:03 -0400)] 
cli: Adjust integer range check, replace magic numbers with constants

The value (1ULL << 63) - 1), used for checking that integer values are
within range, actually mean INT64_MAX, so use that instead.

Also, the negative case is not quite right: the value -(INT64_MAX + 1),
-9223372036854775808, is within the range of a signed 64-bits number
(assuming two's complement), but is not accepted right now.  Adjust the
check so it accepts that value.

I tested this patch manually: we accept  -9223372036854775808 but reject
-9223372036854775809.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Refactor command line value parsing code
Simon Marchi [Tue, 23 Apr 2019 14:09:33 +0000 (10:09 -0400)] 
cli: Refactor command line value parsing code

This patch breaks out the code that parses values from the command line
to bt_value objects.  It introduces a new function which returns a
parsed value directly as a bt_value.

This enables the following patch to introduce support for arrays, by
having this function call itself recursively.

No functional changes intended.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agocli: Refactor handling of negative numbers
Simon Marchi [Mon, 22 Apr 2019 14:41:39 +0000 (10:41 -0400)] 
cli: Refactor handling of negative numbers

This patch breaks out the code that reads a number just after having
read the minus sign introducing a negative number.

Instead of keeping a state in the parser, and going through a new
iteration, we call the new function which returns a bt_value directly.

This enables the following patch to do a similar change, but for the
parsing of all values (which includes the parsing of negative numbers).
In turn, this will allow parsing values recursively, which is needed to
support array values.  Orthogonally, I think the code is easier to
follow this way.

No functional changes intended.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoFix: tests/Makefile.am: do not run missing `flt.utils.muxer`
Philippe Proulx [Wed, 24 Apr 2019 17:59:38 +0000 (13:59 -0400)] 
Fix: tests/Makefile.am: do not run missing `flt.utils.muxer`

This test does not exist anymore.

Most plugins will be tested in Python or even in Bash with a specific
testing sink component class.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoAdapt `src.ctf.lttng-live` to current API
Francis Deslauriers [Mon, 4 Mar 2019 16:02:10 +0000 (11:02 -0500)] 
Adapt `src.ctf.lttng-live` to current API

A `src.ctf.lttng-live` component now ensures the monotonic ordering of
the timestamps its outgoing messages. The component can receive messages
from multiples viewer session (UST 64bit, UST 32bit and/or Kernel) that
in turn may contain one or more traces that in turn may contain one or
more streams of messages. Messages from all these streams have to be
ordered into a single flow of messages where every message has a
timestamp equal or larger than the previous one.. This muxing is done by
tracking the next message of each of the live stream iterator and
returning the message with the smallest timestamp.

The live viewer sessions and everything required to get data and
metadata from the LTTng Relay daemon are now owned by the message
iterator and not the component as it was before.

Parameters
==========
The `url` mandatory string parameter controls the URL of the LTTng Relay
Daemon to which the component should register to received traces.

The `session-not-found-action` optional string parameter controls the
behavior of the component in case the requested session is not
configured on the LTTng Relay Daemon. The three accepted value of this
parameter are: "continue", "fail", and "end".

  continue: The message iterator will try to connect (or reconnect) to
  the requested session for ever.

  fail: The message iterator will return an ERROR status if the session
  is not available at the message iterator initialization stage and
  return END status when the session is no longer available.

  end: The message iterator always returns END status if the session is
  not found or is no longer available.

The `session-not-found-action` defaults to "continue" if not specified.

Future improvement
==================
Using a priority queue to order the messages would speed up the muxing
of messages.

Known limitation
================
If a new live stream iterator returns a message that has a timestamp
smaller (that happened before) than the last message forwarded
downstream but the `src.ctf.lttng-live` message iterator. The message
iterator will return with an error status. I am not sure if this
situation can happen in a single host configuration (which is the only
supported configuration).

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.text.pretty: print inactivity msg handling with BT_LOGD_STR
Francis Deslauriers [Mon, 22 Apr 2019 20:21:07 +0000 (16:21 -0400)] 
sink.text.pretty: print inactivity msg handling with BT_LOGD_STR

Instead of printing that the component received a message iterator
inactivity message to standard error; log this information with
BT_LOGD().

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agograph: Fix: bt_graph_configure() does not propagate errors
Francis Deslauriers [Mon, 1 Apr 2019 13:58:02 +0000 (09:58 -0400)] 
graph: Fix: bt_graph_configure() does not propagate errors

Issue
=====
When configuring the graph, message iterator initialize functions may fail
and return an error status (e.g. _STATUS_NOMEM and _STATUS_ERROR). Those
error status are not propagated back to the caller of
`bt_graph_configure()` function. The caller that will consider the graph
to be configured properly and run it will it assertions down the road.

Solution
========
Return `BT_GRAPH_STATUS_ERROR` if any of the sinks returned a non-OK
status from its `graph_is_configured()` function.

Known drawbacks
===============
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoFix: flt.lttng-utils.debug-info: leaking `bin_dir` char array
Francis Deslauriers [Wed, 24 Apr 2019 15:16:48 +0000 (11:16 -0400)] 
Fix: flt.lttng-utils.debug-info: leaking `bin_dir` char array

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoFix: flt.lttng-utils.debug-info: ".debug" extension not appended
Francis Deslauriers [Wed, 24 Apr 2019 14:54:31 +0000 (10:54 -0400)] 
Fix: flt.lttng-utils.debug-info: ".debug" extension not appended

Issue
=====
The g_strconcat() function returns a newly allocated string and does not
change the string in place as the code seems to assume. This results in
the call to g_strconcat() having no effects. Because of this, the
".debug" extension is not appended to the file name resulting in a
failure find the file on the file system.

Ignoring the return value of this call also results in the leaking of
the resulting char array.

Solution
========
Use g_snprintf() instead to concatenate the file name and its extension.

Known drawbacks
===============
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: field path: have a specific item for "current array element"
Philippe Proulx [Wed, 24 Apr 2019 04:19:06 +0000 (00:19 -0400)] 
lib: field path: have a specific item for "current array element"

This patch makes a field path object have a list of items, which are
unique objects, instead of simple member/choice indexes. One type of
item is an index item (which contains only a structure member or variant
choice index) while the other is a "current array element" item.

The previous algorithm to "walk" a field path from a known root field
or field class was (Python pseudocode):

    current_fc = root_fc
    i = 0

    while i < len(field_path):
        index = field_path[i]

        if type(current_fc) is in (StructureFieldClass, VariantFieldClass):
            current_fc = current_fc[index]
            i += 1
        else:
            current_fc = current_fc.element_field_class

As you can see, there's no special field path index to indicate that
we're in the current element of an array: you just pass through arrays
without "consuming" a field path index.

In TSDL, it can happen like this:

    fields := struct {
        struct {
            int abc;
            int len;
            string strings[len];
        } s[4];
    };

Currently, the field path of the `strings` dynamic array is:

    event payload: [0, 1]

With this patch, the same field path becomes:

    event payload: [0, <CUR>, 1]

and the walking algorithm above becomes:

    current_fc = root_fc

    for item in field_path:
        if type(current_fc) is in (StructureFieldClass, VariantFieldClass):
            assert(type(item) is IndexFieldPathItem)
            current_fc = current_fc[item.index]
        else:
            assert(type(item) is CurrentArrayElementFieldPathItem)
            current_fc = current_fc.element_field_class

or it could also be:

    current_fc = root_fc

    for item in field_path:
        if type(item) is IndexFieldPathItem:
            current_fc = current_fc[item.index]
        else:
            assert(type(item) is CurrentArrayElementFieldPathItem)
            current_fc = current_fc.element_field_class

There is no special case with this now more complete field path.

I also intend to have something like this in CTF 2. Currently, CTF 1.8
does not allow a relative field path to be rewritten as an absolute
field path if it's in an array. For example, you could not rewrite the
TSDL example above as:

    fields := struct {
        struct {
            int abc;
            int len;
            string strings[event.fields.s.len];
        } s[4];
    };

Babeltrace 1 does not accept this, so Babeltrace 2 does not either, and
I don't think CTF is designed this way. I think it's limiting, so I'm
making this patch to accommodate CTF 2 in the future.

This patch also opens the door to having other types of field path items
in the future, like any element within an array (as long as it's before
the requesting dynamic array or variant field), so that you could have:

    event payload: [1, 3, 0]
                    ^  ^  ^-- first member of a structure
                    |  `----- fourth element of an array
                    `-------- second member of a structure

This patch also makes the `flt.lttng-utils.debug-info` and `sink.ctf.fs`
component classes use the modified API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: bfcr_get_sequence_length_cb(): do not set text array's length
Philippe Proulx [Tue, 23 Apr 2019 23:54:42 +0000 (19:54 -0400)] 
Fix: bfcr_get_sequence_length_cb(): do not set text array's length

Issue
=====
In `msg-iter.c`, bfcr_get_sequence_length_cb() gets called when starting
the decoding of any sequence, including text sequences. However, text
arrays are translated into trace IR string field classes.

bfcr_get_sequence_length_cb() calls bt_field_dynamic_array_set_length()
unconditionally, but its field argument can be a string field at this
point. This is a precondition break.

Solution
========
In bt_field_dynamic_array_set_length(), only call
bt_field_dynamic_array_set_length() if the CTF IR field class is NOT a
text sequence. I'm also adding an assertion to confirm that the trace IR
field is a dynamic array field.

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: `tests/Makefile.am`: do not run missing tests
Philippe Proulx [Tue, 23 Apr 2019 22:00:34 +0000 (18:00 -0400)] 
Fix: `tests/Makefile.am`: do not run missing tests

Test sources were removed, but they are still mentioned in this file, so
`make check` cannot find them.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: `tests/ctf-traces/succeed` traces: change CTF version from 0.1 to to 1.8
Philippe Proulx [Tue, 23 Apr 2019 21:57:44 +0000 (17:57 -0400)] 
Fix: `tests/ctf-traces/succeed` traces: change CTF version from 0.1 to to 1.8

This version of CTF, 0.1, never really existed. Also, the first lines of
the `metadata` files changed by this patch already contain `CTF 1.8`,
indicating that this is a bug in the `trace` block.

Somehow Babeltrace 1 is less strict than Babeltrace 2 and accepts those
traces. We take the deliberate decision to refuse them.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: `test_packet_seq_num.in`: change expected disc. packets messages order
Philippe Proulx [Tue, 23 Apr 2019 21:46:00 +0000 (17:46 -0400)] 
Fix: `test_packet_seq_num.in`: change expected disc. packets messages order

Issue
=====
The `test_packet_seq_num` test expects that Babeltrace reports 3, 2, and
1 discard packets in three different messages for CTF trace
`2_streams_lost_in_2`. Babeltrace 1 reports this, but Babeltrace 2
reports 2, 3, and 1.

I believe it's a bug in Babeltrace 1 because it also reports time ranges
which cover the packets which have an unexpected sequence number.

For example, Babeltrace 1:

    [warning] Tracer lost 3 trace packets between [06:15:09.000000090]
    and [06:15:09.000000110] in trace UUID
    eb5045f7b471488eb963221ddf423a7, at path:
    "../ctf-traces/packet_seq_num/2_streams_lost_in_2", within stream id
    0, at relative path: "test_stream_1". You should consider recording
    a new trace with larger buffers or with fewer events enabled.

Babeltrace 2:

    WARNING: Tracer discarded 3 packets between [06:15:09.000000090] and
    [06:15:09.000000091] in trace "2_streams_lost_in_2" (UUID:
    eb5045f7-b471-488e-b963-0221ddf423a7) within stream
    "/home/eepp/dev/babeltrace/tests/ctf-traces/packet_seq_num/2_streams_lost_in_2/test_stream_1"
    (stream class ID: 0, stream ID: 1).

The `test_packet_seq_num` test does not check the reported time ranges,
but this shows that the packet sequence number check might not be done
at the same time in Babeltrace 1 and Babeltrace 2. Because the test
trace contains two data streams with an intersection, and packets were
discarded in this intersection, the order of the warnings is not
guaranteed to be the same.

The time ranges reported by Babeltrace 2 are correct, however. In the
example above, it's okay to report that three packets were discarded
between 06:15:09.000000090 and 06:15:09.000000110, but it's even more
precise to report that they were discarded between 06:15:09.000000090
and 06:15:09.000000091. The time range of the packet with an unexpected
sequence number is 06:15:09.000000091 to 06:15:09.000000110.

Solution
========
Change the test so that it expects 2, 3, and 1 now.

Known drawbacks
===============
Some incompatibility with Babeltrace 1 regarding the order of the
warnings printed by `sink.text.pretty`. However, the locations and the
time ranges of the messages in Babeltrace 2's output are correct.

Most tools and scripts which rely on Babeltrace's text output only check
if there's something (anything) written to the standard error stream
anyway to detect a problem. LTTng analyses is one of those.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: flt.utils.trimmer: accept inited streams ending without other messages
Philippe Proulx [Tue, 23 Apr 2019 21:38:20 +0000 (17:38 -0400)] 
Fix: flt.utils.trimmer: accept inited streams ending without other messages

Issue
=====
It is possible that, for a given stream, an `flt.utils.trimmer`
component receives the stream beginning and stream beginnin activity
messages, and then it needs to be ended. In this case,
`sstate->stream_act_end_ns_from_origin` is never set, so we hit the
assertion.

Solution
========
When ending a stream and when `sstate->stream_act_end_ns_from_origin` is
not set for this stream, use the trimming range's end time as the stream
activity end time.

If `sstate->stream_act_end_ns_from_origin` is not set at this point,
then we know the stream is currently active, so it is safe to use a
specific time as its activity end time. If the last received message for
this stream was a stream activity end message, then we don't reach this
code because it's conditional to
`!sstate->last_msg_is_stream_activity_end`.

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: cli: `flt.utils.trimmer` now expect the `gmt` parameter
Philippe Proulx [Tue, 23 Apr 2019 21:37:57 +0000 (17:37 -0400)] 
Fix: cli: `flt.utils.trimmer` now expect the `gmt` parameter

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoRemove `test_bt_message_iterator`
Philippe Proulx [Tue, 23 Apr 2019 20:40:08 +0000 (16:40 -0400)] 
Remove `test_bt_message_iterator`

This test does not work anymore because some message iterator
postconditions changed. Instead of taking time to fix it now, it will be
much faster for me to rewrite it correctly in Python once we have
working bindings.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: cli: Acquire reference on bt_value_null while parsing args
Simon Marchi [Thu, 18 Apr 2019 18:00:29 +0000 (14:00 -0400)] 
Fix: cli: Acquire reference on bt_value_null while parsing args

In bt_config_query_from_args, we initialize "params" to point to
bt_value_null without acquiring a reference:

    bt_value *params = bt_value_null;

When handling OPT_PARAMS, lower, we call "put" on it before assigning
params to something else:

    bt_value_put_ref(params);

This causes bt_value_null's refcount to drop to 0 and its release to be
called (which should never happen, since its refcount is initialized to
1).  This warning is shown:

    $ ./cli/babeltrace query
    ...
    04-18 13:56:12.267 10081 10081 W VALUES bt_value_null_instance_release_func@value.c:73 Releasing the null value singleton: addr=0x7f882eaf1b60

Fix it by acquiring a new reference in the beginning.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoflt.lttng-utils.debug-info: cleanup: create dedicated msg_iter destroy function
Francis Deslauriers [Wed, 17 Apr 2019 19:55:47 +0000 (15:55 -0400)] 
flt.lttng-utils.debug-info: cleanup: create dedicated msg_iter destroy function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agotests: remove unused automake variable
Francis Deslauriers [Wed, 17 Apr 2019 18:38:10 +0000 (14:38 -0400)] 
tests: remove unused automake variable

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoFix: lib: Mismatch in function declarations and definitions
Francis Deslauriers [Tue, 16 Apr 2019 20:45:57 +0000 (16:45 -0400)] 
Fix: lib: Mismatch in function declarations and definitions

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: Don't copy trace class UUID to output trace class
Francis Deslauriers [Wed, 17 Apr 2019 20:07:46 +0000 (16:07 -0400)] 
flt.lttng-utils.debug-info: Don't copy trace class UUID to output trace class

A `flt.lttng-utils.debug-info` component creates an output trace class
that may be different that of the input trace class, so the UUID should
not be copied. In fact, we don't need a UUID at this point. the sink
component can decide to add one later.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: Implement file descriptor cache
Francis Deslauriers [Wed, 3 Apr 2019 17:06:08 +0000 (13:06 -0400)] 
flt.lttng-utils.debug-info: Implement file descriptor cache

A `flt.lttng-utils.debug-info` component has to open files in order to
do the address resolving when processing a trace. Those file descriptors
are currently associated with a bin_info structure which are stored in a
hash table for each vpid. If, in the same trace, a binary file is loaded
by more than one process, that binary file will be opened twice. This
can create a file descriptor exhaustion problem on long running traces
if the same UST apps are run repeatedly.

This commit implements a file descriptor caching feature to reuse file
descriptors pointing to the same files.

After creating the file descriptor cache (fdcache), users must use the
following two functions to get and put handles to file descriptors:
  struct fd_handle *fd_cache_get_handle(struct fd_cache *fdc, char *path);
  void fd_cache_put_handle(struct fd_cache *fdc, struct fd_handle *handle);

The fd_handles are reference counted internally and their corresponding
file descriptors are closed when the refcount reaches zero.

Files are compared based on the hashed values of inode and device number
rather than solely on the path. This is needed to make sure that a file
opened previously has not changed. This is more likely to happen when
processing a lttng-live trace where the following scenario can happen
and must be supported:
  1. Binary v1 is executed,
  2. Trace data received by debug-info component,
  3. Handle 1 is taken on the bin_a v1 file,
  4. Addresses resolved using handle 1,
  5. Binary is modified,
  6. Binary v2 is compiled,
  7. Binary v2 is executed,
  8. Trace data received by debug-info component,
  9. Handle 2 is taken on the bin_a v2 file,
  10. Addresses resolved using handle 2.

Limitation
----------
It's still be possible to exhaust file descriptors in traces with a
large number of UST apps with no binary file overlap. If this becomes a
problem, we may consider devising an utility to close least recently
used files and reopening file descriptors for later used.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoCleanup: Move `debug-info` in its own sub-directory
Francis Deslauriers [Wed, 3 Apr 2019 16:56:17 +0000 (12:56 -0400)] 
Cleanup: Move `debug-info` in its own sub-directory

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoFix: flt.lttng-utils.debug-info: Error in src line reporting
Francis Deslauriers [Thu, 28 Mar 2019 22:20:52 +0000 (18:20 -0400)] 
Fix: flt.lttng-utils.debug-info: Error in src line reporting

Issue
=====
A `debug-info` component does not print the `src` field of a tracepoint
properly when tracepoint is within a for loop.

  #include "tp.h"
  int main(int argc, char *argv[])
  {
      tracepoint(my_app, empty);
      for(int i = 0; i < 1; i++) {
          tracepoint(my_app, empty);
      }
      return 0;
  }

The problem derives from the DWARF information generated by the
compiler. The compiler may place the DWARF content of the for loop in
`DW_TAG_lexical_block` which the current `debug-info` design doesn't
expect.

Here is a summarized version of DWARF tree containing the first
tracepoint in the code above:
  DW_TAG_subprogram
    DW_TAG_inlined_subroutine
      /* tracepoint callsite info */

Here is a summarized version of the DWARF tree containing the tracepoint
in the for loop:
  DW_TAG_subprogram
    DW_TAG_lexical_block
      DW_TAG_inlined_subroutine
       /* tracepoint callsite info */

The current implementation doesn't expect the presence of a
`DW_TAG_lexical_block` entry as child of the `DW_TAG_inlined_subroutine`
entry and won't look any further down that branch to find the source
information for the current tracepoint. This results in the component
not finding the line number for such callsite and thus leaving the `src`
field empty. Also, on some occasions, the `src` field would contain the
tracepoint definition location (e.g. "tp.h:12") rather then the actual
callsite of that tracepoint.

Solution
========
When iterating over the Debugging Information Entries, if the current
entry contains the address to resolve _but_ is not a of the type
`DW_TAG_inlined_subroutine` try to iterate over the children of that
entry.

Known drawbacks
===============
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: cleanup: remove usage old struct name
Francis Deslauriers [Tue, 16 Apr 2019 21:15:57 +0000 (17:15 -0400)] 
flt.lttng-utils.debug-info: cleanup: remove usage old struct name

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: cleanup: only print debug message on error
Francis Deslauriers [Tue, 16 Apr 2019 21:14:29 +0000 (17:14 -0400)] 
flt.lttng-utils.debug-info: cleanup: only print debug message on error

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: use glib memory and string functions
Francis Deslauriers [Wed, 27 Mar 2019 14:44:05 +0000 (10:44 -0400)] 
flt.lttng-utils.debug-info: use glib memory and string functions

- Change use of glibc's malloc() to glib's g_new0() to follow the rest of
  the project.

- Change use of glibc string functions to their glib equivalent.

- Remove uses of GNU extension of conditional expressions with omitted
  operands as it would only be useful if the evaluation of the condition
  had side effects which it doesn't. Let's prefer code simplicity.

[0]:  https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Conditionals.html

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.ctf.fs: Remove unused function
Francis Deslauriers [Thu, 18 Apr 2019 14:12:24 +0000 (10:12 -0400)] 
sink.ctf.fs: Remove unused function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoplugins/ctf: Remove unused uuid-related fields in struct ctf_fs_metadata
Simon Marchi [Thu, 11 Apr 2019 19:48:30 +0000 (15:48 -0400)] 
plugins/ctf: Remove unused uuid-related fields in struct ctf_fs_metadata

They are unused.  The corresponding fields holding the metadata uuid are
in struct ctf_metadata_decoder, while the fields holding the trace class
uuid are in ctf_trace_class.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years ago.editorconfig: add `charset = utf-8`
Philippe Proulx [Tue, 16 Apr 2019 17:02:38 +0000 (13:02 -0400)] 
.editorconfig: add `charset = utf-8`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoAdd .editorconfig file
Simon Marchi [Tue, 16 Apr 2019 12:08:18 +0000 (08:08 -0400)] 
Add .editorconfig file

This file helps editors set the indentation (and other whitespace)
settings correctly to match the project's coding style.

For now I have just put some simple settings for C, Swig interface and
Python files, but we can add more as needed.

See here for more details:

    https://editorconfig.org/

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoRemove babeltrace 1 Python bindings and tests
Simon Marchi [Fri, 29 Mar 2019 22:18:21 +0000 (18:18 -0400)] 
Remove babeltrace 1 Python bindings and tests

We previously had the goal of providing the Babeltrace 1 Python API (the
babeltrace module) on top of the Babeltrace 2 Python API (the bt2
module).

It was decided that this is no longer required, those who have scripts
working against the Babeltrace 1 API will have to keep using Babeltrace
1.

A factor that influenced this decision is that it would be difficult to
keep the exact same behavior as Babeltrace 1 had, and therefore
guarantee that scripts will keep working.  For example, CTF headers
(event headers or packet headers) are not accessible in trace-ir.  So if
a script relied on reading some header fields, the best we could do
would be to simulate the value of some well-known header fields.  For
example, it would be possible to simulate the timestamp field of an
event header.  However, things like a packet's content_size and
packet_size would be more difficult.

So instead of putting efforts doing something that works halfway, it was
decided that such scripts would have to keep using Babeltrace 1.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoRemove stale trace-ir test files
Simon Marchi [Fri, 29 Mar 2019 23:04:50 +0000 (19:04 -0400)] 
Remove stale trace-ir test files

These test files test things that are now pre-conditions in the library,
that used to throw exceptions.

We could in theory keep testing these cases (verify that the
precondition failure is correctly caught, when in dev mode), but we
would have to change the test strategy completely.  It's not really a
priority, so for now, just remove them.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoBT_ASSERT(): update rendering
Philippe Proulx [Fri, 12 Apr 2019 21:15:38 +0000 (17:15 -0400)] 
BT_ASSERT(): update rendering

* Move flip-table emoji at the beginning.
* Make flip-table emoji compatible with terminals which do not support
  combining diacritics.
* Colorize file name, line number, and function name independently.
* Add `()` after function name.
* Make the whole "Assertion `...` failed." red, but the message itself
  bold.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoRe-implement BT_ASSERT without using the assert macro
Simon Marchi [Mon, 1 Apr 2019 15:55:33 +0000 (11:55 -0400)] 
Re-implement BT_ASSERT without using the assert macro

BT_ASSERT is currently defined using the assert macro.  If NDEBUG is
inadvertently defined, BT_ASSERT has no effect.  This is quite
unfortunate, since a user who has defined BABELTRACE_DEBUG_MODE to 1
probably wants BT_ASSERT to be effective.

This problem was encountered while building the Python bindings, where
the distutils native code builder is passing -DNDEBUG to the compiler.
The BT_ASSERT macro usages in these files were found to be ineffective.

This patch avoids this situation by making BT_ASSERT call our own
handler if the assertion fails.  This also has the advantage of letting
us personalize the behavior on assertion failures.  The presence of the
so-called Lenny Face having absolutely no regards for the furniture is a
good example of this (and was a requirement coming from Philippe
Proulx).

Removing the inclusion of assert.h in assert-internal.h revealed a few
spots that use the assert macro without including assert.h, so they were
adjusted accordingly.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoAdjust bt_component_borrow_class to match declaration
Simon Marchi [Mon, 1 Apr 2019 20:01:08 +0000 (16:01 -0400)] 
Adjust bt_component_borrow_class to match declaration

Rename it to bt_component_borrow_class_const and constify return type,
to match declaration in graph/component-const.h.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoSmall fixes to include/
Simon Marchi [Mon, 1 Apr 2019 16:17:43 +0000 (12:17 -0400)] 
Small fixes to include/

* Function bt_component_filter_borrow_from_self is declared, but does not
  actually exist.

* Parameters to bt_self_component_{get,set}_data are named "private",
  which is the old naming scheme.  Change that to self.

* bt_component_graph is typedef'ed to struct bt_component_graph, which
  doesn't actually exist.  struct bt_graph exists, and there's already a
  typedef for it.

4 years agoctf-writer: Split clock and clock-class declarations and definitions
Francis Deslauriers [Tue, 17 Apr 2018 14:27:31 +0000 (10:27 -0400)] 
ctf-writer: Split clock and clock-class declarations and definitions

Split the clock_class functions of ctf-writer in its own header file.
clock_class deserves it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoAdapt `sink.ctf.fs` to current API
Philippe Proulx [Fri, 8 Mar 2019 16:06:38 +0000 (11:06 -0500)] 
Adapt `sink.ctf.fs` to current API

This patch is a complete rewrite of the `sink.ctf.fs` component class to
work with the current library's API.

Changes
=======
A `sink.ctf.fs` component does not use the CTF writer API anymore: it
tracks its own traces and streams, and writes data thanks to the common,
internal ctfser API (also used by CTF writer).

On the metadata side, the component class has its own CTF IR data
structures. They are based on the common CTF source IR data structures,
but they have additional fields and otherwise contain only what's needed
for a `sink.ctf.fs` component to work.

A `sink.ctf.fs` component systematically "protects" structure FC member
and variant FC option names with a leading `_`. This is suggested by
TSDL 1.8. Because of this, any enumeration FC label could be what
selects a following variant FC option, so enumeration FC labels are also
escaped with `_`. This is a temporary measure which matches the
behaviour of `src.ctf.fs` and `src.ctf.lttng-live`. We should solve this
at the API level later.

If the component fails to resolve the length FC of a dynamic array FC or
the selector FC of a variant FC, it falls back to creating its own
length FC or selector FC just above the requesting FC, within the same
structure FC, giving it a name which avoids any clash with other
members. Here's an example (trace IR, as TSDL):

    struct {
        struct {
            integer { size = 8; } len;
        } s;
        string str[s.len];
    }

This layout is perfectly valid from the trace IR's point of view.
However it is known to fail in Babeltrace 1 and Trace Compass (but is
accepted by Babeltrace 2), so the actual TSDL output for this becomes:

    struct {
        struct {
            integer { size = 8; } _len;
        } _s;
        integer { size = 32; } ___str_len;
        string { encoding = UTF8; } _str[___str_len];
    }

The same goes for a variant FC's selector FC:

    struct {
        struct {
            enum : integer { size = 8; } {
                A = 1,
                B = 5,
                C = 17 ... 24
            } tag;
        } s;
        variant <s.tag> {
            integer { size = 8; } A;
            string B;
            struct { } C;
        } var;
    }

becomes:

    struct {
        struct {
            enum : integer { size = 8; } {
                "_A" = 1,
                "_B" = 5,
                "_C" = 17 ... 24,
            } _tag;
        } _s;
        enum : integer { size = 16; } {
            "_A" = 0,
            "_B" = 1,
            "_C" = 2,
        } ___var_tag;
        variant <___var_tag> {
            integer { size = 8; } _A;
            string { encoding = UTF8; } _B;
            struct { } _C;
        } _var;
    }

This way we don't lose the original length/selector field value while
still writing the dynamic array/variant field.

A generated dynamic array FC's length FC is a 32-bit unsigned integer FC
(should be enough) while a generated variant FC's selector FC is a
16-bit unsigned enumeration FC.

A `sink.ctf.fs` component writes its events to the appropriate streams
as it receives them, as opposed to CTF writer which flushes a whole
packet when calling bt_ctf_stream_flush(). This means a packet's total
size is not limited to the available memory.

A `sink.ctf.fs` component generates a new trace UUID instead of using
the original trace class's UUID. The logic behind this is that there is
no way to know that the received trace and streams match exactly the
original trace and streams (the source and filters can modify them), so
systematically using the original UUID could lead to two different CTF
traces having the same UUID.

A `sink.ctf.fs` component writes the metadata file of a given CTF trace
and closes it when the upstream message iterator ends or when the trace
is destroyed. The component does not take a trace or trace class
reference: it registers a trace destruction listener so that it can free
the resources associated to a trace (and its streams) as soon as it's
destroyed. Also, it frees the resouces associated to a given stream when
getting a stream end message for it.

The way output directory paths and stream file names are created is
unchanged from the previous version. The `assume-single-trace` parameter
still exists.

There are three new parameters:

`ignore-discarded-events` (boolean):
    Ignore discarded events messages. This can be useful because there
    are limitations (see below) regarding where discarded events
    messages can be in the message flow, and what their beginning and
    end times can be.

`ignore-discarded-packets` (boolean):
    Ignore discarded packets messages. This can be useful because there
    are limitations (see below) regarding where discarded packets
    messages can be in the message flow, and what their beginning and
    end times can be.

`quiet` (boolean):
    Do not print anything. When the component is not quiet, it prints a
    message to the standard output every time it creates a complete CTF
    trace with the absolute path to it.

Known limitations
=================
This component class is not complete, in that it does not support all
the features of Babeltrace 2. For most cases, there should be no problem
using it to write streams created by a `src.ctf.fs` or
`src.ctf.lttng-live` component.

As of this patch, the known limitations are:

* Only names which are valid in TSDL are supported. This applies to:

  * Trace class environment keys.
  * Structure FC member names.
  * Variant FC option names.
  * Clock class names.

* The value type of a trace class environment entry must be integer or
  string.

* Unknown stream clocks are not supported.

* Stream activity messages are ignored.

* Discarded events and packets messages must occur between packets.

* There must not be more than one discarded events message or more than
  one discarded packets message between packets.

* The time range of a discarded events message must be from the last
  packet's end time to the next packet's end time, except when it occurs
  before the first packet of a given stream, where its beginning time
  must be the first packet's beginning time.

* The time range of a discarded packets message must be from the last
  packet's end time to the next packet's beginning time.

All the constraints above are checked as soon as possible and, when one
is not satisfied, the component fails with a detailed error.

The very strict and very CTF-ish limitations regarding discarded events
and packets messages are the reason why I added the aforementioned
`ignore-discarded-events` and `ignore-discarded-packets` parameters.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoctfser: have dedicated signed/unsigned integer writing functions
Philippe Proulx [Thu, 11 Apr 2019 13:21:24 +0000 (09:21 -0400)] 
ctfser: have dedicated signed/unsigned integer writing functions

Most of the time there's an external check for signedness anyway, so it
is redundant to pass the signedness to the writing function only for it
to evaluate it again.

In `lib/ctf-writer/fields.c`, the signedness check is now peripheral to
the ctfser writing function.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.052709 seconds and 5 git commands to generate.