babeltrace.git
2 months agolib: remove BT_ASSERT_COND_SUPPORTED check in graph/graph.h
Simon Marchi [Tue, 6 Feb 2024 20:03:12 +0000 (15:03 -0500)] 
lib: remove BT_ASSERT_COND_SUPPORTED check in graph/graph.h

This header file no longer uses pre-condition macros.

Change-Id: I1afd3a709560221dd67100a5a0beb653f79df6a3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11751
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 months agoFix: lib: strengthen clock expectation check for no Unix epoch / no UUID case
Simon Marchi [Mon, 27 Nov 2023 21:23:10 +0000 (16:23 -0500)] 
Fix: lib: strengthen clock expectation check for no Unix epoch / no UUID case

When an iterator sees a clock class with an origin that is not the Unix
and has no UUID, it sets its clock expectation to
CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID.  In this mode, when validating
subsequent clock classes, it validates that the clock class' origin is
not the Unix epoch and that it has no UUID.  This is too loose: an
iterator could send messages with two distinct clocks with unknown
origins and no UUID, and it would pass validation.  However, these two
clock classes are not correletable.

Fix that by making the iterator remember which specific clock class
instance it saw first.  Each subsequent message must have exactly that
clock class instance.

To be sure that a clock class an iterator has saved doesn't get freed,
and then a new one reallocated at the same address, the iterator takes a
strong reference to the clock class.  This ensures that the saved clock
class at least outlives the iterator.

TODO: I would like to write a test for this

Change-Id: I339936b730fe2f4e64dbc58d56557ffcd23cce16
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11448
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
2 months agocpp-common/bt2c: remove lib-str.hpp
Simon Marchi [Thu, 8 Feb 2024 03:15:37 +0000 (22:15 -0500)] 
cpp-common/bt2c: remove lib-str.hpp

This is unused, and I think it will never be.  If we need something like
this, it will likely be in the form of a `format_as` function used by
the `{fmt}` library.

Change-Id: I81e21d697f6b246c986c5c9126b1177a0d5bcb03
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11759
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoconfigure.ac: don't make `tests/utils/env.sh` executable
Philippe Proulx [Fri, 10 Nov 2023 14:54:44 +0000 (09:54 -0500)] 
configure.ac: don't make `tests/utils/env.sh` executable

It's only meant to be sourced, not executed directly.

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

3 months agorun-in-py-utils-bt2-env.sh: rename `UTILSSH` variable -> `utils_sh`
Philippe Proulx [Fri, 10 Nov 2023 14:48:29 +0000 (09:48 -0500)] 
run-in-py-utils-bt2-env.sh: rename `UTILSSH` variable -> `utils_sh`

Uppercase suggests this is an exported variable while it's local to the
script.

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

3 months agorun-in-py-utils-bt2-env.sh: `${@}` -> `$@`
Philippe Proulx [Fri, 10 Nov 2023 14:46:47 +0000 (09:46 -0500)] 
run-in-py-utils-bt2-env.sh: `${@}` -> `$@`

Curly braces not needed here.

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

3 months agorun-in-py-utils-bt2-env.sh: update comment
Philippe Proulx [Fri, 10 Nov 2023 14:45:50 +0000 (09:45 -0500)] 
run-in-py-utils-bt2-env.sh: update comment

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

3 months agorun-in-py-utils-bt2-env.sh: remove unneeded quotes
Philippe Proulx [Fri, 10 Nov 2023 14:41:57 +0000 (09:41 -0500)] 
run-in-py-utils-bt2-env.sh: remove unneeded quotes

Word splitting and globbing doesn't happen in those contexts.

Removing them makes the code easier to read.

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

3 months agorun-in-py-utils-bt2-env.sh: use the arg. count io. checking a string
Philippe Proulx [Fri, 10 Nov 2023 14:40:37 +0000 (09:40 -0500)] 
run-in-py-utils-bt2-env.sh: use the arg. count io. checking a string

More readable.

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

3 months agorun-in-py-utils-bt2-env.sh: update error message style
Philippe Proulx [Fri, 10 Nov 2023 14:25:07 +0000 (09:25 -0500)] 
run-in-py-utils-bt2-env.sh: update error message style

Also print to the standard error.

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

3 months agorun-in-py-utils-bt2-env.sh: use `[[ ... ]]` instead of `[` or `test`
Philippe Proulx [Fri, 10 Nov 2023 14:19:17 +0000 (09:19 -0500)] 
run-in-py-utils-bt2-env.sh: use `[[ ... ]]` instead of `[` or `test`

For the same reason we're using this form in `utils.sh` (see
"tests/utils/utils.sh: use `[[ ... ]]` instead of `[` or `test`").

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

3 months agorun-in-py-utils-bt2-env.sh: update usage and remove redundant comment
Philippe Proulx [Fri, 10 Nov 2023 14:17:17 +0000 (09:17 -0500)] 
run-in-py-utils-bt2-env.sh: update usage and remove redundant comment

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

3 months agotests/utils: `run-python-bt2.sh` -> `run-in-py-env.sh`
Philippe Proulx [Fri, 10 Nov 2023 14:09:21 +0000 (09:09 -0500)] 
tests/utils: `run-python-bt2.sh` -> `run-in-py-env.sh`

This makes it consistent with the underlying Bash function name and
indicates that it doesn't need to run Python itself.

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

3 months agotests/utils/utils.sh: gen_mctf_trace() -> bt_gen_mctf_trace()
Philippe Proulx [Fri, 10 Nov 2023 21:36:27 +0000 (16:36 -0500)] 
tests/utils/utils.sh: gen_mctf_trace() -> bt_gen_mctf_trace()

Adding the `bt_` prefix like other functions in `utils.sh`.

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

3 months agotests/utils/utils.sh: run_python_bt2_test() -> bt_run_py_test()
Philippe Proulx [Fri, 10 Nov 2023 14:04:42 +0000 (09:04 -0500)] 
tests/utils/utils.sh: run_python_bt2_test() -> bt_run_py_test()

Adding the `bt_` prefix like other functions in `utils.sh` and
shortening the rest.

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

3 months agotests/utils/utils.sh: run_python_bt2() -> bt_run_in_py_env()
Philippe Proulx [Fri, 10 Nov 2023 14:03:15 +0000 (09:03 -0500)] 
tests/utils/utils.sh: run_python_bt2() -> bt_run_in_py_env()

Adding the `bt_` prefix like other functions in `utils.sh` and renaming
the rest to indicate that it runs something in a specific environment,
not necessarily Python itself.

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

3 months agotests/utils/utils.sh: run_python() -> bt_run_in_py_utils_env()
Philippe Proulx [Fri, 10 Nov 2023 13:59:49 +0000 (08:59 -0500)] 
tests/utils/utils.sh: run_python() -> bt_run_in_py_utils_env()

Adding the `bt_` prefix like other functions in `utils.sh` and renaming
the rest to indicate that it runs something in a specific environment,
not necessarily Python itself.

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

3 months agotests/utils/utils.sh: remove redundancy when setting def. var. values
Philippe Proulx [Fri, 10 Nov 2023 05:41:41 +0000 (00:41 -0500)] 
tests/utils/utils.sh: remove redundancy when setting def. var. values

This patch removes more redundancy in `utils.sh` by using a function
which sets a variable by name if it's empty and exports it.

This makes the file less error-prone: the variable name is written just
once, making it safer to add more.

The

    export "${varname?}"

form is to make ShellCheck happy, even if a simple `export $varname`
would perfectly work in this context.

The function is unset when it's not needed anymore to avoid polluting
the scope of whatever sources `utils.sh`.

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

3 months agotests/utils/utils.sh: aerate the code
Philippe Proulx [Fri, 10 Nov 2023 05:24:48 +0000 (00:24 -0500)] 
tests/utils/utils.sh: aerate the code

Have newlines above and below declarations and blocks to make the code
more readable.

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

3 months agotests/utils/utils.sh: remove unneeded curly braces around var. names
Philippe Proulx [Fri, 10 Nov 2023 05:11:57 +0000 (00:11 -0500)] 
tests/utils/utils.sh: remove unneeded curly braces around var. names

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

3 months agotests/utils/utils.sh: remove unneeded quotes
Philippe Proulx [Fri, 10 Nov 2023 05:01:54 +0000 (00:01 -0500)] 
tests/utils/utils.sh: remove unneeded quotes

Word splitting and globbing doesn't happen in those contexts.

Removing them makes the code easier to read.

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

3 months agotests/utils/utils.sh: _set_vars_srcdir_builddir(): use `&>`
Philippe Proulx [Fri, 10 Nov 2023 04:54:58 +0000 (23:54 -0500)] 
tests/utils/utils.sh: _set_vars_srcdir_builddir(): use `&>`

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

3 months agotests/utils/utils.sh: use `[[ ... ]]` instead of `[` or `test`
Philippe Proulx [Fri, 10 Nov 2023 04:47:14 +0000 (23:47 -0500)] 
tests/utils/utils.sh: use `[[ ... ]]` instead of `[` or `test`

Even if `[` and `test` are Bash built-ins for POSIX shell backward
compatibility, `[[` has more features, and since we're using it at least
at once place, it makes sense to always use it in my opinion.

Also use `==` instead of `=`, the latter only existing for POSIX shell
backward compatibility, the former being like pretty much all the other
programming languages we use.

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

3 months agotests/utils/utils.sh: gen_mctf_trace(): use an array for the command line
Philippe Proulx [Fri, 10 Nov 2023 04:36:37 +0000 (23:36 -0500)] 
tests/utils/utils.sh: gen_mctf_trace(): use an array for the command line

This removes the redundancy to both print and run the command line.

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

3 months agotests/utils/utils.sh: gen_mctf_trace(): use `echo` instead of `diag`
Philippe Proulx [Fri, 10 Nov 2023 04:35:02 +0000 (23:35 -0500)] 
tests/utils/utils.sh: gen_mctf_trace(): use `echo` instead of `diag`

This makes gen_mctf_trace() independent from needing `tap.sh` or not.

It's like what we do in bt_cli().

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

3 months agotests/utils/utils.sh: use `+=` instead of expanding the same variable
Philippe Proulx [Fri, 10 Nov 2023 04:32:47 +0000 (23:32 -0500)] 
tests/utils/utils.sh: use `+=` instead of expanding the same variable

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

3 months agotests/utils/utils.sh: check_coverage() -> _bt_tests_check_coverage()
Philippe Proulx [Fri, 10 Nov 2023 04:30:06 +0000 (23:30 -0500)] 
tests/utils/utils.sh: check_coverage() -> _bt_tests_check_coverage()

Make this function "private" (by name) as it's not intended that
whatever sources `utils.sh` use it directly (run_python_bt2_test() uses
it if `BT_TESTS_COVERAGE` is `1`).

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

3 months agotests/utils/utils.sh: bt_grep_ok(): only define if `SH_TAP` is `1`
Philippe Proulx [Fri, 10 Nov 2023 04:28:28 +0000 (23:28 -0500)] 
tests/utils/utils.sh: bt_grep_ok(): only define if `SH_TAP` is `1`

This function uses ok() which comes from `tap.sh` which `utils.sh`
only sources if `SH_TAP` is `1`.

Therefore it makes no sense to run or even define this function if the
intention of whatever sources `utils.sh` isn't to output TAP directly.

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

3 months agotests/utils/utils.sh: bt_diff_details_ctf_single(): remove unneeded `expected_stderr_...
Philippe Proulx [Fri, 10 Nov 2023 04:25:55 +0000 (23:25 -0500)] 
tests/utils/utils.sh: bt_diff_details_ctf_single(): remove unneeded `expected_stderr_file` var.

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

3 months agotests/utils/utils.sh: bt_diff_cli(): return directly, don't use `ret`
Philippe Proulx [Fri, 10 Nov 2023 04:24:43 +0000 (23:24 -0500)] 
tests/utils/utils.sh: bt_diff_cli(): return directly, don't use `ret`

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

3 months agotests/utils/utils.sh: bt_diff(): remove useless `ret` var. and `return`
Philippe Proulx [Fri, 10 Nov 2023 04:22:01 +0000 (23:22 -0500)] 
tests/utils/utils.sh: bt_diff(): remove useless `ret` var. and `return`

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

3 months agotests/utils/utils.sh: use backticks to quote in printed messages
Philippe Proulx [Fri, 10 Nov 2023 04:20:46 +0000 (23:20 -0500)] 
tests/utils/utils.sh: use backticks to quote in printed messages

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

3 months agotests/utils/utils.sh: gen_mctf_trace(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:19:24 +0000 (23:19 -0500)] 
tests/utils/utils.sh: gen_mctf_trace(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: run_python_bt2_test(): make `python_exec` var. local
Philippe Proulx [Fri, 10 Nov 2023 04:41:04 +0000 (23:41 -0500)] 
tests/utils/utils.sh: run_python_bt2_test(): make `python_exec` var. local

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

3 months agotests/utils/utils.sh: run_python_bt2_test(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:19:10 +0000 (23:19 -0500)] 
tests/utils/utils.sh: run_python_bt2_test(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: run_python_bt2_test(): remove useless `test_runner_args` var.
Philippe Proulx [Fri, 10 Nov 2023 05:21:54 +0000 (00:21 -0500)] 
tests/utils/utils.sh: run_python_bt2_test(): remove useless `test_runner_args` var.

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

3 months agotests/utils/utils.sh: run_python_bt2(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:18:21 +0000 (23:18 -0500)] 
tests/utils/utils.sh: run_python_bt2(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_grep_ok(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:16:22 +0000 (23:16 -0500)] 
tests/utils/utils.sh: bt_grep_ok(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_diff_details_ctf_gen_single(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:15:54 +0000 (23:15 -0500)] 
tests/utils/utils.sh: bt_diff_details_ctf_gen_single(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_diff_details_ctf_single(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:15:02 +0000 (23:15 -0500)] 
tests/utils/utils.sh: bt_diff_details_ctf_single(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_diff_cli(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:14:34 +0000 (23:14 -0500)] 
tests/utils/utils.sh: bt_diff_cli(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_diff(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:13:33 +0000 (23:13 -0500)] 
tests/utils/utils.sh: bt_diff(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: bt_cli(): use `local -r` when possible
Philippe Proulx [Fri, 10 Nov 2023 04:12:59 +0000 (23:12 -0500)] 
tests/utils/utils.sh: bt_cli(): use `local -r` when possible

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

3 months agotests/utils/utils.sh: run_python_bt2(): remove unneeded env. var.
Philippe Proulx [Fri, 10 Nov 2023 04:09:32 +0000 (23:09 -0500)] 
tests/utils/utils.sh: run_python_bt2(): remove unneeded env. var.

`BABELTRACE_PYTHON_BT2_NO_TRACEBACK` doesn't seem to be used anywhere in
the project: remove it.

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

3 months agotests/utils/utils.sh: don't export `BT_TESTS_ENABLE_ASAN`
Philippe Proulx [Fri, 10 Nov 2023 05:30:41 +0000 (00:30 -0500)] 
tests/utils/utils.sh: don't export `BT_TESTS_ENABLE_ASAN`

It's only needed by run_python_bt2().

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

3 months agotests/utils/utils.sh: use "private" variables if applicable
Philippe Proulx [Fri, 10 Nov 2023 04:06:12 +0000 (23:06 -0500)] 
tests/utils/utils.sh: use "private" variables if applicable

The non-exported `BT_PLUGINS_PATH` and `BT_TESTS_PYTHON_VERSION`
variables aren't directly needed by whatever sources `utils.sh` and its
subprocesses.

`BT_PLUGINS_PATH` is actually exported when calling run_python_bt2(),
for that specific case.

Make them more "private" by using the `_bt_tests_` prefix.

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

3 months agotests/utils/utils.sh: use a function to source `env.sh`
Philippe Proulx [Fri, 10 Nov 2023 04:03:26 +0000 (23:03 -0500)] 
tests/utils/utils.sh: use a function to source `env.sh`

By using a function to do this, we can use a local variable to hold the
`env.sh` path and therefore remove redundancy.

Disabling SC1090 because it's a non-constant source now, but it's
useless to add `source=` here because SC1091 is already disabled.

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

3 months agotests/utils/utils.sh: quote command name when running it
Philippe Proulx [Fri, 10 Nov 2023 04:01:01 +0000 (23:01 -0500)] 
tests/utils/utils.sh: quote command name when running it

Word splitting applies in this context.

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

3 months agotests/utils/utils.sh: use a func. to set `BT_TESTS_{SRC,BUILD}DIR`
Philippe Proulx [Fri, 10 Nov 2023 03:56:05 +0000 (22:56 -0500)] 
tests/utils/utils.sh: use a func. to set `BT_TESTS_{SRC,BUILD}DIR`

By using a function to set those, the `scriptdir` and `testsdir` can be
local and not leak into whatever sources `utils.sh`.

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

3 months agotests/utils/utils.sh: improve comments
Philippe Proulx [Fri, 10 Nov 2023 03:51:50 +0000 (22:51 -0500)] 
tests/utils/utils.sh: improve comments

Add some, make some more readable, add details to some, stay within
72 columns.

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

3 months agotests/utils/env.sh.in: add comments and remove redundancy
Philippe Proulx [Thu, 9 Nov 2023 16:43:10 +0000 (11:43 -0500)] 
tests/utils/env.sh.in: add comments and remove redundancy

This patch removes redundancy in `env.sh.in` by using a function which
sets a variable by name if it's empty and exports it.

This makes the file less error-prone: the variable name is written just
once, making it safer to add more.

The

    export "${varname?}"

form is to make ShellCheck happy, even if a simple `export $varname`
would perfectly work in this context.

The function is unset at the end to avoid polluting the scope of
whatever sources `env.sh`.

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

3 months agotools/shellcheck.sh: allow overriding the shellcheck path
Simon Marchi [Mon, 29 Jan 2024 21:54:10 +0000 (16:54 -0500)] 
tools/shellcheck.sh: allow overriding the shellcheck path

For an unknown (to me) reason, the shellcheck binary from the Arch Linux
package (version 0.9.0-79) hits this error:

    $ tools/shellcheck.sh
    ...
    Running ShellCheck on `./tests/cli/test-intersection.sh`
    shellcheck: (Array.!): undefined array element
    ...

This looks like an error internal to shellcheck.  When using the Linux
x86-64 binary from the release [1], it works fine.  Add a way to
override the shellcheck binary in shellcheck.sh, to make working around
this easier:

    $ SHELLCHECK=/home/smarchi/Downloads/shellcheck-v0.9.0/shellcheck tools/shellcheck.sh
    ... all fine !

[1] https://github.com/koalaman/shellcheck/releases/tag/v0.9.0

Change-Id: I81f0ea2e40b9dbac75e0b0debcce63338986358c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11755
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agotests: add `src.ctf.fs` single field testing framework
Olivier Dion [Wed, 18 Oct 2023 15:02:30 +0000 (11:02 -0400)] 
tests: add `src.ctf.fs` single field testing framework

This patch adds a framework to test the decoding of single CTF 1.8
fields by a `src.ctf.fs` component.

Single CTF 1.8 field tests reside as moultipart documents (see
`tests/utils/python/moultipart.py`) in
`tests/data/plugins/src.ctf.fs/field/ctf-1`.

The new `test-field.sh` script does the following, for each `pass-*.mp`
file found in `tests/data/plugins/src.ctf.fs/field/ctf-1`:

1. Creates a temporary directory TD to hold a CTF 1.8 trace (`TD/trace`)
   and an expectation file (`TD/expect`).

2. Runs `data_from_mp.py` on the moultipart document, also passing TD.

   This script splits the moultipart document to produce `TD/trace` and
   `TD/expect`. The expected parts are, in this order:

   a) A TSDL field class (metadata), without any field name, for
      example:

          integer { size = 32; byte_order = be; }

      If you need to test the decoding of an array field, you may use
      `@` in this part to indicate to `data_from_mp.py` where the
      field name goes, for example:

          string @[23]

   b) A Normand [1] text representing the exact data of an instance
      of a).

   c) What you expect the `sink.test-text.single` component to print
      when it receives an event message containing what a `src.ctf.fs`
      component decoded from `TD/trace`.

      `sink.test-text.single` prints exactly the value of b) with a
      YAML-like format.

3. Runs something like this, keeping the standard output text:

       $ babeltrace2 -c sink.test-text.single "TD/trace"

4. Compares the result of step 3 with `TD/expect` using bt_diff().

Now it becomes easy to test regular and corner cases of our CTF 1.8
decoding by adding new files to
`tests/data/plugins/src.ctf.fs/field/ctf-1`.

As initial examples, `tests/data/plugins/src.ctf.fs/field/ctf-1`
contains a few single field tests already.

Philippe changes:

• Made some style adjustments to the original patch.

• Using `mktemp -d` instead of `mktemp --directory` because macOS
  doesn't seem to know the latter.

• In `utils.sh`, changed bt_diff() to use the new bt_remove_cr_inline()
  to remove CR characters from both files because this is the first time
  the test generates both files.

  Leaving bt_remove_cr() as is because another test uses it directly.

• In the _print_field() function of `bt_plugin_test_text.py`:

  ‣ Changed parts of the strategy to fix some rendering bugs.
  ‣ Using int() for an integer field to avoid printing enum. labels.
  ‣ Added the empty structure field special case.
  ‣ Added comments with output examples.

• In `data_from_mp.py`:

  ‣ Added lots of useful TSDL type aliases available to any CTF 1
    single field test.

  ‣ Made the default Normand byte order little-endian since it's also
    the default TSDL byte order in _make_ctf_1_metadata().

• In `test-field.sh`, using a hard-coded test count.

  See the Gerrit discussion [2] for the rationale.

• Added more initial tests in
  `tests/data/plugins/src.ctf.fs/field/ctf-1`.

[1]: https://github.com/efficios/normand
[2]: https://review.lttng.org/c/babeltrace/+/11149

Change-Id: I7539b46d49200b5e75fe3525401b47b8ff418f6c
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11149
Tested-by: jenkins <jenkins@lttng.org>
3 months agoFix: `babeltrace2 convert`: don't consider the `--plugin-path` opt.
Philippe Proulx [Wed, 7 Feb 2024 17:02:04 +0000 (12:02 -0500)] 
Fix: `babeltrace2 convert`: don't consider the `--plugin-path` opt.

OBSERVED ISSUE
══════════════
When running the (default) `convert` command of the CLI and passing
`--plugin-path` _after_ a conversion argument, the program aborts:

    $ babeltrace2 /some/path --plugin-path=/meow/mix
    [1]    87823 IOT instruction (core dumped)  babeltrace2 /some/path --plugin-path=/meow/mix

I expect such a command line to gracefully tell me that `--plugin-path`
is an unknown option.

CAUSE
═════
This is due to the `convert` command considering the general
`--plugin-path` option (part of the `convert_options` array), but then
not ignoring it during one of its passes.

`--plugin-path` is a general option, not a conversion option. Therefore,
it must not be part of `--plugin-path`.

SOLUTION
════════
Remove the `OPT_PLUGIN_PATH` entry from the `convert_options` array in
`babeltrace2-cfg-cli-args.c`.

The output of the command line above is now:

    ERROR:    [Babeltrace CLI] (babeltrace2.c:2655)
      Command-line error: retcode=1
    CAUSED BY [Babeltrace CLI] (babeltrace2-cfg-cli-args.c:1427)
      While parsing `convert` command's command-line arguments: While
      parsing argument #3
      (`--plugin-path=data/plugins/src.ctf.fs/field/`): Unknown option
      `--plugin-path`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8b22c5f732aae9fd1f3c989bd5aaef2d461d4160
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11756
Tested-by: jenkins <jenkins@lttng.org>
3 months agolib: move graph/message/iterator.h -> graph/iterator.h
Simon Marchi [Tue, 6 Feb 2024 17:35:10 +0000 (17:35 +0000)] 
lib: move graph/message/iterator.h -> graph/iterator.h

This file doesn't belong in the `message` directory, move it up one
level, next to `iterator.c`.

Change-Id: I096d91d5afa32ebb304b5132cad067e820f2bb30
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11749
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/vendor/optional-lite: bump to 3.6.0
Philippe Proulx [Tue, 6 Feb 2024 03:09:35 +0000 (22:09 -0500)] 
cpp-common/vendor/optional-lite: bump to 3.6.0

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I81ff349fb55cd3d3a0474fcff13ef10a439b852c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11747
Tested-by: jenkins <jenkins@lttng.org>
3 months agoUpdate README.adoc
Philippe Proulx [Tue, 6 Feb 2024 03:55:51 +0000 (22:55 -0500)] 
Update README.adoc

Notable changes:

‣ Fix broken LTTng CI links.

‣ Reword a few sentences to improve clarity.

‣ Use mostly "Babeltrace 2".

‣ Remove the sentence saying Babeltrace 2.0 is a "recent" release.

‣ Add an image (a conversion graph diagram) to maintain attention.

‣ Add a ToC, placing it at a specific location after the preamble when
  GitHub renders.

‣ Add thanks to the authors of embedded projects.

‣ Mention `--enable-built-in-plugins` and
  `--enable-built-in-python-plugin-support`.

‣ Transform the note in "Community" to regular text.

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

3 months agobt2c::Logger::_logStrNoThrow(): use `msg`, not `_mBuf.data()`
Philippe Proulx [Fri, 2 Feb 2024 20:34:03 +0000 (15:34 -0500)] 
bt2c::Logger::_logStrNoThrow(): use `msg`, not `_mBuf.data()`

By chance those were always the same, but from the _logStrNoThrow()
point of view, it must use `msg`.

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

3 months agoFix: bt2c::Logger: include the `errno` message into an error cause too
Philippe Proulx [Fri, 2 Feb 2024 20:19:24 +0000 (15:19 -0500)] 
Fix: bt2c::Logger: include the `errno` message into an error cause too

The observed issue is that, when using a BT_CPPLOG_ERRNO*APPEND*()
macro, the logger logs the `errno` message (for example,
`Invalid argument`), but the message of the appended error cause doesn't
contain it.

This is because `bt2c::Logger` relies on bt_log_write_errno() to include
the `errno` message (bt_log_write_errno() is the one calling
g_strerror()).

To fix this, don't call bt_log_write_errno() anymore: consider `initMsg`
in the general private methods (like _logStrNoThrow()), and format an
introductory message (`initMsg`, `: `, and then the result of
g_strerror()) directly into the logErrno*() methods. See the new static
_errnoIntroStr().

The `_InitMsgLogWriter` writer makes the concatenation of `initMsg`
and `msg` using bt_log_write_printf():

    bt_log_write_printf(funcName, fileName, lineNo,
                        static_cast<bt_log_level>(level), tag, "%s%s",
                        initMsg, msg);

`_StdLogWriter` ignores the `initMsg` parameter, but we only call it
when `initMsg` is an empty string anyway (I'm adding an assertion to
confirm that). For example, logStrNoThrow() calls _logStrNoThrow() with
`_StdLogWriter` and an empty `initMsg`. Same for `_MemLogWriter`.

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

3 months agologging/log-api.c: add newline between assertion and declaration
Philippe Proulx [Fri, 2 Feb 2024 20:07:02 +0000 (15:07 -0500)] 
logging/log-api.c: add newline between assertion and declaration

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I7426c7496a17f5e6cc958a578c755257895fc979
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11739
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
3 months agosrc/Makefile.am: add libcpp-common convenience library
Simon Marchi [Mon, 5 Feb 2024 16:42:03 +0000 (11:42 -0500)] 
src/Makefile.am: add libcpp-common convenience library

Some following commits are expected to add .cpp files to the cpp-common
library.  Turn it into a convenience libtool library.

Add a temporary dummy.cpp file, since some platforms don't like building
a library without at least one compiled source file.

Change-Id: I702b242ca2d229ab5064ba36d422368fd9a03909
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11715
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common: add `bt2s::span` 0.11.0 and other related symbols
Philippe Proulx [Wed, 31 Jan 2024 22:41:47 +0000 (17:41 -0500)] 
cpp-common: add `bt2s::span` 0.11.0 and other related symbols

This patch adds `bt2s::span` which wraps `nonstd::span`, that is,
span lite [1], a project written by the author also who wrote our
`bt2s::optional` implementation, therefore I trust him.

span lite is an implementation of `std::span` [2] for C++98 and up:

> The class template `span` describes an object that can refer to a
> contiguous sequence of objects with the first element of the sequence
> at position zero.

This will be useful to pass some data block as a single parameter
without copying the viewed data (in other words, a pointer and a length
with some sugar such as operator[]() and the like).

[1]: https://github.com/martinmoene/span-lite
[2]: https://en.cppreference.com/w/cpp/container/span

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ife35b4be41536fec15aef9d6603a80746c3e8727
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11728
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agocpp-common/bt2s: use a `using` declaration
Philippe Proulx [Wed, 31 Jan 2024 22:37:49 +0000 (17:37 -0500)] 
cpp-common/bt2s: use a `using` declaration

This is exactly the purpose of a `using` declaration, to make the symbol
from the `bpstd`/`nonstd` namespace accessible for unqualified lookup as
if declared in the `bt2s` namespace.

The code is much simpler.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8348f409a463b85f5b2ed1f1fd8f61adb404a6d9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11727
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

3 months ago`optional.hpp.license` belongs to `cpp-common/vendor/optional-lite`
Philippe Proulx [Wed, 31 Jan 2024 21:52:46 +0000 (16:52 -0500)] 
`optional.hpp.license` belongs to `cpp-common/vendor/optional-lite`

Forgot that in c022776a5 ("cpp-common: add `bt2s::optional`, alias of
`nonstd::optional`").

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ica468aa5b034b3eec42e41ffa9cfaa9615a42471
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11726
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

3 months agotests: fix namespace comment style
Simon Marchi [Fri, 2 Feb 2024 16:18:32 +0000 (16:18 +0000)] 
tests: fix namespace comment style

Change-Id: I6befd5bd154ebbba850077cefff6b113d9d47fda
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11738
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoFix: lib: handle BT_FUNC_STATUS_NOT_FOUND in bt_plugin_so_create_all_from_sections
Simon Marchi [Mon, 15 Jan 2024 21:24:19 +0000 (16:24 -0500)] 
Fix: lib: handle BT_FUNC_STATUS_NOT_FOUND in bt_plugin_so_create_all_from_sections

When an SO plugin's init function returns an error and
fail_on_load_error is false, we hit an assert:

    (╯°□°)╯︵ ┻━┻  /home/smarchi/src/babeltrace/src/lib/plugin/plugin-so.c:1351: bt_plugin_so_create_all_from_sections(): Assertion `!plugin` failed.

When an error happens in the plugin's init function, bt_plugin_so_init returns BT_FUNC_STATUS_NOT_FOUND.  We leave the `plugin` variable set, which triggers the assert.

Fix this by putting/resetting `plugin` in that case.  Since there was an
error initializing the plugin, we won't return it to the user, so I
think that release it is the right thing to do here.

Add a test with a plugin whose init function fail.  Test both the
fail_on_load_error true and false cases.

Change-Id: I8e219f728a4b58d0e32307f907243892a02fdccf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: Brice Videau <bvideau@anl.gov>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11679
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Brice Videau <bvideau@anl.gov>
Tested-by: jenkins <jenkins@lttng.org>
3 months agocpp-common/bt2c: add CStringView equality and non-equality operators
Simon Marchi [Mon, 15 Jan 2024 21:25:29 +0000 (16:25 -0500)] 
cpp-common/bt2c: add CStringView equality and non-equality operators

Add `operator==` and `operator!=` functions to check equality or
non-equality between `CStringView` and another `CStringView`,
`const char *` and `std::string`.

Add a test to exercise those.

Change-Id: I2463966aae50792bb3e21ae65f9f124b08114499
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11681
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/bt2c: add `bt2c::IsOneOf` trait
Simon Marchi [Tue, 23 Jan 2024 17:30:43 +0000 (17:30 +0000)] 
cpp-common/bt2c: add `bt2c::IsOneOf` trait

Add the `bt2c::IsOneOf` trait, which is used to check if a type is in a
list of types.

Change-Id: If95ebc542d0581afb3411fcaece6617bb4946612
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11708
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/bt2: add basic PluginSet and bt_plugin_find_all_from_dir wrappers
Simon Marchi [Mon, 15 Jan 2024 21:19:24 +0000 (16:19 -0500)] 
cpp-common/bt2: add basic PluginSet and bt_plugin_find_all_from_dir wrappers

Add a `bt2::PluginSet` class, wrapping `bt_plugin_set`.  It only
contains what I need for a test coming in a subsequent patch.

Add a `bt2::findAllPluginsFromDir` function, wrapping
`bt_plugin_find_all_from_dir`.

Change-Id: Ieca897dec5c08381deb473e701f7e41aee84e89c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11680
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agosrc: Makefile.am cleanups
Simon Marchi [Tue, 16 Jan 2024 04:13:54 +0000 (23:13 -0500)] 
src: Makefile.am cleanups

`shared-object.hpp` is there twice, remove one entry.  Move
`raw-value-proxy.hpp` to respect the alphabetical order.

Change-Id: I314191c2a06ff72c3e89ae4c87252fe8adaac054
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11686
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agotests: rename lib plugins test files
Simon Marchi [Mon, 15 Jan 2024 19:22:41 +0000 (14:22 -0500)] 
tests: rename lib plugins test files

Standardize the names for this test a bit.

Change-Id: I2d70332ed6f25505aac36be7da7a1bdb63da72b6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11678
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agocpp-common/bt2: use bt2c::CStringView in parameters and return values throughout
Simon Marchi [Tue, 16 Jan 2024 18:31:06 +0000 (13:31 -0500)] 
cpp-common/bt2: use bt2c::CStringView in parameters and return values throughout

From what I saw, at -O2 with gcc, passing and returning CStringViews
generates the same code as passing and returning `const char *`.  Change
the `cpp-common/bt2` code to take a return C strings using CStringViews
when possible, which is more convenient than `const char *`.

Since std::string is implicitly convertible to CStringView, there is
generaly no need to have separate overloads that take std::strings.

I left the `CommonStringField::append(const std::string &)` overload,
because this one has an advantage over the `CStringView` overload: it
uses the size of the `std::string`, which is cheaper than calling
`std::strlen`.

There are some cases where leaving the `const char *` overload is
necessary.  For instance, when there is also a `bool` overload.  In that
case, passing a `const char *` to the function would prefer the `bool`
overload over the `CStringView` overload, which is not what we want.

Change-Id: I4c995c995da3edd2f0e9f7034053d52cb1541bb0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11690
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/bt2c: make some constructors of CStringView constexpr
Simon Marchi [Tue, 16 Jan 2024 18:59:43 +0000 (13:59 -0500)] 
cpp-common/bt2c: make some constructors of CStringView constexpr

Change-Id: I56daad7dae1bc65183f016a1a9d2d6c529b3569d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11689
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/bt2c: make CStringView convertible from std::string
Simon Marchi [Tue, 16 Jan 2024 18:58:25 +0000 (13:58 -0500)] 
cpp-common/bt2c: make CStringView convertible from std::string

This will make it possible to have functions that accept CStringViews:

    void foo(CStringView);

and pass in std::strings seamlessly:

    foo(myStdStr);

Change-Id: I76dc55438c2cd87f77ddec421dff7f119e53eff5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11688
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agocpp-common/bt2c: simplify CStringView formatter
Simon Marchi [Mon, 15 Jan 2024 21:34:29 +0000 (16:34 -0500)] 
cpp-common/bt2c: simplify CStringView formatter

Use a format_as function instead of a full-fledged formatter.

Change-Id: I49a015a1c88a49cd7c4bab3ff1cbbf8cad8b6ba0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11682
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agoinclude/babeltrace2/types.h: remove `bt_plugin_so_shared_lib_handle`
Philippe Proulx [Thu, 25 Jan 2024 17:43:20 +0000 (12:43 -0500)] 
include/babeltrace2/types.h: remove `bt_plugin_so_shared_lib_handle`

This was never meant to be public.

In theory, this patch is a breaking change, but I don't see why anybody
would use that type currently.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib832e67cb8b71201157cf83cb7ccac980c4ee57b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11711
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agolib: remove unused includes
Simon Marchi [Fri, 26 Jan 2024 15:33:32 +0000 (15:33 +0000)] 
lib: remove unused includes

Remove a bunch of includes that my IDE (VSCode + clangd) reports as
unused.  I didn't touch the logging and compat includes.

Change-Id: I5fe2cb4a332f000dc7d9b8c015bcd6382684fc6c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11718
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agoinclude/babeltrace2/plugin/plugin-dev.h: "define" -> "definition
Philippe Proulx [Thu, 25 Jan 2024 17:47:20 +0000 (12:47 -0500)] 
include/babeltrace2/plugin/plugin-dev.h: "define" -> "definition

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

3 months agotools/format-cpp.sh: ignore `.git` directory
Philippe Proulx [Tue, 23 Jan 2024 15:39:37 +0000 (10:39 -0500)] 
tools/format-cpp.sh: ignore `.git` directory

A `.hpp` or `.cpp` file could exist in `.git`, for example in
`.git/logs/refs/heads` if the branch name ends with `.hpp` or `.cpp`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I328486a81148fe46221bac8979ab6127ed4e3903
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11707
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agotests: remove unused _TestIntegerValue.test_create_neg
Simon Marchi [Wed, 22 Nov 2023 17:43:47 +0000 (12:43 -0500)] 
tests: remove unused _TestIntegerValue.test_create_neg

This test method is unused, since all sub-classes define a
test_create_neg method.  I confirmed this by:

 - placing an `assert False` inside it and running the test
 - comparing the number of tests ran as reported by the unittest runner,
   before and after the change

Change-Id: Ib2bd1cb919c85e6dddc21c0f305cfab8504d06e9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11409
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agobt2: require msg for _OverflowError in _handle_func_status
Simon Marchi [Wed, 8 Nov 2023 16:21:54 +0000 (16:21 +0000)] 
bt2: require msg for _OverflowError in _handle_func_status

Pyright says:

    /home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/utils.py:160:19 - error: Invalid exception class or object
    Constructor for exception type "type[_OverflowError]" requires one or more arguments (reportGeneralTypeIssues)

That's true, _OverflowError has bt2_error._Error as a base, which
requires a message.  Change _handle_func_status to assert that a msg was
provided when handling that case.

Change-Id: I961c336cf53ce13e5f4241728e1131cccb77efcf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11297
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoFix: bt2: pass _TraceClassConst to destruction listeners
Simon Marchi [Mon, 27 Nov 2023 20:41:31 +0000 (15:41 -0500)] 
Fix: bt2: pass _TraceClassConst to destruction listeners

Trace class destruction listeners currently receive a _TraceClass.  I
think it's a mistake, in that they should receive a _TraceClassConst.
Fix that, tweak the tests to test it.  Test the same thing for trace
destruction listeners (they didn't suffer from the same issue).

Change-Id: I4651ffc44c916d64f6e6f2944fa856b4ed5bb5f6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11447
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoFix: lib: pass correct argument to BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL
Simon Marchi [Fri, 5 Jan 2024 15:26:57 +0000 (10:26 -0500)] 
Fix: lib: pass correct argument to BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL

Reported-By: Brice Videau <bvideau@anl.gov>
Change-Id: I88100e83c0d97ef52255863206923bf11ccc07b5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11624
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Brice Videau <bvideau@anl.gov>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agotools: Add shellcheck.sh
Michael Jeanson [Tue, 7 Nov 2023 19:21:27 +0000 (14:21 -0500)] 
tools: Add shellcheck.sh

This script will run ShellCheck on all files in the tree with the '.sh'
extension and return a non-zero exit code if any of the files has an
issue.

Change-Id: Ib65dcf1c9bd447a92a773284cc138ec0ed01444b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11293

3 months agofix: 'env.sh' is optional, ignore it in shellcheck
Michael Jeanson [Fri, 15 Dec 2023 21:50:19 +0000 (16:50 -0500)] 
fix: 'env.sh' is optional, ignore it in shellcheck

Since 'env.sh' is an optional file, don't fail shellcheck when it is
absent.

Change-Id: I28b768a6023b789f90e4433016e9025f2b5e2f21
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11597
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
3 months agoconfigure: use single word for PROJECT-NAME argument of DX_INIT_DOXYGEN
Simon Marchi [Wed, 3 Jan 2024 03:37:57 +0000 (22:37 -0500)] 
configure: use single word for PROJECT-NAME argument of DX_INIT_DOXYGEN

Running configure with --enable-api-doc shows this warning:

    /home/simark/src/babeltrace/configure: line 25508: 2: command not found

The line 25508 in question is:

  DX_PROJECT=Babeltrace 2

In shell script, this tries to execute the command `2`, with the
`DX_PROJECT` environment variable set to `Babeltrace`.  This is
obviously not what we want.

The documentation for the DX_INIT_DOXYGEN macro says:

   ... call DX_INIT_DOXYGEN with the following parameters: a one-word
   name for the project for use as a filename base etc.

So, we shouldn't pass something with a space as the project name to
DX_INIT_DOXYGEN.  Change it to `babeltrace2`.  I don't think that this
gets used anywhere though, as I didn't see a difference in my build
directory before and after the change (except in the Makefiles, which
don't use the value themselves).

Reported-by: Brice Videau <bvideau@anl.gov>
Change-Id: I5c6a86f3c93ea21d239bd3146eb8359a6c74eaa2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11623
Reviewed-by: Brice Videau <bvideau@anl.gov>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoFix typos
Simon Marchi [Mon, 8 Jan 2024 20:36:24 +0000 (15:36 -0500)] 
Fix typos

Run `typos -w` [1] on the repository, and cherry-pick the good changes.

[1] https://github.com/crate-ci/typos

Change-Id: I995cf7d851cd7ff40e47767ffe14c03fbd2d23bb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11426
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agotests: remove stale comment in stored-values.mctf
Simon Marchi [Wed, 10 Jan 2024 21:27:49 +0000 (16:27 -0500)] 
tests: remove stale comment in stored-values.mctf

Change-Id: Id617e6abb33fdaeff065daa0211cdf8294c86b5d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11643
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 months agoFix: doc: escape double quote in bt_p alias
Simon Marchi [Thu, 11 Jan 2024 20:00:17 +0000 (15:00 -0500)] 
Fix: doc: escape double quote in bt_p alias

The HTML doc shows some `<span class=` where the parameter names are
meant to appear.  Escape those double quotes to fix it.

The output was correct in the past, it only started to display the wrong
thing with this commit, in Doxygen 1.9.0:

https://github.com/doxygen/doxygen/commit/eb3d1eb5ad85c94d6f2c32934fce2b8630331d6c

Reported-By: Brice Videau <bvideau@anl.gov>
Change-Id: I61f3b557e3d8bf1428dd57e4c1ce950461e32479
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11647
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 months agofix: 'load_module()' deprecated in Python 3.12
Michael Jeanson [Thu, 14 Dec 2023 22:11:42 +0000 (17:11 -0500)] 
fix: 'load_module()' deprecated in Python 3.12

Starting with Python 3.10 we get the following warning:

  <frozen importlib._bootstrap>:283: DeprecationWarning: the
  load_module() method is deprecated and slated for removal in
  Python 3.12; use exec_module() instead

Replace our use of 'load_module()' with the recommended [1] alternative
that includes 'module_from_spec()' introduced in Python 3.5. Since we
need to support Python 3.4, keep the original code with a version check.

[1] https://docs.python.org/3.12/library/importlib.html#importlib.machinery.SourceFileLoader.load_module

Change-Id: I77d14f14fcc39e0227baad959c3e211aba309a21
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11583
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 months agologging: Add freebsd support
Michael Jeanson [Thu, 14 Dec 2023 20:42:15 +0000 (15:42 -0500)] 
logging: Add freebsd support

Add the FreeBSD platform specific code to get a thread id for the
logging system.

Change-Id: Ifd2a53c5c47e1b23a7f0a90c1fc0768e7f4dbcb3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11582
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 months agoflt.utils.muxer: use a heap to sort iterators (also: rewrite in C++)
Philippe Proulx [Mon, 6 Nov 2023 21:16:54 +0000 (16:16 -0500)] 
flt.utils.muxer: use a heap to sort iterators (also: rewrite in C++)

The main goal of this patch was to use a heap instead of an array to
sort upstream message iterators so as to improve the performance of a
`flt.utils.muxer` message iterator managing a lot of usptream message
iterators, especially with a lot of connected input ports.

To do this, I first decided to use `std::priority_queue`, and since I'm
not a fan of mixed C and C++, I also decided to take the opportunity to
convert the whole component class C source to C++. This looked like a
good excuse to prove that it's possible, using only common C++ stuff,
including libbabeltrace2 bindings (`bt2` namespace).

Therefore, I'm glad to announce that `flt.utils.muxer` is the first
upstream C++-only component class! 🥳

In the end, because it's more efficient, I decided to write a C++
version of what used to be the `bt_heap_` C API, `bt2c::PrioHeap`, and
to use this instead of `std::priority_queue`. 🤷

This new version has more or less the same logic as the previous one. It
has three classes under the `bt2mux` namespace:

`Comp`:
    The filter component class which doesn't do much.

    Its main purpose is to add an available input port when one is
    connected.

`UpstreamMsgIter`:
    Wraps a `bt2::MessageIterator`, keeping an internal array of
    messages (what bt2::MessageIterator::next() returns), and offering
    the msg() (current message), msgTs() (cached timestamp, if any, of
    current message), discard(), and reload() methods to deal with a
    single message at a time.

    You must call always reload() before calling msg()/msgTs(), and if
    there's current message, you must call discard() before you call
    reload(). Making the caller responsible of this logic removes
    redundant conditions in this class. You may view the
    msg() + discard() pair as a form of message popping. The sequence is
    usually:

    1. We know there's a current message because the last call to
       reload() was successful.

    2. Get the current message with msg(), and then call discard() to
       discard/remove it.

    3. Try to call reload().

       This may return `UpstreamMsgIter::ReloadStatus::NO_MORE`; if it
       does, stop using this upstream message iterator.

       This may also throw `bt2::TryAgain`; if it does, call reload()
       again later.

    Caching the timestamp of the current message is an improvement
    because the heap rebalancing operation could need to use them
    several times when comparing two upstream message iterators.

    This class also offers canSeekBeginning(), seekBeginning(), and
    canSeekForward() which more or less wrap the corresponding
    `bt2::MessageIterator` methods.

`MsgIter`:
    The message iterator class.

    This is where most of the changes are.

    It keeps a `bt2c::PrioHeap` of `UpstreamMsgIter` pointers to sort
    them. The comparator works like before, so that the output message
    order of this version for a given set of upstream message iterators
    should be the same as the previous version.

    Like before, it has an array of pointers to upstream message
    iterators to reload. An upstream message iterator is either part of
    the heap, or part of this array. We need to call reload() on each of
    the upstream message iterators in this array. This is either
    because:

    * We put them here on `MsgIter` construction to avoid getting any
      exception from bt2::MessageIterator::next().

    * The last attempt to call reload() on them threw `bt2::TryAgain`.

    Before MsgIter::_next() selects a message to add to the message
    array, all non-ended upstream message iterators need to be part of
    the heap.

    The logic of clock class expectation is unchanged.

In general, there are more detailed comments, and logging is improved,
in particular the trace level statements of the heap comparator:

    [...] T PLUGIN/FLT.UTILS.MUXER/[muxer]/MSG-ITER operator()@plugins/utils/muxer/msg-iter.cpp:501 Comparing two messages: port-name-a=in0, msg-a-type=PACKET_BEGINNING, msg-a-ts=1441852773113941931, port-name-b=in1, msg-b-type=STREAM_BEGINNING, msg-b-ts=none
    [...] T PLUGIN/FLT.UTILS.MUXER/[muxer]/MSG-ITER operator()@plugins/utils/muxer/msg-iter.cpp:538 Message A has a timestamp, but message B has none: oldest=B
    ...
    [...] T PLUGIN/FLT.UTILS.MUXER/[muxer]/MSG-ITER operator()@plugins/utils/muxer/msg-iter.cpp:501 Comparing two messages: port-name-a=in2, msg-a-type=PACKET_END, msg-a-ts=1441852847496965372, port-name-b=in1, msg-b-type=PACKET_END, msg-b-ts=1441852847496953796
    [...] T PLUGIN/FLT.UTILS.MUXER/[muxer]/MSG-ITER operator()@plugins/utils/muxer/msg-iter.cpp:533 Timestamp of message A is greater than timestamp of message B: oldest=B

My preliminary experiments show that this version is slightly (a few
percentage points) more efficient than the previous one for a typical
four-stream scenario, and then around 12-13 times more efficient for a
208-stream scenario.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2e393a2ef1c33c6b134284028807c687f8adf0e8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11273
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agocpp-common/bt2: return `bt2c::CStringView` instead of `const char *`
Simon Marchi [Mon, 11 Dec 2023 21:10:01 +0000 (16:10 -0500)] 
cpp-common/bt2: return `bt2c::CStringView` instead of `const char *`

This patch makes any method in `cpp-common/bt2` return
`bt2c::CStringView` instead of `const char *` when possible to improve
the usability of the wrapping API.

In `bt2::CommonStringField` and `bt2::CommonStringValue`, I didn't
bother having a different raw value type to set vs. get, therefore the
value() getter returns `bt2c::CStringView` while the value() setter has
overloads for `bt2c::CStringView`, `const char *`, and
`const std::string&`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iab7c7ea9a97035b9bea018f918a5d52516ab676c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11486
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agocpp-common/bt2c: add `bt2c::CStringView`
Philippe Proulx [Tue, 5 Dec 2023 07:00:28 +0000 (02:00 -0500)] 
cpp-common/bt2c: add `bt2c::CStringView`

A `bt2c::CStringView` is like a `bt2s::string_view`, but specialized for
strings that are known to be null-terminated (C strings).

This is useful when wrapping an existing API which has functions
returning `const char *`: return `bt2c::CStringView` from the wrappers
at no cost, but with improved usability:

    if (myObj.name().len() >= 16) {
        // ...
    }

vs.

    if (std::strlen(myObj.name()) >= 16) {
        // ...
    }

A `bt2c::CStringView` only computes the length of the underlying
C string with std::strlen() when needed. It can convert to `std::string`
and `bt2s::string_view`.

`c-string-view.hpp` includes an {fmt} formatter for convenience. It
writes `(null)` when the underlying pointer is null, just like the glibc
printf() does.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I522ce586e9966736dadeeabf30f02da5dc62c80c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11485
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agoplugins/common/muxing/muxing.c: use BT_ASSERT_DBG()
Philippe Proulx [Wed, 29 Nov 2023 17:23:59 +0000 (12:23 -0500)] 
plugins/common/muxing/muxing.c: use BT_ASSERT_DBG()

Potential fast path.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic269b7ca8877ab6eff482a112d1f1133ee48fd6b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11464
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
4 months agocpp-common: fix `#include` patterns
Simon Marchi [Mon, 11 Dec 2023 20:06:12 +0000 (15:06 -0500)] 
cpp-common: fix `#include` patterns

Include from the same directory directly, and from everything else
relative to `src/`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie6dd5777d884911b9ad736ef625b784930ee3a23
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11457
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agobt_secure_getenv(): add missing `unused` attribute for log level
Philippe Proulx [Tue, 28 Nov 2023 19:45:25 +0000 (14:45 -0500)] 
bt_secure_getenv(): add missing `unused` attribute for log level

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I01c209976ebec9aa69227545341b6ccefe591fe2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11456
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agoinclude/babeltrace2: add `noexcept` specifier for C++ ≥ 11
Philippe Proulx [Sat, 25 Nov 2023 16:13:57 +0000 (11:13 -0500)] 
include/babeltrace2: add `noexcept` specifier for C++ ≥ 11

This patch adds the `noexcept` specifier to all the public functions
when building with C++11 and above.

This is similar to what glibc does (from `/usr/include/sys/cdefs.h`):

    #   if __cplusplus >= 201103L
    #    define __THROW noexcept (true)
    #   else
    #    define __THROW throw ()
    #   endif

and then, for example (`/usr/include/string.h`):

    /* Return the length of S.  */
    extern size_t strlen (const char *__s)
         __THROW __attribute_pure__ __nonnull ((1));

Indeed, none of our functions throw, ever, including user callbacks,
because the library always expects them to return some value (doesn't
catch, in other words).

This brings an improvement to a `noexcept` function calling a
libbabeltrace2 function. For example, consider this simple case:

    uint64_t get_cs_value(const bt_clock_snapshot * const opt_cs) noexcept
    {
        return bt_clock_snapshot_get_value(opt_cs);
    }

When bt_clock_snapshot_get_value() isn't `noexcept`, we get (`-O2`):

    get_cs_value(bt_clock_snapshot const*):
            sub     rsp, 8
            call    bt_clock_snapshot_get_value
            add     rsp, 8
            ret

With `noexcept`:

    get_cs_value(bt_clock_snapshot const*):
            jmp     bt_clock_snapshot_get_value

In other words, without this patch, there's some stack adjustment to
prepare for a possible exception when you're already in `noexcept` mode.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0712eab48de93344159b7b7344f28b940ed81712
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11442
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agocpp-common/bt2/wrap.hpp: add wrapOptional() versions
Philippe Proulx [Sun, 26 Nov 2023 01:08:11 +0000 (20:08 -0500)] 
cpp-common/bt2/wrap.hpp: add wrapOptional() versions

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I28ee353257f4b88e78741c512e974be6bd286ed4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11441
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 months agocpp-common/bt2: remove useless `avail` variable where applicable
Philippe Proulx [Sun, 26 Nov 2023 01:05:58 +0000 (20:05 -0500)] 
cpp-common/bt2: remove useless `avail` variable where applicable

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