From 2f0790d05d697a9a74dd4e665d18d34edacd8213 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 22 Aug 2013 17:48:59 -0400 Subject: [PATCH] Fix: improve error message when UST support is disabled Fixes #583 Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- include/lttng/lttng-error.h | 2 +- src/bin/lttng-sessiond/main.c | 4 ++++ src/bin/lttng-sessiond/ust-app.h | 12 ++++++++++++ src/common/error.c | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h index be96d9f61..478713a30 100644 --- a/include/lttng/lttng-error.h +++ b/include/lttng/lttng-error.h @@ -114,7 +114,7 @@ enum lttng_error_code { LTTNG_ERR_TRACE_ALREADY_STOPPED = 81, /* Tracing already stopped */ LTTNG_ERR_KERN_EVENT_ENOSYS = 82, /* Kernel event type not supported */ /* 83 */ - /* 84 */ + LTTNG_ERR_NO_UST = 84, /* LTTng-UST tracer is not supported. Please rebuild lttng-tools with lttng-ust support enabled. */ /* 85 */ /* 86 */ /* 87 */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 06a09fbb9..9d2ad08b0 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2688,6 +2688,10 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, break; case LTTNG_DOMAIN_UST: { + if (!ust_app_supported()) { + ret = LTTNG_ERR_NO_UST; + goto error; + } /* Consumer is in an ERROR state. Report back to client */ if (uatomic_read(&ust_consumerd_state) == CONSUMER_ERROR) { ret = LTTNG_ERR_NO_USTCONSUMERD; diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 92ac9c4e1..c9c47284c 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -315,6 +315,12 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry, struct consumer_socket *socket, int send_zero_data); void ust_app_destroy(struct ust_app *app); +static inline +int ust_app_supported(void) +{ + return 1; +} + #else /* HAVE_LIBLTTNG_UST_CTL */ static inline @@ -512,6 +518,12 @@ void ust_app_destroy(struct ust_app *app) return; } +static inline +int ust_app_supported(void) +{ + return 0; +} + #endif /* HAVE_LIBLTTNG_UST_CTL */ #endif /* _LTT_UST_APP_H */ diff --git a/src/common/error.c b/src/common/error.c index 61d34c24a..9192f2010 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -83,6 +83,7 @@ static const char *error_string_array[] = { [ ERROR_INDEX(LTTNG_ERR_UST_CONTEXT_EXIST)] = "UST context already exist", [ 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_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported", -- 2.34.1