From 45d5d421f3464b541315509ecc2295be81b7139d Mon Sep 17 00:00:00 2001 From: Christian Babeux Date: Fri, 7 Nov 2014 18:18:43 -0500 Subject: [PATCH] Fix: Warn the user when enabling an event in a new domain MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch warn the user when trying to enable an event in a new domain that was not configured prior to the tracing start. Fixes #826 Signed-off-by: Christian Babeux Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/enable_events.c | 42 ++++++++++++++++++++++++++ src/common/error.c | 4 +-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 84bdb83c8..c4da3dfb6 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -798,6 +798,16 @@ static int enable_events(char *session_name) print_channel_name(channel_name), session_name); warn = 1; break; + case LTTNG_ERR_TRACE_ALREADY_STARTED: + { + const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once."; + ERR("Events: %s (channel %s, session %s)", + msg, + print_channel_name(channel_name), + session_name); + error = 1; + break; + } default: ERR("Events: %s (channel %s, session %s)", lttng_strerror(ret), @@ -875,6 +885,16 @@ static int enable_events(char *session_name) print_channel_name(channel_name), session_name); warn = 1; break; + case LTTNG_ERR_TRACE_ALREADY_STARTED: + { + const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once."; + ERR("All events: %s (channel %s, session %s, filter \'%s\')", + msg, + print_channel_name(channel_name), + session_name, opt_filter); + error = 1; + break; + } default: ERR("All events: %s (channel %s, session %s, filter \'%s\')", lttng_strerror(command_ret), @@ -1114,6 +1134,17 @@ static int enable_events(char *session_name) print_channel_name(channel_name), session_name); warn = 1; break; + case LTTNG_ERR_TRACE_ALREADY_STARTED: + { + const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once."; + ERR("Event %s%s: %s (channel %s, session %s)", event_name, + exclusion_string, + msg, + print_channel_name(channel_name), + session_name); + error = 1; + break; + } default: ERR("Event %s%s: %s (channel %s, session %s)", event_name, exclusion_string, @@ -1163,6 +1194,17 @@ static int enable_events(char *session_name) print_channel_name(channel_name), session_name); warn = 1; break; + case LTTNG_ERR_TRACE_ALREADY_STARTED: + { + const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once."; + ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev.name, + exclusion_string, + msg, + print_channel_name(channel_name), + session_name, opt_filter); + error = 1; + break; + } default: ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev.name, exclusion_string, diff --git a/src/common/error.c b/src/common/error.c index 577070e7a..852de6fb4 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -122,8 +122,8 @@ static const char *error_string_array[] = { [ ERROR_INDEX(LTTNG_ERR_UST_CONTEXT_INVAL)] = "UST invalid context", [ ERROR_INDEX(LTTNG_ERR_NEED_ROOT_SESSIOND) ] = "Tracing the kernel requires a root lttng-sessiond daemon, as well as \"tracing\" group membership or root user ID for the lttng client.", [ ERROR_INDEX(LTTNG_ERR_NO_UST) ] = "LTTng-UST tracer is not supported. Please rebuild lttng-tools with lttng-ust support enabled.", - [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STARTED) ] = "Tracing already started", - [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped", + [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STARTED) ] = "Tracing has already been started once", + [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STOPPED) ] = "Tracing has already been stopped", [ ERROR_INDEX(LTTNG_ERR_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported", [ ERROR_INDEX(LTTNG_ERR_NEED_CHANNEL_NAME) ] = "Non-default channel exists within session: channel name needs to be specified with '-c name'", [ ERROR_INDEX(LTTNG_ERR_INVALID) ] = "Invalid parameter", -- 2.34.1