From 9cde3a4ab8b763df804f8105728d90f59521438b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 22 Mar 2024 10:51:20 -0400 Subject: [PATCH] Revert "Fix: lttng-destroy: string formating error when default session is unset" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng/Makefile.am | 3 +-- src/bin/lttng/commands/destroy.cpp | 9 --------- src/bin/lttng/commands/start.cpp | 9 --------- src/bin/lttng/commands/stop.cpp | 9 --------- src/bin/lttng/utils.cpp | 14 +++++++------- src/common/exception.hpp | 2 +- 6 files changed, 9 insertions(+), 37 deletions(-) diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am index e37183746..09c5171d8 100644 --- a/src/bin/lttng/Makefile.am +++ b/src/bin/lttng/Makefile.am @@ -34,8 +34,7 @@ lttng_SOURCES = command.hpp conf.cpp conf.hpp commands/start.cpp \ commands/list_triggers.cpp \ commands/remove_trigger.cpp \ utils.cpp utils.hpp lttng.cpp \ - uprobe.cpp uprobe.hpp \ - exception.hpp exception.cpp + uprobe.cpp uprobe.hpp lttng_CXXFLAGS = $(AM_CXXFLAGS) $(POPT_CFLAGS) diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index ef4b914d3..5e19d4189 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -7,7 +7,6 @@ #define _LGPL_SOURCE #include "../command.hpp" -#include "../exception.hpp" #include #include @@ -273,14 +272,6 @@ cmd_error_code destroy_sessions(const lttng::cli::session_spec& spec) lttng_strerror(-ctl_exception.code())); listing_failed = true; return {}; - } catch (const lttng::cli::no_default_session_error& cli_exception) { - /* - * The retrieval of the default session name already logs - * an error when it fails. There is no value in printing - * anything about this exception. - */ - listing_failed = true; - return {}; } }(); diff --git a/src/bin/lttng/commands/start.cpp b/src/bin/lttng/commands/start.cpp index f00ce973e..f78d3e708 100644 --- a/src/bin/lttng/commands/start.cpp +++ b/src/bin/lttng/commands/start.cpp @@ -7,7 +7,6 @@ #define _LGPL_SOURCE #include "../command.hpp" -#include "../exception.hpp" #include "../utils.hpp" #include @@ -118,14 +117,6 @@ cmd_error_code start_tracing(const lttng::cli::session_spec& spec) lttng_strerror(-ctl_exception.code())); listing_failed = true; return {}; - } catch (const lttng::cli::no_default_session_error& cli_exception) { - /* - * The retrieval of the default session name already logs - * an error when it fails. There is no value in printing - * anything about this exception. - */ - listing_failed = true; - return {}; } }(); diff --git a/src/bin/lttng/commands/stop.cpp b/src/bin/lttng/commands/stop.cpp index 9d5533a21..af42d98db 100644 --- a/src/bin/lttng/commands/stop.cpp +++ b/src/bin/lttng/commands/stop.cpp @@ -7,7 +7,6 @@ #define _LGPL_SOURCE #include "../command.hpp" -#include "../exception.hpp" #include "../utils.hpp" #include @@ -147,14 +146,6 @@ cmd_error_code stop_tracing(const lttng::cli::session_spec& spec) lttng_strerror(-ctl_exception.code())); listing_failed = true; return {}; - } catch (const lttng::cli::no_default_session_error& cli_exception) { - /* - * The retrieval of the default session name already logs - * an error when it fails. There is no value in printing - * anything about this exception. - */ - listing_failed = true; - return {}; } }(); diff --git a/src/bin/lttng/utils.cpp b/src/bin/lttng/utils.cpp index 45fe256a5..403ee0185 100644 --- a/src/bin/lttng/utils.cpp +++ b/src/bin/lttng/utils.cpp @@ -8,7 +8,6 @@ #define _LGPL_SOURCE #include "command.hpp" #include "conf.hpp" -#include "exception.hpp" #include "utils.hpp" #include @@ -716,14 +715,15 @@ lttng::cli::session_list lttng::cli::list_sessions(const struct session_spec& sp lttng::make_unique_wrapper( get_session_name()); - if (!configured_name) { - LTTNG_THROW_CLI_NO_DEFAULT_SESSION(); - } + if (configured_name) { + const struct lttng::cli::session_spec new_spec( + lttng::cli::session_spec::type::NAME, + configured_name.get()); - const struct lttng::cli::session_spec new_spec( - lttng::cli::session_spec::type::NAME, configured_name.get()); + return list_sessions(new_spec); + } - return list_sessions(new_spec); + return lttng::cli::session_list(); } return get_sessions( diff --git a/src/common/exception.hpp b/src/common/exception.hpp index 1880978e7..e43094bb6 100644 --- a/src/common/exception.hpp +++ b/src/common/exception.hpp @@ -20,7 +20,7 @@ throw lttng::posix_error(msg, errno_code, __FILE__, __func__, __LINE__) #define LTTNG_THROW_ERROR(msg) throw lttng::runtime_error(msg, __FILE__, __func__, __LINE__) #define LTTNG_THROW_UNSUPPORTED_ERROR(msg) \ - throw lttng::unsupported_error(msg, __FILE__, __func__, __LINE__) + throw lttng::runtime_error(msg, __FILE__, __func__, __LINE__) #define LTTNG_THROW_COMMUNICATION_ERROR(msg) \ throw lttng::communication_error(msg, __FILE__, __func__, __LINE__) #define LTTNG_THROW_PROTOCOL_ERROR(msg) \ -- 2.34.1