sessiond: lttng: Add command to check kernel tracer status Issue observed -------------- When `lttng enable-channel --kernel` fails, little feedback is available to user to help them to understand the cause. Eg. ``` Error: Channel asdf: Kernel tracer not available (session auto-20231123-092621) ``` Solution -------- The semantic status of the kernel tracer is tracked and persisted in the session daemon (through `init_kernel_tracer` and `cleanup_tracer_tracer`. A new client command `lttng_kernel_tracer_status` is added to request the current value of the `kernel_tracer_status`. The `lttng` client uses this command after enabling a kernel-domain channel fails to provide the user with a more specific cause of the failure. Eg. ``` Error: Channel asdf: Kernel tracer not available (session auto-20231123-092621) Missing one or more required kernel modules Consult lttng-sessiond logs for more information ``` The kernel tracer status is tracked with an enum defined in `include/lttng/kernel.h` to avoid passing potentially different errno values or locale-dependant strings between the LTTng client and session daemon. Loading modules and checking signatures can fail with a number of different errno values. For example: C.f. https://gitlab.com/linux-kernel/stable/-/blob/master/kernel/module/signing.c#L70 * `EKEYREJECTED` * Any other error code C.f. https://gitlab.com/linux-kernel/stable/-/blob/master/Documentation/security/keys/core.rst * `EKEYREVOKED` * `EKEYEXPIRED` * `ENOKEY` * Others, such as `ENOMEM` Known drawbacks --------------- None. Signed-off-by: Kienan Stewart <kstewart@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I2ae4b188f0110a472200c2511439b9e3e600527d
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>
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>
Build fix: Missing message in LTTNG_DEPRECATED invocation Coverity scan build jobs fail since LTTNG_DEPRECATED expects a string and none is provided at the lttng_metadata_regenerate use site. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I7e6701abd24c679f578b0adead771ac93b6566cd
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>
Remove lttng_event_rule_tracepoint lttng_event_rule_tracepoint is "exploded" in: lttng_event_rule_user_tracepoint lttng_event_rule_kernel_tracepoint lttng_event_rule_jul_logging lttng_event_rule_python_logging lttng_event_rule_log4j_logging On the CLI front, the `--domain` option for the add-trigger is removed since for each event rule type the domain is implicit based on the type. `--type` accepts the following: kernel kernel:tracepoint kernel:kprobe kernel:uprobe syscall syscall:entry syscall:exit syscall:entry+exit syscall:* kernel:syscall kernel:syscall:entry kernel:syscall:exit kernel:syscall:entry+exit kernel:syscall:* user user:tracepoint python python:logging jul jul:logging log4j log4j:logging kprobe function Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I4a0489f8f2a79a2c967f5d69461bed10f40b8278
Introduce lttng_event_rule_python_logging A following patch will remove lttng_event_rule_tracepoint. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I222bd4f2616efd1b0c0e36cfe5a89cf5416b6a88
Introduce lttng_event_rule_log4j_logging A following patch will remove lttng_event_rule_tracepoint. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ie94c172ed9550dd7c3ae9967e353a3d6ac5b5907
Introduce lttng_event_rule_jul_logging A following patch will remove lttng_event_rule_tracepoint. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I95f40920b73b5deb42c2e92ad50c43dba0b0e436
Introduce lttng_event_rule_user_tracepoint A following patch will remove lttng_event_rule_tracepoint. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: If814c3ba828e4869cde9af4b9d76c8b830f30654
Introduce lttng_event_rule_kernel_tracepoint A following patch will remove lttng_event_rule_tracepoint. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I614e45be3ef5e41fa081ad24dc1a9dcddb7eb2af
Rename lttng_event_rule_kernel_probe to lttng_event_rule_kernel_kprobe The add trigger command now accepts `kernel:kprobe` instead of `kernel- probe`. `kprobe` is still accepted. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ifd6753f337e93ea8eb393b8d686596112292c5bb
Rename lttng_event_rule_userspace_probe to lttng_event_rule_kernel_uprobe The `--type` option for add trigger now only support `kernel:uprobe`. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I2c4de8e314d6fba735343d21c04fff366b92cca9
Rename lttng_event_rule_syscall to lttng_event_rule_kernel_syscall Allow the usage of "kernel:syscall*" as the `--type` argument for add trigger. A later patch remove the notion of domain. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib5c87ec937bb0acf9c5133532961dcc31e533884