Clean-up: lttng: utils: missing special member functions clang-tidy warns: warning: class 'session_list' defines a move constructor but does not define a destructor, a copy constructor, a copy assignment operator or a move assignment operator [cppcoreguidelines-special-member-functions] This warning related to the "Rule of Five": If a class requires a custom destructor, copy constructor, or copy assignment operator due to manual resource management, it likely needs to explicitly define all five (including move constructor and move assignment operator) to correctly manage the resources across all types of object copying and moving scenarios. This rule helps prevent resource leaks, double frees, and other common issues related to resource management. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I970cd1ab905eb877241f7e559b47349b9371f261
Clean-up: clang-tidy: missing headers prevent analysis clang-tidy complains that some headers omit the inclusion of their dependencies, which prevents the analysis from completing. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ic6d51e82c5f5536c0d421c38a97afddbe64a16ef
CodingStyle.md: remove redundant virtual specifier The coding style mentions that override and virtual should not be used together (as virtual would be redundant). However, one of the examples commits that cardinal sin. Mea culpa. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I77dccde4dcf55591ac890bfa90aaeb1042e80d84
Clean-up: tests: utils: const_cast clang-tidy warns that const_cast should not be used because of the cppcoreguidelines-pro-type-const-cast rule. In this case, const_cast is not strictly necessary and can be replaced by a static_cast to silence the warning. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Iee089716e991c52686a0fdee5a7ac2aae0a30b46
Clean-up: apply suggested clang-tidy fixes Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I926b96120d8c77b3c0d8efc3fcdf1d11d2314e8a
Clean-up: waiter: coding style changes Mark non-throwing functions as noexcept when possible and mark waker as final since we don't expect user to derive from it. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9b2a4c4376b2a96e7238d93e2ad60b1f55317dc2
Fix: waiter: use std::reference_wrapper instead of a raw reference clang-tidy warns that /home/jgalar/EfficiOS/src/lttng-tools/src/common/waiter.hpp:32:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default] The warning itself is bogus since it is not possible to use the default copy-assignment operator in this case. Indeed, _state being a reference, it cannot be rebound after its initialization. The compiler will refuse to generate a default implementation as it would be ill-formed. However, this does highlight a problem in the implementation, namely that the explicit assignment operator does attempt to re-assign _state. Switching the _state reference to use std::reference_wrapper does make it legal to re-bind the reference to a different object. Having the ability to assign a waker is conceptually a bit strange (vs obtaining another instance from the waiter) and should probably be disabled, but it is required for the moment as one the of use in a huge C structure that gets copied using by assignment. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I6f4c740244decb50426ec0571aaea754edaea6a5
Fix: lttng-destroy: string formating error when default session is unset Using `lttng destroy` when no default session is set in .lttngrc results in the following print-out: Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc Did you create a session? (lttng create <my_session>) Error: Failed to format string: string pointer is null This is because the client attempts to format the following message: ERR_FMT("Session `{}` not found", spec.value); When no default session could be found in .lttngrc, spec.value is left at nullptr and it is assumed that the listing succeeded. A new CLI-specific exception, no_default_session_error, is added to the project and thrown when the session listing fails. This allows the calling code to mark the listing as having failed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
Revert "Fix: lttng-destroy: string formating error when default session is unset" This reverts commit e8c353ad12851366573d9bfe45d333a9e9ff742d as it is missing files (wrong revision of the change picked-up from gerrit). Change-Id: Ia426a8004d9827ee72ed39db52d7894f5d4eb34f Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: lttng-destroy: string formating error when default session is unset Using `lttng destroy` when no default session is set in .lttngrc results in the following print-out: Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc Did you create a session? (lttng create <my_session>) Error: Failed to format string: string pointer is null This is because the client attempts to format the following message: ERR_FMT("Session `{}` not found", spec.value); When no default session could be found in .lttngrc, spec.value is left at nullptr and it is assumed that the listing succeeded. A new CLI-specific exception, no_default_session_error, is added to the project and thrown when the session listing fails. This allows the calling code to mark the listing as having failed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
Fix: erroneous specifier used with ERR_FMT macro ERR_FMT uses fmtlib's specifiers rather than the POSIX ones. Change-Id: Iadd914fe2f5556b4d2463a9a6861bcb4d40d9643 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: lttng-destroy: string formating error when default session is unset Using `lttng destroy` when no default session is set in .lttngrc results in the following print-out: Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc Did you create a session? (lttng create <my_session>) Error: Failed to format string: string pointer is null This is because the client attempts to format the following message: ERR_FMT("Session `{}` not found", spec.value); When no default session could be found in .lttngrc, spec.value is left at nullptr and it is assumed that the listing succeeded. A new CLI-specific exception, no_default_session_error, is added to the project and thrown when the session listing fails. This allows the calling code to mark the listing as having failed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
Fix: baddr-statedump: use $(LIBTOOL) --mode=execute GNU libtool inconsistently places the compiled executable in the source directory or in the .libs directory where a libtool wrapper script is placed in the source directory. While slibtool will always place the compiled executable in the .libs directory and a wrapper script in the source directory. This will result with a build error when using slibtool since objcopy needs the executable and not the shell wrapper script, but this can be solved for both implementations by using $(LIBTOOL) --mode=execute on all commands that operate on the libtool compiled executables. Gentoo issue: https://bugs.gentoo.org/858095 The GNU libtool --mode=excute is documented upstream. https://www.gnu.org/software/libtool/manual/html_node/Execute-mode.html https://www.gnu.org/software/libtool/manual/html_node/Debugging-executables.html And the GNU libtool behavior of when to create a wrapper script is documented in the 'Linking Executables' section. "Notice that the executable, hell, was actually created in the .libs subdirectory. Then, a wrapper script (or, on certain platforms, a wrapper executable see Wrapper executables) was created in the current directory. Since libtool created a wrapper script, you should use libtool to install it and debug it too. However, since the program does not depend on any uninstalled libtool library, it is probably usable even without the wrapper script." https://www.gnu.org/software/libtool/manual/html_node/Linking-executables.html And the inconsistency between GNU libtool and slibtool is documented at the Gentoo wiki. "One difference between GNU libtool and slibtool is that the former will conditionally place the compiled executable or a shell wrapper script in the build directory, depending on whether or not the executable depends on a build-local libtool library (e.g. libfoo.la). Where slibtool will always place a compatible wrapper script in the build directory where GNU libtool would have conditionally placed the executable. When the wrapper script is created both GNU libtool and slibtool will place the executable in the .libs directory within the build directory. Consequently build systems, ebuilds, and other users should take care to avoid scenarios like installing the wrapper script to the system instead of the executable. In these cases ideally the executable would be installed by the same libtool implementation that compiled it." https: //wiki.gentoo.org/wiki/Slibtool#Installing_or_using_binaries_created_by_libtool_manually Signed-off-by: orbea <orbea@riseup.net> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I03102ed78af835daa9b9a5836c2979a5f5d4bd8c
Clean-up: sessiond: use empty() instead of comparing size to 0 Harmonize the project's coding style a little by favoring the use of the 'empty()' methood of containers rather than comparing their size to 0. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I22e6b7fe4d94d8f43362fe119b4ca6d480587291
Build fix: missing operator- for iterator on g++7 The project fails to build on 'g++ (SUSE Linux) 7.5.0' since its STL implementation assumes that operator- is available for random access iterators. The build fails with the following error: event_name.cpp:82:71: required from here /usr/include/c++/7/bits/stl_iterator_base_funcs.h:104:21: error: no match for ‘operator-’ (operand types are ‘lttng::utils::random_access_container_wrapper<const bt_value*, const char*, event_name_set_operations>::_iterator<const lttng::utils::random_access_container_wrapper<const bt_value*, const char*, event_name_set_operations>, const char* const>’ and ‘lttng::utils::random_access_container_wrapper<const bt_value*, const char*, event_name_set_operations>::_iterator<const lttng::utils::random_access_container_wrapper<const bt_value*, const char*, event_name_set_operations>, const char* const>’) A trivial implementation of that operator is provided and allows the build to succeed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib1637e81e5cdc42cd5a142dcee21150ced9fcc55