From f73fabfda365d22e7dd180fb1614e37c446fbd9e Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 22 Aug 2012 15:04:52 -0400 Subject: [PATCH] Add lttng-error.h containing every API err. code Move all error codes from sessiond-comm.h to lttng-error.h and rename them changing the prefix LTTCOMM* to the LTTNG_ERR_*. With this change, the error codes will soon be public in that lttng.h will include by default. This commit also removes a bunch of unused code but does NOT changed the values so we don't break the 2.0 API. The lttng_strerror() call uses the new error_get_str function. The lttcomm_* API now only have internal communication error code such as the consumerd errors. Those codes must NEVER be exposed to the public API or, in that case, must be moved to lttng-error.h *without* changing the current values of the lttng_error_code enum. The gaps in the lttng_error_code enum found in lttng-error.h can be used for new error codes but the assigned value are considered immutable for the 2.x API. Signed-off-by: David Goulet --- include/lttng/lttng-error.h | 134 +++++++++ src/bin/lttng-consumerd/lttng-consumerd.c | 4 +- src/bin/lttng-relayd/main.c | 18 +- src/bin/lttng-sessiond/channel.c | 54 ++-- src/bin/lttng-sessiond/cmd.c | 288 ++++++++++--------- src/bin/lttng-sessiond/consumer.c | 4 +- src/bin/lttng-sessiond/context.c | 46 +-- src/bin/lttng-sessiond/event.c | 84 +++--- src/bin/lttng-sessiond/filter.c | 24 +- src/bin/lttng-sessiond/kernel-consumer.c | 4 +- src/bin/lttng-sessiond/kernel.c | 4 +- src/bin/lttng-sessiond/main.c | 107 +++---- src/bin/lttng-sessiond/session.c | 16 +- src/bin/lttng-sessiond/ust-app.c | 2 + src/bin/lttng/commands/create.c | 2 +- src/bin/lttng/commands/destroy.c | 2 +- src/bin/lttng/commands/enable_channels.c | 4 +- src/bin/lttng/commands/enable_consumer.c | 2 +- src/bin/lttng/commands/enable_events.c | 4 +- src/bin/lttng/commands/start.c | 2 +- src/bin/lttng/commands/stop.c | 2 +- src/common/Makefile.am | 2 +- src/common/consumer.c | 18 +- src/common/error.c | 121 ++++++++ src/common/error.h | 5 + src/common/kernel-consumer/kernel-consumer.c | 8 +- src/common/relayd/relayd.c | 4 +- src/common/sessiond-comm/sessiond-comm.c | 124 ++------ src/common/sessiond-comm/sessiond-comm.h | 117 +------- src/common/ust-consumer/ust-consumer.c | 10 +- src/lib/lttng-ctl/lttng-ctl.c | 17 +- tests/tools/Makefile.am | 3 +- tests/tools/test_sessions.c | 7 +- 33 files changed, 671 insertions(+), 572 deletions(-) create mode 100644 include/lttng/lttng-error.h create mode 100644 src/common/error.c diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h new file mode 100644 index 000000000..0e1730a33 --- /dev/null +++ b/include/lttng/lttng-error.h @@ -0,0 +1,134 @@ +/* + * lttng-error.h + * + * Linux Trace Toolkit Control Library Error Header File + * + * The following values are all the possible errors the lttng command line + * client can quit with. + * + * Copyright (C) 2012 - David Goulet + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_ERROR_H +#define LTTNG_ERROR_H + +enum lttng_error_code { + LTTNG_OK = 10, /* Ok */ + LTTNG_ERR_UNK = 11, /* Unknown Error */ + LTTNG_ERR_UND = 12, /* Undefine command */ + /* 13 */ + LTTNG_ERR_UNKNOWN_DOMAIN = 14, /* Tracing domain not known */ + /* 15 */ + LTTNG_ERR_NO_SESSION = 16, /* No session found */ + LTTNG_ERR_CREATE_DIR_FAIL = 17, /* Create directory fail */ + LTTNG_ERR_SESSION_FAIL = 18, /* Create session fail */ + /* 19 */ + /* 20 */ + /* 21 */ + /* 22 */ + LTTNG_ERR_SESS_NOT_FOUND = 23, /* Session by name not found */ + /* 24 */ + LTTNG_ERR_FATAL = 25, /* Fatal error */ + /* 26 */ + LTTNG_ERR_SELECT_SESS = 27, /* Must select a session */ + LTTNG_ERR_EXIST_SESS = 28, /* Session name already exist */ + LTTNG_ERR_NO_EVENT = 29, /* No event found */ + LTTNG_ERR_CONNECT_FAIL = 30, /* Unable to connect to unix socket */ + /* 31 */ + LTTNG_ERR_EPERM = 32, /* Permission denied */ + LTTNG_ERR_KERN_NA = 33, /* Kernel tracer unavalable */ + LTTNG_ERR_KERN_VERSION = 34, /* Kernel tracer not compatible */ + LTTNG_ERR_KERN_EVENT_EXIST = 35, /* Kernel event already exists */ + LTTNG_ERR_KERN_SESS_FAIL = 36, /* Kernel create session failed */ + LTTNG_ERR_KERN_CHAN_EXIST = 37, /* Kernel channel already exists */ + LTTNG_ERR_KERN_CHAN_FAIL = 38, /* Kernel create channel failed */ + LTTNG_ERR_KERN_CHAN_NOT_FOUND = 39, /* Kernel channel not found */ + LTTNG_ERR_KERN_CHAN_DISABLE_FAIL = 40, /* Kernel disable channel failed */ + LTTNG_ERR_KERN_CHAN_ENABLE_FAIL = 41, /* Kernel enable channel failed */ + LTTNG_ERR_KERN_CONTEXT_FAIL = 42, /* Kernel add context failed */ + LTTNG_ERR_KERN_ENABLE_FAIL = 43, /* Kernel enable event failed */ + LTTNG_ERR_KERN_DISABLE_FAIL = 44, /* Kernel disable event failed */ + LTTNG_ERR_KERN_META_FAIL = 45, /* Kernel open metadata failed */ + LTTNG_ERR_KERN_START_FAIL = 46, /* Kernel start trace failed */ + LTTNG_ERR_KERN_STOP_FAIL = 47, /* Kernel stop trace failed */ + LTTNG_ERR_KERN_CONSUMER_FAIL = 48, /* Kernel consumer start failed */ + LTTNG_ERR_KERN_STREAM_FAIL = 49, /* Kernel create stream failed */ + /* 50 */ + /* 51 */ + /* 52 */ + LTTNG_ERR_KERN_LIST_FAIL = 53, /* Kernel listing events failed */ + LTTNG_ERR_UST_CALIBRATE_FAIL = 54, /* UST calibration failed */ + /* 55 */ + LTTNG_ERR_UST_SESS_FAIL = 56, /* UST create session failed */ + LTTNG_ERR_UST_CHAN_EXIST = 57, /* UST channel already exist */ + LTTNG_ERR_UST_CHAN_FAIL = 58, /* UST create channel failed */ + LTTNG_ERR_UST_CHAN_NOT_FOUND = 59, /* UST channel not found */ + LTTNG_ERR_UST_CHAN_DISABLE_FAIL = 60, /* UST disable channel failed */ + LTTNG_ERR_UST_CHAN_ENABLE_FAIL = 61, /* UST enable channel failed */ + /* 62 */ + LTTNG_ERR_UST_ENABLE_FAIL = 63, /* UST enable event failed */ + LTTNG_ERR_UST_DISABLE_FAIL = 64, /* UST disable event failed */ + LTTNG_ERR_UST_META_FAIL = 65, /* UST open metadata failed */ + LTTNG_ERR_UST_START_FAIL = 66, /* UST start trace failed */ + LTTNG_ERR_UST_STOP_FAIL = 67, /* UST stop trace failed */ + LTTNG_ERR_UST_CONSUMER64_FAIL = 68, /* 64-bit UST consumer start failed */ + LTTNG_ERR_UST_CONSUMER32_FAIL = 69, /* 32-bit UST consumer start failed */ + LTTNG_ERR_UST_STREAM_FAIL = 70, /* UST create stream failed */ + /* 71 */ + /* 72 */ + /* 73 */ + LTTNG_ERR_UST_LIST_FAIL = 74, /* UST listing events failed */ + LTTNG_ERR_UST_EVENT_EXIST = 75, /* UST event exist */ + LTTNG_ERR_UST_EVENT_NOT_FOUND = 76, /* UST event not found */ + LTTNG_ERR_UST_CONTEXT_EXIST = 77, /* UST context exist */ + LTTNG_ERR_UST_CONTEXT_INVAL = 78, /* UST context invalid */ + LTTNG_ERR_NEED_ROOT_SESSIOND = 79, /* root sessiond is needed */ + LTTNG_ERR_TRACE_ALREADY_STARTED = 80, /* Tracing already started */ + LTTNG_ERR_TRACE_ALREADY_STOPPED = 81, /* Tracing already stopped */ + LTTNG_ERR_KERN_EVENT_ENOSYS = 82, /* Kernel event type not supported */ + /* 83 */ + /* 84 */ + /* 85 */ + /* 86 */ + /* 87 */ + /* 88 */ + /* 89 */ + /* 90 */ + /* 91 */ + /* 92 */ + /* 93 */ + /* 94 */ + /* 95 */ + /* 96 */ + LTTNG_ERR_INVALID = 97, /* Invalid parameter */ + LTTNG_ERR_NO_USTCONSUMERD = 98, /* No UST consumer detected */ + LTTNG_ERR_NO_KERNCONSUMERD = 99, /* No Kernel consumer detected */ + LTTNG_ERR_EVENT_EXIST_LOGLEVEL = 100, /* Event enabled with different loglevel */ + LTTNG_ERR_URL_DATA_MISS = 101, /* Missing network data URL */ + LTTNG_ERR_URL_CTRL_MISS = 102, /* Missing network control URL */ + LTTNG_ERR_ENABLE_CONSUMER_FAIL = 103, /* Enabling consumer failed */ + LTTNG_ERR_RELAYD_CONNECT_FAIL = 104, /* lttng-relayd create session failed */ + LTTNG_ERR_RELAYD_VERSION_FAIL = 105, /* lttng-relayd not compatible */ + LTTNG_ERR_FILTER_INVAL = 106, /* Invalid filter bytecode */ + LTTNG_ERR_FILTER_NOMEM = 107, /* Lack of memory for filter bytecode */ + LTTNG_ERR_FILTER_EXIST = 108, /* Filter already exist */ + LTTNG_ERR_NO_CONSUMER = 109, /* No consumer exist for the session */ + + /* MUST be last element */ + LTTNG_ERR_NR, /* Last element */ +}; + +#endif /* LTTNG_ERROR_H */ diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index e5d7ba1c6..d49c3eb33 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -376,12 +376,12 @@ int main(int argc, char **argv) } } ret = EXIT_SUCCESS; - lttng_consumer_send_error(ctx, CONSUMERD_EXIT_SUCCESS); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_SUCCESS); goto end; error: ret = EXIT_FAILURE; - lttng_consumer_send_error(ctx, CONSUMERD_EXIT_FAILURE); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_FAILURE); end: lttng_consumer_destroy(ctx); diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index cb115afda..3826f0a75 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -977,9 +977,9 @@ end: free(root_path); /* send the session id to the client or a negative return code on error */ if (ret < 0) { - reply.ret_code = htobe32(LTTCOMM_ERR); + reply.ret_code = htobe32(LTTNG_ERR_UNK); } else { - reply.ret_code = htobe32(LTTCOMM_OK); + reply.ret_code = htobe32(LTTNG_OK); } reply.handle = htobe64(stream->stream_handle); send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply, @@ -1058,9 +1058,9 @@ end_unlock: rcu_read_unlock(); if (ret < 0) { - reply.ret_code = htobe32(LTTCOMM_ERR); + reply.ret_code = htobe32(LTTNG_ERR_UNK); } else { - reply.ret_code = htobe32(LTTCOMM_OK); + reply.ret_code = htobe32(LTTNG_OK); } send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0); @@ -1081,7 +1081,7 @@ void relay_unknown_command(struct relay_command *cmd) struct lttcomm_relayd_generic_reply reply; int ret; - reply.ret_code = htobe32(LTTCOMM_ERR); + reply.ret_code = htobe32(LTTNG_ERR_UNK); ret = cmd->sock->ops->sendmsg(cmd->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0); if (ret < 0) { @@ -1097,13 +1097,13 @@ static int relay_start(struct lttcomm_relayd_hdr *recv_hdr, struct relay_command *cmd) { - int ret = htobe32(LTTCOMM_OK); + int ret = htobe32(LTTNG_OK); struct lttcomm_relayd_generic_reply reply; struct relay_session *session = cmd->session; if (!session) { DBG("Trying to start the streaming without a session established"); - ret = htobe32(LTTCOMM_ERR); + ret = htobe32(LTTNG_ERR_UNK); } reply.ret_code = ret; @@ -1151,7 +1151,7 @@ static int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr, struct relay_command *cmd, struct lttng_ht *streams_ht) { - int ret = htobe32(LTTCOMM_OK); + int ret = htobe32(LTTNG_OK); struct relay_session *session = cmd->session; struct lttcomm_relayd_metadata_payload *metadata_struct; struct relay_stream *metadata_stream; @@ -1223,7 +1223,7 @@ static int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr, struct relay_command *cmd) { - int ret = htobe32(LTTCOMM_OK); + int ret = htobe32(LTTNG_OK); struct lttcomm_relayd_version reply; struct relay_session *session = NULL; diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 4ec12302b..dfc789267 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -91,17 +91,17 @@ int channel_kernel_disable(struct ltt_kernel_session *ksession, kchan = trace_kernel_get_channel_by_name(channel_name, ksession); if (kchan == NULL) { - ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; goto error; } else if (kchan->enabled == 1) { ret = kernel_disable_channel(kchan); if (ret < 0 && ret != -EEXIST) { - ret = LTTCOMM_KERN_CHAN_DISABLE_FAIL; + ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL; goto error; } } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -118,15 +118,15 @@ int channel_kernel_enable(struct ltt_kernel_session *ksession, if (kchan->enabled == 0) { ret = kernel_enable_channel(kchan); if (ret < 0) { - ret = LTTCOMM_KERN_CHAN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_CHAN_ENABLE_FAIL; goto error; } } else { - ret = LTTCOMM_KERN_CHAN_EXIST; + ret = LTTNG_ERR_KERN_CHAN_EXIST; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -145,7 +145,7 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, if (attr == NULL) { defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); if (defattr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } attr = defattr; @@ -154,18 +154,18 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, /* Channel not found, creating it */ ret = kernel_create_channel(ksession, attr, ksession->trace_path); if (ret < 0) { - ret = LTTCOMM_KERN_CHAN_FAIL; + ret = LTTNG_ERR_KERN_CHAN_FAIL; goto error; } /* Notify kernel thread that there is a new channel */ ret = notify_thread_pipe(kernel_pipe); if (ret < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: free(defattr); return ret; @@ -177,12 +177,12 @@ error: int channel_ust_enable(struct ltt_ust_session *usess, int domain, struct ltt_ust_channel *uchan) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; /* If already enabled, everything is OK */ if (uchan->enabled) { DBG3("Channel %s already enabled. Skipping", uchan->name); - ret = LTTCOMM_UST_CHAN_EXIST; + ret = LTTNG_ERR_UST_CHAN_EXIST; goto end; } @@ -198,16 +198,16 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_EXEC_NAME: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } if (ret < 0) { if (ret != -EEXIST) { - ret = LTTCOMM_UST_CHAN_ENABLE_FAIL; + ret = LTTNG_ERR_UST_CHAN_ENABLE_FAIL; goto error; } else { - ret = LTTCOMM_OK; + ret = LTTNG_OK; } } @@ -225,7 +225,7 @@ error: int channel_ust_create(struct ltt_ust_session *usess, int domain, struct lttng_channel *attr) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; struct ltt_ust_channel *uchan = NULL; struct lttng_channel *defattr = NULL; @@ -233,7 +233,7 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, if (attr == NULL) { defattr = channel_new_default_attr(domain); if (defattr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } attr = defattr; @@ -246,18 +246,18 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, * (unlike kernel tracing). */ if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) { - ret = LTTCOMM_INVALID; + ret = LTTNG_ERR_INVALID; goto error; } if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) { - ret = LTTCOMM_INVALID; + ret = LTTNG_ERR_INVALID; goto error; } /* Create UST channel */ uchan = trace_ust_create_channel(attr, usess->pathname); if (uchan == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } uchan->enabled = 1; @@ -275,12 +275,12 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_EXEC_NAME: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error_free_chan; } if (ret < 0 && ret != -EEXIST) { - ret = LTTCOMM_UST_CHAN_ENABLE_FAIL; + ret = LTTNG_ERR_UST_CHAN_FAIL; goto error_free_chan; } @@ -292,7 +292,7 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, DBG2("Channel %s created successfully", uchan->name); free(defattr); - return LTTCOMM_OK; + return LTTNG_OK; error_free_chan: /* @@ -311,7 +311,7 @@ error: int channel_ust_disable(struct ltt_ust_session *usess, int domain, struct ltt_ust_channel *uchan) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; /* Already disabled */ if (uchan->enabled == 0) { @@ -332,12 +332,12 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } if (ret < 0 && ret != -EEXIST) { - ret = LTTCOMM_UST_DISABLE_FAIL; + ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL; goto error; } @@ -345,7 +345,7 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain, DBG2("Channel %s disabled successfully", uchan->name); - return LTTCOMM_OK; + return LTTNG_OK; end: error: diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 1b1f87b8e..460f1d69f 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -188,7 +188,7 @@ static int list_lttng_ust_global_events(char *channel_name, lttng_ht_lookup(ust_global->channels, (void *)channel_name, &iter); node = lttng_ht_iter_get_node_str(&iter); if (node == NULL) { - ret = -LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } @@ -205,7 +205,7 @@ static int list_lttng_ust_global_events(char *channel_name, tmp = zmalloc(nb_event * sizeof(struct lttng_event)); if (tmp == NULL) { - ret = -LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -265,7 +265,7 @@ static int list_lttng_kernel_events(char *channel_name, kchan = trace_kernel_get_channel_by_name(channel_name, kernel_session); if (kchan == NULL) { - ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; goto error; } @@ -274,13 +274,12 @@ static int list_lttng_kernel_events(char *channel_name, DBG("Listing events for channel %s", kchan->channel->name); if (nb_event == 0) { - ret = nb_event; - goto error; + goto end; } *events = zmalloc(nb_event * sizeof(struct lttng_event)); if (*events == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -318,10 +317,12 @@ static int list_lttng_kernel_events(char *channel_name, i++; } +end: return nb_event; error: - return ret; + /* Negate the error code to differentiate the size from an error */ + return -ret; } /* @@ -331,14 +332,14 @@ error: static int add_uri_to_consumer(struct consumer_output *consumer, struct lttng_uri *uri, int domain, const char *session_name) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; const char *default_trace_dir; assert(uri); if (consumer == NULL) { DBG("No consumer detected. Don't add URI. Stopping."); - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; goto error; } @@ -365,7 +366,7 @@ static int add_uri_to_consumer(struct consumer_output *consumer, /* Set URI into consumer output object */ ret = consumer_set_network_uri(consumer, uri); if (ret < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } else if (ret == 1) { /* @@ -378,7 +379,7 @@ static int add_uri_to_consumer(struct consumer_output *consumer, if (uri->stype == LTTNG_STREAM_CONTROL && strlen(uri->subdir) == 0) { ret = consumer_set_subdir(consumer, session_name); if (ret < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } } @@ -431,7 +432,7 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) ret = kernel_consumer_send_session(socket->fd, session); pthread_mutex_unlock(socket->lock); if (ret < 0) { - ret = LTTCOMM_KERN_CONSUMER_FAIL; + ret = LTTNG_ERR_KERN_CONSUMER_FAIL; goto error; } } @@ -457,13 +458,13 @@ static int create_connect_relayd(struct consumer_output *output, /* Create socket object from URI */ sock = lttcomm_alloc_sock_from_uri(uri); if (sock == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } ret = lttcomm_create_sock(sock); if (ret < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -471,7 +472,7 @@ static int create_connect_relayd(struct consumer_output *output, ret = relayd_connect(sock); if (ret < 0) { ERR("Unable to reach lttng-relayd"); - ret = LTTCOMM_RELAYD_SESSION_FAIL; + ret = LTTNG_ERR_RELAYD_CONNECT_FAIL; goto free_sock; } @@ -483,7 +484,7 @@ static int create_connect_relayd(struct consumer_output *output, ret = relayd_version_check(sock, RELAYD_VERSION_COMM_MAJOR, RELAYD_VERSION_COMM_MINOR); if (ret < 0) { - ret = LTTCOMM_RELAYD_VERSION_FAIL; + ret = LTTNG_ERR_RELAYD_VERSION_FAIL; goto close_sock; } } else if (uri->stype == LTTNG_STREAM_DATA) { @@ -491,13 +492,13 @@ static int create_connect_relayd(struct consumer_output *output, } else { /* Command is not valid */ ERR("Relayd invalid stream type: %d", uri->stype); - ret = LTTCOMM_INVALID; + ret = LTTNG_ERR_INVALID; goto close_sock; } *relayd_sock = sock; - return LTTCOMM_OK; + return LTTNG_OK; close_sock: if (sock) { @@ -535,7 +536,7 @@ static int send_consumer_relayd_socket(int domain, struct ltt_session *session, /* Connect to relayd and make version check if uri is the control. */ ret = create_connect_relayd(consumer, session->name, relayd_uri, &sock); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto close_sock; } @@ -548,11 +549,11 @@ static int send_consumer_relayd_socket(int domain, struct ltt_session *session, ret = consumer_send_relayd_socket(consumer_fd, sock, consumer, relayd_uri->stype); if (ret < 0) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; goto close_sock; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; /* * Close socket which was dup on the consumer side. The session daemon does @@ -583,21 +584,21 @@ static int send_consumer_relayd_sockets(int domain, /* Don't resend the sockets to the consumer. */ if (consumer->dst.net.relayd_socks_sent) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto error; } /* Sending control relayd socket. */ ret = send_consumer_relayd_socket(domain, session, &consumer->dst.net.control, consumer, fd); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } /* Sending data relayd socket. */ ret = send_consumer_relayd_socket(domain, session, &consumer->dst.net.data, consumer, fd); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -615,7 +616,7 @@ error: */ static int setup_relayd(struct ltt_session *session) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; struct ltt_ust_session *usess; struct ltt_kernel_session *ksess; struct consumer_socket *socket; @@ -640,7 +641,7 @@ static int setup_relayd(struct ltt_session *session) send_consumer_relayd_sockets(LTTNG_DOMAIN_UST, session, usess->consumer, socket->fd); pthread_mutex_unlock(socket->lock); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } } @@ -657,7 +658,7 @@ static int setup_relayd(struct ltt_session *session) send_consumer_relayd_sockets(LTTNG_DOMAIN_KERNEL, session, ksess->consumer, socket->fd); pthread_mutex_unlock(socket->lock); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } } @@ -683,7 +684,7 @@ int cmd_disable_channel(struct ltt_session *session, int domain, { ret = channel_kernel_disable(session->kernel_session, channel_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -699,12 +700,12 @@ int cmd_disable_channel(struct ltt_session *session, int domain, uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); if (uchan == NULL) { - ret = LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } ret = channel_ust_disable(usess, domain, uchan); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; @@ -715,11 +716,11 @@ int cmd_disable_channel(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID: #endif default: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -758,7 +759,7 @@ int cmd_enable_channel(struct ltt_session *session, ret = channel_kernel_enable(session->kernel_session, kchan); } - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -785,7 +786,7 @@ int cmd_enable_channel(struct ltt_session *session, case LTTNG_DOMAIN_UST_PID: #endif default: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; goto error; } @@ -812,12 +813,12 @@ int cmd_disable_event(struct ltt_session *session, int domain, kchan = trace_kernel_get_channel_by_name(channel_name, ksess); if (kchan == NULL) { - ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; goto error; } ret = event_kernel_disable_tracepoint(ksess, kchan, event_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -834,12 +835,12 @@ int cmd_disable_event(struct ltt_session *session, int domain, uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { - ret = LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } ret = event_ust_disable_tracepoint(usess, domain, uchan, event_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -853,11 +854,11 @@ int cmd_disable_event(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -881,12 +882,12 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, kchan = trace_kernel_get_channel_by_name(channel_name, ksess); if (kchan == NULL) { - ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; goto error; } ret = event_kernel_disable_all(ksess, kchan); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -903,7 +904,7 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { - ret = LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } @@ -922,11 +923,11 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -945,7 +946,7 @@ int cmd_add_context(struct ltt_session *session, int domain, /* Add kernel context to kernel tracer */ ret = context_kernel_add(session->kernel_session, ctx, event_name, channel_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; @@ -956,7 +957,7 @@ int cmd_add_context(struct ltt_session *session, int domain, assert(usess); ret = context_ust_add(usess, domain, ctx, event_name, channel_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; @@ -967,11 +968,11 @@ int cmd_add_context(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -988,14 +989,14 @@ int cmd_set_filter(struct ltt_session *session, int domain, switch (domain) { case LTTNG_DOMAIN_KERNEL: - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; break; case LTTNG_DOMAIN_UST: { struct ltt_ust_session *usess = session->ust_session; ret = filter_ust_set(usess, domain, bytecode, event_name, channel_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; @@ -1006,11 +1007,11 @@ int cmd_set_filter(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1041,13 +1042,13 @@ int cmd_enable_event(struct ltt_session *session, int domain, if (kchan == NULL) { attr = channel_new_default_attr(domain); if (attr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } strncpy(attr->name, channel_name, sizeof(attr->name)); ret = cmd_enable_channel(session, domain, attr, wpipe); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { free(attr); goto error; } @@ -1059,13 +1060,13 @@ int cmd_enable_event(struct ltt_session *session, int domain, session->kernel_session); if (kchan == NULL) { /* This sould not happen... */ - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } ret = event_kernel_enable_tracepoint(session->kernel_session, kchan, event); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -1086,13 +1087,13 @@ int cmd_enable_event(struct ltt_session *session, int domain, /* Create default channel */ attr = channel_new_default_attr(domain); if (attr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } strncpy(attr->name, channel_name, sizeof(attr->name)); ret = cmd_enable_channel(session, domain, attr, wpipe); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { free(attr); goto error; } @@ -1106,7 +1107,7 @@ int cmd_enable_event(struct ltt_session *session, int domain, /* At this point, the session and channel exist on the tracer */ ret = event_ust_enable_tracepoint(usess, domain, uchan, event); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; @@ -1117,11 +1118,11 @@ int cmd_enable_event(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1152,13 +1153,13 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, /* Create default channel */ attr = channel_new_default_attr(domain); if (attr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } strncpy(attr->name, channel_name, sizeof(attr->name)); ret = cmd_enable_channel(session, domain, attr, wpipe); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { free(attr); goto error; } @@ -1189,12 +1190,12 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, kchan, kernel_tracer_fd); break; default: - ret = LTTCOMM_KERN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_ENABLE_FAIL; goto error; } /* Manage return value */ - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -1215,13 +1216,13 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, /* Create default channel */ attr = channel_new_default_attr(domain); if (attr == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } strncpy(attr->name, channel_name, sizeof(attr->name)); ret = cmd_enable_channel(session, domain, attr, wpipe); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { free(attr); goto error; } @@ -1239,17 +1240,17 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, case LTTNG_EVENT_ALL: case LTTNG_EVENT_TRACEPOINT: ret = event_ust_enable_all_tracepoints(usess, domain, uchan); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } break; default: - ret = LTTCOMM_UST_ENABLE_FAIL; + ret = LTTNG_ERR_UST_ENABLE_FAIL; goto error; } /* Manage return value */ - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -1261,11 +1262,11 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1284,19 +1285,19 @@ ssize_t cmd_list_tracepoints(int domain, struct lttng_event **events) case LTTNG_DOMAIN_KERNEL: nb_events = kernel_list_events(kernel_tracer_fd, events); if (nb_events < 0) { - ret = LTTCOMM_KERN_LIST_FAIL; + ret = LTTNG_ERR_KERN_LIST_FAIL; goto error; } break; case LTTNG_DOMAIN_UST: nb_events = ust_app_list_events(events); if (nb_events < 0) { - ret = LTTCOMM_UST_LIST_FAIL; + ret = LTTNG_ERR_UST_LIST_FAIL; goto error; } break; default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } @@ -1320,13 +1321,13 @@ ssize_t cmd_list_tracepoint_fields(int domain, case LTTNG_DOMAIN_UST: nb_fields = ust_app_list_event_fields(fields); if (nb_fields < 0) { - ret = LTTCOMM_UST_LIST_FAIL; + ret = LTTNG_ERR_UST_LIST_FAIL; goto error; } break; case LTTNG_DOMAIN_KERNEL: default: /* fall-through */ - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } @@ -1355,14 +1356,14 @@ int cmd_start_trace(struct ltt_session *session) if (session->enabled) { /* Already started. */ - ret = LTTCOMM_TRACE_ALREADY_STARTED; + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; goto error; } session->enabled = 1; ret = setup_relayd(session); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { ERR("Error setting up relayd for session %s", session->name); goto error; } @@ -1373,7 +1374,7 @@ int cmd_start_trace(struct ltt_session *session) if (ksession->metadata == NULL) { ret = kernel_open_metadata(ksession); if (ret < 0) { - ret = LTTCOMM_KERN_META_FAIL; + ret = LTTNG_ERR_KERN_META_FAIL; goto error; } } @@ -1383,7 +1384,7 @@ int cmd_start_trace(struct ltt_session *session) ret = kernel_open_metadata_stream(ksession); if (ret < 0) { ERR("Kernel create metadata stream failed"); - ret = LTTCOMM_KERN_STREAM_FAIL; + ret = LTTNG_ERR_KERN_STREAM_FAIL; goto error; } } @@ -1393,7 +1394,7 @@ int cmd_start_trace(struct ltt_session *session) if (kchan->stream_count == 0) { ret = kernel_open_channel_stream(kchan); if (ret < 0) { - ret = LTTCOMM_KERN_STREAM_FAIL; + ret = LTTNG_ERR_KERN_STREAM_FAIL; goto error; } /* Update the stream global counter */ @@ -1404,14 +1405,14 @@ int cmd_start_trace(struct ltt_session *session) /* Setup kernel consumer socket and send fds to it */ ret = init_kernel_tracing(ksession); if (ret < 0) { - ret = LTTCOMM_KERN_START_FAIL; + ret = LTTNG_ERR_KERN_START_FAIL; goto error; } /* This start the kernel tracing */ ret = kernel_start_session(ksession); if (ret < 0) { - ret = LTTCOMM_KERN_START_FAIL; + ret = LTTNG_ERR_KERN_START_FAIL; goto error; } @@ -1425,12 +1426,12 @@ int cmd_start_trace(struct ltt_session *session) ret = ust_app_start_trace_all(usess); if (ret < 0) { - ret = LTTCOMM_UST_START_FAIL; + ret = LTTNG_ERR_UST_START_FAIL; goto error; } } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1453,7 +1454,7 @@ int cmd_stop_trace(struct ltt_session *session) usess = session->ust_session; if (!session->enabled) { - ret = LTTCOMM_TRACE_ALREADY_STOPPED; + ret = LTTNG_ERR_TRACE_ALREADY_STOPPED; goto error; } @@ -1481,7 +1482,7 @@ int cmd_stop_trace(struct ltt_session *session) ret = kernel_stop_session(ksession); if (ret < 0) { - ret = LTTCOMM_KERN_STOP_FAIL; + ret = LTTNG_ERR_KERN_STOP_FAIL; goto error; } @@ -1493,12 +1494,12 @@ int cmd_stop_trace(struct ltt_session *session) ret = ust_app_stop_trace_all(usess); if (ret < 0) { - ret = LTTCOMM_UST_STOP_FAIL; + ret = LTTNG_ERR_UST_STOP_FAIL; goto error; } } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1521,12 +1522,12 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, /* Can't enable consumer after session started. */ if (session->enabled) { - ret = LTTCOMM_TRACE_ALREADY_STARTED; + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; goto error; } if (!session->start_consumer) { - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; goto error; } @@ -1553,7 +1554,7 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, if (consumer == NULL) { consumer = consumer_copy_output(ksess->consumer); if (consumer == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } /* Trash the consumer subdir, we are about to set a new one. */ @@ -1571,7 +1572,7 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, if (consumer == NULL) { consumer = consumer_copy_output(usess->consumer); if (consumer == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } /* Trash the consumer subdir, we are about to set a new one. */ @@ -1612,7 +1613,7 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, ret = send_consumer_relayd_socket(domain, session, &uris[i], consumer, socket->fd); pthread_mutex_unlock(socket->lock); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { rcu_read_unlock(); goto error; } @@ -1621,7 +1622,7 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, } /* All good! */ - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1648,14 +1649,14 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, */ session = session_find_by_name(name); if (session != NULL) { - ret = LTTCOMM_EXIST_SESS; + ret = LTTNG_ERR_EXIST_SESS; goto find_error; } /* Create tracing session in the registry */ ret = session_create(name, path, LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds)); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto session_error; } @@ -1672,7 +1673,7 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, /* Create default consumer output for the session not yet created. */ session->consumer = consumer_create_output(CONSUMER_DST_LOCAL); if (session->consumer == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto consumer_error; } @@ -1693,14 +1694,14 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, session->start_consumer = 1; ret = cmd_set_consumer_uri(0, session, nb_uri, uris); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto consumer_error; } session->consumer->enabled = 1; end: - return LTTCOMM_OK; + return LTTNG_OK; consumer_error: session_destroy(session); @@ -1771,7 +1772,7 @@ int cmd_calibrate(int domain, struct lttng_calibrate *calibrate) kcalibrate.type = calibrate->type; ret = kernel_calibrate(kernel_tracer_fd, &kcalibrate); if (ret < 0) { - ret = LTTCOMM_KERN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_ENABLE_FAIL; goto error; } break; @@ -1783,17 +1784,17 @@ int cmd_calibrate(int domain, struct lttng_calibrate *calibrate) ucalibrate.type = calibrate->type; ret = ust_app_calibrate_glb(&ucalibrate); if (ret < 0) { - ret = LTTCOMM_UST_CALIBRATE_FAIL; + ret = LTTNG_ERR_UST_CALIBRATE_FAIL; goto error; } break; } default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1821,19 +1822,19 @@ int cmd_register_consumer(struct ltt_session *session, int domain, /* Can't register a consumer if there is already one */ if (ksess->consumer_fds_sent != 0) { - ret = LTTCOMM_KERN_CONSUMER_FAIL; + ret = LTTNG_ERR_KERN_CONSUMER_FAIL; goto error; } sock = lttcomm_connect_unix_sock(sock_path); if (sock < 0) { - ret = LTTCOMM_CONNECT_FAIL; + ret = LTTNG_ERR_CONNECT_FAIL; goto error; } socket = consumer_allocate_socket(sock); if (socket == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; close(sock); goto error; } @@ -1841,7 +1842,7 @@ int cmd_register_consumer(struct ltt_session *session, int domain, socket->lock = zmalloc(sizeof(pthread_mutex_t)); if (socket->lock == NULL) { PERROR("zmalloc pthread mutex"); - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } pthread_mutex_init(socket->lock, NULL); @@ -1859,11 +1860,11 @@ int cmd_register_consumer(struct ltt_session *session, int domain, } default: /* TODO: Userspace tracing */ - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1890,7 +1891,7 @@ ssize_t cmd_list_domains(struct ltt_session *session, *domains = zmalloc(nb_dom * sizeof(struct lttng_domain)); if (*domains == NULL) { - ret = -LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -1907,7 +1908,8 @@ ssize_t cmd_list_domains(struct ltt_session *session, return nb_dom; error: - return ret; + /* Return negative value to differentiate return code */ + return -ret; } @@ -1936,14 +1938,14 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, break; default: *channels = NULL; - ret = -LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } if (nb_chan > 0) { *channels = zmalloc(nb_chan * sizeof(struct lttng_channel)); if (*channels == NULL) { - ret = -LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -1955,7 +1957,8 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, return nb_chan; error: - return ret; + /* Return negative value to differentiate return code */ + return -ret; } /* @@ -1983,14 +1986,15 @@ ssize_t cmd_list_events(int domain, struct ltt_session *session, break; } default: - ret = -LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - ret = nb_event; + return nb_event; error: - return ret; + /* Return negative value to differentiate return code */ + return -ret; } /* @@ -2060,12 +2064,12 @@ int cmd_disable_consumer(int domain, struct ltt_session *session) if (session->enabled) { /* Can't disable consumer on an already started session */ - ret = LTTCOMM_TRACE_ALREADY_STARTED; + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; goto error; } if (!session->start_consumer) { - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; goto error; } @@ -2091,16 +2095,16 @@ int cmd_disable_consumer(int domain, struct ltt_session *session) break; default: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; goto error; } if (consumer) { consumer->enabled = 0; /* Success at this point */ - ret = LTTCOMM_OK; + ret = LTTNG_OK; } else { - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; } error: @@ -2121,12 +2125,12 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) /* Can't enable consumer after session started. */ if (session->enabled) { - ret = LTTCOMM_TRACE_ALREADY_STARTED; + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; goto error; } if (!session->start_consumer) { - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; goto error; } @@ -2145,13 +2149,13 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) * had previously occured. */ if (ksess->consumer_fds_sent) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; goto error; } consumer = ksess->tmp_consumer; if (consumer == NULL) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; /* No temp. consumer output exists. Using the current one. */ DBG3("No temporary consumer. Using default"); consumer = ksess->consumer; @@ -2168,7 +2172,7 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) if (ret < 0) { if (ret != -EEXIST) { ERR("Trace directory creation error"); - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } } @@ -2177,18 +2181,18 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) DBG2("Consumer output is network. Validating URIs"); /* Validate if we have both control and data path set. */ if (!consumer->dst.net.control_isset) { - ret = LTTCOMM_URL_CTRL_MISS; + ret = LTTNG_ERR_URL_CTRL_MISS; goto error; } if (!consumer->dst.net.data_isset) { - ret = LTTCOMM_URL_DATA_MISS; + ret = LTTNG_ERR_URL_DATA_MISS; goto error; } /* Check established network session state */ if (session->net_handle == 0) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; ERR("Session network handle is not set on enable-consumer"); goto error; } @@ -2225,13 +2229,13 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) * had previously occured. */ if (usess->start_trace) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; goto error; } consumer = usess->tmp_consumer; if (consumer == NULL) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; /* No temp. consumer output exists. Using the current one. */ DBG3("No temporary consumer. Using default"); consumer = usess->consumer; @@ -2248,7 +2252,7 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) if (ret < 0) { if (ret != -EEXIST) { ERR("Trace directory creation error"); - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } } @@ -2257,24 +2261,24 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) DBG2("Consumer output is network. Validating URIs"); /* Validate if we have both control and data path set. */ if (!consumer->dst.net.control_isset) { - ret = LTTCOMM_URL_CTRL_MISS; + ret = LTTNG_ERR_URL_CTRL_MISS; goto error; } if (!consumer->dst.net.data_isset) { - ret = LTTCOMM_URL_DATA_MISS; + ret = LTTNG_ERR_URL_DATA_MISS; goto error; } /* Check established network session state */ if (session->net_handle == 0) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; DBG2("Session network handle is not set on enable-consumer"); goto error; } if (consumer->net_seq_index == -1) { - ret = LTTCOMM_ENABLE_CONSUMER_FAIL; + ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; DBG2("Network index is not set on the consumer"); goto error; } @@ -2307,10 +2311,10 @@ int cmd_enable_consumer(int domain, struct ltt_session *session) if (consumer) { consumer->enabled = 1; /* Success at this point */ - ret = LTTCOMM_OK; + ret = LTTNG_OK; } else { /* Should not really happend... */ - ret = LTTCOMM_NO_CONSUMER; + ret = LTTNG_ERR_NO_CONSUMER; } error: diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index b35c91195..b69df16fd 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -48,7 +48,7 @@ int consumer_send_destroy_relayd(struct consumer_socket *sock, /* Bail out if consumer is disabled */ if (!consumer->enabled) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; DBG3("Consumer is disabled"); goto error; } @@ -611,7 +611,7 @@ int consumer_send_relayd_socket(int consumer_sock, /* Bail out if consumer is disabled */ if (!consumer->enabled) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto error; } diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 83085cfc8..1bf3c6768 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -78,13 +78,13 @@ static int add_kctx_all_channels(struct ltt_kernel_session *ksession, if (no_event) { ret = kernel_add_channel_context(kchan, kctx); if (ret < 0) { - ret = LTTCOMM_KERN_CONTEXT_FAIL; + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; } } else { ret = add_kctx_to_event(kctx, kchan, event_name); if (ret < 0) { - ret = LTTCOMM_KERN_CONTEXT_FAIL; + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; } else if (ret == 1) { /* Event found and context added */ @@ -95,11 +95,11 @@ static int add_kctx_all_channels(struct ltt_kernel_session *ksession, } if (!found && !no_event) { - ret = LTTCOMM_NO_EVENT; + ret = LTTNG_ERR_NO_EVENT; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -125,13 +125,13 @@ static int add_kctx_to_channel(struct lttng_kernel_context *kctx, if (no_event) { ret = kernel_add_channel_context(kchan, kctx); if (ret < 0) { - ret = LTTCOMM_KERN_CONTEXT_FAIL; + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; } } else { ret = add_kctx_to_event(kctx, kchan, event_name); if (ret < 0) { - ret = LTTCOMM_KERN_CONTEXT_FAIL; + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; } else if (ret == 1) { /* Event found and context added */ @@ -140,11 +140,11 @@ static int add_kctx_to_channel(struct lttng_kernel_context *kctx, } if (!found && !no_event) { - ret = LTTCOMM_NO_EVENT; + ret = LTTNG_ERR_NO_EVENT; goto error; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -299,7 +299,7 @@ int context_kernel_add(struct ltt_kernel_session *ksession, kctx.ctx = LTTNG_KERNEL_CONTEXT_HOSTNAME; break; default: - return LTTCOMM_KERN_CONTEXT_FAIL; + return LTTNG_ERR_KERN_CONTEXT_FAIL; } kctx.u.perf_counter.type = ctx->u.perf_counter.type; @@ -310,24 +310,24 @@ int context_kernel_add(struct ltt_kernel_session *ksession, if (strlen(channel_name) == 0) { ret = add_kctx_all_channels(ksession, &kctx, event_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } } else { /* Get kernel channel */ kchan = trace_kernel_get_channel_by_name(channel_name, ksession); if (kchan == NULL) { - ret = LTTCOMM_KERN_CHAN_NOT_FOUND; + ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; goto error; } ret = add_kctx_to_channel(&kctx, kchan, event_name); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } } - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -340,7 +340,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, struct lttng_event_context *ctx, char *event_name, char *channel_name) { - int ret = LTTCOMM_OK, have_event = 0; + int ret = LTTNG_OK, have_event = 0; struct lttng_ht_iter iter; struct lttng_ht *chan_ht; struct ltt_ust_channel *uchan = NULL; @@ -360,7 +360,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } @@ -373,7 +373,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, if (strlen(channel_name) != 0) { uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); if (uchan == NULL) { - ret = LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } } @@ -382,7 +382,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, if (uchan && have_event) { uevent = trace_ust_find_event_by_name(uchan->events, event_name); if (uevent == NULL) { - ret = LTTCOMM_UST_EVENT_NOT_FOUND; + ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } } @@ -407,7 +407,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, goto end; } } - ret = LTTCOMM_UST_EVENT_NOT_FOUND; + ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } else if (!uchan && !have_event) { /* Add ctx all events, all channels */ /* For all channels */ @@ -423,19 +423,19 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, end: switch (ret) { case -EEXIST: - ret = LTTCOMM_UST_CONTEXT_EXIST; + ret = LTTNG_ERR_UST_CONTEXT_EXIST; break; case -ENOMEM: - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; break; case -EINVAL: - ret = LTTCOMM_UST_CONTEXT_INVAL; + ret = LTTNG_ERR_UST_CONTEXT_INVAL; break; case -ENOSYS: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; break; default: - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 24dd292a4..ee3ebfe3b 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -82,20 +82,20 @@ int event_kernel_disable_tracepoint(struct ltt_kernel_session *ksession, kevent = trace_kernel_get_event_by_name(event_name, kchan); if (kevent == NULL) { - ret = LTTCOMM_NO_EVENT; + ret = LTTNG_ERR_NO_EVENT; goto error; } ret = kernel_disable_event(kevent); if (ret < 0) { - ret = LTTCOMM_KERN_DISABLE_FAIL; + ret = LTTNG_ERR_KERN_DISABLE_FAIL; goto error; } DBG("Kernel event %s disable for channel %s.", kevent->event->name, kchan->channel->name); - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -118,7 +118,7 @@ int event_kernel_disable_all_tracepoints(struct ltt_kernel_session *ksession, continue; } } - ret = LTTCOMM_OK; + ret = LTTNG_OK; return ret; } @@ -129,7 +129,7 @@ int event_kernel_disable_all_syscalls(struct ltt_kernel_session *ksession, struct ltt_kernel_channel *kchan) { ERR("Cannot disable syscall tracing for existing session. Please destroy session instead."); - return LTTCOMM_OK; /* Return OK so disable all succeeds */ + return LTTNG_OK; /* Return OK so disable all succeeds */ } /* @@ -141,7 +141,7 @@ int event_kernel_disable_all(struct ltt_kernel_session *ksession, int ret; ret = event_kernel_disable_all_tracepoints(ksession, kchan); - if (ret != LTTCOMM_OK) + if (ret != LTTNG_OK) return ret; ret = event_kernel_disable_all_syscalls(ksession, kchan); return ret; @@ -162,13 +162,13 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession, if (ret < 0) { switch (-ret) { case EEXIST: - ret = LTTCOMM_KERN_EVENT_EXIST; + ret = LTTNG_ERR_KERN_EVENT_EXIST; break; case ENOSYS: - ret = LTTCOMM_KERN_EVENT_ENOSYS; + ret = LTTNG_ERR_KERN_EVENT_ENOSYS; break; default: - ret = LTTCOMM_KERN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_ENABLE_FAIL; break; } goto end; @@ -176,16 +176,16 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession, } else if (kevent->enabled == 0) { ret = kernel_enable_event(kevent); if (ret < 0) { - ret = LTTCOMM_KERN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_ENABLE_FAIL; goto end; } } else { /* At this point, the event is considered enabled */ - ret = LTTCOMM_KERN_EVENT_EXIST; + ret = LTTNG_ERR_KERN_EVENT_EXIST; goto end; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; end: return ret; } @@ -213,7 +213,7 @@ int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession, size = kernel_list_events(kernel_tracer_fd, &event_list); if (size < 0) { - ret = LTTCOMM_KERN_LIST_FAIL; + ret = LTTNG_ERR_KERN_LIST_FAIL; goto end; } @@ -231,7 +231,7 @@ int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession, } free(event_list); - ret = LTTCOMM_OK; + ret = LTTNG_OK; end: return ret; @@ -253,14 +253,14 @@ int event_kernel_enable_all_syscalls(struct ltt_kernel_session *ksession, ret = kernel_create_event(&event, kchan); if (ret < 0) { if (ret == -EEXIST) { - ret = LTTCOMM_KERN_EVENT_EXIST; + ret = LTTNG_ERR_KERN_EVENT_EXIST; } else { - ret = LTTCOMM_KERN_ENABLE_FAIL; + ret = LTTNG_ERR_KERN_ENABLE_FAIL; } goto end; } - ret = LTTCOMM_OK; + ret = LTTNG_OK; end: return ret; } @@ -274,7 +274,7 @@ int event_kernel_enable_all(struct ltt_kernel_session *ksession, int tp_ret; tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd); - if (tp_ret != LTTCOMM_OK) { + if (tp_ret != LTTNG_OK) { goto end; } @@ -328,7 +328,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, /* Get all UST available events */ size = ust_app_list_events(&events); if (size < 0) { - ret = LTTCOMM_UST_LIST_FAIL; + ret = LTTNG_ERR_UST_LIST_FAIL; goto error; } @@ -344,7 +344,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, events[i].pid); if (ret < 0) { if (ret != -EEXIST) { - ret = LTTCOMM_UST_ENABLE_FAIL; + ret = LTTNG_ERR_UST_ENABLE_FAIL; goto error; } } @@ -354,7 +354,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, /* Create ust event */ uevent = trace_ust_create_event(&events[i]); if (uevent == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error_destroy; } @@ -363,10 +363,10 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, events[i].pid); if (ret < 0) { if (ret == -EEXIST) { - ret = LTTCOMM_UST_EVENT_EXIST; + ret = LTTNG_ERR_UST_EVENT_EXIST; goto error; } else { - ret = LTTCOMM_UST_ENABLE_FAIL; + ret = LTTNG_ERR_UST_ENABLE_FAIL; goto error_destroy; } } @@ -387,11 +387,11 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - return LTTCOMM_OK; + return LTTNG_OK; error_destroy: trace_ust_destroy_event(uevent); @@ -407,14 +407,14 @@ error: int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, struct ltt_ust_channel *uchan, struct lttng_event *event) { - int ret = LTTCOMM_OK, to_create = 0; + int ret = LTTNG_OK, to_create = 0; struct ltt_ust_event *uevent; uevent = trace_ust_find_event_by_name(uchan->events, event->name); if (uevent == NULL) { uevent = trace_ust_create_event(event); if (uevent == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } /* Valid to set it after the goto error since uevent is still NULL */ @@ -431,13 +431,13 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, DBG("Enable event %s does not match existing event %s with loglevel " "respectively of %d and %d", event->name, uevent->attr.name, uevent->attr.loglevel, event->loglevel); - ret = LTTCOMM_EVENT_EXIST_LOGLEVEL; + ret = LTTNG_ERR_EVENT_EXIST_LOGLEVEL; goto error; } if (uevent->enabled) { /* It's already enabled so everything is OK */ - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto end; } @@ -456,10 +456,10 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, if (ret < 0) { if (ret == -EEXIST) { - ret = LTTCOMM_UST_EVENT_EXIST; + ret = LTTNG_ERR_UST_EVENT_EXIST; goto end; } else { - ret = LTTCOMM_UST_ENABLE_FAIL; + ret = LTTNG_ERR_UST_ENABLE_FAIL; goto error; } } @@ -471,7 +471,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto end; } @@ -485,7 +485,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, DBG("Event UST %s %s in channel %s", uevent->attr.name, to_create ? "created" : "enabled", uchan->name); - ret = LTTCOMM_OK; + ret = LTTNG_OK; end: return ret; @@ -516,13 +516,13 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain, uevent = trace_ust_find_event_by_name(uchan->events, event_name); if (uevent == NULL) { - ret = LTTCOMM_UST_EVENT_NOT_FOUND; + ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } if (uevent->enabled == 0) { /* It's already enabled so everything is OK */ - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto end; } @@ -530,7 +530,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST: ret = ust_app_disable_event_glb(usess, uchan, uevent); if (ret < 0 && ret != -EEXIST) { - ret = LTTCOMM_UST_DISABLE_FAIL; + ret = LTTNG_ERR_UST_DISABLE_FAIL; goto error; } break; @@ -540,12 +540,12 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } uevent->enabled = 0; - ret = LTTCOMM_OK; + ret = LTTNG_OK; end: DBG2("Event UST %s disabled in channel %s", uevent->attr.name, @@ -584,7 +584,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain, /* Get all UST available events */ size = ust_app_list_events(&events); if (size < 0) { - ret = LTTCOMM_UST_LIST_FAIL; + ret = LTTNG_ERR_UST_LIST_FAIL; goto error; } @@ -595,7 +595,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain, ret = ust_app_disable_event_pid(usess, uchan, uevent, events[i].pid); if (ret < 0 && ret != -EEXIST) { - ret = LTTCOMM_UST_DISABLE_FAIL; + ret = LTTNG_ERR_UST_DISABLE_FAIL; goto error; } uevent->enabled = 0; @@ -612,11 +612,11 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } - return LTTCOMM_OK; + return LTTNG_OK; error: free(events); diff --git a/src/bin/lttng-sessiond/filter.c b/src/bin/lttng-sessiond/filter.c index e012cb8a1..f0acffdc1 100644 --- a/src/bin/lttng-sessiond/filter.c +++ b/src/bin/lttng-sessiond/filter.c @@ -76,7 +76,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, struct lttng_filter_bytecode *bytecode, char *event_name, char *channel_name) { - int ret = LTTCOMM_OK, have_event = 0; + int ret = LTTNG_OK, have_event = 0; struct lttng_ht_iter iter; struct lttng_ht *chan_ht; struct ltt_ust_channel *uchan = NULL; @@ -96,7 +96,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: #endif default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } @@ -109,7 +109,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, if (strlen(channel_name) != 0) { uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); if (uchan == NULL) { - ret = LTTCOMM_UST_CHAN_NOT_FOUND; + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; goto error; } } @@ -118,7 +118,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, if (uchan && have_event) { uevent = trace_ust_find_event_by_name(uchan->events, event_name); if (uevent == NULL) { - ret = LTTCOMM_UST_EVENT_NOT_FOUND; + ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } } @@ -130,7 +130,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, bytecode); } else if (uchan && !have_event) { /* Add filter to channel */ ERR("Cannot add filter to channel"); - ret = LTTCOMM_FATAL; /* not supported. */ + ret = LTTNG_ERR_FATAL; /* not supported. */ goto error; } else if (!uchan && have_event) { /* Add filter to event */ /* Add context to event without having the channel name */ @@ -146,30 +146,30 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, goto end; } } - ret = LTTCOMM_UST_EVENT_NOT_FOUND; + ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } else if (!uchan && !have_event) { /* Add filter all events, all channels */ ERR("Cannot add filter to channel"); - ret = LTTCOMM_FATAL; /* not supported. */ + ret = LTTNG_ERR_FATAL; /* not supported. */ goto error; } end: switch (ret) { case -EEXIST: - ret = LTTCOMM_FILTER_EXIST; + ret = LTTNG_ERR_FILTER_EXIST; break; case -ENOMEM: - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; break; case -EINVAL: - ret = LTTCOMM_FILTER_INVAL; + ret = LTTNG_ERR_FILTER_INVAL; break; case -ENOSYS: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; break; default: - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 474b9a300..825121382 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -233,7 +233,7 @@ int kernel_consumer_send_channel_stream(int sock, /* Bail out if consumer is disabled */ if (!session->consumer->enabled) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto error; } @@ -276,7 +276,7 @@ int kernel_consumer_send_session(int sock, struct ltt_kernel_session *session) /* Bail out if consumer is disabled */ if (!session->consumer->enabled) { - ret = LTTCOMM_OK; + ret = LTTNG_OK; goto error; } diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index d52d9aa62..34695efff 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -307,7 +307,7 @@ int kernel_enable_event(struct ltt_kernel_event *event) if (ret < 0) { switch (errno) { case EEXIST: - ret = LTTCOMM_KERN_EVENT_EXIST; + ret = LTTNG_ERR_KERN_EVENT_EXIST; break; default: PERROR("enable kernel event"); @@ -336,7 +336,7 @@ int kernel_disable_event(struct ltt_kernel_event *event) if (ret < 0) { switch (errno) { case EEXIST: - ret = LTTCOMM_KERN_EVENT_EXIST; + ret = LTTNG_ERR_KERN_EVENT_EXIST; break; default: PERROR("disable kernel event"); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a9bb2157e..318da741f 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -882,7 +882,7 @@ restart: health_code_update(&consumer_data->health); - if (code == CONSUMERD_COMMAND_SOCK_READY) { + if (code == LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) { consumer_data->cmd_sock = lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); if (consumer_data->cmd_sock < 0) { @@ -1791,7 +1791,7 @@ error_version: PERROR("close"); } kernel_tracer_fd = -1; - return LTTCOMM_KERN_VERSION; + return LTTNG_ERR_KERN_VERSION; error_modules: ret = close(kernel_tracer_fd); @@ -1806,9 +1806,9 @@ error: WARN("No kernel tracer available"); kernel_tracer_fd = -1; if (!is_root) { - return LTTCOMM_NEED_ROOT_SESSIOND; + return LTTNG_ERR_NEED_ROOT_SESSIOND; } else { - return LTTCOMM_KERN_NA; + return LTTNG_ERR_KERN_NA; } } @@ -1845,7 +1845,7 @@ static int copy_session_consumer(int domain, struct ltt_session *session) dir_name = DEFAULT_UST_TRACE_DIR; break; default: - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; goto error; } @@ -1854,7 +1854,7 @@ static int copy_session_consumer(int domain, struct ltt_session *session) sizeof(consumer->subdir) - strlen(consumer->subdir) - 1); DBG3("Copy session consumer subdir %s", consumer->subdir); - ret = LTTCOMM_OK; + ret = LTTNG_OK; error: return ret; @@ -1878,7 +1878,7 @@ static int create_ust_session(struct ltt_session *session, break; default: ERR("Unknown UST domain on create session %d", domain->type); - ret = LTTCOMM_UNKNOWN_DOMAIN; + ret = LTTNG_ERR_UNKNOWN_DOMAIN; goto error; } @@ -1886,7 +1886,7 @@ static int create_ust_session(struct ltt_session *session, lus = trace_ust_create_session(session->path, session->id, domain); if (lus == NULL) { - ret = LTTCOMM_UST_SESS_FAIL; + ret = LTTNG_ERR_UST_SESS_FAIL; goto error; } @@ -1896,11 +1896,11 @@ static int create_ust_session(struct ltt_session *session, /* Copy session output to the newly created UST session */ ret = copy_session_consumer(domain->type, session); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } - return LTTCOMM_OK; + return LTTNG_OK; error: free(lus); @@ -1919,7 +1919,7 @@ static int create_kernel_session(struct ltt_session *session) ret = kernel_create_session(session, kernel_tracer_fd); if (ret < 0) { - ret = LTTCOMM_KERN_SESS_FAIL; + ret = LTTNG_ERR_KERN_SESS_FAIL; goto error; } @@ -1928,7 +1928,7 @@ static int create_kernel_session(struct ltt_session *session) /* Copy session output to the newly created Kernel session */ ret = copy_session_consumer(LTTNG_DOMAIN_KERNEL, session); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -1949,7 +1949,7 @@ static int create_kernel_session(struct ltt_session *session) session->kernel_session->uid = session->uid; session->kernel_session->gid = session->gid; - return LTTCOMM_OK; + return LTTNG_OK; error: trace_kernel_destroy_session(session->kernel_session); @@ -1991,7 +1991,7 @@ static unsigned int lttng_sessions_count(uid_t uid, gid_t gid) static int process_client_msg(struct command_ctx *cmd_ctx, int sock, int *sock_error) { - int ret = LTTCOMM_OK; + int ret = LTTNG_OK; int need_tracing_session = 1; int need_domain; @@ -2015,9 +2015,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, if (opt_no_kernel && need_domain && cmd_ctx->lsm->domain.type == LTTNG_DOMAIN_KERNEL) { if (!is_root) { - ret = LTTCOMM_NEED_ROOT_SESSIOND; + ret = LTTNG_ERR_NEED_ROOT_SESSIOND; } else { - ret = LTTCOMM_KERN_NA; + ret = LTTNG_ERR_KERN_NA; } goto error; } @@ -2026,7 +2026,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, if (cmd_ctx->lsm->cmd_type == LTTNG_REGISTER_CONSUMER) { pthread_mutex_lock(&kconsumer_data.pid_mutex); if (kconsumer_data.pid > 0) { - ret = LTTCOMM_KERN_CONSUMER_FAIL; + ret = LTTNG_ERR_KERN_CONSUMER_FAIL; pthread_mutex_unlock(&kconsumer_data.pid_mutex); goto error; } @@ -2075,10 +2075,10 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, cmd_ctx->session = session_find_by_name(cmd_ctx->lsm->session.name); if (cmd_ctx->session == NULL) { if (cmd_ctx->lsm->session.name != NULL) { - ret = LTTCOMM_SESS_NOT_FOUND; + ret = LTTNG_ERR_SESS_NOT_FOUND; } else { /* If no session name specified */ - ret = LTTCOMM_SELECT_SESS; + ret = LTTNG_ERR_SELECT_SESS; } goto error; } else { @@ -2098,7 +2098,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, switch (cmd_ctx->lsm->domain.type) { case LTTNG_DOMAIN_KERNEL: if (!is_root) { - ret = LTTCOMM_NEED_ROOT_SESSIOND; + ret = LTTNG_ERR_NEED_ROOT_SESSIOND; goto error; } @@ -2113,7 +2113,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, /* Consumer is in an ERROR state. Report back to client */ if (uatomic_read(&kernel_consumerd_state) == CONSUMER_ERROR) { - ret = LTTCOMM_NO_KERNCONSUMERD; + ret = LTTNG_ERR_NO_KERNCONSUMERD; goto error; } @@ -2122,7 +2122,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, if (cmd_ctx->session->kernel_session == NULL) { ret = create_kernel_session(cmd_ctx->session); if (ret < 0) { - ret = LTTCOMM_KERN_SESS_FAIL; + ret = LTTNG_ERR_KERN_SESS_FAIL; goto error; } } @@ -2135,7 +2135,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, pthread_mutex_unlock(&kconsumer_data.pid_mutex); ret = start_consumerd(&kconsumer_data); if (ret < 0) { - ret = LTTCOMM_KERN_CONSUMER_FAIL; + ret = LTTNG_ERR_KERN_CONSUMER_FAIL; goto error; } uatomic_set(&kernel_consumerd_state, CONSUMER_STARTED); @@ -2159,7 +2159,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, { /* Consumer is in an ERROR state. Report back to client */ if (uatomic_read(&ust_consumerd_state) == CONSUMER_ERROR) { - ret = LTTCOMM_NO_USTCONSUMERD; + ret = LTTNG_ERR_NO_USTCONSUMERD; goto error; } @@ -2168,7 +2168,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, if (cmd_ctx->session->ust_session == NULL) { ret = create_ust_session(cmd_ctx->session, &cmd_ctx->lsm->domain); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } } @@ -2183,7 +2183,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, pthread_mutex_unlock(&ustconsumer64_data.pid_mutex); ret = start_consumerd(&ustconsumer64_data); if (ret < 0) { - ret = LTTCOMM_UST_CONSUMER64_FAIL; + ret = LTTNG_ERR_UST_CONSUMER64_FAIL; uatomic_set(&ust_consumerd64_fd, -EINVAL); goto error; } @@ -2212,7 +2212,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, pthread_mutex_unlock(&ustconsumer32_data.pid_mutex); ret = start_consumerd(&ustconsumer32_data); if (ret < 0) { - ret = LTTCOMM_UST_CONSUMER32_FAIL; + ret = LTTNG_ERR_UST_CONSUMER32_FAIL; uatomic_set(&ust_consumerd32_fd, -EINVAL); goto error; } @@ -2246,13 +2246,13 @@ skip_domain: switch (cmd_ctx->lsm->domain.type) { case LTTNG_DOMAIN_UST: if (uatomic_read(&ust_consumerd_state) != CONSUMER_STARTED) { - ret = LTTCOMM_NO_USTCONSUMERD; + ret = LTTNG_ERR_NO_USTCONSUMERD; goto error; } break; case LTTNG_DOMAIN_KERNEL: if (uatomic_read(&kernel_consumerd_state) != CONSUMER_STARTED) { - ret = LTTCOMM_NO_KERNCONSUMERD; + ret = LTTNG_ERR_NO_KERNCONSUMERD; goto error; } break; @@ -2267,7 +2267,7 @@ skip_domain: if (!session_access_ok(cmd_ctx->session, LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds), LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds))) { - ret = LTTCOMM_EPERM; + ret = LTTNG_ERR_EPERM; goto error; } } @@ -2321,7 +2321,7 @@ skip_domain: * be a DOMAIN enuam. */ ret = cmd_enable_consumer(cmd_ctx->lsm->domain.type, cmd_ctx->session); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -2361,6 +2361,7 @@ skip_domain: nb_events = cmd_list_tracepoints(cmd_ctx->lsm->domain.type, &events); if (nb_events < 0) { + /* Return value is a negative lttng_error_code. */ ret = -nb_events; goto error; } @@ -2381,7 +2382,7 @@ skip_domain: free(events); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_LIST_TRACEPOINT_FIELDS: @@ -2392,6 +2393,7 @@ skip_domain: nb_fields = cmd_list_tracepoint_fields(cmd_ctx->lsm->domain.type, &fields); if (nb_fields < 0) { + /* Return value is a negative lttng_error_code. */ ret = -nb_fields; goto error; } @@ -2413,7 +2415,7 @@ skip_domain: free(fields); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_SET_CONSUMER_URI: @@ -2425,13 +2427,13 @@ skip_domain: len = nb_uri * sizeof(struct lttng_uri); if (nb_uri == 0) { - ret = LTTCOMM_INVALID; + ret = LTTNG_ERR_INVALID; goto error; } uris = zmalloc(len); if (uris == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -2441,13 +2443,13 @@ skip_domain: if (ret <= 0) { DBG("No URIs received from client... continuing"); *sock_error = 1; - ret = LTTCOMM_SESSION_FAIL; + ret = LTTNG_ERR_SESSION_FAIL; goto error; } ret = cmd_set_consumer_uri(cmd_ctx->lsm->domain.type, cmd_ctx->session, nb_uri, uris); - if (ret != LTTCOMM_OK) { + if (ret != LTTNG_OK) { goto error; } @@ -2491,7 +2493,7 @@ skip_domain: if (nb_uri > 0) { uris = zmalloc(len); if (uris == NULL) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } @@ -2501,13 +2503,13 @@ skip_domain: if (ret <= 0) { DBG("No URIs received from client... continuing"); *sock_error = 1; - ret = LTTCOMM_SESSION_FAIL; + ret = LTTNG_ERR_SESSION_FAIL; goto error; } if (nb_uri == 1 && uris[0].dtype != LTTNG_DST_PATH) { DBG("Creating session with ONE network URI is a bad call"); - ret = LTTCOMM_SESSION_FAIL; + ret = LTTNG_ERR_SESSION_FAIL; goto error; } } @@ -2532,6 +2534,7 @@ skip_domain: nb_dom = cmd_list_domains(cmd_ctx->session, &domains); if (nb_dom < 0) { + /* Return value is a negative lttng_error_code. */ ret = -nb_dom; goto error; } @@ -2547,7 +2550,7 @@ skip_domain: free(domains); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_LIST_CHANNELS: @@ -2558,6 +2561,7 @@ skip_domain: nb_chan = cmd_list_channels(cmd_ctx->lsm->domain.type, cmd_ctx->session, &channels); if (nb_chan < 0) { + /* Return value is a negative lttng_error_code. */ ret = -nb_chan; goto error; } @@ -2573,7 +2577,7 @@ skip_domain: free(channels); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_LIST_EVENTS: @@ -2584,6 +2588,7 @@ skip_domain: nb_event = cmd_list_events(cmd_ctx->lsm->domain.type, cmd_ctx->session, cmd_ctx->lsm->u.list.channel_name, &events); if (nb_event < 0) { + /* Return value is a negative lttng_error_code. */ ret = -nb_event; goto error; } @@ -2599,7 +2604,7 @@ skip_domain: free(events); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_LIST_SESSIONS: @@ -2624,7 +2629,7 @@ skip_domain: session_unlock_list(); - ret = LTTCOMM_OK; + ret = LTTNG_OK; break; } case LTTNG_CALIBRATE: @@ -2642,7 +2647,7 @@ skip_domain: cdata = &kconsumer_data; break; default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; goto error; } @@ -2655,12 +2660,12 @@ skip_domain: struct lttng_filter_bytecode *bytecode; if (cmd_ctx->lsm->u.filter.bytecode_len > 65336) { - ret = LTTCOMM_FILTER_INVAL; + ret = LTTNG_ERR_FILTER_INVAL; goto error; } bytecode = zmalloc(cmd_ctx->lsm->u.filter.bytecode_len); if (!bytecode) { - ret = LTTCOMM_FILTER_NOMEM; + ret = LTTNG_ERR_FILTER_NOMEM; goto error; } /* Receive var. len. data */ @@ -2670,14 +2675,14 @@ skip_domain: if (ret <= 0) { DBG("Nothing recv() from client var len data... continuing"); *sock_error = 1; - ret = LTTCOMM_FILTER_INVAL; + ret = LTTNG_ERR_FILTER_INVAL; goto error; } if (bytecode->len + sizeof(*bytecode) != cmd_ctx->lsm->u.filter.bytecode_len) { free(bytecode); - ret = LTTCOMM_FILTER_INVAL; + ret = LTTNG_ERR_FILTER_INVAL; goto error; } @@ -2688,7 +2693,7 @@ skip_domain: break; } default: - ret = LTTCOMM_UND; + ret = LTTNG_ERR_UND; break; } @@ -2838,7 +2843,7 @@ restart: check_consumer_health(); break; default: - reply.ret_code = LTTCOMM_UND; + reply.ret_code = LTTNG_ERR_UND; break; } diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index 3764c1253..7d0ee7d4a 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -143,7 +143,7 @@ int session_destroy(struct ltt_session *session) /* Safety check */ if (session == NULL) { ERR("Session pointer was null on session destroy"); - return LTTCOMM_OK; + return LTTNG_OK; } DBG("Destroying session %s", session->name); @@ -155,7 +155,7 @@ int session_destroy(struct ltt_session *session) rcu_read_unlock(); free(session); - return LTTCOMM_OK; + return LTTNG_OK; } /* @@ -170,26 +170,26 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) new_session = zmalloc(sizeof(struct ltt_session)); if (new_session == NULL) { PERROR("zmalloc"); - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error_malloc; } /* Define session name */ if (name != NULL) { if (snprintf(new_session->name, NAME_MAX, "%s", name) < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error_asprintf; } } else { ERR("No session name given"); - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error; } /* Define session system path */ if (path != NULL) { if (snprintf(new_session->path, PATH_MAX, "%s", path) < 0) { - ret = LTTCOMM_FATAL; + ret = LTTNG_ERR_FATAL; goto error_asprintf; } new_session->start_consumer = 1; @@ -216,7 +216,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) if (ret < 0) { if (ret != -EEXIST) { ERR("Trace directory creation error"); - ret = LTTCOMM_CREATE_DIR_FAIL; + ret = LTTNG_ERR_CREATE_DIR_FAIL; goto error; } } @@ -235,7 +235,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) DBG("Tracing session %s created in %s with ID %u by UID %d GID %d", name, path, new_session->id, new_session->uid, new_session->gid); - return LTTCOMM_OK; + return LTTNG_OK; error: error_asprintf: diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 6a2cfc988..af0a51b88 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2196,6 +2196,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) ret = create_ust_app_metadata(ua_sess, usess->pathname, app); if (ret < 0) { + ret = LTTNG_ERR_UST_META_FAIL; goto error_rcu_unlock; } @@ -2227,6 +2228,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Got all streams */ lttng_fd_put(LTTNG_FD_APPS, 2); free(ustream); + ret = LTTNG_ERR_UST_STREAM_FAIL; break; } ustream->handle = ustream->obj->handle; diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 95a0a6ab3..96bb184a7 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -338,7 +338,7 @@ static int create_session(void) if (ret < 0) { /* Don't set ret so lttng can interpret the sessiond error. */ switch (-ret) { - case LTTCOMM_EXIST_SESS: + case LTTNG_ERR_EXIST_SESS: WARN("Session %s already exists", session_name); break; } diff --git a/src/bin/lttng/commands/destroy.c b/src/bin/lttng/commands/destroy.c index fea96f175..f26da0669 100644 --- a/src/bin/lttng/commands/destroy.c +++ b/src/bin/lttng/commands/destroy.c @@ -74,7 +74,7 @@ static int destroy_session(const char *session_name) ret = lttng_destroy_session(session_name); if (ret < 0) { switch (-ret) { - case LTTCOMM_SESS_NOT_FOUND: + case LTTNG_ERR_SESS_NOT_FOUND: WARN("Session name %s not found", session_name); break; default: diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 57c8a1eb8..a5b15fae7 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -186,8 +186,8 @@ static int enable_channel(char *session_name) ret = lttng_enable_channel(handle, &chan); if (ret < 0) { switch (-ret) { - case LTTCOMM_KERN_CHAN_EXIST: - case LTTCOMM_UST_CHAN_EXIST: + case LTTNG_ERR_KERN_CHAN_EXIST: + case LTTNG_ERR_UST_CHAN_EXIST: WARN("Channel %s: %s (session %s", channel_name, lttng_strerror(ret), session_name); goto error; diff --git a/src/bin/lttng/commands/enable_consumer.c b/src/bin/lttng/commands/enable_consumer.c index 692cdda02..e59608950 100644 --- a/src/bin/lttng/commands/enable_consumer.c +++ b/src/bin/lttng/commands/enable_consumer.c @@ -208,7 +208,7 @@ static int enable_consumer(char *session_name) if (ret < 0) { ERR("Enabling consumer for session %s: %s", session_name, lttng_strerror(ret)); - if (ret == -LTTCOMM_ENABLE_CONSUMER_FAIL) { + if (ret == -LTTNG_ERR_ENABLE_CONSUMER_FAIL) { ERR("Perhaps the session was previously started?"); } goto error; diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index a2c8a68b2..5a22c9513 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -369,7 +369,7 @@ static int enable_events(char *session_name) ret = lttng_enable_event(handle, &ev, channel_name); if (ret < 0) { switch (-ret) { - case LTTCOMM_KERN_EVENT_EXIST: + case LTTNG_ERR_KERN_EVENT_EXIST: WARN("Kernel events already enabled (channel %s, session %s)", channel_name, session_name); break; @@ -536,7 +536,7 @@ static int enable_events(char *session_name) if (ret < 0) { /* Turn ret to positive value to handle the positive error code */ switch (-ret) { - case LTTCOMM_KERN_EVENT_EXIST: + case LTTNG_ERR_KERN_EVENT_EXIST: WARN("Kernel event %s already enabled (channel %s, session %s)", event_name, channel_name, session_name); break; diff --git a/src/bin/lttng/commands/start.c b/src/bin/lttng/commands/start.c index b1840c3e8..82122cc63 100644 --- a/src/bin/lttng/commands/start.c +++ b/src/bin/lttng/commands/start.c @@ -83,7 +83,7 @@ static int start_tracing(void) ret = lttng_start_tracing(session_name); if (ret < 0) { switch (-ret) { - case LTTCOMM_TRACE_ALREADY_STARTED: + case LTTNG_ERR_TRACE_ALREADY_STARTED: WARN("Tracing already started for session %s", session_name); break; default: diff --git a/src/bin/lttng/commands/stop.c b/src/bin/lttng/commands/stop.c index 998a2a42a..7c89e37e5 100644 --- a/src/bin/lttng/commands/stop.c +++ b/src/bin/lttng/commands/stop.c @@ -79,7 +79,7 @@ static int stop_tracing(void) ret = lttng_stop_tracing(session_name); if (ret < 0) { switch (-ret) { - case LTTCOMM_TRACE_ALREADY_STOPPED: + case LTTNG_ERR_TRACE_ALREADY_STOPPED: WARN("Tracing already stopped for session %s", session_name); break; default: diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 84bed094f..ca48153c3 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -9,7 +9,7 @@ noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h uri.h utils. # Common library noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = utils.c utils.h runas.c runas.h common.h futex.c futex.h uri.c uri.h +libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h common.h futex.c futex.h uri.c uri.h # Consumer library noinst_LTLIBRARIES += libconsumer.la diff --git a/src/common/consumer.c b/src/common/consumer.c index 2ee6c3313..008bf8e54 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1376,16 +1376,16 @@ splice_error: /* send the appropriate error description to sessiond */ switch (ret) { case EBADF: - lttng_consumer_send_error(ctx, CONSUMERD_SPLICE_EBADF); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_SPLICE_EBADF); break; case EINVAL: - lttng_consumer_send_error(ctx, CONSUMERD_SPLICE_EINVAL); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_SPLICE_EINVAL); break; case ENOMEM: - lttng_consumer_send_error(ctx, CONSUMERD_SPLICE_ENOMEM); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_SPLICE_ENOMEM); break; case ESPIPE: - lttng_consumer_send_error(ctx, CONSUMERD_SPLICE_ESPIPE); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_SPLICE_ESPIPE); break; } @@ -1523,7 +1523,7 @@ void *lttng_consumer_thread_poll_fds(void *data) metadata_ht); if (ret < 0) { ERR("Error in allocating pollfd or local_outfds"); - lttng_consumer_send_error(ctx, CONSUMERD_POLL_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_POLL_ERROR); pthread_mutex_unlock(&consumer_data.lock); goto end; } @@ -1549,7 +1549,7 @@ void *lttng_consumer_thread_poll_fds(void *data) goto restart; } perror("Poll error"); - lttng_consumer_send_error(ctx, CONSUMERD_POLL_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_POLL_ERROR); goto end; } else if (num_rdy == 0) { DBG("Polling thread timed out"); @@ -1726,7 +1726,7 @@ void *lttng_consumer_thread_receive_fds(void *data) } DBG("Sending ready command to lttng-sessiond"); - ret = lttng_consumer_send_error(ctx, CONSUMERD_COMMAND_SOCK_READY); + ret = lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_COMMAND_SOCK_READY); /* return < 0 on error, but == 0 is not fatal */ if (ret < 0) { ERR("Error sending ready command to lttng-sessiond"); @@ -1882,7 +1882,7 @@ int consumer_add_relayd_socket(int net_seq_idx, int sock_type, /* Not found. Allocate one. */ relayd = consumer_allocate_relayd_sock_pair(net_seq_idx); if (relayd == NULL) { - lttng_consumer_send_error(ctx, CONSUMERD_OUTFD_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto error; } } @@ -1896,7 +1896,7 @@ int consumer_add_relayd_socket(int net_seq_idx, int sock_type, /* Get relayd socket from session daemon */ ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1); if (ret != sizeof(fd)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); ret = -1; goto error; } diff --git a/src/common/error.c b/src/common/error.c new file mode 100644 index 000000000..016027acd --- /dev/null +++ b/src/common/error.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2012 - David Goulet + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _GNU_SOURCE +#include + +#include + +#include "error.h" + +#define ERROR_INDEX(code) (code - LTTNG_OK) + +/* + * Human readable error message. + */ +static const char *error_string_array[] = { + /* LTTNG_OK code MUST be at the top for the ERROR_INDEX macro to work */ + [ ERROR_INDEX(LTTNG_OK) ] = "Success", + [ ERROR_INDEX(LTTNG_ERR_UNK) ] = "Unknown error", + [ ERROR_INDEX(LTTNG_ERR_UND) ] = "Undefined command", + [ ERROR_INDEX(LTTNG_ERR_UNKNOWN_DOMAIN) ] = "Unknown tracing domain", + [ ERROR_INDEX(LTTNG_ERR_NO_SESSION) ] = "No session found", + [ ERROR_INDEX(LTTNG_ERR_CREATE_DIR_FAIL) ] = "Create directory failed", + [ ERROR_INDEX(LTTNG_ERR_SESSION_FAIL) ] = "Create session failed", + [ ERROR_INDEX(LTTNG_ERR_SESS_NOT_FOUND) ] = "Session name not found", + [ ERROR_INDEX(LTTNG_ERR_FATAL) ] = "Fatal error of the session daemon", + [ ERROR_INDEX(LTTNG_ERR_SELECT_SESS) ] = "A session MUST be selected", + [ ERROR_INDEX(LTTNG_ERR_EXIST_SESS) ] = "Session name already exist", + [ ERROR_INDEX(LTTNG_ERR_NO_EVENT) ] = "Event not found", + [ ERROR_INDEX(LTTNG_ERR_CONNECT_FAIL) ] = "Unable to connect to Unix socket", + [ ERROR_INDEX(LTTNG_ERR_EPERM) ] = "Permission denied", + [ ERROR_INDEX(LTTNG_ERR_KERN_NA) ] = "Kernel tracer not available", + [ ERROR_INDEX(LTTNG_ERR_KERN_VERSION) ] = "Kernel tracer version is not compatible", + [ ERROR_INDEX(LTTNG_ERR_KERN_EVENT_EXIST) ] = "Kernel event already exists", + [ ERROR_INDEX(LTTNG_ERR_KERN_SESS_FAIL) ] = "Kernel create session failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_CHAN_EXIST) ] = "Kernel channel already exists", + [ ERROR_INDEX(LTTNG_ERR_KERN_CHAN_FAIL) ] = "Kernel create channel failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_CHAN_NOT_FOUND) ] = "Kernel channel not found", + [ ERROR_INDEX(LTTNG_ERR_KERN_CHAN_DISABLE_FAIL) ] = "Disable kernel channel failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_CHAN_ENABLE_FAIL) ] = "Enable kernel channel failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_CONTEXT_FAIL) ] = "Add kernel context failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_ENABLE_FAIL) ] = "Enable kernel event failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_DISABLE_FAIL) ] = "Disable kernel event failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_META_FAIL) ] = "Opening metadata failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_START_FAIL) ] = "Starting kernel trace failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_STOP_FAIL) ] = "Stoping kernel trace failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_CONSUMER_FAIL) ] = "Kernel consumer start failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_STREAM_FAIL) ] = "Kernel create stream failed", + [ ERROR_INDEX(LTTNG_ERR_KERN_LIST_FAIL) ] = "Listing kernel events failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CALIBRATE_FAIL) ] = "UST calibration failed", + [ ERROR_INDEX(LTTNG_ERR_UST_SESS_FAIL) ] = "UST create session failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CHAN_FAIL) ] = "UST create channel failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CHAN_EXIST) ] = "UST channel already exist", + [ ERROR_INDEX(LTTNG_ERR_UST_CHAN_NOT_FOUND) ] = "UST channel not found", + [ ERROR_INDEX(LTTNG_ERR_UST_CHAN_DISABLE_FAIL) ] = "Disable UST channel failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CHAN_ENABLE_FAIL) ] = "Enable UST channel failed", + [ ERROR_INDEX(LTTNG_ERR_UST_ENABLE_FAIL) ] = "Enable UST event failed", + [ ERROR_INDEX(LTTNG_ERR_UST_DISABLE_FAIL) ] = "Disable UST event failed", + [ ERROR_INDEX(LTTNG_ERR_UST_META_FAIL) ] = "Opening metadata failed", + [ ERROR_INDEX(LTTNG_ERR_UST_START_FAIL) ] = "Starting UST trace failed", + [ ERROR_INDEX(LTTNG_ERR_UST_STOP_FAIL) ] = "Stoping UST trace failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CONSUMER64_FAIL) ] = "64-bit UST consumer start failed", + [ ERROR_INDEX(LTTNG_ERR_UST_CONSUMER32_FAIL) ] = "32-bit UST consumer start failed", + [ ERROR_INDEX(LTTNG_ERR_UST_STREAM_FAIL) ] = "UST create stream failed", + [ ERROR_INDEX(LTTNG_ERR_UST_LIST_FAIL) ] = "Listing UST events failed", + [ ERROR_INDEX(LTTNG_ERR_UST_EVENT_EXIST) ] = "UST event already exist", + [ ERROR_INDEX(LTTNG_ERR_UST_EVENT_NOT_FOUND)] = "UST event not found", + [ 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 and \"tracing\" group user membership", + [ 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", + [ ERROR_INDEX(LTTNG_ERR_INVALID) ] = "Invalid parameter", + [ ERROR_INDEX(LTTNG_ERR_NO_USTCONSUMERD) ] = "No UST consumer detected", + [ ERROR_INDEX(LTTNG_ERR_NO_KERNCONSUMERD) ] = "No kernel consumer detected", + [ ERROR_INDEX(LTTNG_ERR_EVENT_EXIST_LOGLEVEL) ] = "Event already enabled with different loglevel", + [ ERROR_INDEX(LTTNG_ERR_URL_DATA_MISS) ] = "Missing data path URL", + [ ERROR_INDEX(LTTNG_ERR_URL_CTRL_MISS) ] = "Missing control data path URL", + [ ERROR_INDEX(LTTNG_ERR_ENABLE_CONSUMER_FAIL) ] = "Enabling consumer failed", + [ ERROR_INDEX(LTTNG_ERR_RELAYD_CONNECT_FAIL) ] = "Unable to connect to lttng-relayd", + [ ERROR_INDEX(LTTNG_ERR_RELAYD_VERSION_FAIL) ] = "Relay daemon not compatible", + [ ERROR_INDEX(LTTNG_ERR_FILTER_INVAL) ] = "Invalid filter bytecode", + [ ERROR_INDEX(LTTNG_ERR_FILTER_NOMEM) ] = "Not enough memory for filter bytecode", + [ ERROR_INDEX(LTTNG_ERR_FILTER_EXIST) ] = "Filter already exist", + [ ERROR_INDEX(LTTNG_ERR_NO_CONSUMER) ] = "Consumer not found for tracing session", + + /* Last element */ + [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code" +}; + +/* + * Return ptr to string representing a human readable error code from the + * lttng_error_code enum. + * + * These code MUST be negative in other to treat that as an error value. + */ +const char *error_get_str(int32_t code) +{ + code = -code; + + if (code < LTTNG_OK || code > LTTNG_ERR_NR) { + code = LTTNG_ERR_NR; + } + + return error_string_array[ERROR_INDEX(code)]; +} diff --git a/src/common/error.h b/src/common/error.h index 4350408e6..03af109a1 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -20,12 +20,15 @@ #include #include +#include #include #ifndef _GNU_SOURCE #error "lttng-tools error.h needs _GNU_SOURCE" #endif +#include + /* Stringify the expansion of a define */ #define XSTR(d) STR(d) #define STR(s) #s @@ -109,4 +112,6 @@ extern int lttng_opt_verbose; } while(0); #endif +const char *error_get_str(int32_t code); + #endif /* _ERROR_H */ diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 4a7ba0451..86e405158 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -92,7 +92,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ret = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg)); if (ret != sizeof(msg)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_CMD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); return ret; } if (msg.cmd_type == LTTNG_CONSUMER_STOP) { @@ -120,7 +120,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.channel.mmap_len, msg.u.channel.max_sb_size); if (new_channel == NULL) { - lttng_consumer_send_error(ctx, CONSUMERD_OUTFD_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; } if (ctx->on_recv_channel != NULL) { @@ -150,7 +150,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, /* Get stream file descriptor from socket */ ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1); if (ret != sizeof(fd)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); rcu_read_unlock(); return ret; } @@ -167,7 +167,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.stream.net_index, msg.u.stream.metadata_flag); if (new_stream == NULL) { - lttng_consumer_send_error(ctx, CONSUMERD_OUTFD_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; } diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index f79555fa8..27cb58e52 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -136,7 +136,7 @@ int relayd_add_stream(struct lttcomm_sock *sock, const char *channel_name, reply.ret_code = be32toh(reply.ret_code); /* Return session id or negative ret code. */ - if (reply.ret_code != LTTCOMM_OK) { + if (reply.ret_code != LTTNG_OK) { ret = -reply.ret_code; ERR("Relayd add stream replied error %d", ret); } else { @@ -328,7 +328,7 @@ int relayd_send_close_stream(struct lttcomm_sock *sock, uint64_t stream_id, reply.ret_code = be32toh(reply.ret_code); /* Return session id or negative ret code. */ - if (reply.ret_code != LTTCOMM_OK) { + if (reply.ret_code != LTTNG_OK) { ret = -reply.ret_code; ERR("Relayd close stream replied error %d", ret); } else { diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index aee9458b4..01e5f865d 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -48,105 +48,23 @@ struct lttcomm_net_family net_families[] = { * Human readable error message. */ static const char *lttcomm_readable_code[] = { - [ LTTCOMM_ERR_INDEX(LTTCOMM_OK) ] = "Success", - [ LTTCOMM_ERR_INDEX(LTTCOMM_ERR) ] = "Unknown error", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UND) ] = "Undefined command", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NOT_IMPLEMENTED) ] = "Not implemented", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UNKNOWN_DOMAIN) ] = "Unknown tracing domain", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_SESSION) ] = "No session found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_LIST_FAIL) ] = "Unable to list traceable apps", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_APPS) ] = "No traceable apps found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_SESS_NOT_FOUND) ] = "Session name not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACE) ] = "No trace found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_FATAL) ] = "Fatal error of the session daemon", - [ LTTCOMM_ERR_INDEX(LTTCOMM_CREATE_DIR_FAIL) ] = "Create directory failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_START_FAIL) ] = "Start trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_STOP_FAIL) ] = "Stop trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_TRACEABLE) ] = "App is not traceable", - [ LTTCOMM_ERR_INDEX(LTTCOMM_SELECT_SESS) ] = "A session MUST be selected", - [ LTTCOMM_ERR_INDEX(LTTCOMM_EXIST_SESS) ] = "Session name already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_CONNECT_FAIL) ] = "Unable to connect to Unix socket", - [ LTTCOMM_ERR_INDEX(LTTCOMM_APP_NOT_FOUND) ] = "Application not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_EPERM) ] = "Permission denied", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_NA) ] = "Kernel tracer not available", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_VERSION) ] = "Kernel tracer version is not compatible", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_EVENT_EXIST) ] = "Kernel event already exists", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_SESS_FAIL) ] = "Kernel create session failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_EXIST) ] = "Kernel channel already exists", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_FAIL) ] = "Kernel create channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_NOT_FOUND) ] = "Kernel channel not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_DISABLE_FAIL) ] = "Disable kernel channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_ENABLE_FAIL) ] = "Enable kernel channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CONTEXT_FAIL) ] = "Add kernel context failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_ENABLE_FAIL) ] = "Enable kernel event failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DISABLE_FAIL) ] = "Disable kernel event failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_META_FAIL) ] = "Opening metadata failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_START_FAIL) ] = "Starting kernel trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_STOP_FAIL) ] = "Stoping kernel trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CONSUMER_FAIL) ] = "Kernel consumer start failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_STREAM_FAIL) ] = "Kernel create stream failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DIR_FAIL) ] = "Kernel trace directory creation failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DIR_EXIST) ] = "Kernel trace directory already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_NO_SESSION) ] = "No kernel session found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_LIST_FAIL) ] = "Listing kernel events failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CALIBRATE_FAIL) ] = "UST calibration failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_VERSION) ] = "UST tracer version is not compatible", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_SESS_FAIL) ] = "UST create session failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CHAN_FAIL) ] = "UST create channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CHAN_EXIST) ] = "UST channel already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CHAN_NOT_FOUND) ] = "UST channel not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CHAN_DISABLE_FAIL) ] = "Disable UST channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CHAN_ENABLE_FAIL) ] = "Enable UST channel failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONTEXT_FAIL) ] = "Add UST context failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_ENABLE_FAIL) ] = "Enable UST event failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_DISABLE_FAIL) ] = "Disable UST event failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_META_FAIL) ] = "Opening metadata failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_START_FAIL) ] = "Starting UST trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_STOP_FAIL) ] = "Stoping UST trace failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONSUMER64_FAIL) ] = "64-bit UST consumer start failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONSUMER32_FAIL) ] = "32-bit UST consumer start failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_STREAM_FAIL) ] = "UST create stream failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_DIR_FAIL) ] = "UST trace directory creation failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_DIR_EXIST) ] = "UST trace directory already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_NO_SESSION) ] = "No UST session found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_LIST_FAIL) ] = "Listing UST events failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_EVENT_EXIST) ] = "UST event already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_EVENT_NOT_FOUND)] = "UST event not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONTEXT_EXIST)] = "UST context already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_UST_CONTEXT_INVAL)] = "UST invalid context", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "Tracing the kernel requires a root lttng-sessiond daemon and \"tracing\" group user membership", - [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STARTED) ] = "Tracing already started", - [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped", - [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported", - - [ LTTCOMM_ERR_INDEX(CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready", - [ LTTCOMM_ERR_INDEX(CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds", - [ LTTCOMM_ERR_INDEX(CONSUMERD_ERROR_RECV_FD) ] = "consumerd error on receiving fds", - [ LTTCOMM_ERR_INDEX(CONSUMERD_ERROR_RECV_CMD) ] = "consumerd error on receiving command", - [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_ERROR) ] = "consumerd error in polling thread", - [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_NVAL) ] = "consumerd polling on closed fd", - [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_HUP) ] = "consumerd all fd hung up", - [ LTTCOMM_ERR_INDEX(CONSUMERD_EXIT_SUCCESS) ] = "consumerd exiting normally", - [ LTTCOMM_ERR_INDEX(CONSUMERD_EXIT_FAILURE) ] = "consumerd exiting on error", - [ LTTCOMM_ERR_INDEX(CONSUMERD_OUTFD_ERROR) ] = "consumerd error opening the tracefile", - [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_EBADF) ] = "consumerd splice EBADF", - [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_EINVAL) ] = "consumerd splice EINVAL", - [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ENOMEM) ] = "consumerd splice ENOMEM", - [ LTTCOMM_ERR_INDEX(CONSUMERD_SPLICE_ESPIPE) ] = "consumerd splice ESPIPE", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_EVENT) ] = "Event not found", - [ LTTCOMM_ERR_INDEX(LTTCOMM_INVALID) ] = "Invalid parameter", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_USTCONSUMERD) ] = "No UST consumer detected", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_KERNCONSUMERD) ] = "No kernel consumer detected", - [ LTTCOMM_ERR_INDEX(LTTCOMM_EVENT_EXIST_LOGLEVEL) ] = "Event already enabled with different loglevel", - [ LTTCOMM_ERR_INDEX(LTTCOMM_URL_DATA_MISS) ] = "Missing data path URL", - [ LTTCOMM_ERR_INDEX(LTTCOMM_URL_CTRL_MISS) ] = "Missing control data path URL", - [ LTTCOMM_ERR_INDEX(LTTCOMM_ENABLE_CONSUMER_FAIL) ] = "Enabling consumer failed", - [ LTTCOMM_ERR_INDEX(LTTCOMM_RELAYD_SESSION_FAIL) ] = "Unable to create session on lttng-relayd", - [ LTTCOMM_ERR_INDEX(LTTCOMM_RELAYD_VERSION_FAIL) ] = "Relay daemon not compatible", - [ LTTCOMM_ERR_INDEX(LTTCOMM_FILTER_INVAL) ] = "Invalid filter bytecode", - [ LTTCOMM_ERR_INDEX(LTTCOMM_FILTER_NOMEM) ] = "Not enough memory for filter bytecode", - [ LTTCOMM_ERR_INDEX(LTTCOMM_FILTER_EXIST) ] = "Filter already exist", - [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_CONSUMER) ] = "Consumer not found for tracing session", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_ERROR_RECV_FD) ] = "consumerd error on receiving fds", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_ERROR_RECV_CMD) ] = "consumerd error on receiving command", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_POLL_ERROR) ] = "consumerd error in polling thread", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_POLL_NVAL) ] = "consumerd polling on closed fd", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_POLL_HUP) ] = "consumerd all fd hung up", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_EXIT_SUCCESS) ] = "consumerd exiting normally", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_EXIT_FAILURE) ] = "consumerd exiting on error", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_OUTFD_ERROR) ] = "consumerd error opening the tracefile", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_SPLICE_EBADF) ] = "consumerd splice EBADF", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_SPLICE_EINVAL) ] = "consumerd splice EINVAL", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_SPLICE_ENOMEM) ] = "consumerd splice ENOMEM", + [ LTTCOMM_ERR_INDEX(LTTCOMM_CONSUMERD_SPLICE_ESPIPE) ] = "consumerd splice ESPIPE", + + /* Last element */ + [ LTTCOMM_ERR_INDEX(LTTCOMM_NR) ] = "Unknown error code" }; /* @@ -157,13 +75,13 @@ static const char *lttcomm_readable_code[] = { */ const char *lttcomm_get_readable_code(enum lttcomm_return_code code) { - int tmp_code = -code; + code = -code; - if (tmp_code >= LTTCOMM_OK && tmp_code < LTTCOMM_NR) { - return lttcomm_readable_code[LTTCOMM_ERR_INDEX(tmp_code)]; + if (code < LTTCOMM_CONSUMERD_COMMAND_SOCK_READY && code > LTTCOMM_NR) { + code = LTTCOMM_NR; } - return "Unknown error code"; + return lttcomm_readable_code[LTTCOMM_ERR_INDEX(code)]; } /* diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index e544bf545..32ce38430 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -48,7 +48,7 @@ /* * Get the error code index from 0 since LTTCOMM_OK start at 1000 */ -#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) +#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) enum lttcomm_sessiond_command { /* Tracer command */ @@ -93,107 +93,20 @@ enum lttcomm_sessiond_command { * lttcomm error code. */ enum lttcomm_return_code { - LTTCOMM_OK = 10, /* Ok */ - LTTCOMM_ERR, /* Unknown Error */ - LTTCOMM_UND, /* Undefine command */ - LTTCOMM_NOT_IMPLEMENTED, /* Command not implemented */ - LTTCOMM_UNKNOWN_DOMAIN, /* Tracing domain not known */ - LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */ - LTTCOMM_NO_SESSION, /* No session found */ - LTTCOMM_CREATE_DIR_FAIL, /* Create directory fail */ - LTTCOMM_SESSION_FAIL, /* Create session fail */ - LTTCOMM_START_FAIL, /* Start tracing fail */ - LTTCOMM_STOP_FAIL, /* Stop tracing fail */ - LTTCOMM_LIST_FAIL, /* Listing apps fail */ - LTTCOMM_NO_APPS, /* No traceable application */ - LTTCOMM_SESS_NOT_FOUND, /* Session name not found */ - LTTCOMM_NO_TRACE, /* No trace exist */ - LTTCOMM_FATAL, /* Session daemon had a fatal error */ - LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */ - LTTCOMM_SELECT_SESS, /* Must select a session */ - LTTCOMM_EXIST_SESS, /* Session name already exist */ - LTTCOMM_NO_EVENT, /* No event found */ - LTTCOMM_CONNECT_FAIL, /* Unable to connect to unix socket */ - LTTCOMM_APP_NOT_FOUND, /* App not found in traceable app list */ - LTTCOMM_EPERM, /* Permission denied */ - LTTCOMM_KERN_NA, /* Kernel tracer unavalable */ - LTTCOMM_KERN_VERSION, /* Kernel tracer version is not compatible */ - LTTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */ - LTTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */ - LTTCOMM_KERN_CHAN_EXIST, /* Kernel channel already exists */ - LTTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */ - LTTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */ - LTTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */ - LTTCOMM_KERN_CHAN_ENABLE_FAIL, /* Kernel enable channel failed */ - LTTCOMM_KERN_CONTEXT_FAIL, /* Kernel add context failed */ - LTTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */ - LTTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */ - LTTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */ - LTTCOMM_KERN_START_FAIL, /* Kernel start trace failed */ - LTTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */ - LTTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */ - LTTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */ - LTTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */ - LTTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */ - LTTCOMM_KERN_NO_SESSION, /* No kernel session found */ - LTTCOMM_KERN_LIST_FAIL, /* Kernel listing events failed */ - LTTCOMM_UST_CALIBRATE_FAIL, /* UST calibration failed */ - LTTCOMM_UST_VERSION, /* UST tracer version is not compatible */ - LTTCOMM_UST_SESS_FAIL, /* UST create session failed */ - LTTCOMM_UST_CHAN_EXIST, /* UST channel already exist */ - LTTCOMM_UST_CHAN_FAIL, /* UST create channel failed */ - LTTCOMM_UST_CHAN_NOT_FOUND, /* UST channel not found */ - LTTCOMM_UST_CHAN_DISABLE_FAIL, /* UST disable channel failed */ - LTTCOMM_UST_CHAN_ENABLE_FAIL, /* UST enable channel failed */ - LTTCOMM_UST_CONTEXT_FAIL, /* UST add context failed */ - LTTCOMM_UST_ENABLE_FAIL, /* UST enable event failed */ - LTTCOMM_UST_DISABLE_FAIL, /* UST disable event failed */ - LTTCOMM_UST_META_FAIL, /* UST open metadata failed */ - LTTCOMM_UST_START_FAIL, /* UST start trace failed */ - LTTCOMM_UST_STOP_FAIL, /* UST stop trace failed */ - LTTCOMM_UST_CONSUMER64_FAIL, /* 64-bit UST consumer start failed */ - LTTCOMM_UST_CONSUMER32_FAIL, /* 32-bit UST consumer start failed */ - LTTCOMM_UST_STREAM_FAIL, /* UST create stream failed */ - LTTCOMM_UST_DIR_FAIL, /* UST trace directory creation failed */ - LTTCOMM_UST_DIR_EXIST, /* UST trace directory exist */ - LTTCOMM_UST_NO_SESSION, /* No UST session found */ - LTTCOMM_UST_LIST_FAIL, /* UST listing events failed */ - LTTCOMM_UST_EVENT_EXIST, /* UST event exist */ - LTTCOMM_UST_EVENT_NOT_FOUND, /* UST event not found */ - LTTCOMM_UST_CONTEXT_EXIST, /* UST context exist */ - LTTCOMM_UST_CONTEXT_INVAL, /* UST context invalid */ - LTTCOMM_NEED_ROOT_SESSIOND, /* root sessiond is needed */ - LTTCOMM_TRACE_ALREADY_STARTED, /* Tracing already started */ - LTTCOMM_TRACE_ALREADY_STOPPED, /* Tracing already stopped */ - LTTCOMM_KERN_EVENT_ENOSYS, /* Kernel event type not supported */ - - CONSUMERD_COMMAND_SOCK_READY, /* when consumerd command socket ready */ - CONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */ - CONSUMERD_ERROR_RECV_FD, /* error on receiving fds */ - CONSUMERD_ERROR_RECV_CMD, /* error on receiving command */ - CONSUMERD_POLL_ERROR, /* Error in polling thread in kconsumerd */ - CONSUMERD_POLL_NVAL, /* Poll on closed fd */ - CONSUMERD_POLL_HUP, /* All fds have hungup */ - CONSUMERD_EXIT_SUCCESS, /* kconsumerd exiting normally */ - CONSUMERD_EXIT_FAILURE, /* kconsumerd exiting on error */ - CONSUMERD_OUTFD_ERROR, /* error opening the tracefile */ - CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */ - CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */ - CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ - CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ - LTTCOMM_INVALID, /* Invalid parameter */ - LTTCOMM_NO_USTCONSUMERD, /* No UST consumer detected */ - LTTCOMM_NO_KERNCONSUMERD, /* No Kernel consumer detected */ - LTTCOMM_EVENT_EXIST_LOGLEVEL, /* Event already enabled with different loglevel */ - LTTCOMM_URL_DATA_MISS, /* Missing network data URL */ - LTTCOMM_URL_CTRL_MISS, /* Missing network control URL */ - LTTCOMM_ENABLE_CONSUMER_FAIL, /* Enabling consumer failed */ - LTTCOMM_RELAYD_SESSION_FAIL, /* lttng-relayd create session failed */ - LTTCOMM_RELAYD_VERSION_FAIL, /* lttng-relayd not compatible */ - LTTCOMM_FILTER_INVAL, /* Invalid filter bytecode */ - LTTCOMM_FILTER_NOMEM, /* Lack of memory for filter bytecode */ - LTTCOMM_FILTER_EXIST, /* Filter already exist */ - LTTCOMM_NO_CONSUMER, /* No consumer exist for the tracing session */ + LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 1, /* Command socket ready */ + LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */ + LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */ + LTTCOMM_CONSUMERD_ERROR_RECV_CMD, /* Error on receiving command */ + LTTCOMM_CONSUMERD_POLL_ERROR, /* Error in polling thread */ + LTTCOMM_CONSUMERD_POLL_NVAL, /* Poll on closed fd */ + LTTCOMM_CONSUMERD_POLL_HUP, /* All fds have hungup */ + LTTCOMM_CONSUMERD_EXIT_SUCCESS, /* Consumerd exiting normally */ + LTTCOMM_CONSUMERD_EXIT_FAILURE, /* Consumerd exiting on error */ + LTTCOMM_CONSUMERD_OUTFD_ERROR, /* Error opening the tracefile */ + LTTCOMM_CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */ + LTTCOMM_CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */ + LTTCOMM_CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ + LTTCOMM_CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ /* MUST be last element */ LTTCOMM_NR, /* Last element */ diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 9cafe398e..855d07141 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -102,7 +102,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, if (ret != sizeof(msg)) { DBG("Consumer received unexpected message size %zd (expects %zu)", ret, sizeof(msg)); - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); return ret; } if (msg.cmd_type == LTTNG_CONSUMER_STOP) { @@ -135,7 +135,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } ret = lttcomm_recv_fds_unix_sock(sock, fds, nb_fd); if (ret != sizeof(fds)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); rcu_read_unlock(); return ret; } @@ -147,7 +147,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.channel.mmap_len, msg.u.channel.max_sb_size); if (new_channel == NULL) { - lttng_consumer_send_error(ctx, CONSUMERD_OUTFD_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; } if (ctx->on_recv_channel != NULL) { @@ -178,7 +178,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } ret = lttcomm_recv_fds_unix_sock(sock, fds, nb_fd); if (ret != sizeof(fds)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); rcu_read_unlock(); return ret; } @@ -200,7 +200,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.stream.net_index, msg.u.stream.metadata_flag); if (new_stream == NULL) { - lttng_consumer_send_error(ctx, CONSUMERD_OUTFD_ERROR); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; } diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 3bef3b6d7..ef288726a 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -524,7 +524,7 @@ static int ask_sessiond_varlen(struct lttcomm_session_msg *lsm, } /* Check error code if OK */ - if (llm.ret_code != LTTCOMM_OK) { + if (llm.ret_code != LTTNG_OK) { ret = -llm.ret_code; goto end; } @@ -1041,18 +1041,13 @@ int lttng_list_tracepoint_fields(struct lttng_handle *handle, */ const char *lttng_strerror(int code) { - /* lttcomm error codes range from -LTTCOMM_OK down to -LTTCOMM_NR */ - if (code > -LTTCOMM_OK) { - return "Ended with errors"; - } - - return lttcomm_get_readable_code(code); + return error_get_str(code); } /* * Create a brand new session using name and url for destination. * - * Returns LTTCOMM_OK on success or a negative error code. + * Returns LTTNG_OK on success or a negative error code. */ int lttng_create_session(const char *name, const char *url) { @@ -1072,7 +1067,7 @@ int lttng_create_session(const char *name, const char *url) /* There should never be a data URL */ size = parse_str_urls_to_uri(url, NULL, &uris); if (size < 0) { - return LTTCOMM_INVALID; + return LTTNG_ERR_INVALID; } lsm.u.uri.size = size; @@ -1351,7 +1346,7 @@ int lttng_set_consumer_url(struct lttng_handle *handle, size = parse_str_urls_to_uri(control_url, data_url, &uris); if (size < 0) { - return LTTCOMM_INVALID; + return LTTNG_ERR_INVALID; } lsm.u.uri.size = size; @@ -1543,7 +1538,7 @@ int _lttng_create_session_ext(const char *name, const char *url, /* There should never be a data URL */ size = parse_str_urls_to_uri(url, NULL, &uris); if (size < 0) { - return LTTCOMM_INVALID; + return LTTNG_ERR_INVALID; } lsm.u.uri.size = size; diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am index 074c8ec8f..3d2590092 100644 --- a/tests/tools/Makefile.am +++ b/tests/tools/Makefile.am @@ -11,7 +11,8 @@ UTILS=../utils.h SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c \ $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \ $(top_srcdir)/src/common/uri.c \ - $(top_srcdir)/src/common/utils.c + $(top_srcdir)/src/common/utils.c \ + $(top_srcdir)/src/common/error.c KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c \ $(top_srcdir)/src/bin/lttng-sessiond/consumer.c \ $(top_srcdir)/src/common/uri.c \ diff --git a/tests/tools/test_sessions.c b/tests/tools/test_sessions.c index cd8003dda..efe19ecdc 100644 --- a/tests/tools/test_sessions.c +++ b/tests/tools/test_sessions.c @@ -28,6 +28,7 @@ #include #include +#include #include "utils.h" @@ -132,7 +133,7 @@ static int create_one_session(char *name, char *path) int ret; ret = session_create(name, path, geteuid(), getegid()); - if (ret == LTTCOMM_OK) { + if (ret == LTTNG_OK) { /* Validate */ ret = find_session_name(name); if (ret < 0) { @@ -144,7 +145,7 @@ static int create_one_session(char *name, char *path) return 0; } } else { - if (ret == LTTCOMM_EXIST_SESS) { + if (ret == LTTNG_ERR_EXIST_SESS) { printf("(session already exists) "); } return -1; @@ -162,7 +163,7 @@ static int destroy_one_session(struct ltt_session *session) ret = session_destroy(session); - if (ret == LTTCOMM_OK) { + if (ret == LTTNG_OK) { /* Validate */ if (session == NULL) { return 0; -- 2.34.1