liblttng-ctl: use export list to define exported symbols Symbols are currently exported by default by liblttng-ctl.so (usable by other shared libraries / programs using liblttng-ctl.so), so we must use LTTNG_HIDDEN on all symbols that are meant to be internal to liblttng-ctl.so. Of course, this is easy to forget, so over the years many symbols that were not meant to be exported were exported, and must now stay exported to avoid breaking the ABI. As explained here [1], a better method is to make symbols hidden by default, and mark those we want to be exported as such. I have tried to use this, but when subsequently converting the code to C++, I have noticed that some symbols related to the STL were exported anyway, which is bad. The other alternative, implemented in this patch, is to use an explicit symbol export list [2], using libtool's -export-symbols (which uses the linker's -version-script option). Only the symbols listed here are exported. So, in practice, this patch: - Adds an liblttng-ctl.sym file with the list of exported symbols and adjusts the Makefile to use the -export-symbol option - Removes LTTNG_HIDDEN and all its uses abidiff shows no changes for liblttng-ctl.so between before and after this patch. [1] https://gcc.gnu.org/wiki/Visibility [2] https://www.gnu.org/software/libtool/manual/libtool.html#Link-mode Change-Id: I5d8c558303894b0ad8113c6e52f79a053bb580e1 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
hashtable: silence -fsanitize=address warning for `hashlittle()` function Issue ===== The code of this function triggers the following heap-buffer-overflow warning when compiled with `-fsanitize=address` in specific situation: ==247225==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001310 at pc 0x5559db6c575a bp 0x7f193e6faeb0 sp 0x7f193e6faea0 READ of size 4 at 0x602000001310 thread T4 (Notification) #0 0x5559db6c5759 in hashlittle /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:315 #1 0x5559db6c6df4 in hash_key_str /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:490 #2 0x5559db5e3282 in hash_trigger_by_name_uid /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:378 #3 0x5559db5ecbe3 in trigger_name_taken /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2333 #4 0x5559db5ecd7c in generate_trigger_name /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2362 #5 0x5559db5ed6e0 in handle_notification_thread_command_register_trigger /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2491 #6 0x5559db5ef967 in handle_notification_thread_command /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2927 #7 0x5559db5ddbb7 in thread_notification /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread.c:693 #8 0x5559db60e56d in launch_thread /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/thread.c:66 #9 0x7f19456ec608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477 #10 0x7f1945602292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292) Given that the `k` pointer used in this loop is a `uint32_t *` we might read bytes outside of the allocated key if the key is less than 4 bytes long. As the comment about Valgrind explains, this is not a real problem because memory protections are typically word bounded. I tried to use the `__SANITIZE_ADDRESS__` define to select the Valgrind implementation of this code when building with AddressSanitizer but that still triggers the same head-buffer-overflow warning. Why wasn't that a problem before? ======================================= The trigger feature will use small default names like "T0". Workaround ========== Exclude this function from the sanitizing using the compiler attribute "no_sanitize_address". Drawback ======== This removes our sanitizing coverage for this function. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I82d0d3539916ed889faa93871f9b700064f2c52a
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>
Clean-up: hash table utils are unnecessarily non-const Non-const internal utilities make it hard/impossible to write const-correct code in the rest of the project. This clean-up allows the notification subsystem to improve on this code-quality front (see follow-up patches). Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: define _LGPL_SOURCE in C files Defining this in headers is a bad practice, since the header is not necessarily the first in the include list. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
HT support for keys with two uint64_t Add the support in the hashtable abstraction layer to handle a key composed of a two uint64_t. The hash function is a simple XOR between the two hashes and the compare function resolves the eventual collisions by comparing the two values. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
Move metadata creation into lttng-sessiond and lttng-consumed The metadata is completely generated in the session daemon and pushed to the consumer which writes the full string to a ustctl channel object. On each event/channel notification from the tracer, the metadata is generated on the spot and kept in the UST registry of the session daemon. On stop and destroy command, the metadata is pushed to the consumer. On application unregistration as well, the metadata is handled. Needs to be use in locked-step with LTTng-UST: "Move metadata creation into lttng-sessiond and lttng-consumed" Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
Set hidden visibility for calls used in lttng-ctl The liblttng-ctl had multiple dynamic symbols that are only used inside the lttng-tools code tree and should not be exposed to the user. This commit sets every function calls found with "objdump -T" with a hidden visibility attribute. The strpbrk_or_eos() is set static and the struct net_families as well so we don't export those two symbols. At this stage there is still the filter_* calls that need to be fixed. Signed-off-by: David Goulet <dgoulet@efficios.com>
License header fixes Most of the source files had the wrong FSF address. Also reworded the first paragraph so that licensecheck's regexes actually pick up the version number. I made sure lttng.h and lttng-ctl.c advertise LGPL-2.1. Every other file touched in this patch was and remains under GPL2, please make sure this is correct. (Some files related to the RCU hashtable are under LGPL-2.1+, but their headers were already clean). (closes #155) Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir@gmail.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
Revert FreeBSD compatibility layer Move those commits to the compat-freebsd branch instead of master branch which is currently between release canditate and stable and this compat layer will NOT go into 2.0-stable. Revert "Fix rest of the code to support compat layer" This reverts commit a440509044c2828bf6dbfb05e8d9d6d0277ce1a4. Revert "Fix consumer to handle compat layer" This reverts commit fbb2c21aac1386b7752f6254b2bd0bf001fa0ac1. Revert "Multiple fix for FreeBSD compat layer" This reverts commit bcc5eeb02fcad910c4de961b040351dad31b6f9f. Revert "Add multiple FreeBSD compat layer" This reverts commit d50813007e79158828e8ee6e1b5444950bc90847. Revert "Add FreeBSD compat layer for splice and sync_file_range" This reverts commit 826a02a292d2bd409be87ea96ba2fccbccee76b1. Revert "Support XSI strerror_r in error.h" This reverts commit e672cc585c3d67ee80278e29b538a3aed65df825. Revert "Add FreeBSD compat layer for socket.h" This reverts commit ef50a575de02a28aa158d7ba34b3d20ea329751a. Revert "Fix FreeBSD support for rculfhash mmap" This reverts commit e21193ea4abf7d93112b8ad3144ba11484d623c6. Revert "Add FreeBSD compat layer for endian.h" This reverts commit ae9d96fe577c198df432102cde69a28e82cccc1b. Signed-off-by: David Goulet <dgoulet@efficios.com>
Complete change of the source directory tree For the sake of clearness and awesomeness :P, this change was needed for better semantic across the code and better organization of source files. src/ --> Contains source files of the project bin/ --> Contains every binaries this git tree builds (lttng, lttng-sessiond and lttng-consumerd). lib/ --> Contains exported libraries (lttng-ctl). common/ --> Contains shared code for the entire project. (internal libraries mostly) Every internal headers are moved from include/ to src/common. The include directory only contains exported public headers now (lttng/lttng.h). The -I$(top_srcdir)/src is also added for all Makefiles. The consumerd APIs are not exported anymore. The reason is that the consumer will get completely re-engineered in the next months. It's our safety net for the APIs breakage of the coming year concerning the consumerd library. Renaming is done also on some internal libraries to follow the naming convention. The public library liblttngctl is renamed to liblttng-ctl making it linkable now with "-llttng-ctl" deprecating the old "-llttngctl". No code is changed with this commit except #include statements added/removed/renamed. This is why there is yet files and internal API calls that does not follow the naming convention (Ex: lttngerr.h, lttng-share.h in src/common). Signed-off-by: David Goulet <dgoulet@efficios.com>