SoW-2019-0002: Dynamic Snapshot Revision 1
Clean-up: remove instances of loop initial declarations Loop initial declarations are not permitted by the project's coding standard and cause the build to fail on Solaris platforms. tracker.c: In function 'lttng_tracker_ids_serialize': tracker.c:314:2: error: 'for' loop initial declarations are only allowed in C99 mode for (unsigned int i = 0; i < count; i++) { ^ Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I627974ef82ca26586c96d354f217f9943db9d67c
tests: 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: I89cd4b4b7440f71f52426a5508252932bb46e796 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
fd-tracker: restore suspended handles from their inode's path In order to support session rotations and, to a lesser degree, the "clear" command, the fd-tracker internals (lttng_inode and fs_handle) need to recover from files being renamed while the handle to it is suspended. This refactor introduces a "location" to the lttng_inode which is updated anytime an unlink or rename is performed on an fs_handle. Keep in mind that multiple independent fs_handles can refer to the same lttng_inode (a unique tuple of device id and inode number). This location is used to restore the fs_handle whenever it is needed. Moreover, since the session rotation/clear operations sometimes rely on directories having been emptied after rename/unlink, the current scheme of renaming unlinked files to the form "filename-deleted-suffix" no longer works. The renaming scheme is replaced by a new "unlinked file pool", which is an hidden directory at the base of the output directory which contains the files which were unlinked to which references (fs_handles) are still being held. The API of the fd-tracker itself had to be changed slightly and the tests are adapted as a consequence. New tests targeting this new behaviour are also added. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9b1344da1966c85bdd6b51838507d3208e1d9a42
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>
Fix: build failures when `--without-lttng-ust` The `--without-lttng-ust` configure option makes the build to fail due to 2 bugs 1. Missing object file for session unit tests causes the following errors: CCLD test_session ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_track_id': /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:712: undefined reference to `lttng_tracker_id_lookup_string' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:723: undefined reference to `lttng_tracker_id_get_list' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:729: undefined reference to `lttng_tracker_list_add' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:810: undefined reference to `lttng_tracker_id_set_list' ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_untrack_id': /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:826: undefined reference to `lttng_tracker_id_lookup_string' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:836: undefined reference to `lttng_tracker_id_get_list' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:841: undefined reference to `lttng_tracker_list_remove' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:925: undefined reference to `lttng_tracker_id_set_list' ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_list_tracker_ids': /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:949: undefined reference to `lttng_tracker_id_get_list' ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session': /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:167: undefined reference to `lttng_tracker_list_create' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:171: undefined reference to `lttng_tracker_list_create' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:175: undefined reference to `lttng_tracker_list_create' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:179: undefined reference to `lttng_tracker_list_create' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:183: undefined reference to `lttng_tracker_list_create' ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:187: more undefined references to `lttng_tracker_list_create' follow ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session': /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:199: undefined reference to `lttng_tracker_list_destroy' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:200: undefined reference to `lttng_tracker_list_destroy' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:201: undefined reference to `lttng_tracker_list_destroy' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:202: undefined reference to `lttng_tracker_list_destroy' /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:203: undefined reference to `lttng_tracker_list_destroy' ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:204: more undefined references to `lttng_tracker_list_destroy' follow collect2: error: ld returned 1 exit status Makefile:1062: recipe for target 'test_session' failed make[1]: *** [test_session] Error 1 make[1]: Leaving directory '/home/frdeso/projets/lttng/tools/tests/unit' Makefile:1166: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 2. An extra colon at the end of the `trace_ust_track_id()` stub function gives this error: CC utils.o In file included from ust-app.h:26:0, from lttng-sessiond.h:31, from utils.c:27: trace-ust.h:339:1: error: expected identifier or '(' before '{' token { ^ trace-ust.h:336:19: warning: 'trace_ust_track_id' declared 'static' but never defined [-Wunused-function] static inline int trace_ust_track_id(enum lttng_tracker_type tracker_type, ^~~~~~~~~~~~~~~~~~ Makefile:729: recipe for target 'utils.o' failed Both bugs are trivial to fix. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Change-Id: I66c57d206ad0142db057443374d28bbcf16c02f7 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Make lttng_directory_handle reference countable Currently, the lttng_directory_handle API assumes that the caller has exclusive ownership of the lttng_directory_handle. Directory handles are passed by reference and populated by an "init" method and finalized using the "fini" method. In order to allow multiple references to a path or directory file descriptor in follow-up patches, the API is moved to a model where directory handles are dynamically allocated and released using the "put" method. No change in behaviour is intended by this change beyond adapting the API. The objective of the change is to make it easier to implement copy operations of trace chunks that are configured to use an fd-tracker and reduce the number of open file descriptors when lttng_directory_handles are copied. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ibc8e97ea9e949adafef44533c30b61e3a9fa1f7d
tests: make functions static in test_notification.c Fixes: CC test_notification.o /home/smarchi/src/lttng-tools/tests/unit/test_notification.c:50:6: error: no previous declaration for ‘test_condition_buffer_usage’ [-Werror=missing-declarations] void test_condition_buffer_usage(struct lttng_condition *buffer_usage_condition) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_notification.c:265:6: error: no previous declaration for ‘test_condition_buffer_usage_low’ [-Werror=missing-declarations] void test_condition_buffer_usage_low(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_notification.c:280:6: error: no previous declaration for ‘test_condition_buffer_usage_high’ [-Werror=missing-declarations] void test_condition_buffer_usage_high(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_notification.c:295:6: error: no previous declaration for ‘test_action’ [-Werror=missing-declarations] void test_action(void) ^~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_notification.c:305:6: error: no previous declaration for ‘test_trigger’ [-Werror=missing-declarations] void test_trigger(void) ^~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: I4df29ec42436798005e740d5b6fb34973ea22350 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: make functions static in test_utils_compat_poll.c Fixes: CC test_utils_compat_poll.o /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:74:6: error: no previous declaration for ‘test_alloc’ [-Werror=missing-declarations] void test_alloc(void) ^~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:95:6: error: no previous declaration for ‘test_add_del’ [-Werror=missing-declarations] void test_add_del(void) ^~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:133:6: error: no previous declaration for ‘test_mod_wait’ [-Werror=missing-declarations] void test_mod_wait(void) ^~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_compat_poll.c:189:6: error: no previous declaration for ‘test_func_def’ [-Werror=missing-declarations] void test_func_def(void) ^~~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: I1feeed8ee3f76783e22ffedd5292a06deee3e233 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: make functions static in test_utils_expand_path.c Fixes: CC test_utils_expand_path.o /home/smarchi/src/lttng-tools/tests/unit/test_utils_expand_path.c:126:5: error: no previous declaration for ‘prepare_valid_results’ [-Werror=missing-declarations] int prepare_valid_results(void) ^~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_expand_path.c:182:5: error: no previous declaration for ‘free_valid_results’ [-Werror=missing-declarations] int free_valid_results(void) ^~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_expand_path.c:195:5: error: no previous declaration for ‘prepare_symlink_tree’ [-Werror=missing-declarations] int prepare_symlink_tree(void) ^~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_utils_expand_path.c:235:5: error: no previous declaration for ‘free_symlink_tree’ [-Werror=missing-declarations] int free_symlink_tree(void) ^~~~~~~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: I220a2f8dadb355adb4fb974a2f3a0e161b0618e6 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: make functions static in test_session.c Fixes: CC test_session.o /home/smarchi/src/lttng-tools/tests/unit/test_session.c:219:6: error: no previous declaration for ‘test_session_list’ [-Werror=missing-declarations] void test_session_list(void) ^~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:225:6: error: no previous declaration for ‘test_create_one_session’ [-Werror=missing-declarations] void test_create_one_session(void) ^~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:232:6: error: no previous declaration for ‘test_validate_session’ [-Werror=missing-declarations] void test_validate_session(void) ^~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:258:6: error: no previous declaration for ‘test_destroy_session’ [-Werror=missing-declarations] void test_destroy_session(void) ^~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:278:6: error: no previous declaration for ‘test_duplicate_session’ [-Werror=missing-declarations] void test_duplicate_session(void) ^~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:284:6: error: no previous declaration for ‘test_session_name_generation’ [-Werror=missing-declarations] void test_session_name_generation(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_session.c:309:6: error: no previous declaration for ‘test_large_session_number’ [-Werror=missing-declarations] void test_large_session_number(void) ^~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: Ib1f6a004e6feb4693c4331a8b0ce67ee1697703c Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: make functions static in test_uri.c Fixes: CC test_uri.o /home/smarchi/src/lttng-tools/tests/unit/test_uri.c:33:6: error: no previous declaration for ‘test_uri_parsing’ [-Werror=missing-declarations] void test_uri_parsing(void) ^~~~~~~~~~~~~~~~ /home/smarchi/src/lttng-tools/tests/unit/test_uri.c:201:6: error: no previous declaration for ‘test_uri_cmp’ [-Werror=missing-declarations] void test_uri_cmp() ^~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: Ia0d7b08a10ec9f8d3f6f2d5b4fa9c4f417827024 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: make entry_handler static in ini_config test Fixes: CC ini_config.o /home/smarchi/src/lttng-tools/tests/unit/ini_config/ini_config.c:37:5: error: no previous declaration for ‘entry_handler’ [-Werror=missing-declarations] int entry_handler(const struct config_entry *entry, ^~~~~~~~~~~~~ Change-Id: I937fda691d5ab81bf7567ab50fd90903911dfc57 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Replace libuuid with internal implementation We use a very small subset of libuuid features to transform UUIDs between their string and binary representation. Plus we have a lot of compat code for different platforms with some unspecified default behavior regarding the use of upper/lower case. Drop the dependency on libuuid and replace it with a minimal internal implementation that respects RFC4122. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I744e3cf65d6a22d0acf7a9943c10943ba64e8468 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Silence bogus warning when building with old GCC versions gcc version 7.4.0 (and possibly others) warn that `new_handle` may be used uninitialized. It is not clear what code path would trigger this uninitialized use. Moreover, the warning is not present when building with recent versions of gcc and clang, nor is it flagged by Coverity. This points to the warning being bogus. Still, setting `new_handle` to NULL silences the warning on this gcc version. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Clean-up: tests: unchecked closedir value in test_fd_tracker closedir's return value is not checked in a utility function of the test_fd_tracker unit test. 1407702 Unchecked return value If the function returns an error value, the error value may be mistaken for a normal value. In fd_count: Value returned from a function is not checked for errors before being used (CWE-252) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>