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
common: compile libcompat as C++ I got errors like these for programs that use libcompat (usually through libcommon), but are still linked with gcc, rather than g++: CCLD filter-grammar-test /usr/bin/ld: ./.libs/libcommon.a(directory-handle.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `_ _gxx_personality_v0' Automake still links them with gcc, because they don't contain any C++ source directly. Fix that by changing them to be C++ source. Change-Id: I3eeca3d9af8940795b69f48d306f282ae0b08589 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bin: compile lttng-relayd as a C++ Same as the previous commit, but change lttng-relayd to be a C++ program. In addition to what was mentioned in previous commits: - Test test_relayd_backward_compat_group_by_session uses an object file from the relayd binary, so it's simpler to change this test to be C++ as well. - There are some declarations related to fs_handle in fd-tracker.h. Remove them, as they are already in fs-handle.h. Change-Id: I72c5fdecd2e82c30633563a47bd641af1dcfa29c Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bin: compile lttng-sessiond as C++ Same as commit 48a400056134 ("bin: compile lttng as C++"), but change lttng-sessiond to be a C++ program. In addition to the categories of changes already mentioned in that commit's message, here are some interesting changes: - Add an include in trigger.h, an exported header, to fix: CXX notification-thread.lo In file included from /home/simark/src/lttng-tools/src/bin/lttng-sessiond/notification-thread.cpp:9: /home/simark/src/lttng-tools/include/lttng/trigger/trigger.h:142:13: error: use of enum ‘lttng_error_code’ without previous declaration 142 | extern enum lttng_error_code lttng_register_trigger_with_name( | ^~~~~~~~~~~~~~~~ - We get this with clang: CXX lttng-conf.o In file included from /home/simark/src/lttng-tools/src/bin/lttng/conf.cpp:18: In file included from /home/simark/src/lttng-tools/src/common/common.h:14: In file included from /home/simark/src/lttng-tools/src/common/runas.h:17: In file included from /home/simark/src/lttng-tools/src/common/sessiond-comm/sessiond-comm.h:38: In file included from /home/simark/src/lttng-tools/src/common/unix.h:17: /home/simark/src/lttng-tools/src/common/payload-view.h:82:27: error: 'lttng_payload_view_from_payload' has C-linkage specified, but returns user-defined type 'struct lttng_payload_view' which is incompatible with C [-Werror,-Wreturn-type-c-linkage] struct lttng_payload_view lttng_payload_view_from_payload( ^ Turns out that because of the "const" field in lttng_payload_view, clang doesn't consider that type incompatible with C. I don't really want to remove the "const" for C code using that API, so conditionally remove it if we are compiling with clang in C++. - clang gives: CXX event.lo In file included from /home/simark/src/lttng-tools/src/bin/lttng-sessiond/event.cpp:19: /home/simark/src/lttng-tools/src/common/bytecode/bytecode.h:50:1: error: struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] struct literal_string { ^ It looks like that type isn't even used? Remove it. - it's not possible to initialize some union members, for example with lttcomm_consumer_msg, in consumer.cpp. Initialize it in a separate statement. - It's not possible to use the transparent union trick when calling urcu function, for example in thread_application_registration, in register.cpp. We need to instantiate a cds_wfcq_head_ptr_t object, assign the appropriate field, and pass that object to the function. - the ALIGNED_CONST_PTR trick does not work in C++: CXX consumer.lo In file included from /home/simark/src/lttng-tools/src/common/error.h:19, from /home/simark/src/lttng-tools/src/common/common.h:12, from /home/simark/src/lttng-tools/src/bin/lttng-sessiond/consumer.cpp:19: /home/simark/src/lttng-tools/src/bin/lttng-sessiond/consumer.cpp: In function ‘int consumer_send_relayd_socket(consumer_socket*, lttcomm_relayd_sock*, consumer_output*, lttng_stream_type, uint64_t, const char*, const char*, const char*, int, const uint64_t*, time_t, bool)’: /home/simark/src/lttng-tools/src/common/macros.h:116:58: error: expected primary-expression before ‘]’ token 116 | #define ALIGNED_CONST_PTR(value) (((const typeof(value) []) { value })) | ^ /home/simark/src/lttng-tools/src/bin/lttng-sessiond/consumer.cpp:1192:48: note: in expansion of macro ‘ALIGNED_CONST_PTR’ 1192 | ret = consumer_send_fds(consumer_sock, ALIGNED_CONST_PTR(rsock->sock.fd), 1); | ^~~~~~~~~~~~~~~~~ Replace uses with copying the data in a local variable (which is properly aligned), and pass the address to that variable to the function. - In consumer.h, an array field in a structure is defined using the max macro. It can't be replaced with std::max, since std::max isn't constexpr in C++11. Define a max_constexpr function locally and use it. - g++ 7 doesn't support non-trivial designated initializers, leading to errors like: CXX globals.lo /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/globals.cpp:44:1: sorry, unimplemented: non-trivial designated initializers not supported }; ^ Change consumer_data to have a constructor instead. Change initializations of some structures, such as lttcomm_lttng_msg, to initialize the fields separate from the variable declaration. This requires making these variable non-const which is not ideal. But once everything is C++, these types could get a fancy constructor, and then they can be made const again. - When compiling without UST support the stub versions of functions ust_app_rotate_session & co, in ust-app.h, are used. Some of them have the return type "enum lttng_error_code", but return 0, an invalid value, causing: CXX main.o In file included from /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/lttng-sessiond.h:22:0, from /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/main.cpp:45: /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/ust-app.h: In function ‘lttng_error_code ust_app_snapshot_record(ltt_ust_session*, const consumer_output*, int, uint64_t)’: /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/ust-app.h:575:9: error: invalid conversion from ‘int’ to ‘lttng_error_code’ [-fpermissive] return 0; ^ Change these functions to return LTTNG_ERR_UNK. These functions are not supposed to be called if UST support is not included. But even if they were: all their callers check that the return value is not LTTNG_OK. The value 0 would be considered an error, so will be LTTNG_ERR_UNK. Change-Id: I2cdd34459a54b1943087b43843ef20b35b7bf7d8 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
build: Use liblttng-sessiond-common.la instead of SESSIOND_OBJS This allows correctly linking test_session and test_ust_data with slibtool. Signed-off-by: orbea <orbea@riseup.net> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I5c18187e4185218db337ac3548f0d44fb60501f3
build: Add the liblttng-sessiond-comm.la convenience library This allows correctly linking test_kernel_data with slibtool. Signed-off-by: orbea <orbea@riseup.net> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib076854dc2a4f0234ad3fb04ea1c3c7c4d4a2b7e
tests: Move tap-driver.sh out of the autotools aux directory We have made local modifications to this script, move it to the test suite directory so it doesn't get overwritten by an updated version from autotools. Running 'make check' on current RHEL or Fedora without this patch results in the following error: make[5]: Entering directory '/builddir/build/BUILD/lttng-tools-2.12.4/tests/regression' tap-driver.sh: invalid option: '--post-script' Change-Id: I22823176cc5b98901865c9415250ce8e49384cbd Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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
Rename firing policy to rate policy This is necessary since that now that the policy is moved to the actions it is a bit weird to use the term "firing". CLI change is done in a later patch. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Id6940a49cd0640a8fa7145dab5b805fcfa515f40
Move test_action to its own file Further unit testing on action objects will be conducted in the test_action.c file. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib17aed9eb02592d5c13bc2875d4203b81ab04cf3
Cleanup: Move `create_posix_shm()` to common/shm.c * This function will be used for trigger error accounting. * This function is renamed to `shm_create_anonymous()` and now takes one parameter for the owner of the shared memory area. Again this is code reuse. * Remove erroneous comment about the `name` parameter for the `shm_open()` function. It's the absence (and not its presence) of the '/' at the beginning of the name that makes the behaviour implementation defined. * Move the bin/lttng-sessiond/shm.c to common/shm.c so that all shm related functions are in one location. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I690b38801ffb4772e7c5069c4cccf470b0671f63
lttng-ctl: Introduce lttng_log_level_rule This object corresponds to the criteria a event-rule tracepoint must respect for an event to be consired under the event-rule tracepoint criteria. The lttng tracepoint event rule object now have the following API function in regards to log level rule: lttng_event_rule_tracepoint_set_log_level_rule lttng_event_rule_tracepoint_get_log_level_rule Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Iefd361d1b7d85c6803e891166429a2830e2404a2