lttng-tools.git
18 months agoClean-up: lttng: utils: coding style fix
Jérémie Galarneau [Fri, 28 Apr 2023 14:46:08 +0000 (10:46 -0400)] 
Clean-up: lttng: utils: coding style fix

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia23ad0168729819bcb0735ff8e55ce02fc9bcd20

18 months agoTests: Introduce test_ust_constructor
Mathieu Desnoyers [Fri, 17 Feb 2023 20:32:25 +0000 (15:32 -0500)] 
Tests: Introduce test_ust_constructor

Test instrumentation coverage of C/C++ constructors and destructors by
LTTng-UST tracepoints.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia9e5a5a57bfa7fd4316f8a914ef97effd020262e

18 months agoTests: Introduce gen-ust-events-constructor test application
Mathieu Desnoyers [Fri, 17 Feb 2023 14:57:03 +0000 (09:57 -0500)] 
Tests: Introduce gen-ust-events-constructor test application

This test application tests C/C++ constructor/destructor instrumentation coverage.

* How to use:

lttng create
lttng enable-event -u 'tp*'
lttng start
./gen-ust-events-constructor
lttng stop
lttng view

* Before UST fixes:

[11:57:09.949917277] (+?.?????????) compudjdev tp_so:constructor_c_provider_shared_library: { cpu_id = 6 }, { }
[11:57:09.949962573] (+0.000045296) compudjdev tp_so:constructor_cplusplus_provider_shared_library: { cpu_id = 6 }, { msg = "global - shared library define and provider" }
[11:57:09.952145202] (+0.002182629) compudjdev tp:constructor_cplusplus: { cpu_id = 6 }, { msg = "global - same unit after provider" }
[11:57:09.952146517] (+0.000001315) compudjdev tp:constructor_c_across_units_after_provider: { cpu_id = 6 }, { }
[11:57:09.952146887] (+0.000000370) compudjdev tp:constructor_cplusplus: { cpu_id = 6 }, { msg = "global - across units after provider" }
[11:57:09.952634622] (+0.000487735) compudjdev tp:constructor_cplusplus: { cpu_id = 6 }, { msg = "main() local" }
[11:57:09.952635522] (+0.000000900) compudjdev tp_so:constructor_cplusplus_provider_shared_library: { cpu_id = 6 }, { msg = "main() local - shared library define and provider" }
[11:57:09.952636176] (+0.000000654) compudjdev tp_a:constructor_cplusplus_provider_static_archive: { cpu_id = 6 }, { msg = "main() local - static archive define and provider" }
[11:57:09.952636906] (+0.000000730) compudjdev tp:main: { cpu_id = 6 }, { }
[11:57:09.952637469] (+0.000000563) compudjdev tp_a:destructor_cplusplus_provider_static_archive: { cpu_id = 6 }, { msg = "main() local - static archive define and provider" }
[11:57:09.952638106] (+0.000000637) compudjdev tp_so:destructor_cplusplus_provider_shared_library: { cpu_id = 6 }, { msg = "main() local - shared library define and provider" }
[11:57:09.952638516] (+0.000000410) compudjdev tp:destructor_cplusplus: { cpu_id = 6 }, { msg = "main() local" }
[11:57:09.952681576] (+0.000043060) compudjdev tp:destructor_cplusplus: { cpu_id = 6 }, { msg = "global - across units after provider" }
[11:57:09.952682066] (+0.000000490) compudjdev tp:destructor_cplusplus: { cpu_id = 6 }, { msg = "global - same unit after provider" }
[11:57:09.952729603] (+0.000047537) compudjdev tp_so:destructor_cplusplus_provider_shared_library: { cpu_id = 6 }, { msg = "global - shared library define and provider" }

* After UST fixes:

[11:49:37.921028048] (+?.?????????) compudjdev tp_so:constructor_c_provider_shared_library: { cpu_id = 22 }, { }
[11:49:37.921033701] (+0.000005653) compudjdev tp_a:constructor_c_provider_static_archive: { cpu_id = 22 }, { }
[11:49:37.921036278] (+0.000002577) compudjdev tp_so:constructor_cplusplus_provider_shared_library: { cpu_id = 22 }, { msg = "global - shared library define and provider" }
[11:49:37.921037961] (+0.000001683) compudjdev tp_a:constructor_cplusplus_provider_static_archive: { cpu_id = 22 }, { msg = "global - static archive define and provider" }
[11:49:37.921039431] (+0.000001470) compudjdev tp:constructor_c_across_units_before_define: { cpu_id = 22 }, { }
[11:49:37.921040288] (+0.000000857) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units before define" }
[11:49:37.921041208] (+0.000000920) compudjdev tp:constructor_c_same_unit_before_define: { cpu_id = 22 }, { }
[11:49:37.921042021] (+0.000000813) compudjdev tp:constructor_c_same_unit_after_define: { cpu_id = 22 }, { }
[11:49:37.921042568] (+0.000000547) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit before define" }
[11:49:37.921043161] (+0.000000593) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit after define" }
[11:49:37.921044058] (+0.000000897) compudjdev tp:constructor_c_across_units_after_define: { cpu_id = 22 }, { }
[11:49:37.921044585] (+0.000000527) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units after define" }
[11:49:37.921045585] (+0.000001000) compudjdev tp:constructor_c_same_unit_before_provider: { cpu_id = 22 }, { }
[11:49:37.921046385] (+0.000000800) compudjdev tp:constructor_c_same_unit_after_provider: { cpu_id = 22 }, { }
[11:49:37.921046938] (+0.000000553) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit before provider" }
[11:49:37.921047548] (+0.000000610) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit after provider" }
[11:49:37.921048428] (+0.000000880) compudjdev tp:constructor_c_across_units_after_provider: { cpu_id = 22 }, { }
[11:49:37.921048918] (+0.000000490) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units after provider" }
[11:49:37.921050001] (+0.000001083) compudjdev tp:constructor_cplusplus: { cpu_id = 22 }, { msg = "main() local" }
[11:49:37.921050628] (+0.000000627) compudjdev tp_so:constructor_cplusplus_provider_shared_library: { cpu_id = 22 }, { msg = "main() local - shared library define and provider" }
[11:49:37.921051368] (+0.000000740) compudjdev tp_a:constructor_cplusplus_provider_static_archive: { cpu_id = 22 }, { msg = "main() local - static archive define and provider" }
[11:49:37.921052098] (+0.000000730) compudjdev tp:main: { cpu_id = 22 }, { }
[11:49:37.921052758] (+0.000000660) compudjdev tp_a:destructor_cplusplus_provider_static_archive: { cpu_id = 22 }, { msg = "main() local - static archive define and provider" }
[11:49:37.921053758] (+0.000001000) compudjdev tp_so:destructor_cplusplus_provider_shared_library: { cpu_id = 22 }, { msg = "main() local - shared library define and provider" }
[11:49:37.921054595] (+0.000000837) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "main() local" }
[11:49:37.921055698] (+0.000001103) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units after provider" }
[11:49:37.921056455] (+0.000000757) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit after provider" }
[11:49:37.921057011] (+0.000000556) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit before provider" }
[11:49:37.921057558] (+0.000000547) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units after define" }
[11:49:37.921058188] (+0.000000630) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit after define" }
[11:49:37.921058658] (+0.000000470) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - same unit before define" }
[11:49:37.921059168] (+0.000000510) compudjdev tp:destructor_cplusplus: { cpu_id = 22 }, { msg = "global - across units before define" }
[11:49:37.921059768] (+0.000000600) compudjdev tp_a:destructor_cplusplus_provider_static_archive: { cpu_id = 22 }, { msg = "global - static archive define and provider" }
[11:49:37.921060445] (+0.000000677) compudjdev tp_so:destructor_cplusplus_provider_shared_library: { cpu_id = 22 }, { msg = "global - shared library define and provider" }
[11:49:37.921067265] (+0.000006820) compudjdev tp:destructor_c_across_units_after_provider: { cpu_id = 22 }, { }
[11:49:37.921067901] (+0.000000636) compudjdev tp:destructor_c_same_unit_after_provider: { cpu_id = 22 }, { }
[11:49:37.921068515] (+0.000000614) compudjdev tp:destructor_c_same_unit_before_provider: { cpu_id = 22 }, { }
[11:49:37.921069128] (+0.000000613) compudjdev tp:destructor_c_across_units_after_define: { cpu_id = 22 }, { }
[11:49:37.921069831] (+0.000000703) compudjdev tp:destructor_c_same_unit_after_define: { cpu_id = 22 }, { }
[11:49:37.921070445] (+0.000000614) compudjdev tp:destructor_c_same_unit_before_define: { cpu_id = 22 }, { }
[11:49:37.921071075] (+0.000000630) compudjdev tp:destructor_c_across_units_before_define: { cpu_id = 22 }, { }
[11:49:37.921071721] (+0.000000646) compudjdev tp_a:destructor_c_provider_static_archive: { cpu_id = 22 }, { }
[11:49:37.921072605] (+0.000000884) compudjdev tp_so:destructor_c_provider_shared_library: { cpu_id = 22 }, { }

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4572c2548acf5e295f70e88137ab12b3b86d17c9

18 months agoFix: io-hint: add missing include for off_t
Michael Jeanson [Thu, 27 Apr 2023 17:08:16 +0000 (13:08 -0400)] 
Fix: io-hint: add missing include for off_t

Change-Id: I73ca36d43c7a9b9b5f67e77e835426964b315f65
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
18 months agoBuild fix: g++ 4.8 incorrectly disambiguates enum and member
Jérémie Galarneau [Wed, 26 Apr 2023 22:13:02 +0000 (18:13 -0400)] 
Build fix: g++ 4.8 incorrectly disambiguates enum and member

g++ 4.8 fails to build with the following error:

  commands/start.cpp: In function ‘cmd_error_code {anonymous}::start_tracing(const session_spec&)’:
  commands/start.cpp:123:76: error: ‘session_spec::type’ is not a class, namespace, or enumeration
    if (!listing_failed && sessions.size() == 0 && spec.type == session_spec::type::NAME) {
                                                                              ^
  commands/start.cpp:144:36: error: ‘session_spec::type’ is not a class, namespace, or enumeration
       if (spec.type != session_spec::type::NAME) {
                                    ^

The `type` member is renamed to type_ to workaround this compiler bug.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id46ca4219d4d96db71a9d4523c3571303b2e97a7

19 months agoTest: client: start, stop, destroy: add tests for --glob/--all
Jérémie Galarneau [Fri, 21 Apr 2023 19:48:56 +0000 (15:48 -0400)] 
Test: client: start, stop, destroy: add tests for --glob/--all

Test the CLI client's start, stop, and destroy commands along with their
--all and --glob options.

The tests validate that only the targeted sessions are affected by the
various commands and that the commands don't error-out when multiple
sessions are targetted.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie39e999608a063cc4573d790120fbe0896917d6f

19 months agolttng: rename iterator_template to _iterator
Jérémie Galarneau [Fri, 21 Apr 2023 19:11:44 +0000 (15:11 -0400)] 
lttng: rename iterator_template to _iterator

iterator_template is not meant to be used directly and is private: it
should be prefixed with an underscore.

Moreover, "template" in the name doesn't really add anything; remove it.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id891afeb596788d8d40cdf45e3f50dd8bf0427cc

19 months agoMove create_unique_class util to the memory namespace
Jérémie Galarneau [Fri, 21 Apr 2023 18:48:53 +0000 (14:48 -0400)] 
Move create_unique_class util to the memory namespace

create_unique_class is helpful to write unique_ptr wrappers and is now
accessed in numerous places even though it lives in the `details`
namespace.

Moving it to the `memory` namespace to live with other memory management
facilities.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id4bb5100c1eb3a7e1e2d65f5b2d40ff8f97c786e

19 months agolttng: destroy: ensure a cmd_error_code is returned by the command
Jérémie Galarneau [Thu, 20 Apr 2023 21:01:14 +0000 (17:01 -0400)] 
lttng: destroy: ensure a cmd_error_code is returned by the command

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7adef3df9b0a76de893341131cd5d0da2c9ab5df

19 months agoClean-up: lttng-destroy: move static symbols to anonymous namespace
Jérémie Galarneau [Thu, 20 Apr 2023 18:40:32 +0000 (14:40 -0400)] 
Clean-up: lttng-destroy: move static symbols to anonymous namespace

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iebea98532e1c6d0c7309c0ea40e6585a25b8b3df

19 months agoTest: mi: inverted logic in stop validation test
Jérémie Galarneau [Wed, 26 Apr 2023 02:24:17 +0000 (22:24 -0400)] 
Test: mi: inverted logic in stop validation test

Stopping a session twice should succeed (no-op). Moreover, the test
mentions it tests a 'start' while it tests a 'stop' operation.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4c8f19f0ecc181921fb5e3dd4f882e3c2285adcd

19 months agolttng: stop: ensure a cmd_error_code is returned by the command
Jérémie Galarneau [Thu, 20 Apr 2023 16:34:35 +0000 (12:34 -0400)] 
lttng: stop: ensure a cmd_error_code is returned by the command

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iee537cbda297cee72a1d5ad49738ac347f42d3fd

19 months agoClean-up: lttng-stop: move static symbols to anonymous namespace
Jérémie Galarneau [Thu, 20 Apr 2023 15:54:57 +0000 (11:54 -0400)] 
Clean-up: lttng-stop: move static symbols to anonymous namespace

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4cb91315993ffa4f0f53698f7912540fe2aa4075

19 months agoClean-up: rotation-thread: disable move and copy
Jérémie Galarneau [Thu, 20 Apr 2023 15:47:22 +0000 (11:47 -0400)] 
Clean-up: rotation-thread: disable move and copy

Disable unused move and copy constructors and assignment operators, as
reported by clang-tidy.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I610e60dd082bc7c552a6f304ea44e9970487e558

19 months agolttng: start: ensure a cmd_error_code is returned by the command
Jérémie Galarneau [Wed, 19 Apr 2023 19:15:50 +0000 (15:15 -0400)] 
lttng: start: ensure a cmd_error_code is returned by the command

The start_tracing functions mix cmd_error_code and lttng_error_code
values in "raw" integers which is unexpected by the top-level client.

For instance, the client returns '80' when attempting to start a session
that is already active.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I12c15e8aa3eb960e1e47d5166307995af8c46989

19 months agolttng: start: move static symbols to anonymous namespace
Jérémie Galarneau [Wed, 19 Apr 2023 19:15:26 +0000 (15:15 -0400)] 
lttng: start: move static symbols to anonymous namespace

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I295b39aa2f286bc494a0d2eb0b5c8528e0b6afc3

19 months agolttng: Add --glob option to lttng-destroy
Olivier Dion [Mon, 6 Feb 2023 22:19:36 +0000 (17:19 -0500)] 
lttng: Add --glob option to lttng-destroy

Change-Id: I930adc74e1ab2d285f99e0aef01ba1108df089a4
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agolttng: Add --all, --glob options to lttng-stop
Olivier Dion [Mon, 6 Feb 2023 21:11:56 +0000 (16:11 -0500)] 
lttng: Add --all, --glob options to lttng-stop

Change-Id: Ida7c8f68f9b52f7ab4414bf060383864bd2e3046
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agolttng: Add --all, --glob options to lttng-start
Olivier Dion [Mon, 6 Feb 2023 21:06:10 +0000 (16:06 -0500)] 
lttng: Add --all, --glob options to lttng-start

Change-Id: I8ff806c7ea7a51b8fa69206bd427b5e106706073
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agolttng: Add list_sessions utility
Olivier Dion [Mon, 6 Feb 2023 20:55:39 +0000 (15:55 -0500)] 
lttng: Add list_sessions utility

Get a list of sessions given a session specification.

The `NAME' specification returns the session that has the given
name. The `GLOB_PATTERN' specification returns all sessions that match a
pattern. The `ALL' specification returns all sessions.

Change-Id: If69698d6dd59d54ba16669571ef49ed5bb9b8997
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoFix: mi: Pass const session to mi_lttng_session
Olivier Dion [Tue, 28 Feb 2023 22:02:38 +0000 (17:02 -0500)] 
Fix: mi: Pass const session to mi_lttng_session

There's no reason for session to be not constant.

Change-Id: I55d63e142853f78ba643600b5c1869866ee1bb5e
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoClean-up: clang-tidy autofixes to eventfd and file-descriptor
Jérémie Galarneau [Tue, 18 Apr 2023 21:57:46 +0000 (17:57 -0400)] 
Clean-up: clang-tidy autofixes to eventfd and file-descriptor

eventfd must be marked explicit to prevent erroneous implicit
conversions.

A destructor is provided since other special member functions are
defined (see cppcoreguidelines-special-member-functions).

file_descriptor's constructor is replaced by a trivial constructor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1623a2f8db0d613201a534293f5e1476b779283c

19 months agoTests: utils: lttng_pgrep spams output when racing with a process
Jérémie Galarneau [Thu, 20 Apr 2023 15:07:44 +0000 (11:07 -0400)] 
Tests: utils: lttng_pgrep spams output when racing with a process

lttng_pgrep is often used to check if a process is alive. As such, it is
often used on PIDs which are tearing down.

The file redirection used in `tr '\0' '\n' < /proc/"$pid"/cmdline` often
fails (which is correct) because the /proc/$pid folder no longer exists.

When this occurs, the test output is cluttered with annoying errors like:
  ./tests/regression/kernel//../../utils/utils.sh: line 151: /proc/845/cmdline: No such file or directory

This part of the command now runs under a subshell to hide the error
when it occurs.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6a26cb63cd56c46557a73e2e475b0cac729cc67f

19 months agoTests: enable test_callstack on 32-bit x86
Jérémie Galarneau [Wed, 19 Apr 2023 21:48:25 +0000 (17:48 -0400)] 
Tests: enable test_callstack on 32-bit x86

The test application used by test_callstack defines syscall
stubs (instead of using the libc) for both 32 and 64 bit variants of
x86. This limits the architectures that can run this test.

However, the `uname` check is erroneous as it assumes that `uname -m`
will return x86 for both architectures. It doesn't; it returns i386 or
i686 (and I presume others) for 32-bit kernels.

As such, the check is modified to check for '86' which, as far as I
know, doesn't clash with other architectures.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I267a81fadb2f1db6b135c6886ae5700184f2ae5b

19 months agoTests: fix: kernel/test_callstack: number of tests on i386
Michael Jeanson [Wed, 19 Apr 2023 18:28:43 +0000 (14:28 -0400)] 
Tests: fix: kernel/test_callstack: number of tests on i386

The number of planned tests is incorrect when not running the userspace
callstack tests which is limited to x86_64.

Fixes the following error:

  ERROR: kernel/test_callstack 12 - Wait after kill session daemon # UNPLANNED
  # Looks like you planned 11 tests but ran 1 extra.
  ERROR: kernel/test_callstack - too many tests run (expected 11, got 12)
  ERROR: kernel/test_callstack - exited with status 1

Change-Id: Icf662968ac977b08594eca99e18476e43cc4ea79
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoAdd getrandom compat for MacOS, FreeBSD and Cygwin
Michael Jeanson [Tue, 18 Apr 2023 21:58:01 +0000 (17:58 -0400)] 
Add getrandom compat for MacOS, FreeBSD and Cygwin

Use the BSD arc4random_buf() function which should be non-blocking on
all of these platforms.

Change-Id: Ib43373cad82373dc83995fdb3d01c2a2d43ab683
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoTests: metadata-regeneration: restore date at the end of the test
Jérémie Galarneau [Tue, 18 Apr 2023 18:58:04 +0000 (14:58 -0400)] 
Tests: metadata-regeneration: restore date at the end of the test

The metadata-regeneration test sets the date is the past to validate
that the clock offset is re-computed when regenerating a trace's
metadata.

In doing so, it leaves the time in the past which causes 'make' to panic
when it checks for changes while continuing to evaluate the 'check'
target.

  make[4]: Entering directory '/root/workspace/lttng-tools_master_rootbuild_i386/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/i386-rootnode/platform/deb11-i386/test_type/base/src/lttng-tools/tests/perf'
  make[4]: Warning: File '.deps/find_event.Po' has modification time 1363500490 s in the future
  ============================================================================
  Testsuite summary for lttng-tools 2.14.0-pre
  ============================================================================
  # TOTAL: 0
  # PASS:  0
  # SKIP:  0
  # XFAIL: 0
  # FAIL:  0
  # XPASS: 0
  # ERROR: 0
  ============================================================================
  make[4]: warning:  Clock skew detected.  Your build may be incomplete.
  make[4]: Leaving directory '/root/workspace/lttng-tools_master_rootbuild_i386/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/i386-rootnode/platform/deb11-i386/test_type/base/src/lttng-tools/tests/perf'
  make[3]: warning:  Clock skew detected.  Your build may be incomplete.
  make[3]: Leaving directory '/root/workspace/lttng-tools_master_rootbuild_i386/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/i386-rootnode/platform/deb11-i386/test_type/base/src/lttng-tools/tests/perf'
  make[2]: warning:  Clock skew detected.  Your build may be incomplete.
  make[2]: Leaving directory '/root/workspace/lttng-tools_master_rootbuild_i386/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/node/i386-rootnode/platform/deb11-i386/test_type/base/src/lttng-tools/tests/perf'
  make[1]: *** [Makefile:557: check-recursive] Error 1

The date is sampled at the beginning of the test and restored when it
ends. This leaves the system with a wrong time (offset by the duration
of the test itself). Still, its better than being 40 years in the past.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4a128b57d4d9fd61eec097948b688060815f4a4c

19 months agoBuild fix: add a noop compat wrapper for posix_fadvise
Michael Jeanson [Tue, 18 Apr 2023 16:11:33 +0000 (12:11 -0400)] 
Build fix: add a noop compat wrapper for posix_fadvise

This allows building on platforms without posix_fadvise.

Change-Id: I13fd6404cd02eb8038a97693db27d9619246401d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoClean-up: error.hpp/error.cpp coding style fix
Jérémie Galarneau [Tue, 18 Apr 2023 15:44:42 +0000 (11:44 -0400)] 
Clean-up: error.hpp/error.cpp coding style fix

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I570dabdc2ea83bf9aded48e64fc9e1f83a061044

19 months agoBuild fix: missing error_get_str on non-glibc builds
Michael Jeanson [Tue, 18 Apr 2023 15:29:21 +0000 (11:29 -0400)] 
Build fix: missing error_get_str on non-glibc builds

The function declaration was erroneously moved inside this ifdef. This
breaks non glibc builds.

Introduced in :

  commit 003f455dab0204dd3f066ecdbea0470035f8181f
  Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
  Date:   Thu Apr 13 14:31:33 2023 -0400

    Fix: logging: unhandled error in *_FMT macros

    Coverity reports:

    1508779 Uncaught exception
    If the exception is ever thrown, the program will crash.

    In lttng::​sessiond::​rotation_thread::​_thread_function(): A C++ exception
    is thrown but never caught (CWE-248)

    The *_FMT macros, which use fmtlib, don't handle the case where
    fmt::format throws. This can happen, in particular, when an invalid
    format string is used.

    The macros are modified to log the exception and abort.

Change-Id: I5eb3b2a673e224f3c99cae7faece31175084db9d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoClean-up: remove unnecessary inclusion
Jérémie Galarneau [Tue, 18 Apr 2023 15:42:04 +0000 (11:42 -0400)] 
Clean-up: remove unnecessary inclusion

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7f8b875fe2cdcf7909a953bb6061229c4a5bca71

19 months agoBuild fix: missing header on macOS
Jérémie Galarneau [Tue, 18 Apr 2023 15:28:22 +0000 (11:28 -0400)] 
Build fix: missing header on macOS

The build fails on macOS (on both ARM64 and AMD64 platforms):
  exception.cpp:32:41: error: use of undeclared identifier 'error_get_str'
          runtime_error(msg + ": " + std::string(error_get_str(error_code)),
                                                 ^

error_get_str is defined in lttng/lttng-error.h

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I69fa0c0bc442d0cb28779f6b4c55d0b6a7196791

19 months agoBuild fix: failure on macOS caused by missing space in Makefile
Michael Jeanson [Tue, 18 Apr 2023 15:06:56 +0000 (11:06 -0400)] 
Build fix: failure on macOS caused by missing space in Makefile

Change-Id: Ia30100d293ad52e422998512d44173af16858257
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
19 months agoBuild fix: common: eventfd only exists on Linux
Jérémie Galarneau [Wed, 12 Apr 2023 18:53:37 +0000 (14:53 -0400)] 
Build fix: common: eventfd only exists on Linux

The project fails to build on non-Linux platforms since eventfd is a
Linux-exclusive facility.

From the project's point of view, the eventfd util belongs in libcommon.
However, we will need to write a wrapper if it ends up being used on
non-Linux platform.

For the moment, exclude it from the internal libcommon sources when
building on non-Linux platforms as it is only used on the session
daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If528ac522d72a95e87a4f496531ea679a81030a2

19 months agoReplace uses of the URCU tls helpers by the standard thread_local
Jérémie Galarneau [Mon, 17 Apr 2023 18:46:56 +0000 (14:46 -0400)] 
Replace uses of the URCU tls helpers by the standard thread_local

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6751ad8c3a121638b07d333ac6f28547b25f54f2

19 months agoClean-up: use const reference where possible
Jérémie Galarneau [Thu, 13 Apr 2023 18:41:43 +0000 (14:41 -0400)] 
Clean-up: use const reference where possible

These exceptions can all be caught by const reference.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I11a4f5018c838d77212340efa6f94d5d1c005ed6

19 months agoCoverity warning: sessiond: uncaught exception in main
Jérémie Galarneau [Thu, 13 Apr 2023 18:34:31 +0000 (14:34 -0400)] 
Coverity warning: sessiond: uncaught exception in main

Coverity reports:
1508778 Uncaught exception
If the exception is ever thrown, the program will crash.

In main: A C++ exception is thrown but never caught (CWE-248)

In particular, Coverity reports that pthread_mutex_lock can error-out,
which would cause an lttng::posix_error exception to be thrown.

This isn't particularly likely to happen, but it is nonetheless
preferable to catch exceptions at the top-level and log them before
exiting.

Change-Id: I4f7a52db3c9cd19764e7d12fd62afa60af99dabd
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoFix: logging: unhandled error in *_FMT macros
Jérémie Galarneau [Thu, 13 Apr 2023 18:31:33 +0000 (14:31 -0400)] 
Fix: logging: unhandled error in *_FMT macros

Coverity reports:

1508779 Uncaught exception
If the exception is ever thrown, the program will crash.

In lttng::​sessiond::​rotation_thread::​_thread_function(): A C++ exception
is thrown but never caught (CWE-248)

The *_FMT macros, which use fmtlib, don't handle the case where
fmt::format throws. This can happen, in particular, when an invalid
format string is used.

The macros are modified to log the exception and abort.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7f4a066b418a9d544a679f773df7e94640755f47

19 months agoClean-up: common: error_log_time doesn't need to be global
Jérémie Galarneau [Mon, 17 Apr 2023 18:25:47 +0000 (14:25 -0400)] 
Clean-up: common: error_log_time doesn't need to be global

error_log_time is only used in error.cpp. Reduce its visibility to the
file.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifbd821af12d7378b203cd7a2c1d48d28ed00cb40

19 months agoTests: select_poll_epoll: Add support for _time64
Jérémie Galarneau [Fri, 11 Nov 2022 22:35:12 +0000 (17:35 -0500)] 
Tests: select_poll_epoll: Add support for _time64

Add support for the 64-bit time_t syscalls SYS_ppoll_time64
and SYS_pselect6_time64.

These syscalls exist on 32-bit platforms since the 5.1 kernel. 32-bit
platforms with a 64-bit time_t only have these and don't have the
original syscalls (such as 32-bit RISC-V).

In doing so, the original syscalls were renamed to add the `_time32`
suffix which causes the validation steps to fail.

This patch ensures that the 64-bit version of the pselect and ppoll
syscalls are called whenever they are available, allowing the tests to
succeed.

It also ensures that we don't attempt to use the 32-bit versions that
don't exist on newer 32-bit platforms like RISCV-32.

The test is also cleaned-up:

  - The *invalid_pointer, *invalid_fd, *ulong_max, and *buffer_overflow
    tests are identical except for the syscall(...) invocation. They are
    combined to share as much code as possible regardless of which
    syscalls the platform's ABI supports.

  - Harmonized test names between the test script and test application

  - Test names are printed when using the list option and used to launch
    a test (rather than a numeric id)

  - Allow the test application to print the list of supported tested
    syscalls

Fixes: https://github.com/lttng/lttng-tools/pull/162
Change-Id: I974f780022441fedfa45414d672092606e657cf6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoRemove fcntl wrapper
Michael Jeanson [Tue, 17 Jan 2023 22:49:42 +0000 (17:49 -0500)] 
Remove fcntl wrapper

Replace the questionnable sync_file_range wrapper by more descriptive
util functions. Remove the unimplemented splice wrapper, I'd rather have
a build failure / adjust the build system on some platforms than have
hard to diagnose runtime issues.

Change-Id: I4114d0d9765ae3d95a1488c945e5d66a20c2029d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoBuild fix: brace-enclosed initlializer lists error with g++ 4.8
Michael Jeanson [Wed, 12 Apr 2023 18:14:21 +0000 (14:14 -0400)] 
Build fix: brace-enclosed initlializer lists error with g++ 4.8

A build error occurs when building using g++ 4.8 :

rotation-thread.cpp: In constructor 'lttng::sessiond::rotation_thread::rotation_thread(lttng::sessiond::rotation_thread_timer_queue&, notification_thread_handle&)':
rotation-thread.cpp:400:58: error: invalid initialization of non-const reference of type 'lttng::sessiond::rotation_thread_timer_queue&' from an rvalue of type '<brace-enclosed initializer list>'
  _notification_thread_handle{ notification_thread_handle }

Use old-style initialization of references instead.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia3392a88b8a2d8dd8c60330c16229f507338e7cd

19 months agoFix: warning: "HAVE_GETIPNODEBYNAME" is not defined
Michael Jeanson [Tue, 28 Mar 2023 16:06:00 +0000 (12:06 -0400)] 
Fix: warning: "HAVE_GETIPNODEBYNAME" is not defined

Change-Id: I3214a63daea3c2d44f8712127cd0d776d429f130
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoExtras: python bindings: update context types
Christophe Bedard [Mon, 20 Feb 2023 21:20:51 +0000 (13:20 -0800)] 
Extras: python bindings: update context types

This adds context types from LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL (20)
to LTTNG_EVENT_CONTEXT_TIME_NS (41) so that the list matches
lttng_event_context_type in include/lttng/event.h.

Change-Id: Ied908aa51cf75e931794acef61271468efeff6a7
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoDocs: lttng-add-context(1): fix typo
Christophe Bedard [Tue, 21 Feb 2023 20:31:11 +0000 (12:31 -0800)] 
Docs: lttng-add-context(1): fix typo

Change-Id: Ie6d182e00d2aae07f8dd405e3b4b9ec8205ad1da
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoTests: fix: test_list_triggers_cli fails to list userspace-probe-sdt trigger
Jérémie Galarneau [Fri, 14 Apr 2023 18:57:06 +0000 (14:57 -0400)] 
Tests: fix: test_list_triggers_cli fails to list userspace-probe-sdt trigger

The listing of triggers which use an event rule match condition
consisting in a user space probe set on an SDT probe fails since
28f23191d.

The coding style imposes an order of includes. However, the order in
which the probe declarations generated by systemtap vs sdt.h matters.

From SYSTEMTAP(2):
  Sometimes, semaphore variables are not necessary nor helpful. Skipping
  them can simplify the build process, by omitting the extra "test.o"
  file. To skip dependence upon semaphore variables, include "<sys/sdt.h>"
  within the application before "test.h":
  [...]
  In this mode, the ENABLED() test is fixed at 1.

The reformatted version of userspace-probe-sdt-binary.c includes sdt.h
after the probe causing the probes to use a guarding semaphore.

Unfortunately, we can't instrument such probes and the registration of
the trigger silently fails. The silent failure is addressed by a
follow-up commit.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5146f55ed5d9d109f1f7bc32e0f7c2c8bf839f8e

19 months agoFix: sessiond: silent kernel notifier registration error
Jérémie Galarneau [Fri, 14 Apr 2023 18:39:05 +0000 (14:39 -0400)] 
Fix: sessiond: silent kernel notifier registration error

When a kernel notifier fails to be registered, the error is silently
ignored because of a missing jump to the error label.

This was noticed while debugging an unrelated problem where the kernel
tracer would fail to add a userspace probe to a semaphore-protected SDT
probe.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9261ad7131b1b53152fe8960f17a6fca7029440f

19 months agoTests: fix: list_triggers_cli: kallsyms contains prefixed symbols
Jérémie Galarneau [Thu, 13 Apr 2023 19:50:57 +0000 (15:50 -0400)] 
Tests: fix: list_triggers_cli: kallsyms contains prefixed symbols

The test_list_triggers_cli test fails with:

  # Listing event-rule-matches kernel probe
  ./tests/regression/tools/trigger/test_list_triggers_cli: line 808: [[: 0xffffffffc1fca020
  ffffffffc1fca030: syntax error in expression (error token is "ffffffffc1fca030")
  ./tests/regression/tools/trigger/test_list_triggers_cli: line 813: 0xffffffffc1fca020
  ffffffffc1fca030 - 0xffffffffc1fca0c0
  ffffffffc1fca0b0 : syntax error in expression (error token is "ffffffffc1fca030 - 0xffffffffc1fca0c0
  ffffffffc1fca0b0 ")

This is due to the fact that /proc/kallsyms now contains prefixed
symbols (e.g. `__pfx_lttng_channel_enable`) which cause the test to fail
since the grep invocation doesn't expect more than one match.

Matching the begin/end of the "word" (or rather, function name) allows
us to check for exact matches only.

https://github.com/torvalds/linux/commit/9f2899fe36a623885d8576604cb582328ad32b3c

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifc04757719c733caf55c8eea447e18a2246a9f49

19 months ago.git-blame-ignore-revs: add reformat commit
Jérémie Galarneau [Fri, 14 Apr 2023 20:45:18 +0000 (16:45 -0400)] 
.git-blame-ignore-revs: add reformat commit

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If722c422f56d45720cae933f3d7fac4f650c4bc5

19 months agoClean-up: run format-cpp on the tree
Jérémie Galarneau [Wed, 12 Apr 2023 15:57:50 +0000 (11:57 -0400)] 
Clean-up: run format-cpp on the tree

The original re-format commit missed a number of files that were caught
by format-cpp. Hopefully this is the last large reformat commit for a
while.

Change-Id: I493ee6d9fe6187e0bd087c68ed346af69c929c1e
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoclang-format: specify bitfield spacing to fit with the existing code
Jérémie Galarneau [Wed, 12 Apr 2023 16:04:06 +0000 (12:04 -0400)] 
clang-format: specify bitfield spacing to fit with the existing code

Change-Id: I46732823ad8341ca0e0c2e55b6b58e3e435f855a
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoAdd a code formatting script
Jérémie Galarneau [Wed, 12 Apr 2023 15:39:33 +0000 (11:39 -0400)] 
Add a code formatting script

Add a code formatting script derived from the one provided in the
Babeltrace tree.

Change-Id: Idaf127ac199d1783769b7fe6a3216113bd9b7e83
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoCleanup: rotation-thread: enforce conding standard following fix
Jérémie Galarneau [Tue, 4 Apr 2023 17:45:24 +0000 (13:45 -0400)] 
Cleanup: rotation-thread: enforce conding standard following fix

A fix introducing
rotate_notification_channel_subscription_change_eventfd didn't follow
the current coding standard so as to make it easier to backport to the
stable branches.

Clean-up the affected code to follow the current standard:
  - Replace the use of a raw eventfd to use the eventfd utility,
  - Subscribe and unsubscribe functions made use of global variables to
    communicate with the rotation thread: replace that with the
    rotation_thread class to centralize the interface,
  - Make the code using eventfd exception-safe (automatic memory
    management, use of various RAII utils),
  - Replacement of non-null pointers by references.

Change-Id: I7e363e21b829fd0939a336aca2570fdbcc346967
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agovendor: fmtlib: Upgrade fmtlib to 9.1.0
Jérémie Galarneau [Tue, 11 Apr 2023 20:24:43 +0000 (16:24 -0400)] 
vendor: fmtlib: Upgrade fmtlib to 9.1.0

gcc warns that:

  declaration of ‘struct fmt::v8::detail::parse_format_string(fmt::v8::basic_string_view, Handler&&) [with bool IS_CONSTEXPR = false; Char = char; Handler = fmt::v8::detail::vformat_to(fmt::v8::detail::buffer&, fmt::v8::basic_string_view, fmt::v8::basic_format_args::type, char>::value, fmt::v8::appender, std::back_insert_iterator::type> > >::type, typename fmt::v8::type_identity::type> >, fmt::v8::detail::locale_ref) [with Char = char; typename fmt::v8::type_identity::type = char; typename std::conditional::type, char>::value, fmt::v8::appender, std::back_insert_iterator::type> > >::type = fmt::v8::appender]::format_handler]::writer’ shadows a global declaration [-Wshadow]
  struct writer {
  ^~~~~~
  commands/start.cpp:22:26: note: shadowed declaration is here
  static struct mi_writer *writer;
  ^~~~~~
  In file included from ../../../src/common/format.hpp:19:0,

This problem was fixed in more recent versions of fmtlib than the one we
vendorized (8.1.0): https://github.com/fmtlib/fmt/issues/1688

Upgrade the vendorized fmtlib to the latest stable release since it
fixes a number of similar warnings. However, the fix described in the
issue had to be re-applied as c06851456 (in fmtlib's tree) reintroduces
the problem.

A format_as helper function must be provided to format enums since this
version, as seen in ust-field-convert.cpp.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5092d1c348670ec358d571f19d3598ee7662cd21

19 months agoFix: sessiond: size-based notification occasionally not triggered
Jérémie Galarneau [Tue, 4 Apr 2023 15:03:03 +0000 (11:03 -0400)] 
Fix: sessiond: size-based notification occasionally not triggered

Issue observed
==============

When tracing to multiple sessions with scheduled size-based rotations
that occur simultaneously (typically because they trace the same events
and use the same rotation schedule configuration), the start of some
rotations seems to be delayed indefinitely.

Cause
=====

The size-based rotations are implemented by piggy-backing onto the
channel monitoring facilities.

Essentially, a per-channel timer samples a number of statistics on the
consumer daemon end, which transmits them to the session daemon.

The session daemon's notification subsystem evaluates the statistics
against the various registered triggers bound to the channels being
monitored when a statistics sample is received.

To implement size-based rotations, internal triggers are registered with
the "consumed size" condition set to a given threshold. A session
rotation management thread (which also performs other tasks) uses a
notification channel to wait for sessions to reach their target size,
starts rotations as needed, and sets a new threshold according to the
sessions' configured rotation schedule.

The rotation thread uses liblttng-ctl's API to consume notifications
from a notification channel.

At any time, a notification channel may have multiple notifications
queued-up internally in its buffers. This is because a notification
channel multiplexes command replies and notifications over the same UNIX
socket. The current protocol specifies that multiple notifications can
be received before the reply to a command.

In such cases, the notification channel client implementation internally
queues them and provides them on the next calls to
lttng_notification_channel_get_next_notification().

This is correct with respect to the public API, which is intended to be
used in "blocking mode". However, this internal user uses the
notification channel's raw file descriptor to wake-up when a
notification is available.

This is problematic because notifications may be queued by the
notification channel (and thus removed from the socket) while waiting
for command replies (subscribing and unsubscribing from notification
conditions). In such a case, a notification is available but the
rotation thread does not wake-up to consume it as nothing is available
in the socket's buffer.

When this happens, a session that is supposed to rotate automatically
appears to grow indefinitely. It will typically eventually rotate as new
notifications become available and cause the rotation thread to wake-up.
However, a "lag" builds up as the notification that caused the wake-up
is not consumed. Instead, the last buffered notification is provided to
the rotation thread.

Solution
========

Use an event_fd to wake-up the rotation thread whenever a command
completes on the notification channel. This ensures that any
notification that was queued while waiting for a reply to the command is
eventually consumed.

Known drawbacks
===============

None.

Note
====

The use of C++ features is kept to a minimum in this patch in order to
make it easier to backport to the stable releases. A clean-up patch
follows and makes the code conform to the coding standards.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8974b10124704d1e66e8da32d495fee738e3d43f

19 months agoAdd the lttng::eventfd class
Jérémie Galarneau [Wed, 29 Mar 2023 21:15:20 +0000 (17:15 -0400)] 
Add the lttng::eventfd class

Add an RAII wrapper around the use of eventfd(), extending the
file_descriptor class. The implementation of file_descriptor is moved to
its own TU to make clean-up the interface.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie177018ce8ffe24e78f1be82bdd2f77ba9b19e32

19 months agoFix: file-descriptor: missing include guards
Jérémie Galarneau [Wed, 29 Mar 2023 20:18:36 +0000 (16:18 -0400)] 
Fix: file-descriptor: missing include guards

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I05551e67a28e75b353f22e8df9f2ecde8dad5f5b

19 months agofile-desrcriptor: add assignment operator
Jérémie Galarneau [Wed, 29 Mar 2023 19:13:18 +0000 (15:13 -0400)] 
file-desrcriptor: add assignment operator

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I65ec468e0825801db47da6b1298d0bc09028415d

19 months agoFix: file-descriptor: unnecessary assert in move constructor
Jérémie Galarneau [Wed, 29 Mar 2023 17:41:26 +0000 (13:41 -0400)] 
Fix: file-descriptor: unnecessary assert in move constructor

There is no use in checking the current fd in the move constructor. This
is probably a left-over from the inital move assignment operator.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I416d2778784ddea448904118c940914c030bf399

19 months agoDocs: missing period at the end of comment
Jérémie Galarneau [Wed, 29 Mar 2023 17:32:02 +0000 (13:32 -0400)] 
Docs: missing period at the end of comment

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I62fcddcfa57289a2177acd25931fc1962abb206b

19 months agoPython bindings: silence warnings in generated code
Michael Jeanson [Tue, 4 Apr 2023 19:19:29 +0000 (15:19 -0400)] 
Python bindings: silence warnings in generated code

Add -Wnull-dereference to the list of ignored flags for swig generated
code. This triggers on SWIG 3.0.12.

Change-Id: Idf5da19666581ac97f7120520d5dcd03eb00d0a7
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoFix: leftover python inline type hint
Michael Jeanson [Tue, 28 Mar 2023 21:27:29 +0000 (17:27 -0400)] 
Fix: leftover python inline type hint

When rebasing the python 3.4 support patches, a leftover inline type
hint was introduced. Fix it to restore python 3.4 support.

Change-Id: Ieed4f555f757a6ee37285c0317659524ec97bfa8
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoPython bindings: warnings in generated code causes build failure
Jérémie Galarneau [Tue, 28 Mar 2023 18:41:15 +0000 (14:41 -0400)] 
Python bindings: warnings in generated code causes build failure

Swig regularily introduces new warnings in the generated code which
makes it difficult to maintain a buildable tree with -Werror. The option
is disabled for this sub-project.

The warnings that appear in the code generated by the current version of
Swig (4.1.0) are also silenced.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I008de07f67b2ce6ebedcf138de5a68c87d869af2

19 months agoBump minimal python3 version to 3.4
Michael Jeanson [Tue, 28 Mar 2023 14:43:51 +0000 (10:43 -0400)] 
Bump minimal python3 version to 3.4

Change-Id: If1e264d09fccba53d000211681de91d633fbd28f
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoTests: python: use quoted annotations to support python <= 3.6
Michael Jeanson [Mon, 27 Mar 2023 19:25:23 +0000 (15:25 -0400)] 
Tests: python: use quoted annotations to support python <= 3.6

Python 3.0 introduced syntax for parameter and return type annotations,
as specified in PEP 484. Python 3.6 introduced support for variable type
annotations, as specified in PEP 526.

Upstream recommends using quoted annotations for librairies that need to
support older python versions.

See https://typing.readthedocs.io/en/latest/source/libraries.html#compatibility-with-older-python-versions

Change-Id: Ifc6017a7baa9f0589e85d32005ac9ead18c1c9fb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoTests: python: enum.auto() introduced in python 3.6
Michael Jeanson [Mon, 27 Mar 2023 19:37:24 +0000 (15:37 -0400)] 
Tests: python: enum.auto() introduced in python 3.6

Assign descriptive string values to the enumeration members instead of
using auto() and provide a repr() method that hides the value as
recommended upstream [1].

[1] https://docs.python.org/3.6/library/enum.html#omitting-values

Change-Id: I0bc8fcc19d68342ade1aeb587f07a9b483f81b3e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 months agoTests: python: path-like object introduced in python 3.6
Michael Jeanson [Mon, 27 Mar 2023 19:25:07 +0000 (15:25 -0400)] 
Tests: python: path-like object introduced in python 3.6

Prior to python 3.6 the builtin open() function expected a string or
bytes object for the pathname. Add a compat method to convert the
path-like object to a string on interpreters that lack PEP-519 [1]
support.

[1] https://peps.python.org/pep-0519/

Change-Id: I23d1da1202e17db621f1fb89f7a79b12694dd4a6
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoFix: truncated len in lttng_event_rule_user_tracepoint_serialize()
Michael Jeanson [Thu, 23 Mar 2023 16:45:18 +0000 (12:45 -0400)] 
Fix: truncated len in lttng_event_rule_user_tracepoint_serialize()

Observed issue
==============

On 64-bit big-endian platforms, the serialization/deserialization tests
of tracepoint event rules fail since the length of individual exclusions
is truncated in lttng_event_rule_user_tracepoint_serialize and appear as
"0" on the receiving end.

Cause
=====

The length of the exclusion name string is stored in a variable of type
`size_t`. However, since the protocol expects it to be expressed as a
uint32_t, the value is added to the payload by copying the first 4 bytes
of the value.

On a 32-bit system this would be fine since `sizeof(size_t) == 4`. Even
worse, it would work most of the time (assuming an exclusion name string
< 4GiB) on a little-endian 64-bit system as the least significant bits
would be copied and correctly express the length of the string.

On a big-endian 64-bit platform, the most-significant 4 bytes are copied
to the payload buffer thus making the string length appear as "0".

Solution
========

A temporary variable is used to hold the "casted" value and make it safe
to copy to the payload buffer regardless of the platform's endianness.

Known drawbacks
===============

None.

Change-Id: I64c03345fff7ffea2f8fcb84692a085da31c421b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoTests: remove leftover debug printing in test_add_trigger_cli
Michael Jeanson [Wed, 22 Mar 2023 19:08:10 +0000 (15:08 -0400)] 
Tests: remove leftover debug printing in test_add_trigger_cli

Change-Id: Ie5d0cc18ae35ff5848008fae5942d93eac5f2f70
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoFix: invalid syntax with python 3.5 in test_ust.py
Michael Jeanson [Wed, 22 Mar 2023 14:28:14 +0000 (10:28 -0400)] 
Fix: invalid syntax with python 3.5 in test_ust.py

The following error was encountered while running the test suite with
python 3.5 :

  File "./tools/context/test_ust.py", line 99
    client: lttngtest.Controller = lttngtest.LTTngClient(test_env, log=tap.diagnostic)
          ^
  SyntaxError: invalid syntax

Remove the type hint.

Change-Id: I2d8c39d092b8a1659208b89aaca1cf11ca53866a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoBuild fix: brace-enclosed initlializer lists error with g++ 4.8
Michael Jeanson [Mon, 20 Mar 2023 19:05:04 +0000 (15:05 -0400)] 
Build fix: brace-enclosed initlializer lists error with g++ 4.8

A build error occurs when building using g++ 4.8 :

 In file included from session.hpp:18:0,
                  from lttng-sessiond.hpp:21,
                  from utils.cpp:10:
 ../../../src/common/pthread-lock.hpp: In constructor 'lttng::pthread::details::mutex::mutex(pthread_mutex_t&)':
 ../../../src/common/pthread-lock.hpp:29:61: error: invalid initialization of non-const reference of type 'pthread_mutex_t&' from an rvalue of type '<brace-enclosed initializer list>'
   explicit mutex(pthread_mutex_t& mutex_p) : _mutex{ mutex_p }

Use oldstyle initialization of references instead.

Change-Id: I2fd756b48fd8e70e30199c86527c025117bfb6ff
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoBuild fix: POD static_assert check fails on lttng_event_exclusions
Jérémie Galarneau [Tue, 21 Mar 2023 15:15:19 +0000 (11:15 -0400)] 
Build fix: POD static_assert check fails on lttng_event_exclusions

A build error occurs when building using g++ 6.4.0 on PPC32:

  In file included from ../../src/common/buffer-view.hpp:11:0,
                   from event.cpp:9:
  ../../src/common/macros.hpp: In instantiation of 'AllocatedType* zmalloc(size_t) [with AllocatedType = lttng_event_exclusion; size_t = unsigned int]':
  event.cpp:270:77:   required from here
  ../../src/common/macros.hpp:102:2: error: static assertion failed: type can be malloc'ed
    static_assert(can_malloc<AllocatedType>::value, "type can be malloc'ed");
    ^~~~~~~~~~~~~

A bug affecting gcc [6.1, 7.4] causes flexible array members to generate
a destructor for compound types. In turn, this makes any type that
contains a flexible array a non-POD object which is a problem under some
use-case (e.g., being allocated using C-style memory management
facilities).

Explicitly specifying a length of zero works around this bug, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71147

The same bug affects re2 and they have fixed it in a similar way:
https://github.com/google/re2/blob/9049cd28d7496e05e7b7beaec89291d8bc6a31ee/re2/dfa.cc#L123

Change-Id: I730cdeb86bb39cdbfdc5165f854ab5906aeb2192
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
20 months agoport: add missing attributes in getrandom_nonblock() on macOS
Michael Jeanson [Tue, 7 Mar 2023 19:10:00 +0000 (14:10 -0500)] 
port: add missing attributes in getrandom_nonblock() on macOS

Change-Id: I2e4944cf17ba72c75b8c5cfd5ce0d7b806d14b67
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoFix: adding a user space probe fails on thumb functions
Olivier Dion [Wed, 22 Feb 2023 20:19:14 +0000 (15:19 -0500)] 
Fix: adding a user space probe fails on thumb functions

On some architectures, calling convention details are embedded in the
symbol addresses. Uprobe requires a "clean" symbol offset (or at least,
an address where an instruction boundary would be legal) to add
instrumentation. sanitize_uprobe_offset implements that sanitization
logic on a per-architecture basis.

The least significant bit is used when branching to switch to thumb ISA.
However, it's an invalid address for us; mask the least significant bit.

We were not masking the thumb bit, thus using the wrong address offset
by one.

Change-Id: Iaff8ccea3a319f9d9ad80501f1beccd74d1ef56d
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoFix: Tests that assume CPU 0 is present
Olivier Dion [Thu, 16 Feb 2023 20:34:26 +0000 (15:34 -0500)] 
Fix: Tests that assume CPU 0 is present

Add util_event_generator.sh to shellcheck test while at it.

Change-Id: I261452496827a5b9fc08b39a1132b13a39d0a7f5
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoFix: Wrong assumption about possible CPUs
Olivier Dion [Tue, 14 Feb 2023 19:35:34 +0000 (14:35 -0500)] 
Fix: Wrong assumption about possible CPUs

cpuset is not necessary contiguous.  Thus, we need to parse
/sys/devices/system/cpu/posssible correctly.

Also, the `get_exposed_cpus_list' utility functions is required for
taskset-ting on the correct CPUs available to the test environment.

Change-Id: I062ce8d311ff0e8c4b757fe6f36387e3007cfa27
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoport: fix -Wdeprecated-declarations warning about sprintf on macOS clang 14
Michael Jeanson [Tue, 7 Mar 2023 19:16:44 +0000 (14:16 -0500)] 
port: fix -Wdeprecated-declarations warning about sprintf on macOS clang 14

Remove uses of sprintf to fix this warning:

    warning: 'sprintf' is deprecated: This function is provided for
    compatibility reasons only.  Due to security concerns inherent in the
    design of sprintf(3), it is highly recommended that you use snprintf(3)
    instead. [-Wdeprecated-declarations]

Change-Id: Ifff3746c1cc4e51a8cf4c08ccd845c887d76c6be
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoTests: fix: parse-callback reports missing addr2line
Olivier Dion [Fri, 10 Mar 2023 18:17:46 +0000 (13:17 -0500)] 
Tests: fix: parse-callback reports missing addr2line

addr2line from binutils is required for this script to work correctly.
However, it silently fails. Fix this by using `subprocess.run' with
`check=True' instead of `subprocess.getoutput'. That way, an exception
is raised if an error occurs.

Fix the shebang by not assuming where python is installed while at it.

Change-Id: I5157b3dbccf6bfbe08a6b6840b38f5db9010fe96
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 months agoDocs: sessiond: document the role of an application's two sockets
Jérémie Galarneau [Tue, 7 Mar 2023 22:03:27 +0000 (17:03 -0500)] 
Docs: sessiond: document the role of an application's two sockets

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I355588af1b3408c8c209aae09c2897640d4ca5b4

20 months agoClean-up: coding style fix and missing method in lttng::ctl::error
Jérémie Galarneau [Tue, 28 Feb 2023 17:44:55 +0000 (12:44 -0500)] 
Clean-up: coding style fix and missing method in lttng::ctl::error

Methods must not contain get/set for trivial accessors. get_code() is
renamed to code() to follow this guideline.

Moreover, the method was not implemented. It is marked as noexcept and
the _error_code member is made `const` as there is no reason for it to
be mutated.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If0fca5cc91c1cb72fff183ee6d29588ff4b5c030

20 months agoFix: lttng remove-trigger -h fails
Olivier Dion [Wed, 22 Feb 2023 21:45:27 +0000 (16:45 -0500)] 
Fix: lttng remove-trigger -h fails

The error was that `argv' was incremented before passing it to
`argpar_iter_create'. However, the macro `SHOW_HELP' implicitly
deferences `argv[0]' to determine the command name.

Fix this by introducing a new variable `args' leaving `argv' untouched.

Change-Id: Id50fa2424550280a1e5e207429d643f5e8e00396
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoman/README.md: Update asciidoc url to asciidoc.org
Jérémie Galarneau [Wed, 22 Feb 2023 21:57:22 +0000 (16:57 -0500)] 
man/README.md: Update asciidoc url to asciidoc.org

Reported-by: Kamil Beker
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1e68fc6ff6e234eeab126a091b2b713e65697136

21 months agoREADME.adoc: Update asciidoc url to asciidoc.org
Jérémie Galarneau [Wed, 22 Feb 2023 21:56:01 +0000 (16:56 -0500)] 
README.adoc: Update asciidoc url to asciidoc.org

Reported-by: Kamil Beker
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib78323c82e81dbcaa577f3234e7cbbb2d5130086

21 months agocompat: off64_t is not defined by musl
Jérémie Galarneau [Tue, 17 Jan 2023 21:57:35 +0000 (16:57 -0500)] 
compat: off64_t is not defined by musl

This helps compile with latest musl, where off64_t is not defined unless
_LARGEFILE64_SOURCE is defined. On glibc, _LARGEFILE64_SOURCE is defined
if _GNU_SOURCE is defined, so the problem is only seen with musl.

Since the project uses AC_SYS_LARGEFILE, which from the autoconf doc:
"arrange for 64-bit file offsets, known as large-file support."

As such, it is safe to assume off_t is 64-bit wide. This is checked by a
static_assert to catch any platform where autoconf would let a 32-bit
off_t slip.

Reported-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If2c6007a8c85bc3f3065002af8a7538b882fb4a8

21 months agotests: make test_shellcheck depend on shellcheck
Michael Jeanson [Fri, 17 Feb 2023 19:04:31 +0000 (14:04 -0500)] 
tests: make test_shellcheck depend on shellcheck

Since this test is only useful for development, don't fail the build on
platforms that lack shellcheck.

Another approach could be to add a dedicated make target to run the meta
tests but this was easier as a quick fix.

Change-Id: If9d30c7c4e3ee526f028ad82545e631ace272354
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoFix: tests: add shellcheck test to distribution
Michael Jeanson [Thu, 16 Feb 2023 16:37:10 +0000 (11:37 -0500)] 
Fix: tests: add shellcheck test to distribution

Add the shellcheck test to the distribution, also copy it to the build
dir for oot builds and while where are here, rename it with the 'test_'
prefix to match the rest of the test suite.

Change-Id: Iaeff191022d16ea666c2145aa7e907aeebb6c5ff
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoTests: Add meta shellcheck test
Olivier Dion [Mon, 6 Feb 2023 19:21:07 +0000 (14:21 -0500)] 
Tests: Add meta shellcheck test

Pass shellcheck on a list of known correct shell scripts. The idea is to
add scripts to the list incrementally and avoid regressions.

Change-Id: If9b15879cfd4d3c3bdbc6b5fc3efb5638593ca74
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoBuild feature: Add pre-inst-env script
Olivier Dion [Fri, 3 Feb 2023 20:29:53 +0000 (15:29 -0500)] 
Build feature: Add pre-inst-env script

This script setup environment variables for running compiled binaries
from the project without having to install them.

Usage example:

  $ ./pre-inst-env lttng create

Change-Id: Ie7839f32cfdc32103db035e2189b6f8a4c5cabe4
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoTests: snapshot tests complain that nothing is output
Jérémie Galarneau [Mon, 13 Feb 2023 20:43:18 +0000 (15:43 -0500)] 
Tests: snapshot tests complain that nothing is output

The user space snapshot tests invoke a common script that runs the
actual tests. In doing so, the parent script's tap generator isn't
involved in the production of the tests' tap output and outputs an error
message as diagnostic.

  ok 134 - Wait after kill session daemon
  # Looks like your test died before it could output anything.

`exec`-ing the common script sidesteps the problem by replacing the
shell entirely.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I53783fa783eb5581bf41fc1a5504dbd4e14fa595

21 months agoTests: Test snapshot maximum size correctly
Olivier Dion [Wed, 1 Feb 2023 22:11:02 +0000 (17:11 -0500)] 
Tests: Test snapshot maximum size correctly

The minimum size for a channel is determined by:

  sub-buffer-size * sub-buffer-count * possible-cpus

where sub-buffer-size is the system page size and sub-buffer-count is 2.

We set a snapshot with a maximum size of the minimum size. From there,
we need to spam that amount of events, assuming each event to be one
byte, on every online CPUs. We can then ensure that the total snapshot's
size is equal to the minimum size for a channel. However, there's a
little bias if the number of possible cores is greater than the number
of online cores. In that case, the bias is one sub-buffer for each extra
ring buffer.

Change-Id: I4718e134684463789b4f7be9b12c9bf3d6cfec20
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoTests: Add get_possible_cpus_count utility
Olivier Dion [Wed, 1 Feb 2023 21:04:14 +0000 (16:04 -0500)] 
Tests: Add get_possible_cpus_count utility

lttng-ust uses the possible number of CPUs to allocate its ring buffers.
Certain tests have to take that into consideration in their calculation
instead of relying on online processors.

Thus, add the same logic for calculating the possible CPUs on the
system.

Change-Id: I9f14afba3e4adad9547cbd9386f8e1b1b55a3253
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoFix: lttng-disable-event: erroneous error code used in logging
Jérémie Galarneau [Fri, 3 Feb 2023 19:31:39 +0000 (14:31 -0500)] 
Fix: lttng-disable-event: erroneous error code used in logging

66cefebdc introduced `disable_ret` to hold the integral result of
lttng_disable_event_ext() instead of mixing enums and integers.

In doing so, one use site was left unmodified which resulted in the
wrong variable being used to log an error when the command failed.

This was spotted by clang:
  commands/disable_events.cpp:252:21: warning: result of comparison of
  constant -83 with expression of type 'enum   cmd_error_code' is always false [-Wtautological-constant-out-of-range-compare]
                                      command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I282ebee0140f7044847aab6c43ba6bd0c185fc46

21 months agoAdd a .git-blame-ignore-revs file
Jérémie Galarneau [Fri, 3 Feb 2023 19:26:24 +0000 (14:26 -0500)] 
Add a .git-blame-ignore-revs file

The git-blame command supports the `--ignore-revs-file` option
since git 2.23. This option allows a file containing a list of revisions
that git-blame must ignore to be specified.

It can be used as such:
  git blame --ignore-revs-file=.git-blame-ignore-revs some-file.cpp

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I39692f9eda999703e3e3bacb6e02f6e714eeb8a8

21 months agoBuild fix: consumer: unused-but-set-variable warning
Jérémie Galarneau [Fri, 3 Feb 2023 19:05:05 +0000 (14:05 -0500)] 
Build fix: consumer: unused-but-set-variable warning

clang 15.0.7 produces the following warning, preventing the build of the
project with -Werror:

  consumer/consumer.cpp:2519:15: error: variable 'num_hup' set but not used [-Werror,-Wunused-but-set-variable]
          int num_rdy, num_hup, high_prio, ret, i, err = -1;
                       ^

num_hup is indeed not used, so remove its declaration and its
assignations.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iccd8aa7716602d6babd1ed5aa23d06268385480c

21 months agoBuild fix: filter parser fails to build with -Werror
Jérémie Galarneau [Fri, 3 Feb 2023 18:59:23 +0000 (13:59 -0500)] 
Build fix: filter parser fails to build with -Werror

Using bison 3.8.2 and clang 15.0.7, the project fails to build with
-Werror as building the generated parser results in the following
warning:

  CXX      filter/libfilter_la-filter-parser.lo
  filter/filter-parser.cpp:1552:9: error: variable 'yynerrs' set but not used [-Werror,-Wunused-but-set-variable]
      int yynerrs = 0;
          ^

A pragma directive is inserted to silence the warning and allow the
build to go through.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4c46a5df91bdeca6ad4e2a8ff7f2a98ee94c4f1d

21 months agotests: Execute perl using /usr/bin/env
Olivier Dion [Wed, 1 Feb 2023 18:28:50 +0000 (13:28 -0500)] 
tests: Execute perl using /usr/bin/env

Perl is not necessary installed under /bin.  Thus, use /usr/bin/env to
get the corretion location from PATH.

Change-Id: Ie5f037bcfa69c344b63cf04ec7374dc28218d1c7
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 months agoReplace explicit rcu_read_lock/unlock with lttng::urcu::read_lock_guard
Jérémie Galarneau [Sat, 28 Jan 2023 09:54:09 +0000 (04:54 -0500)] 
Replace explicit rcu_read_lock/unlock with lttng::urcu::read_lock_guard

The explicit use of rcu_read_lock/unlock() has been a frequent source of
bugs in the code base as the locks can often end-up imbalanced when
error paths are taken (through goto's).

Since lttng::urcu::read_lock_guard was implemented in a previous commit,
replace all usages of the rcu_read_lock/unlock() API with an RAII
lock_guard wrapper.

Essentially, lttng::urcu::read_lock_guard acquires the RCU reader lock
on construction, and releases it when it goes out of scope. This
automates what is accomplished in the various error paths by jumping to
error handling labels.

For more info, see: https://en.cppreference.com/w/cpp/thread/lock_guard

No user-visible change of behaviour is intended by this patch. The scope
of some critical sections has been reduced when possible and when it
didn't matter from a correctness standpoint. The RCU reader lock would
often be held longer than necessary to simplify the error paths.

Explicit scopes are used to limit the lifetime of the reader lock guards
when used in long functions or when it is only intended to protect the
iteration over cds_lfht instances. In those cases, the following pattern
is used:

```cpp
void foo()
{
  [...]
  {
    lttng::urcu::read_lock_guard read_guard;

    cds_lfht_for_each(...) {
      [...]
  }
  [...]
}
```

This explicitly bounds the critical section and also serves as a hint as
to why the read guard is being used. It is fairly verbose, but I think
it's a good compromise until we add an idiomatic urcu wrapper that
automates this stuff too.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie3ef8ddf0f1ab813971522176115688939696370

21 months agoClean-up: replace uses of `int enabled` with boolean flags
Jérémie Galarneau [Sat, 28 Jan 2023 18:18:32 +0000 (13:18 -0500)] 
Clean-up: replace uses of `int enabled` with boolean flags

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If9cf1b6e2db67d461479a43d8ed3c3e07c4133ba

21 months agoClean-up: replace uses of `int found` as bool by `bool found`
Jérémie Galarneau [Sat, 28 Jan 2023 18:10:39 +0000 (13:10 -0500)] 
Clean-up: replace uses of `int found` as bool by `bool found`

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I95c4cefdc0836203d3bf8e6b9c273cf5f1cbf3fc

21 months agoClean-up: ust-consumerd: remove stub of removed function
Jérémie Galarneau [Wed, 1 Feb 2023 19:22:32 +0000 (14:22 -0500)] 
Clean-up: ust-consumerd: remove stub of removed function

lttng_ustconsumer_allocate_channel() no longer exists. However,
it is still declared and a stub is present when building without
liblttng-ust. Remove both as they are no longer needed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I33f357bf642822a4825b9d3ceba098f1421c0132

This page took 0.051446 seconds and 4 git commands to generate.