Fix: lttng-destroy: string formating error when default session is unset Using `lttng destroy` when no default session is set in .lttngrc results in the following print-out: Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc Did you create a session? (lttng create <my_session>) Error: Failed to format string: string pointer is null This is because the client attempts to format the following message: ERR_FMT("Session `{}` not found", spec.value); When no default session could be found in .lttngrc, spec.value is left at nullptr and it is assumed that the listing succeeded. A new CLI-specific exception, no_default_session_error, is added to the project and thrown when the session listing fails. This allows the calling code to mark the listing as having failed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
Revert "Fix: lttng-destroy: string formating error when default session is unset" This reverts commit e8c353ad12851366573d9bfe45d333a9e9ff742d as it is missing files (wrong revision of the change picked-up from gerrit). Change-Id: Ia426a8004d9827ee72ed39db52d7894f5d4eb34f Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: lttng-destroy: string formating error when default session is unset Using `lttng destroy` when no default session is set in .lttngrc results in the following print-out: Error: Can't find valid lttng config /root/lttng-build/home/.lttngrc Did you create a session? (lttng create <my_session>) Error: Failed to format string: string pointer is null This is because the client attempts to format the following message: ERR_FMT("Session `{}` not found", spec.value); When no default session could be found in .lttngrc, spec.value is left at nullptr and it is assumed that the listing succeeded. A new CLI-specific exception, no_default_session_error, is added to the project and thrown when the session listing fails. This allows the calling code to mark the listing as having failed. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I33b4f38a424f22dfa9d3628cf12441b59df53f12
lttng: enable-channel: move kernel tracer status check to util In order to re-use the same logic in the enable-event command, move the kernel status checking and printing to a common utility function. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I85956298c27fd7073ac02aac901d39e3d82bb280
lttng: reuse random_access_container_wrapper for session_list Reimplement lttng::cli::session_list in terms of the random_access_container_wrapper utility since the code is essentially duplicated. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I99160a54d5d2dfa7cf65a6287b271e9c2238c510
lttng: move session_list to the lttng::cli namespace This is a preliminary step to re-use the random_access_container util to replace the implementation of session_list. No behaviour change is intended by this change. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I32d0354a6985b8c6fb58813cf880ef04a10678dd
Build fix: g++ 4.8 incorrectly disambiguates enum and member g++ 4.8 fails to build with the following error: commands/start.cpp: In function ‘cmd_error_code {anonymous}::start_tracing(const session_spec&)’: commands/start.cpp:123:76: error: ‘session_spec::type’ is not a class, namespace, or enumeration if (!listing_failed && sessions.size() == 0 && spec.type == session_spec::type::NAME) { ^ commands/start.cpp:144:36: error: ‘session_spec::type’ is not a class, namespace, or enumeration if (spec.type != session_spec::type::NAME) { ^ The `type` member is renamed to type_ to workaround this compiler bug. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Id46ca4219d4d96db71a9d4523c3571303b2e97a7
lttng: Add list_sessions utility Get a list of sessions given a session specification. The `NAME' specification returns the session that has the given name. The `GLOB_PATTERN' specification returns all sessions that match a pattern. The `ALL' specification returns all sessions. Change-Id: If69698d6dd59d54ba16669571ef49ed5bb9b8997 Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Run clang-format on the whole tree Generated by running: find -not \( -path "./src/vendor*" -prune \) -iname "*.h" -o -iname "*.hpp" -o -iname "*.c" -o -iname "*.cpp" -exec clang-format -i {} \; Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9557e7d84e305187475ef88124857cf2f438bbb1
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>
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
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>