babeltrace.git
4 years agoFix: Unmap before truncating
Jonathan Rajotte [Wed, 19 Jun 2019 17:28:14 +0000 (13:28 -0400)] 
Fix: Unmap before truncating

The mmap/mman compat layer for mingw uses the CreateFileMapping
and UnmapViewOfFile thus implicitly imposes an order for truncation and
ummapping [1].

For truncation calls, the underlying windows API call is SetEndOfFile.
This function requires that the file be unmapped before being called [1].

[1]
  If CreateFileMapping is called to create a file mapping object for
  hFile, UnmapViewOfFile must be called first to unmap all views and
  call CloseHandle to close the file mapping object before you can call
  SetEndOfFile.

[1] https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setendoffile#remarks

Change-Id: Id4713ca3af612baa24e1fa4a749384eab452598a
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1519
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
4 years agofix: Add missing stdint include on Windows
Michael Jeanson [Mon, 17 Jun 2019 16:54:48 +0000 (12:54 -0400)] 
fix: Add missing stdint include on Windows

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I3e1369e282360401a6e0c0516828068ea15de780
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1478
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agofix: test_trimmer on macOs and Solaris
Michael Jeanson [Mon, 17 Jun 2019 16:10:34 +0000 (12:10 -0400)] 
fix: test_trimmer on macOs and Solaris

The 'wc' tool on BSD based system adds leading spaces to it's output,
which breaks the quoted compare. Use bash parameter expansion to trim all
spaces from the 'num_events' variable.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I15aef8c6987e40bcb018f32c7c094eabbc3d83c3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1476
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 years agolib: remove BT_LIB_LOG*() macro usage comment
Philippe Proulx [Fri, 14 Jun 2019 21:24:49 +0000 (17:24 -0400)] 
lib: remove BT_LIB_LOG*() macro usage comment

This is explained in `CONTRIBUTING.adoc` now.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I76ed90889f4648311735b0c66389c82b2a1cf31b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1447
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoUpdate `CONTRIBUTING.adoc`
Philippe Proulx [Sat, 15 Jun 2019 18:08:28 +0000 (14:08 -0400)] 
Update `CONTRIBUTING.adoc`

Changes:

* Change to Asciidoctor format. This is what GitHub uses, so this guide
  is correctly converted on GitHub.

* Update reference count section's terminology and function names.

* Update logging section:

  * Reorganize sections, making guides explicit.

  * Header paths.

  * More details about the available log levels.

  * Library-specific logging statement macros (more or less copied from
    `src/lib/logging.h`).

  * Component-specific logging statement macros.

  * Have clear guides on how to instrument generic, library, and
    component class C source and header file

  * More details about which log level to choose.

  * More details about which logging tag to choose.

Removing the `CONTRIBUTING.html` global Makefile target as we cannot
use Asciidoc to build `CONTRIBUTING.adoc` anymore.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I98effa1fb087274c453014d95115d471b5b115ad
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1446
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: add comment about why `bt_lib_log_level` is exported
Philippe Proulx [Wed, 19 Jun 2019 07:11:36 +0000 (03:11 -0400)] 
lib: add comment about why `bt_lib_log_level` is exported

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic3dd3ff9cb6f39ac369a55c06ef9a752d60d7fc7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1512
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: use `LIBBABELTRACE2_INIT_LOG_LEVEL` env. var. to initialize log level
Philippe Proulx [Wed, 19 Jun 2019 07:03:38 +0000 (03:03 -0400)] 
lib: use `LIBBABELTRACE2_INIT_LOG_LEVEL` env. var. to initialize log level

Use the `LIBBABELTRACE2_INIT_LOG_LEVEL` environment variable instead of
`BABELTRACE_LOGGING_GLOBAL_LEVEL` to make it very clear that it's about
the library, and not related to the individual component log levels, for
example.

`INIT` is in the name to indicate that it's only the initial log level;
the library user can still change it at run time with
bt_logging_set_global_level(), while the other log level environment
variables, `BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL` and
`BABELTRACE_PYTHON_BT2_LOG_LEVEL`, are used to set the definitive log
levels of those modules.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibf580bed6c30d88b4fbe3aed20f38cc969bc9295
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1511
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc.ctf.fs: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Wed, 19 Jun 2019 06:38:56 +0000 (02:38 -0400)] 
src.ctf.fs: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iee65b871881b4719d429b6343e3a7e437bac732c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1510

4 years agosrc.ctf.fs: honor component's initial log level
Philippe Proulx [Wed, 19 Jun 2019 06:14:39 +0000 (02:14 -0400)] 
src.ctf.fs: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I75064d71438939a351748671534efcdf83059192
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1509
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc.ctf.lttng-live: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Wed, 19 Jun 2019 05:42:10 +0000 (01:42 -0400)] 
src.ctf.lttng-live: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9fe4f0ca7e6c061e90a3c46019e9e0913f737842
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1508
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.ctf.fs: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Tue, 18 Jun 2019 19:20:23 +0000 (15:20 -0400)] 
sink.ctf.fs: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1b337c6fb7c38def67cd5418c96df2df6faa020e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1502
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.text.details: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Tue, 18 Jun 2019 18:58:17 +0000 (14:58 -0400)] 
sink.text.details: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If44884543ec8e79ef4f940955033c991d1112ecb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1501
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.text.details: honor component's initial log level
Philippe Proulx [Tue, 18 Jun 2019 18:48:54 +0000 (14:48 -0400)] 
sink.text.details: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If24cf10be949c4e637b4677b9780c00a58e14df2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1500
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years ago`ctf` plugin: metadata: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Tue, 18 Jun 2019 18:38:53 +0000 (14:38 -0400)] 
`ctf` plugin: metadata: use BT_COMP_LOG*() instead of BT_LOG*()

Because we need to pass around the log level and the self component
pointer at several places within the files of this directory, this patch
adds a new internal `struct meta_log_config` which contains both and can
be passed as a single parameter and contained as a single member. It is
not meant to be known by anything calling the functions from files
outside this directory.

The generated parser and lexer can't use the BT_COMP_LOG*() macros
because they lack contextual data to access the self component pointer,
so they are left as is.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifa95256e7931416b890e8da0bb7c2552f396a8d2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1499

4 years ago`ctf` plugin: `bt_msg_iter`: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Tue, 18 Jun 2019 17:50:28 +0000 (13:50 -0400)] 
`ctf` plugin: `bt_msg_iter`: use BT_COMP_LOG*() instead of BT_LOG*()

As of this patch, the users of `bt_msg_iter` set the new self component
parameter to `NULL` as this work is reserved for a following patch.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I98328d43e0f67d1c4b1cf5493fa9c9cd02a32393
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1498
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years ago`ctf` plugin: `bt_bfcr`: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Tue, 18 Jun 2019 17:35:19 +0000 (13:35 -0400)] 
`ctf` plugin: `bt_bfcr`: use BT_COMP_LOG*() instead of BT_LOG*()

As of this patch, the only user of `bt_bfcr` is `bt_msg_iter`, which
sets the new self component parameter to `NULL` because it's not
available at this point (work reserved for a following patch).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Idcdbc21f0d6ab3062e4c9350228456bdfdeb23cf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1497

4 years agosink.ctf.fs: honor component's initial log level
Philippe Proulx [Tue, 18 Jun 2019 17:24:33 +0000 (13:24 -0400)] 
sink.ctf.fs: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5381ab04b9f2e3611c5f08006896a30e63451635
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1496
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 years agosrc.ctf.lttng-live: honor component's initial log level and query LL
Philippe Proulx [Tue, 18 Jun 2019 05:22:38 +0000 (01:22 -0400)] 
src.ctf.lttng-live: honor component's initial log level and query LL

Except for `viewer-connection.c` which is pretty consistent in having a
named "viewer connection" instance in each function, the other files
deal with too many objects/concepts to have a systematic expression to
identify the log level, so they use local `log_level` variables.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I102408375d4d3d2df21c756b6581c642ece77ff1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1494
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib/object.h: log conditionally to `BT_OBJECT_DONT_LOG` undefined
Philippe Proulx [Tue, 18 Jun 2019 04:01:25 +0000 (00:01 -0400)] 
lib/object.h: log conditionally to `BT_OBJECT_DONT_LOG` undefined

There are a few places within the project, but outside the library, that
for historic reasons use the library's internal `bt_object` API to have
reference counting. The `bt_object` API belongs to the library for the
moment and should not be included as such.

There's an issue when you need logging in your module and the functions
which log within `object.h` cannot make sense of the
`BT_LOG_OUTPUT_LEVEL` expression. To avoid this and save short-term
development time, make them not log if `BT_OBJECT_DONT_LOG` is defined.
Then, outside the library, you can do something like:

    #define BT_LOG_OUTPUT_LEVEL my_log_level
    #define BT_LOG_TAG MY-TAG
    #include "logging/log.h"

    #define BT_OBJECT_DONT_LOG
    #include "lib/object.h"

Another solution would be to include `lib/logging.h` before
`logging/log.h`, but that's not always easy.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If3037b67e5c4f87f57db96528d0a9516c8f9d6ea
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1493
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoRemove unused `src/plugins/ctf/print.h`
Philippe Proulx [Mon, 17 Jun 2019 23:28:23 +0000 (19:28 -0400)] 
Remove unused `src/plugins/ctf/print.h`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I989c98d9273f69362fd9f4d7390a91323e780886
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1492
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoRemove unused `src/plugins/ctf/common/utils`
Philippe Proulx [Mon, 17 Jun 2019 23:27:16 +0000 (19:27 -0400)] 
Remove unused `src/plugins/ctf/common/utils`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia66dfc005c8091187c3883727bf7f68582a201da
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1491
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years ago`ctf` plugin: metadata: use local log level
Philippe Proulx [Mon, 17 Jun 2019 23:20:08 +0000 (19:20 -0400)] 
`ctf` plugin: metadata: use local log level

As of this patch, the users of the common metadata functions and objects
set the new log level parameters to their own (global) log level.

The goal is to eventually have a per-component log level for the `ctf`
plugin's component classes.

Unfortunately, `YYFPRINTF` and `YY_FATAL_ERROR` are pretty limited in
terms of available context. I'm leaving the
`BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL` environment variable to set
the logging level of the parser and lexer modules.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I34651e6d0c14b5acc9b4198681c2aea4c003dc7a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1490
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years ago`ctf` plugin: `bt_msg_iter`: use object's log level
Philippe Proulx [Mon, 17 Jun 2019 22:13:54 +0000 (18:13 -0400)] 
`ctf` plugin: `bt_msg_iter`: use object's log level

As of this patch, the users of `bt_msg_iter` set the new log level
parameter to their own (global) log level.

The goal is to eventually have a per-component log level for the `ctf`
plugin's component classes.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I279d22831c5857dc10622e6cabacf64c32fa5ed4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1488
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years ago`ctf` plugin: `bt_bfcr`: use object's log level
Philippe Proulx [Mon, 17 Jun 2019 22:00:09 +0000 (18:00 -0400)] 
`ctf` plugin: `bt_bfcr`: use object's log level

As of this patch, the only user of `bt_bfcr` is `bt_msg_iter`, which
sets the new log level parameter to its own (global) log level.

The goal is to eventually have a per-component log level for the `ctf`
plugin's component classes.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie77969d587c03c7d0257c19bb151ee22707b9842
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1487
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoutils.sink.counter: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Mon, 17 Jun 2019 17:19:57 +0000 (13:19 -0400)] 
utils.sink.counter: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic963197053b374df6b891c8b6af1050255c626d9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1481
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.lttng-utils.debug-info: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Mon, 17 Jun 2019 17:18:11 +0000 (13:18 -0400)] 
flt.lttng-utils.debug-info: use BT_COMP_LOG*() instead of BT_LOG*()

Note that the API of `bin-info.h` is tested in
`tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c`, and since
the BT_COMP_LOG*() macros can call bt_component_get_name(), which is
defined in the Babeltrace library, `test_bin_info` needs to be linked
with the Babeltrace library now.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibb29ece3936478f0e82f28d7f889a067d771a703
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1480
Tested-by: jenkins <jenkins@lttng.org>
4 years agoflt.lttng-utils.debug-info: honor component's initial log level
Philippe Proulx [Mon, 17 Jun 2019 05:45:14 +0000 (01:45 -0400)] 
flt.lttng-utils.debug-info: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I49d4f5ecbdcc546c511e2469581db4f0e785a54a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1479
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: rename `lib-logging.h` to `logging.h`
Philippe Proulx [Sat, 15 Jun 2019 17:02:55 +0000 (13:02 -0400)] 
lib: rename `lib-logging.h` to `logging.h`

Now we include "lib/logging.h" instead of "lib/lib-logging.h" to get
internal library logging support. The old file name was redundant.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I996b58c4b8c4914207a9f7e0b8ff6146ad65f5cb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1473
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoLogging: define `BT_LOG*_SUPPORTED` when logging is supported
Philippe Proulx [Sat, 15 Jun 2019 16:58:38 +0000 (12:58 -0400)] 
Logging: define `BT_LOG*_SUPPORTED` when logging is supported

Rely on those new `BT_LOG_SUPPORTED`, `BT_LIB_LOG_SUPPORTED`,
`BT_COMP_LOG_SUPPORTED`, definitions instead of the header include
guards to know whether or not logging is supported at a given point.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4d076e30b528882d036f7cfc367b5dbb39401dda
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1472
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.utils.muxer: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Sat, 15 Jun 2019 15:32:09 +0000 (11:32 -0400)] 
flt.utils.muxer: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I57e8c7980ad50ae687cfa545c5f434d4027b18e3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1471
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.utils.trimmer: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Sat, 15 Jun 2019 15:23:27 +0000 (11:23 -0400)] 
flt.utils.trimmer: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib4280e02ef7520fdca0dc4718ae36d5e34ae56ca
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1470
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc.text.dmesg: use BT_COMP_LOG*() instead of BT_LOG*()
Philippe Proulx [Sat, 15 Jun 2019 15:18:39 +0000 (11:18 -0400)] 
src.text.dmesg: use BT_COMP_LOG*() instead of BT_LOG*()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I38ff470120dbc9c303bd0fb23e1b552b99e07fc0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1469
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoLogging: add `src/plugins/comp-logging.h` (BT_COMP_LOG*())
Philippe Proulx [Sat, 15 Jun 2019 15:04:54 +0000 (11:04 -0400)] 
Logging: add `src/plugins/comp-logging.h` (BT_COMP_LOG*())

This new header is intended to be included by the different component
class files so that their logging statements can automatically include
the component's name. The BT_COMP_LOG*() macros prepend a prefix similar
to this to the logging message:

    [mein-sink]

where `mein-sink` is a component's name.

Having the component name within each logging message of a given
component class adds valuable context and can help resolve issues
faster.

I did not include the plugin name and the component class's type and
name within the prefix because we already have them thanks to the
logging tag, for example `PLUGIN/SRC.CTF.FS`. This would be redundant,
make the logging message longer, and make `comp-logging.h` more complex.

The BT_COMP_LOG*() macros rely on the `BT_COMP_LOG_SELF_COMP`
definition. This is an expression which is, in the logging statement
context, the `bt_self_component *` address. Because we have the self
component there, we are free to prepend more contextual information to
the logging message in the future, should we need it.

Typically, when a component class source file defines
`BT_LOG_OUTPUT_LEVEL` to `(my_comp->log_level)`, where `my_comp` points
to the component's private structure, it will also define
`BT_COMP_LOG_SELF_COMP` to `(my_comp->self_comp)`.

If `BT_COMP_LOG_SELF_COMP` evaluates to `NULL`, the macros use the
prefix

    [N/A]

This could be the case when instrumenting code that is shared for both
graph and non-graph contexts, for example the metadata and stream
decoders of the `ctf` plugin which can also be used within a query
operation.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I62c63ed78d234922f556631726fb7bb852924f0a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1468
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.utils.trimmer: honor component's initial log level
Philippe Proulx [Sat, 15 Jun 2019 06:39:50 +0000 (02:39 -0400)] 
flt.utils.trimmer: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I785a46dad409a9d1ab75426ce49059169e47c74e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1467
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoflt.utils.muxer: honor component's initial log level
Philippe Proulx [Sat, 15 Jun 2019 06:31:40 +0000 (02:31 -0400)] 
flt.utils.muxer: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie0a6c76fa2c462bcd352081e98aa14411bfd13d8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1466
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoMove bt_{self_component,message_iterator}_status_string() to `common.h`
Philippe Proulx [Sat, 15 Jun 2019 06:29:58 +0000 (02:29 -0400)] 
Move bt_{self_component,message_iterator}_status_string() to `common.h`

Now `muxer.c` does not include internal library headers.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I33a9cf2db3df6a8d06d385f352280d90a922c4d9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1465
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.utils.counter: honor component's initial log level
Philippe Proulx [Sat, 15 Jun 2019 05:59:47 +0000 (01:59 -0400)] 
sink.utils.counter: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib5bc755a8ff3db0a869b448f83dd9a888ee7df9b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1464
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc.text.dmesg: honor component's initial log level
Philippe Proulx [Sat, 15 Jun 2019 02:41:01 +0000 (22:41 -0400)] 
src.text.dmesg: honor component's initial log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibf940cce2980389241ee6f4790c4c651280918a5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1463
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agotests: bt2: add query log level tests
Philippe Proulx [Sat, 15 Jun 2019 04:44:52 +0000 (00:44 -0400)] 
tests: bt2: add query log level tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I725d3b7d64b4a820da1f3762c3217af9a88a0ca3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1462
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: pass log level to bt_query_executor_query()
Philippe Proulx [Sat, 15 Jun 2019 04:42:10 +0000 (00:42 -0400)] 
lib: pass log level to bt_query_executor_query()

This new parameter indicates the log level to use during the query
execution.

The project's component classes are changed to receive this log level,
but they do not use it. This work is reserved for a future patch.

The CLI passes its default log level (main `--log-level` option) to
bt_query_executor_query().

Python bindings are adapted accordingly.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I929d545a1df2f4d6d083f6c536f6fcf26aa972bd
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1461
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoLogging: pass dynamic log level to common functions and subsystems
Philippe Proulx [Sat, 15 Jun 2019 03:59:04 +0000 (23:59 -0400)] 
Logging: pass dynamic log level to common functions and subsystems

This patch makes the project's common functions and subsystems get a
dynamic log level instead of using a global one set from an environment
variable. The goal is to achieve per-component log levels, so the common
functions and subsystems must receive, eventually, the component's
specific log level.

"Naked" functions (without a context object of some sort) simply get
their log level from a new parameter. In that case `BT_LOG_OUTPUT_LEVEL`
is simply defined to `log_level`, so a local `log_level` variable must
exist when using logging statements. Subsystems, such as an FD cache or
a CTF serializer, get their log level from a new parameter in their
initialization function and then use it for their other operations.

It was somehow hard to do this for `src/common` alone without also doing
it for the rest so I'm doing all of them at once here.

For those subsystems, the local `logging.c` and `logging.h` disappear.

`tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c` needs to pass
a log level to the FD cache subsystem; I used the WARN level instead of
setting the log level from an environment variable for this test alone.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I35979a8fe4c74afe5921c3b6651015cd7ee2760a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1460
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc/logging/log.h: add BT_LOG_WRITE_CUR_LVL(), BT_LOG_WRITE_ERRNO_CUR_LVL()
Philippe Proulx [Sat, 15 Jun 2019 03:29:46 +0000 (23:29 -0400)] 
src/logging/log.h: add BT_LOG_WRITE_CUR_LVL(), BT_LOG_WRITE_ERRNO_CUR_LVL()

BT_LOG_WRITE_CUR_LVL() is like BT_LOG_WRITE(), but it compares the
given log level to a current log level parameter instead of
`_BT_LOG_OUTPUT_LEVEL`.

BT_LOG_WRITE_ERRNO_CUR_LVL() is the same thing, but for
BT_LOG_WRITE_ERRNO().

The goal of this is to be able to control which variable contains the
current log level at the call site to achieve per-component log levels.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I670664a7cb465954c2f0f8b3551ea49fd1465e32
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1459
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agocli: add component-specific `--log-level` option (run/convert commands)
Philippe Proulx [Sat, 15 Jun 2019 02:52:27 +0000 (22:52 -0400)] 
cli: add component-specific `--log-level` option (run/convert commands)

This new option makes it possible to specify a log level for a specific
component instance. The main program's `--log-level` option becomes the
default log level which the specific `--log-level` options override.

For example:

    babeltrace2 -c src.mein.source --log-level=I \
                -c sink.ctf.fs --log-level=D

makes the log level of the source be INFO and the log level of the
sink be DEBUG. The log level of the other components (implicit muxer),
of the CLI, and of the library is the default WARN.

    babeltrace2 --log-level=E -c src.mein.source --log-level=I \
                              -c sink.ctf.fs

makes the log level of the source be INFO and the log level of the sink,
of the other components (implicit muxer), of the CLI, and of the library
be ERROR.

The CLI still sets the known log level environment variables until
subsequent patches make each component honor its initial log level, that
is, until each component uses the log level for its logging statements
as returned by bt_component_get_logging_level().

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8a3b05b7147fdb0149ecff670c542c9a229beddb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1458
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.text.pretty: remove logging (not used)
Philippe Proulx [Sat, 15 Jun 2019 01:52:15 +0000 (21:52 -0400)] 
sink.text.pretty: remove logging (not used)

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5449d5a3aa89466764bea8ba7523c580ac695e29
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1457
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agotest_graph.py: add bt2.Graph.add_component() logging level parameter tests
Philippe Proulx [Sat, 15 Jun 2019 01:48:50 +0000 (21:48 -0400)] 
test_graph.py: add bt2.Graph.add_component() logging level parameter tests

GraphTestCase.test_add_component_logging_level() is pretty much the same
test as GenericComponentTestCase.test_logging_level(), but the former's
purpose is to test the bt2.Graph.add_component() part of this, while the
latter tests the component's public `logging_level` property.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9c82e8a7ab6a733810eabfee5ccef66cd619a610
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1456
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agotest_component.py: add `logging_level` property tests
Philippe Proulx [Sat, 15 Jun 2019 01:44:11 +0000 (21:44 -0400)] 
test_component.py: add `logging_level` property tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibc7dbbbb3d497efe8b8c237488fd0733c094f242
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1455
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: set component's initial log level when adding it to the graph
Philippe Proulx [Sat, 15 Jun 2019 01:16:07 +0000 (21:16 -0400)] 
lib: set component's initial log level when adding it to the graph

This patch changes the bt_graph_add_*_component*() functions so that
they accept a log level parameter. This is now considered the
component's initial log level, so that we can achieve per-component log
levels.

The component initialization method types are not changed: because the
log level is part of a component's state, a component initialization
method can retrieve its own, current log level with the new
bt_component_get_logging_level() function. When you call
bt_graph_add_*_component*(), the function creates an initial component
object, sets its initial log level, and then calls its initialization
method.

Eventually, we can add a new, optional "logging level changed" component
method to notify it that its log level changed (caused by a call to
bt_component_set_logging_level(), for example).

The project's components do not honor their initial log level within the
scope of this patch: this is postponed to another patch. In other words,
they still use shared object constructors and environment variables to
set their log level at the component class level.

The CLI passes the configured log level (`--log-level`, `-v`, or `-d`
options) when it calls the bt_graph_add_*_component() functions. As of
this patch, it also still sets the known log level environment
variables.

Python bindings are adjusted accordingly. Their tests are not changed
because the log level parameter is optional (defaults to
`bt2.LoggingLevel.NONE`) and it's the last one of
bt2.Graph.add_component(). The constructor of `bt2.ComponentSpec` also
accepts a new, optional log level parameter to configure the component
specifier as such. You can access the log level of a component with the
new `logging_level` property.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If258335f46ffabb587dd777b5109fc66d8a59f54
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1454
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoAdd internal bt_common_logging_level_string()
Philippe Proulx [Sat, 15 Jun 2019 01:14:06 +0000 (21:14 -0400)] 
Add internal bt_common_logging_level_string()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6fd26a0657d93efc8a30d6055d755c5e2b852f2e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1453
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agocli: use log level integer instead of letter in configuration
Philippe Proulx [Sat, 15 Jun 2019 01:09:51 +0000 (21:09 -0400)] 
cli: use log level integer instead of letter in configuration

This patch makes `struct bt_config` have an integer log level (to be set
to one of the `BT_LOG_*` values) instead of a letter. The
bt_log_get_letter_from_level() and bt_log_get_level_from_letter() can be
used to translate from/to a log level letter/integer, so we use that.

This is just cleaner and makes more sense than carrying a letter in the
configuration which is just one encoding of a log level value.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5cbc3f2cb9ac868bc99e9458468a09c58e716884
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1452
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosrc/logging/log.h: add utility functions for log level to/from string
Philippe Proulx [Sat, 15 Jun 2019 01:06:03 +0000 (21:06 -0400)] 
src/logging/log.h: add utility functions for log level to/from string

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I389b5da1a574523a986d2884126b8f862765d914
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1451
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoLogging: standardize logging tags
Philippe Proulx [Fri, 14 Jun 2019 21:29:56 +0000 (17:29 -0400)] 
Logging: standardize logging tags

Use `/` to show the subsystem to source file hierarchy, and use typical
component class identifier, but in uppercase (for example,
`SRC.CTF.FS`).

See the changes in `CONTRIBUTING.adoc` for more details.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I94aaf431e6a93e607496267c54419b012564daaf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1449
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 years agoconfigure.ac: change default minimal log level from VERBOSE to DEBUG
Philippe Proulx [Fri, 14 Jun 2019 21:15:27 +0000 (17:15 -0400)] 
configure.ac: change default minimal log level from VERBOSE to DEBUG

The goal here is that Babeltrace users have enough logging by default
without impacting the performance too much. From what I measured once
this patch is applied, the performance is very similar to an INFO build.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I20346f0f3eecf725e730a3e5add94804637c7193
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1445
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agosink.text.pretty: remove message iterator inactivity message logging
Philippe Proulx [Fri, 14 Jun 2019 21:13:59 +0000 (17:13 -0400)] 
sink.text.pretty: remove message iterator inactivity message logging

This is not the role of this component class. A detailed component
class, `sink.text.details`, shows all the messages.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic01b766a81fd622fc768d71f70aec4b4a136c3d0
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1444
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: plugin.h: force header user to include "lib/logging.h"
Philippe Proulx [Fri, 14 Jun 2019 21:12:36 +0000 (17:12 -0400)] 
lib: plugin.h: force header user to include "lib/logging.h"

This pattern is found in other headers where, instead of including the
logging header for the user, we ask her to set up the logging and then
include the header.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I922b09f63eff41b9c3ba30df7ace0b8b30b5b5b2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1443
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoLogging: check `BT_DEBUG_MODE` instead of `NDEBUG`
Philippe Proulx [Fri, 14 Jun 2019 21:11:40 +0000 (17:11 -0400)] 
Logging: check `BT_DEBUG_MODE` instead of `NDEBUG`

This project does not rely on `NDEBUG`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I35b282711f373998ea8361b343e9abf32fb6390c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1442
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agolib: `component-class-sink-colander.c`: remove useless `void *` cast
Philippe Proulx [Fri, 14 Jun 2019 21:10:26 +0000 (17:10 -0400)] 
lib: `component-class-sink-colander.c`: remove useless `void *` cast

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iddd16093dbdd9236151d948f09afe084c5685a6f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1441
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoRename: <some/internal-header.h> -> "some/internal-header.h"
Philippe Proulx [Fri, 14 Jun 2019 21:08:08 +0000 (17:08 -0400)] 
Rename: <some/internal-header.h> -> "some/internal-header.h"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icad3fb88de3c5c2e6658c44dc00ece97cb1096b8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1440
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
4 years agoStandardize log levels used by logging statements across the project
Philippe Proulx [Fri, 14 Jun 2019 20:58:49 +0000 (16:58 -0400)] 
Standardize log levels used by logging statements across the project

Let's use this approach now:

INFO level:
    Any useful information which a non-developer user would possibly
    understand.

    Anything logged with this level must _not_ happen repetitively on
    the fast path, that is, nothing related to each message, for
    example. This level is used for sporadic and one-shot events.

    * CLI or component configuration report.
    * Successful plugin, component, or message iterator initialization.
    * In the library: anything related to plugins, graphs, component
      classes, components, message iterators, connections, and ports
      which is not on the fast path.
    * Successful connection to or disconnection from another system.
    * An _optional_ subsystem cannot be loaded.
    * An _optional_ field/datum cannot be found.

DEBUG level:
    Something that only Babeltrace developers would be interested into,
    which can occur on the fast path, but not more often than once per
    message.

    * Object construction and destruction.
    * Object recycling (except fields).
    * Object copying (except fields and values).
    * Object freezing (whatever the type, as freezing only occurs in
      developer mode).
    * Object cancellation.
    * Calling user methods and logging the result.
    * Setting object properties (except fields and values).

VERBOSE level:
    Low-level debugging context information (anything that does not fit
    the other log levels). More appropriate for tracing in general.

    * Reference count change.
    * Fast path, low level state machine's state change.
    * Get or set an object's property.
    * Object comparison's intermediate results.

This will also be written in `CONTRIBUTING.adoc` by another patch.

The goal here is to make the DEBUG level the default minimal, build-time
log level, so that Babeltrace users have enough logging by default
without impacting the performance too much. From what I measured once
this patch is applied, the performance is very similar to an INFO build.

Many DEBUG logging statements are upgraded to the INFO level because
they only occur once, or very rarely, and consist of interesting
information for someone who does not have deep knowledge of the
Babeltrace source code.

Many VERBOSE logging statements are upgraded to the DEBUG level so that,
by default, we have more information in the log file of someone who
needs support. Those statements are executed seldom enough (at most once
per message) to be promoted as such.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icdd1ec8f1f54396eea5588968d85e446030f282d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1439
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agobt2: message_iterator.py: packet beginning/end messages have a single CS
Philippe Proulx [Mon, 17 Jun 2019 20:48:53 +0000 (16:48 -0400)] 
bt2: message_iterator.py: packet beginning/end messages have a single CS

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia650a2e33483a999216aaf15dccecc5196bb4876
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1483
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agobt2: stream activity messages: create with unknown/infinite default CS
Philippe Proulx [Fri, 14 Jun 2019 02:22:26 +0000 (22:22 -0400)] 
bt2: stream activity messages: create with unknown/infinite default CS

This patch makes it possible to create stream activity beginning and end
messages with unknown or infinite default clock snapshots. It was
already possible to create them with known default clock snapshots, that
is, with a value.

With this patch, you pass either `self._unknown_clock_snapshot` or
`self._infinite_clock_snapshot`, when implementing a
`bt2._UserMessageIterator`, as the default clock snapshot when you call
self._create_stream_activity_beginning_message() or
self._create_stream_activity_end_message(). They are instances of
internal types which are only used for this. The creation methods use
`_unknown_clock_snapshot` by default. This is similar to how
bt_message_stream_activity_beginning_create() and
bt_message_stream_activity_end_create() create messages with unknown
default clock snapshots.

`test_message.py` tests the new feature.

Also in this patch: `_BaseClockSnapshot` does not inherit
`object._UniqueObject` anymore so that `_UnknownClockSnapshot` and
`_InfiniteClockSnapshot` do not either. This is so that the default
clock snapshot properties of the stream activity beginning/end messages
can return instances of those types without having actual native
pointers, because there are none.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I56d5cd9fffb77d505f61522073aaf80ccd58eb8e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1430
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoPut `flt.lttng-utils.debug-info` tests into their own directory
Philippe Proulx [Thu, 13 Jun 2019 15:22:26 +0000 (11:22 -0400)] 
Put `flt.lttng-utils.debug-info` tests into their own directory

The goal is to have each component class tests in their own directory
under `tests/plugins`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3f68d2af9087690c6a34d238197c9bb9e96b021c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1423
Tested-by: jenkins
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
4 years agoRemove unused `tests/plugins/test_utils_muxer_complete.in`
Philippe Proulx [Thu, 13 Jun 2019 15:13:13 +0000 (11:13 -0400)] 
Remove unused `tests/plugins/test_utils_muxer_complete.in`

This script was the runner for the `flt.utils.muxer` test running in C,
which does not exist anymore. We'll write `flt.utils.muxer` tests either
in Python or with `sink.text.details` and expectation files.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I28df6d20c3bd3ee0b056790046d041787e702430
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1422
Tested-by: jenkins
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
4 years agoAdd facilities to test CLI and plugin regressions with expectation files
Philippe Proulx [Tue, 11 Jun 2019 23:08:46 +0000 (19:08 -0400)] 
Add facilities to test CLI and plugin regressions with expectation files

This patch adds `tests/utils/diff.sh.in` (which becomes
`tests/utils/diff.sh`) which contains shell functions to use the CLI and
a `sink.text.details` component to easily test the CLI itself and
plugins for regressions with expectation files.

There are three functions in `tests/utils/diff.sh.in`:

bt_diff_cli():
    Compares the output of the CLI with specific arguments to the
    content of a file.

bt_diff_details_ctf_single():
    Compares the output of the CLI using an `src.ctf.fs` component to
    open a specific CTF trace and a `sink.text.details` component to the
    content of a file.

bt_diff_details_ctf_gen_single():
    Like bt_diff_details_ctf_single(), but runs a given CTF trace
    generating program instead of using an existing CTF trace.

When there's any difference, the functions write the full diff to the
standard error. This makes it possible to look at what's wrong in the
CI.

`tests/plugins/ctf` is moved to `tests/plugins/src.ctf.fs` to indicate
that we're testing this specific component class. The specific query
tests are moved to `tests/plugins/src.ctf.fs/query`.

`tests/plugins/src.ctf.fs/diff/test_diff.in` uses `tests/utils/diff.sh`
to show how to use bt_diff_details_ctf_single() and
bt_diff_details_ctf_gen_single().

The functions test_ctf_single() and test_ctf_gen_single() use resp.
bt_diff_details_ctf_single() and bt_diff_details_ctf_gen_single() to
compare the given CTF traces using a `sink.text.details` component to
expectation files ending with `.expect` in the same directory.

In both test_ctf_single() and test_ctf_gen_single(), we make the
`sink.text.details` component hide the trace and stream names because
`src.ctf.fs` puts absolute paths in them. For test_ctf_gen_single(), we
also make the `sink.text.details` component hide UUIDs because CTF
writer creates random ones by default.

More specifically, this line:

    test_ctf_gen_single simple

means:

1. Run the program `gen-trace-simple` in the same directory to generate
   a CTF trace.

2. Get the output of:

       babeltrace2 /path/to/trace -c sink.text.details \
                   -p with-uuid=no,with-trace-name=no,with-stream-name=no

3. Compare the content of 2. to the file `trace-simple.expect` in the
   same directory.

This line:

    test_ctf_single smalltrace

means:

1. Get the output of:

       babeltrace2 "$BTDIR/tests/ctf-traces/succeed/smalltrace" \
                   -c sink.text.details \
                   -p with-trace-name=no,with-stream-name=no

2. Compare the content of 1. to the file `trace-smalltrace.expect` in
   the same directory.

Eventually, we can move the test_ctf_gen_single() and test_ctf_single()
functions outside the `src.ctf.fs` tests to make them available to test
other plugins and parts of the project. They are placed there for the
moment because only the `src.ctf.fs` tests need them.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I53660111c23117926e3ee114b5d0cd060fff87d3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1414
Tested-by: jenkins
4 years agoAdd `sink.text.details`, a testing textual sink which prints details
Philippe Proulx [Sat, 8 Jun 2019 00:26:34 +0000 (20:26 -0400)] 
Add `sink.text.details`, a testing textual sink which prints details

This patch adds a new sink component class, `sink.text.details`. Such
a sink component prints all the messages and their details, including
the full metadata objects, in a deterministic way.

You can test it easily like this:

    babeltrace2 /path/to/trace -c sink.text.details

The purpose of this sink is to use it for regression testing using the
following approach:

1. Run the `babeltrace2` program with a `sink.text.details` component,
   providing a known input trace to the graph, for example a CTF trace
   with `src.ctf.fs`. The graph can include one or more filters with
   specific parameters to test them specifically.

2. Inspect the output with your human eyes and brain. Verify that
   everything is as expected. It is possible that, for a given test,
   some elements of the output are less important (for example, the
   metadata objects or the message times): there are component
   parameters to remove parts of the output to reduce the noise.

3. Save the output of 2. to a file.

4. Create a test which runs 1. with the same input and compares its
   output to the file saved in 3. Any regression will show up as a
   difference between both inputs.

Step 2. is particularly important because this is where you validate
that the output shows what you expect from the graph. To make this
easier, I tried to make the output format of `sink.text.details` as
human-readable as possible:

* The component optionally colorizes the output. This is the default
  when the terminal supports it. There's no color codes by default when
  you redirect the output.

* The component honors the preferred display base of integer fields and
  prepends the typical `0x` and `0` prefixes.

* The component inserts digit separators to make it easier to read large
  numbers, for example `102,354,895,784,619` and `0x7f4d:d04f:c636`.

* The component does not print the metadata objects interlaced with the
  data and message objects. I found that this was noisy, for example
  showing all the integer field class details for each integer field
  when what you really want is to inspect the event payloads from one
  message to the other.

  Instead, I chose to print trace classes, stream classes, and event
  classes only once, and before the message which is associated to them.
  This typically occurs before a stream beginning message, but for event
  classes, it can also occur before an event message, as a source can
  add event classes to an existing stream class.

* The component assigns a unique ID to each trace object to follow the
  messages associated to a specific stream more easily, as many streams
  can share the same ID, across difference traces or even with the same
  trace, when they have different stream classes.

  The component prints this unique trace ID, as well as the stream
  class and stream IDs, before each message type as such
  (`{Trace 1, Stream class ID 0, Stream ID 2}` in the following
  example):

      [102,354,895,784,619 cycles, 1,441,852,773,172,610,636 ns from origin]
      {Trace 1, Stream class ID 0, Stream ID 2}
      Event `lttng_ust_statedump:build_id` (Class ID 56):
        Common context:
          vpid: 17,868
          ip: 0x7f4d:d04f:c636
        Payload:
          baddr: 0x7f4d:d02d:1000
          ...

  A unique trace ID is never reused for two different traces within the
  lifetime of a `sink.text.details` component.

  You can track all the messages of a given stream with this unique
  tuple. For example, you can find the last packet beginning message for
  the packet of a given event message having unique trace ID 0, stream
  class ID 2, and stream ID 5 by finding the last

      {Trace 0, Stream class ID 2, Stream ID 5}
      Packet beginning

  string.

  This makes it possible to avoid redundancy and reduce textual noise in
  the printed messages. For example, the component does not print the
  packet context field for each event message, but only for the packet
  beginning message.

In order to make step 4. continue to work in the future and really test
regressions, the output of step 1. must always be the same
(deterministic). For `sink.text.details`, this means:

* The component does not print run-time addresses.

* The component sorts mappings of enumeration field classes (by label),
  and ranges within such mappings, before it prints them.

* The component sorts event classes of stream classes (by ID) before
  it prints them.

* The component sorts stream classes of trace classes (by ID) before
  it prints them.

* The component sorts streams of traces (by ID and class ID) before
  it prints them.

* The component sorts environment entries of trace classes (by name)
  before it prints them.

To make step 3. easier, the component does not print trailing spaces
or trailing empty lines.

A `sink.text.details` component can also be used for support if we want
all the details of a given graph's output.

The available component parameters are:

`color`:
  `never`, `auto`, or `always` (just like `sink.text.pretty`).

  Default: `auto`

`with-metadata`:
  True to print metadata objects (only the first time they are
  encountered).

  Default: true

`with-time`:
  True to print message times.

  Default: true

`with-trace-class-name`:
  True to print trace class names.

  Default: true

`with-trace-name`:
  True to print trace names.

  Default: true

`with-stream-class-name`:
  True to print stream class names.

  Default: true

`with-stream-name`:
  True to print stream names.

  Default: true

`with-uuid`:
  True to print UUIDs.

  Default: true

`compact`:
  True to make the output compact (one message per line, no property
  names).

  Default: false

This patch does not add the facilities to create tests easily using the
CLI and a `sink.text.details` component: this is reserved for a future
patch.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9cc39cdfe44436974600388342029a2e4e2acb76
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1412
Tested-by: jenkins
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoAdd bt_common_sep_digits()
Philippe Proulx [Tue, 11 Jun 2019 14:59:56 +0000 (10:59 -0400)] 
Add bt_common_sep_digits()

This new utility function adds digit separators to a string representing
a number. For example, `1983291832` can become `1,983,291,832`.

See the function's comment for more details.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I39dedc69fbc76b31252a64c68261a35d8ac7c7a8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1411
Tested-by: jenkins
4 years agofix: Add missing glib include on MINGW
Michael Jeanson [Fri, 14 Jun 2019 21:15:23 +0000 (17:15 -0400)] 
fix: Add missing glib include on MINGW

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I4b8486406270314f610e6001eba854ddd189983c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1437
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agotests: Move ctf-writer to it's own directory
Michael Jeanson [Thu, 13 Jun 2019 18:23:20 +0000 (14:23 -0400)] 
tests: Move ctf-writer to it's own directory

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I4033b31392867c468419aa43f31675af3842c6f1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1427
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agotests: Move libtestcommon to utils
Michael Jeanson [Thu, 13 Jun 2019 18:10:51 +0000 (14:10 -0400)] 
tests: Move libtestcommon to utils

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I4efe6edae5d70921cbfb106f5184c58f7e2e5abb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1426
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoCleanup: remove plugin-common.h
Michael Jeanson [Thu, 13 Jun 2019 15:09:29 +0000 (11:09 -0400)] 
Cleanup: remove plugin-common.h

It was only used to define 'UNUSED_VAR' which we can use literally.

Change-Id: Idf84f6ecee711e2caf4b7d68f5e6f598b0aca22e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1425
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoCleanup: remove private babeltrace.h
Michael Jeanson [Wed, 12 Jun 2019 22:09:37 +0000 (18:09 -0400)] 
Cleanup: remove private babeltrace.h

 * Remove unused macros
 * Replace duplicated macros with their glib equivalent
 * Move the *safe* static inlines to their own header
 * Namespace the remaining macros and move them to macros.h
 * Explicitly include 'common/macros.h' in all private headers that use
   'BT_HIDDEN'.
 * Remove BT_UNUSED, the attribute is a hard requirement anyway
 * Remove zmalloc and replace the only callsite with calloc

Change-Id: I1bd765ad27c808c8bbe5ef232062267cb4a230d9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1424
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agofix: Static build fails with ctfser missing symbols
Michael Jeanson [Thu, 13 Jun 2019 14:50:42 +0000 (10:50 -0400)] 
fix: Static build fails with ctfser missing symbols

Spliting the ctf-writer from the main library had the side effect of not
including the ctfser convience library in the main lib anymore. Thus it
should now be linked with the binairies to satisfy the dependencies when
we statically link the plugins in.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I4626dcabce1914f0af2287afe8c3fcf7b7db9946
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1421
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoRe-organize sources
Michael Jeanson [Mon, 10 Jun 2019 21:44:09 +0000 (17:44 -0400)] 
Re-organize sources

 * Create a top-level 'src' directory.
 * Move all private headers from the public include directory to the
   'src' directory.
 * Rename all those private headers to remove the 'internal' notation.
 * Use double quotes in `#include` directives when including a private
   header so that we can easily know.

Change-Id: I05fbb81d969b3735aaf303ec2c222be7142c19ab
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1413
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agotap-driver.sh: flush stdout after each test result
Michael Jeanson [Wed, 12 Jun 2019 14:50:30 +0000 (10:50 -0400)] 
tap-driver.sh: flush stdout after each test result

This is useful in a CI system where stdout is fully buffered and you
look at the console output to see which test is hanging.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I998b83347ca2445f46c3e195b797ce75b0096adb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1415
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: src.ctf.fs: increment packet offset before init of index entry
Francis Deslauriers [Mon, 10 Jun 2019 16:30:10 +0000 (12:30 -0400)] 
Fix: src.ctf.fs: increment packet offset before init of index entry

Issue
=====
The `current_packet_offset_bytes` variable is incremented before the
initialization of the current `index_entry` by `init_index_entry()`.
This lead to each entry having the offset of the next entry and the last
entry having a erroneous offset.

Solution
========
Increment the `current_packet_offset_bytes` variable after the
initialization of each entry.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I7592b2d70f402aa413de97a687bfe4fe1bf1b825
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1409
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoctf-writer: externalize libbabeltrace2-ctf-writer
Michael Jeanson [Fri, 7 Jun 2019 16:25:10 +0000 (12:25 -0400)] 
ctf-writer: externalize libbabeltrace2-ctf-writer

Completely split the ctf writer part from the main babeltrace2 library.

 * Remove the obsolete libbabeltrace2-ctf library
 * Add a new libbabeltrace2-ctf-writer library
 * Remove the ctf writer includes from the main include file
 * Fork an internal copy of assert-pre.h that doesn't use the library
   structures.
 * Add a logging context specific to ctf writer

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Iff9ab62ee9eeb8abd290fb1d758a73050e21c99b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1410
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoCleanup: Move build logic to python-plugin-provider Makefile
Michael Jeanson [Thu, 30 May 2019 15:35:17 +0000 (11:35 -0400)] 
Cleanup: Move build logic to python-plugin-provider Makefile

Simplify the root Makefile, group the python provider build logic in a
single Makefile.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I580a3577e0a84f5b6e624ed2ed74a56a0b6b3960
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1353
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoCleanup: remove useless Makefiles from extras
Michael Jeanson [Thu, 30 May 2019 15:36:26 +0000 (11:36 -0400)] 
Cleanup: remove useless Makefiles from extras

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I8eaf99fab641f264699c16b2069b81c16e27bda5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1354
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: use `babeltrace2` instead of `babeltrace` in plugin paths
Philippe Proulx [Sat, 8 Jun 2019 00:31:02 +0000 (20:31 -0400)] 
Fix: use `babeltrace2` instead of `babeltrace` in plugin paths

This was overlooked when renaming some parts of the project from
`babeltrace` to `babeltrace2` recently.

Basically it made the project not work when installed.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie1079cee61d6cb6b9bc3787332e4635ee738542f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1408

4 years agoFix: doc/bindings/python/Makefile.am: run the `sphinx` Python 3 package
Philippe Proulx [Fri, 7 Jun 2019 15:13:35 +0000 (11:13 -0400)] 
Fix: doc/bindings/python/Makefile.am: run the `sphinx` Python 3 package

In `sphinx-build.py` (removed), importing `main` and `make_main` from
the `sphinx` package is not considered stable: it used to work for me,
but now it doesn't (cannot import). Instead, run the `sphinx` package
directly with the Python interpreter's `-m` option.

We do this instead of running `sphinx-build` directly because we want to
pick Sphinx for Python 3 (because we're importing the `bt2` package for
autodoc), not for Python 2, and the installed `sphinx-build` program can
be the one for Python 2 on some distributions.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I158dbb96a8b3a26db67dd6e16254a64ac9d24446
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1401

4 years agobt2: add `_Trace.cls` property
Philippe Proulx [Thu, 6 Jun 2019 23:06:11 +0000 (19:06 -0400)] 
bt2: add `_Trace.cls` property

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0669de442d91da7b188a02d633e1fad15fc5814c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1395
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agobt2: rename object's own BT class property to `cls`
Philippe Proulx [Thu, 6 Jun 2019 22:57:59 +0000 (18:57 -0400)] 
bt2: rename object's own BT class property to `cls`

Having `mein_event.event_class` is redundant; what we really want is
`mein_event.class`, but `class` is a reserved word, so use `cls`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib1f0c91ca37e91b7704ca61fb7380bb79cb48927
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1394
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agobt2: prepend `_` prefix to names of classes that the user cannot create
Philippe Proulx [Thu, 6 Jun 2019 22:32:03 +0000 (18:32 -0400)] 
bt2: prepend `_` prefix to names of classes that the user cannot create

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icf47793836daede471372be16fb278884eb54f38
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1393
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoRemove everything related to the `bt2.ctf_writer` Python module
Philippe Proulx [Thu, 6 Jun 2019 22:17:14 +0000 (18:17 -0400)] 
Remove everything related to the `bt2.ctf_writer` Python module

This module wraps CTF writer, but is currently incomplete and would
require much work to finish, as CTF writer is completely decoupled from
the Babeltrace library.

Since we plan to make Babeltrace 1 and Babeltrace 2 coinstallable, and
that CTF writer 2 does not add many important features to CTF writer 1,
we decided to postpone the development of its Python bindings to when it
supports CTF 2.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie8ceeac8bfcce86dec3cb426d7030ad445274cd2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1392

4 years agoRemove everything related to the `babeltrace` Python package
Philippe Proulx [Fri, 7 Jun 2019 02:47:32 +0000 (22:47 -0400)] 
Remove everything related to the `babeltrace` Python package

This package is the Babeltrace 1 package, and since we plan to make
Babeltrace 1 and Babeltrace 2 coinstallable, we decided to drop the
support for this one.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I37f2de0129df00ae5d78fc3f81ad6c57763809cb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1391
Tested-by: jenkins
4 years agotests: clean up test_trimmer
Simon Marchi [Fri, 7 Jun 2019 18:28:53 +0000 (14:28 -0400)] 
tests: clean up test_trimmer

This patch changes test_trimmer to reduce duplication of the
boilerplate.  I intend to add some test cases to this test in a
following patch, so this change allows me to understand better what the
test does currently and will help adding test cases.

Note that there are pairs of tests that are pretty much redundant, such
as:

- "Read a trace with the trimmer enabled (GMT relative timestamps)"
- "Ran successfully with --begin and --end (GMT relative timestamps)"

So I have only kept the second test of such pairs.

Change-Id: I075df21ed9c03495ab516d3870ccf7b63276d3ce
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1407
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: make precondition failure messages more clear on message creation
Philippe Proulx [Thu, 6 Jun 2019 21:39:37 +0000 (17:39 -0400)] 
lib: make precondition failure messages more clear on message creation

Suggested-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If1486d9bbb3fad02235ce14f53a974e57283fc1b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1390
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agosrc.ctf.fs: trace-info: omit stream `range-ns` field when no TS
Francis Deslauriers [Thu, 6 Jun 2019 04:05:53 +0000 (00:05 -0400)] 
src.ctf.fs: trace-info: omit stream `range-ns` field when no TS

Don't print -1 timestamps when packet contexts don't have
`timestamp_begin` and `timestamp_end` fields. Simply omit this part of
the query reply.

Remove FIXME comment as the only user of the index now handles absent
timestamps.

Tests
=====
Adapt `test_ctf_plugin` stream sorting function to fall back on using
the `paths` field if `range-ns` field is absent and rename it to
abstract implementation details.

Add test case to test that `range-ns` fields are absent on traces
without `timestamp_begin` and `timestamp_end` fields in their packet
context.

Example
=======
Here is an example of the output of the `trace-info` query on a trace
without packet contexts before this commit:
  -
    streams:
      -
       range-ns:
          begin: -1
          end: -1
       paths:
          - /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context/stream
       class-id: 0
       port-name: /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context | 0 | /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context/stream
    range-ns:
      begin: -1
      end: 0
    name: no-packet-context
    path: /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context

Here is an example of the output of the `trace-info` query on a trace
without packet contexts after this commit:
  -
    streams:
      -
       class-id: 0
       port-name: /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context | 0 | /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context/stream
       paths:
          - /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context/stream
    name: no-packet-context
    path: /home/frdeso/projets/babeltrace/tests/ctf-traces/succeed/no-packet-context

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I419f57960a52d8ed2823fdb06982e5c20710b6da
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1387
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agodoc: Rename to babeltrace2
Michael Jeanson [Tue, 4 Jun 2019 21:08:46 +0000 (17:08 -0400)] 
doc: Rename to babeltrace2

Adjust the documentation and manpages following the rename of the
executables and library.

Change-Id: I42cc662a94be6ece489af85d0415440bf1c1f36e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1406
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: rename include dir to babeltrace2
Michael Jeanson [Tue, 4 Jun 2019 19:39:50 +0000 (15:39 -0400)] 
lib: rename include dir to babeltrace2

Rename the include dir to be co-installable with bt1.

Change-Id: Icb9a048988544eaca7054648b9c7a9e76d70b9db
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1405
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: Reset libbabeltrace2 to SONANE 0
Michael Jeanson [Mon, 3 Jun 2019 21:07:05 +0000 (17:07 -0400)] 
lib: Reset libbabeltrace2 to SONANE 0

Following the rename of the library, reset the SONAME to zero and
decouple this from the project versioning which is not tied directly to
the library ABI.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: If3a3c890674d6236cfe33b5f3f1e3fe4229c5691
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1404
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agolib: Rename to libbabeltrace2
Michael Jeanson [Tue, 4 Jun 2019 19:16:19 +0000 (15:16 -0400)] 
lib: Rename to libbabeltrace2

We decided to make babeltrace2 co-installable with babeltrace1 since it
offers backward compatibility but is not a full drop in replacement.

Change-Id: I6da0230858601dd35ae35424540c73ba7b143858
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1403
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agocli: Rename to babeltrace2
Michael Jeanson [Tue, 4 Jun 2019 18:22:42 +0000 (14:22 -0400)] 
cli: Rename to babeltrace2

We decided to make babeltrace2 co-installable with babeltrace1 since it
offers backward compatibility but is not a full drop in replacement.

This first change renames the command line executables.

Change-Id: I52db05629b6349a5221f6b684cb15b289db8c6b3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1402
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: lib: expose bt_lib_log_level symbol
Simon Marchi [Thu, 6 Jun 2019 18:57:13 +0000 (14:57 -0400)] 
Fix: lib: expose bt_lib_log_level symbol

The Python plugin provider does not work.  It fails to be loaded:

    $ ./cli/babeltrace -v list-plugins --plugin-path /tmp/python
    ...
    06-06 15:03:51.883 13378 13378 I PLUGIN init_python_plugin_provider@plugin.c:80 Cannot open `libbabeltrace-python-plugin-provider.so`: /home/smarchi/build/babeltrace/python-plugin-provider/.libs/libbabeltrace-python-plugin-provider.so: undefined symbol: bt_lib_log_level: continuing without Python plugin support.
    ...

The Python plugin provider is built as a .so separate from the main
libbabeltrace.so lib.  However, it uses the logging system of the lib,
including the bt_lib_log_level symbol.  This symbol is currently not
exposed to other shared objects because it is marked as BT_HIDDEN.
Remove BT_HIDDEN to make the symbol visible to the python plugin
provider shared object.

Now that the Python bindings are merged, re-enable the Python plugin
provider test, which exposes the problem.

Note that the Python plugin provider is built as a separate .so for
packaging purposes (so it can be distributed separately), but is still
considered part of the lib.  This is why it is allowed to include and
use internal lib things.

Reported-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I716ae2eb6e2457c7a4f130a394f97391d56454e4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1388
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoAdd missing test_output_ctf_metadata to gitignore
Michael Jeanson [Wed, 5 Jun 2019 19:07:20 +0000 (15:07 -0400)] 
Add missing test_output_ctf_metadata to gitignore

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ia73e2a4510e2085c54794caa179a13cbac89fa77
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1384
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoCleanup: use detected asciidoc to build CONTRIBUTING.html
Michael Jeanson [Thu, 30 May 2019 15:10:15 +0000 (11:10 -0400)] 
Cleanup: use detected asciidoc to build CONTRIBUTING.html

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I3ed041bf02711fe5f3267865410756b8df8bfb3f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1352
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agoFix: src.ctf.fs: trace-info: fields no appended if range not set
Francis Deslauriers [Thu, 6 Jun 2019 03:54:47 +0000 (23:54 -0400)] 
Fix: src.ctf.fs: trace-info: fields no appended if range not set

Issue
=====
If the stream range is not set, the entire `if` clause is skipped and
the `paths`, `stream-id`, and `port-name` are not returned by the query
for that stream.

Solution
========
Append the value of this file group info even if the stream range is not
set.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I7e185bcf3b640a684fc7944423eeb8d337764b19
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1386
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
4 years agosrc.ctf.fs: merge all indexes to the fs_ds_group level
Francis Deslauriers [Wed, 15 May 2019 18:59:10 +0000 (14:59 -0400)] 
src.ctf.fs: merge all indexes to the fs_ds_group level

Background
==========
The index contains information on the packets of the underlying CTF
trace (e.g. timestamp begin and end). It is currently used to compute
the time boundaries of the all streams during the `trace-info` query. It
will probably be used for seeking in the future. Currently, each
datastream file has its own index.

To find the time boundaries of a given stream, we need to get the first
entry of the first datastream file and the last entry of the last
datastream file.

Why merge all the indexes ?
===========================
There are two reasons why we want to merge the file indexes into a
single stream index:
* It's slightly simpler to extract the time boundaries of the stream.

* Changes to overcome various packet timestamps tracer bugs are about to
  be introduced and will need to iterate over all sorted index entries of
  each stream.

Approach
========
Move the index from `struct ctf_fs_ds_file_info` to
`struct ctf_fs_ds_file_group` and merge the indexes of a given stream
when merging the different chunks of the same trace.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iabee86c7c76c69b56cbf86449f8930e6d35969e2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1362
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agosrc.ctf.fs: bubble up `ctf_fs_ds_file_group_create()` error
Francis Deslauriers [Tue, 4 Jun 2019 16:30:17 +0000 (12:30 -0400)] 
src.ctf.fs: bubble up `ctf_fs_ds_file_group_create()` error

This will be used by a future commit to bubble up other allocation
errors.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3a847d8e2e2db15f661360305b4818afba1666ab
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1372
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 years agosink.ctf.fs: add more comments in code where it's not straightforward
Philippe Proulx [Tue, 4 Jun 2019 20:58:26 +0000 (16:58 -0400)] 
sink.ctf.fs: add more comments in code where it's not straightforward

This patch adds a few comments in the code of `sink.ctf.fs` to help
future contributors without deep knowledge of CTF.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibaa9ae27adb42f76329d0eab5a321368f452fc56
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1376
Tested-by: jenkins
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 years agoRename "default beginning/end CS" -> "beginning/end default CS"
Philippe Proulx [Mon, 3 Jun 2019 20:23:07 +0000 (16:23 -0400)] 
Rename "default beginning/end CS" -> "beginning/end default CS"

Because the target is the "default clock", it makes more sense to keep
those words together and have the beginning/end adjective outside.

Suggested-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9fdd32c6acefc51b63b322dc41470c50b9226dfa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1369
Tested-by: jenkins
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
This page took 0.050427 seconds and 4 git commands to generate.