From c160a3a4602bb9dd18d49148876bda6783d8acda 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 ee9312704..cba349e63 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -630,6 +630,16 @@ static int enable_events(char *session_name) WARN("Kernel events already enabled (channel %s, session %s)", print_channel_name(channel_name), session_name); 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), @@ -703,6 +713,16 @@ static int enable_events(char *session_name) " (channel %s, session %s)", print_channel_name(channel_name), session_name); 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(ret), @@ -879,6 +899,17 @@ static int enable_events(char *session_name) exclusion_string, print_channel_name(channel_name), session_name); 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, @@ -915,6 +946,17 @@ static int enable_events(char *session_name) exclusion_string, print_channel_name(channel_name), session_name); 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 53b55b93f..3e445dab1 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -84,8 +84,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