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>
clang-tidy: add Chrome-inspired checks Add the checks used by the Chrome project. Most of these changes were produced and applied by clang-tidy. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I4058dafbdef00e81ac04f202fdfe377384a99e6b
Run clang-format on the whole tree Generated by running: find -not \( -path "./src/vendor*" -prune \) -iname "*.h" -o -iname "*.hpp" -o -iname "*.c" -o -iname "*.cpp" -exec clang-format -i {} \; Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9557e7d84e305187475ef88124857cf2f438bbb1
Build fix: missing consumer.hpp include in lttng-consumerd.hpp A follow-up commit changes the order of inclusions and fails to build since lttng-consumerd.hpp doesn't include consumer.hpp for its use of `enum lttng_consumer_type`. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I8eb6e9ab0e97624c3cae85057c15703873534c2c
Standardize quit pipes behavior Standardize the behavior of the quit pipes to trigger on any poll events. Change-Id: I0beeefcbd1a55b2aa308eb28b617487ffdeb737e Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Rename C++ header files to .hpp Rename all C++ header files (include/**/*-internal.h, src/**/*.h except argpar and msgpack, some headers in tests) to have the .hpp extension. Doing so highlights that we include some C++ header files in some test files still compiled as C. This is ok for now, as the files they include don't actually contain C++ code incompatible with C yet, but they could eventually. This is something we can fix later. Change-Id: I8bf326b6b2946a3e26704f3ef3ac5831bbe9bc26 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Prepare for '-Wunused-parameter' In preparation for '-Wextra' Change-Id: I30e6abb9502fc97daa565fde450d1e4235cf1ec7 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure: add '-Wredundant-decls' to warning flags Change-Id: I5329ebe83aab40e6796b506c28e853b4af3c5e99 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common: use single Makefile for parallel builds Use a single Makefile in 'src/common' as it contains multiple subdirectories with a small number of objects to compile. This allows faster parallel builds since parallelism in automake is applied per Makefile. There is anectodal evidence of a 25 seconds improvement to the build process on a 36 core machine. Change-Id: If2ce266050e345d58b00bf65b574ccf5168f28f1 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Introduce libcommon-lgpl for liblttng-ctl liblttng-ctl is a LGPLv2.1 library should should not use GPLv2 code. Introduce libcommon-lgpl as a static archive containing only LGPLv2.1 compatible code. This also removes the dependency from liblttng-ctl to liburcu. Include some source files in libcommon-lgpl.a which are indirectly needed by source files required in libcommon-lgpl.a: - endpoint.cpp, - lttng-elf.cpp, - lttng-elf.h. Include some source files in libcommon-lgpl.a which are only needed to link the lttng executable: - domain.cpp, - spawn-viewer.cpp, spawn-viewer.h. Introduce the new source file hashtable/seed.cpp to move the lttng_ht_seed symbol in a source file which does not require liburcu-cds, so it can be present in libcommon-lgpl. This allows building compile units which are needed in the lgpl common library which also contain functions which directly refer to lttng_ht_seed. Programs and libraries which use libhashtable.la are changed to use libcommon-gpl.la instead. libhashtable becomes internal to libcommon. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I27d2acb823a6d951692a5da88ce32bbe6bafb072
Rename libcommon.so to libcommon-gpl.so libcommon is a static library is currently used by both liblttng-ctl (LGPLv2.1) and all lttng-tools executables (GPLv2). Given that some code in libcommon depends on liburcu, this introduces an indirect dependency from liblttng-ctl to liburcu, which is unwanted. This first step renames libcommon.so to libcommon-gpl.so. Following steps will introduce a more lightweight libcommon-lgpl.so which only contains LGPLv2.1 code, and removes the dependency on liburcu. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ia8f37ea229f68550200cbb1528216a505bbbd45f
Copyright ownership transfer Apply copyright ownership transfer from David Goulet, Julien Desfossez, and Simon Marchi to EfficiOS Inc. Link: https://lists.lttng.org/pipermail/lttng-dev/2022-January/030087.html Link: https://lists.lttng.org/pipermail/lttng-dev/2022-January/030092.html Link: https://lists.lttng.org/pipermail/lttng-dev/2022-January/030091.html Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Signed-off-by: David Goulet <dgoulet@ev0ke.net> Signed-off-by: Julien Desfossez <ju@klipix.org> Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: Id13575afd4a2a09bb91a8d2b7a12dc3db8dc329f
lib: compile liblttng-ctl as C++ Same as the previous commits, but compile the liblttng-ctl library as C++ code (while still offering a C interface). Some exported global variables (for example in deprecated-symbols.cpp) have to be made non-const, otherwise we get: CXX deprecated-symbols.lo /home/simark/src/lttng-tools/src/lib/lttng-ctl/deprecated-symbols.cpp:21:33: error: ‘visibility’ attribute ignored [-Werror=attributes] 21 | LTTNG_EXPORT const char * const config_element_pid_tracker; | ^~~~~~~~~~~~~~~~~~~~~~~~~~ I think this is related to the fact that const global variables automatically have internal linkage in C++. Despite using -export-symbols in src/lib/lttng-ctl/Makefile.am, some new ELF symbols become exposed. It could be related to this, in the ld man page: --retain-symbols-file does not discard undefined symbols, or symbols needed for relocations. One new symbol I see, for example, is `_Z16connect_sessiondv`. Looking at liblttng-ctl.so, I indeed see a relocation for this symbol: 000000000010b778 0000053e00000007 R_X86_64_JUMP_SLOT 00000000000314a2 _Z16connect_sessiondv + 0 And that would explain why the linker keeps that symbol visible. This is related to the entry for this function in the procedure linkage table. I'm not entirely sure why these functions didn't generate a PLT entry in C, but do in C++. To avoid these new symbols, build everything with -fvisibility=hidden and -fvisibility-inlines-hidden, and tag functions we really want to export with LTTNG_EXPORT, a new macro defined to __attribute__((visibility("default"))). This macro is publicly visible, because it has to be used in distributed header files (although it's of no use for users of liblttng-ctl). Change-Id: Ie51bf0a2edfb87e5f46f9c39eed5309d9f8c41d6 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bin: compile lttng-consumerd as a C++ Same as the previous commits, but change lttng-consumerd to be a C++ program. Function lttng_consumer_get_type is dlsym-ed by tests/regression/tools/notification/consumer_testpoints.c, so we have two choices: make the dlsym use the mangled name or make the function have a C linkage name. The latter is better, because the mangled name is implementation-defined, and therefore more fragile. Change-Id: I1986e38c193a935721e52c89426c89fd434ccd6b Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Force usage of assert() condition when NDEBUG is defined Reuse the BT2 approach to force the usage of the assertion condition even when assert() are removed by the NDEBUG define. See `BT_USE_EXPR()` macro and documentation in Babeltrace commit[0]: commit 1778c2a4134647150b199b2b57130817144446b0 Author: Philippe Proulx <eeppeliteloop@gmail.com> Date: Tue Apr 21 11:15:42 2020 -0400 lib: assign a unique ID to each pre/postcond. and report it on failure 0: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0 Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3844b6ae7e95952d90033898397ac936540b785c
Fix: Handle SIGBUS in sessiond and consumerd There is an issue with the security model of lib ring buffer (lttng-ust) vs SIGBUS handling by consumer daemon. We do not handle SIGBUS in the consumer daemon. An application using ftruncate on a ring buffer shm could cause the consumer to be killed with SIGBUS. Wire up SIGBUS handling in the session daemon as well given that it also uses liblttng-ust-ctl. This depends on "liblttng-ust-ctl: Implement SIGBUS handling" in lttng-ust, which extends the API of liblttng-ust-ctl, which requires the user application to define the TLS sigbus state with DEFINE_LTTNG_UST_SIGBUS_STATE(). It therefore needs to be introduced in locked-step between lttng-ust and lttng-tools. Considering that this change in liblttng-ust-ctl modifies the ABI, it is done with a major soname version bump of the library, so it is allowed to break the API. Depends-on: lttng-ust: I7ade988e3e68a87930fbcee3e14e59c3fb66e755 Fixes: #1284 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I76a91616bd35b21c5e891c8306c73ed5e8725ebb
Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: build failure with -fno-common GCC 10 will default to building with -fno-common, this inhibits the linker from merging multiple tentative definitions of a symbol in an archive. I'm not sure I understand what happen with the symbols in mi-lttng.h but a similar issue was adressed in: commit 4965f956f3ef47388fb4a1b2f8f504abfe31afe7 Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> Date: Fri May 22 12:53:30 2015 -0400 Fix: Mark MI and Config string declarations as extern This fixes a build issue with GCC 5.1 which would complain about these symbols being defined multiple times. Make sure these symbols are extern and defined only in one compile unit. For more information, see: https://gcc.gnu.org/gcc-10/porting_to.html Change-Id: I139c9695371836cb1011f9ce192080b602ed2fbc Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>