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>
Remove extern "C" from internal headers All internal code is now compiled as C++, we can now remove all 'extern "C"' declarations from internal headers. This means files will see each other's declarations as C++, and we can now use things in headers. Remove the min/min_t/max/max_t macros from macros.h as well. Change-Id: I5a6b7ef60be5f46160c6d5ca39f082d2137d5a07 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bin: compile lttng as C++ Compile the code of the lttng binary as C++ source. - start by renaming all files under src/bin/lttng to have the .cpp extension, adjust Makefile.am accordingly - apply the sophisticated algorithm: while does_not_build(): fix_error() until completion Fixes fall in these categories: - add extern "C" to headers of functions implemented in C. This is likely temporary: at some point some of these things will be implemented in C++, at which point we'll remove the extern "C". - rename mi_lttng_version to mi_lttng_version_data, to avoid a -Wshadow warning about the mi_lttng_version function hiding the mi_lttng_version's struct constructor - we have the same warning about lttng_calibrate, but we can't rename it, it's exposed in a public header. Add some pragmas to disable the warning around there. We will need more macro smartness in case we need to support a compiler that doesn't understand these pragmas. - in filter-ast.h, add a dummy field to the empty struct, to avoid a -Wextern-c-compat warning with clang++ (it warns us that the struct has size 0 in C but size 1 in C++). - in add_context.cpp, we can't initialize ctx_opts' union field like we did in C. Fix that by adding a ctx_opts constructor for each kind of context and implement the PERF_* macros to use them. - need to explicitly cast void pointer to type of the destination, for example the eturn value of allocation functions, or parameter of "destroy" functions - need to explicitly cast when passing an int to an enum parameter, for example an lttng_error_code parameter - remove use of designated array initializers, for example for schedule_type_str in disable_rotation.cpp - fix order of struct initializers to match order of field declarations, for example in list_triggers.cpp, function cmd_list_triggers - rename some things to avoid clashing with keywords, for example in runas.h Change-Id: Id743b141552a412b4104af4dda8969eef5032388 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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>
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>
relayd: introduce --group-output-by-session LTTng-relayd now support the grouping of traces per session. This mode can be used via the "--group-output-per-session" switch. The default, and current way, of grouping is done around the host (hostname) of the traced system. When grouped by host the following folder hierarchy is mostly found on the filesystem: <hostname>/<session_name>-<datetime>/<trace> When using "--group-output-per-session", the following hierarchy is found on the filesystem: <session_name>/<hostname>-<datetime>/<trace> We also need to support base path information that come from the URIs set at the client level: lttng create --set-url=net://localhost/extra/path/information When grouping by host (current behaviour), it result in the following hierarchy: <hostname>/<base_path>/<trace> e.g: <hostname>/extra/path/information/<trace> We want to part from this way of handling the base path since it can lead to unexpected conflict between session. When grouping by session using a base path, the following hierarchy is produced: <session_name>/<hostname>-<datetime>/<base_path>/<trace> e.g: <session_name>/<hostname>-<datetime>/extra/path/information/<trace> We encourage user to move away from using base path entirely as it bypasses introduces potential name clashes and completely bypasses the relay daemon's storage policy. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: time constants already defined on macOS Include the compatibility time.h header in the common/time.h to override any platform-defined constants. It seems that the NSEC_PER_SEC (and other similar definitions) are defined to nothing on macOS. This was already fixed in the compatibility header in the past. This also adds USEC_PER_SEC to the list of undef-initions on macOS. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Add a time_to_iso8601_str() utility time_to_iso8601_str() formats a Unix timestamp to an ISO 8601 compatible string. For now, the only ISO 8601 time format used in LTTng-tools is the "YYYYmmddTHHMMSS+HHMM" form used by the session rotation feature. Since ISO 8601 allows many formats, this functions may need to be renamed at some point. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: hide internal libcommon time utilities libcommon's time-handling utilities are used by liblttng-ctl. Like other symbols of libcommon, they must be marked as hidden to prevent them from being exported as part of the liblttng-ctl interface. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Support minute and hour as time suffixes utils_parse_time_suffix now support the following suffix: "us" for microsecond, "ms" for millisecond, "s" for second, "m" for minute, "h" for hour This removes the use of "m" for milliseconds and "u" for microseconds. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: Connect timeout arithmetic in inet/inet6 (v4) The nanoseconds part of the timespec struct time_a is not always bigger than time_b since it wraps around each second. Use 64-bit arithmetic to compute the difference. Merge/move duplicated code into utils.c. This function is really doing two things. Split it into timespec_to_ms() and timespec_abs_diff(). Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>