--- /dev/null
+/*
+ * 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 <dgoulet@efficios.com>
+ *
+ * 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 */
}
}
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);
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,
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);
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) {
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;
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;
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;
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;
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;
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;
/* 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;
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;
}
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;
}
}
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;
if (attr == NULL) {
defattr = channel_new_default_attr(domain);
if (defattr == NULL) {
- ret = LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
attr = defattr;
* (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;
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;
}
DBG2("Channel %s created successfully", uchan->name);
free(defattr);
- return LTTCOMM_OK;
+ return LTTNG_OK;
error_free_chan:
/*
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) {
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;
}
DBG2("Channel %s disabled successfully", uchan->name);
- return LTTCOMM_OK;
+ return LTTNG_OK;
end:
error:
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;
}
tmp = zmalloc(nb_event * sizeof(struct lttng_event));
if (tmp == NULL) {
- ret = -LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
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;
}
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;
}
i++;
}
+end:
return nb_event;
error:
- return ret;
+ /* Negate the error code to differentiate the size from an error */
+ return -ret;
}
/*
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;
}
/* 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) {
/*
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;
}
}
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;
}
}
/* 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;
}
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;
}
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) {
} 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) {
/* 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;
}
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
/* 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;
}
*/
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;
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;
}
}
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;
}
}
{
ret = channel_kernel_disable(session->kernel_session,
channel_name);
- if (ret != LTTCOMM_OK) {
+ if (ret != LTTNG_OK) {
goto error;
}
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;
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;
ret = channel_kernel_enable(session->kernel_session, kchan);
}
- if (ret != LTTCOMM_OK) {
+ if (ret != LTTNG_OK) {
goto error;
}
case LTTNG_DOMAIN_UST_PID:
#endif
default:
- ret = LTTCOMM_UNKNOWN_DOMAIN;
+ ret = LTTNG_ERR_UNKNOWN_DOMAIN;
goto error;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
/* 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;
assert(usess);
ret = context_ust_add(usess, domain, ctx, event_name, channel_name);
- if (ret != LTTCOMM_OK) {
+ if (ret != LTTNG_OK) {
goto error;
}
break;
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;
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;
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;
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;
}
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;
}
/* 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;
}
/* 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;
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;
/* 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;
}
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;
}
/* 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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
}
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;
}
}
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 */
/* 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;
}
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;
usess = session->ust_session;
if (!session->enabled) {
- ret = LTTCOMM_TRACE_ALREADY_STOPPED;
+ ret = LTTNG_ERR_TRACE_ALREADY_STOPPED;
goto error;
}
ret = kernel_stop_session(ksession);
if (ret < 0) {
- ret = LTTCOMM_KERN_STOP_FAIL;
+ ret = LTTNG_ERR_KERN_STOP_FAIL;
goto error;
}
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;
/* 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;
}
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. */
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. */
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;
}
}
/* All good! */
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
error:
return ret;
*/
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;
}
/* 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;
}
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);
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;
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;
/* 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;
}
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);
}
default:
/* TODO: Userspace tracing */
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
goto error;
}
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
error:
return ret;
*domains = zmalloc(nb_dom * sizeof(struct lttng_domain));
if (*domains == NULL) {
- ret = -LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
return nb_dom;
error:
- return ret;
+ /* Return negative value to differentiate return code */
+ return -ret;
}
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;
}
return nb_chan;
error:
- return ret;
+ /* Return negative value to differentiate return code */
+ return -ret;
}
/*
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;
}
/*
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;
}
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:
/* 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;
}
* 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;
if (ret < 0) {
if (ret != -EEXIST) {
ERR("Trace directory creation error");
- ret = LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
}
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;
}
* 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;
if (ret < 0) {
if (ret != -EEXIST) {
ERR("Trace directory creation error");
- ret = LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
}
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;
}
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:
/* Bail out if consumer is disabled */
if (!consumer->enabled) {
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
DBG3("Consumer is disabled");
goto error;
}
/* Bail out if consumer is disabled */
if (!consumer->enabled) {
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
goto error;
}
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 */
}
if (!found && !no_event) {
- ret = LTTCOMM_NO_EVENT;
+ ret = LTTNG_ERR_NO_EVENT;
goto error;
}
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
error:
return ret;
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 */
}
if (!found && !no_event) {
- ret = LTTCOMM_NO_EVENT;
+ ret = LTTNG_ERR_NO_EVENT;
goto error;
}
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
error:
return ret;
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;
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;
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;
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
goto error;
}
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;
}
}
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;
}
}
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 */
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;
}
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;
continue;
}
}
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
return ret;
}
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 */
}
/*
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;
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;
} 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;
}
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;
}
}
free(event_list);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
end:
return ret;
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;
}
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;
}
/* 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;
}
events[i].pid);
if (ret < 0) {
if (ret != -EEXIST) {
- ret = LTTCOMM_UST_ENABLE_FAIL;
+ ret = LTTNG_ERR_UST_ENABLE_FAIL;
goto error;
}
}
/* Create ust event */
uevent = trace_ust_create_event(&events[i]);
if (uevent == NULL) {
- ret = LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error_destroy;
}
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;
}
}
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);
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 */
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;
}
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;
}
}
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
goto end;
}
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;
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;
}
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;
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,
/* 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;
}
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;
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);
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;
case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
#endif
default:
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
goto error;
}
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;
}
}
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;
}
}
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 */
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;
}
/* Bail out if consumer is disabled */
if (!session->consumer->enabled) {
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
goto error;
}
/* Bail out if consumer is disabled */
if (!session->consumer->enabled) {
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
goto error;
}
if (ret < 0) {
switch (errno) {
case EEXIST:
- ret = LTTCOMM_KERN_EVENT_EXIST;
+ ret = LTTNG_ERR_KERN_EVENT_EXIST;
break;
default:
PERROR("enable kernel 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");
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) {
PERROR("close");
}
kernel_tracer_fd = -1;
- return LTTCOMM_KERN_VERSION;
+ return LTTNG_ERR_KERN_VERSION;
error_modules:
ret = close(kernel_tracer_fd);
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;
}
}
dir_name = DEFAULT_UST_TRACE_DIR;
break;
default:
- ret = LTTCOMM_UNKNOWN_DOMAIN;
+ ret = LTTNG_ERR_UNKNOWN_DOMAIN;
goto error;
}
sizeof(consumer->subdir) - strlen(consumer->subdir) - 1);
DBG3("Copy session consumer subdir %s", consumer->subdir);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
error:
return ret;
break;
default:
ERR("Unknown UST domain on create session %d", domain->type);
- ret = LTTCOMM_UNKNOWN_DOMAIN;
+ ret = LTTNG_ERR_UNKNOWN_DOMAIN;
goto error;
}
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;
}
/* 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);
ret = kernel_create_session(session, kernel_tracer_fd);
if (ret < 0) {
- ret = LTTCOMM_KERN_SESS_FAIL;
+ ret = LTTNG_ERR_KERN_SESS_FAIL;
goto error;
}
/* 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;
}
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);
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;
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;
}
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;
}
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 {
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;
}
/* 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;
}
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;
}
}
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);
{
/* 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;
}
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;
}
}
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;
}
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;
}
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;
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;
}
}
* 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;
}
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;
}
free(events);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_LIST_TRACEPOINT_FIELDS:
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;
}
free(fields);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_SET_CONSUMER_URI:
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;
}
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;
}
if (nb_uri > 0) {
uris = zmalloc(len);
if (uris == NULL) {
- ret = LTTCOMM_FATAL;
+ ret = LTTNG_ERR_FATAL;
goto error;
}
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;
}
}
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;
}
free(domains);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_LIST_CHANNELS:
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;
}
free(channels);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_LIST_EVENTS:
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;
}
free(events);
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_LIST_SESSIONS:
session_unlock_list();
- ret = LTTCOMM_OK;
+ ret = LTTNG_OK;
break;
}
case LTTNG_CALIBRATE:
cdata = &kconsumer_data;
break;
default:
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
goto error;
}
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 */
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;
}
break;
}
default:
- ret = LTTCOMM_UND;
+ ret = LTTNG_ERR_UND;
break;
}
check_consumer_health();
break;
default:
- reply.ret_code = LTTCOMM_UND;
+ reply.ret_code = LTTNG_ERR_UND;
break;
}
/* 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);
rcu_read_unlock();
free(session);
- return LTTCOMM_OK;
+ return LTTNG_OK;
}
/*
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;
if (ret < 0) {
if (ret != -EEXIST) {
ERR("Trace directory creation error");
- ret = LTTCOMM_CREATE_DIR_FAIL;
+ ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
}
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:
ret = create_ust_app_metadata(ua_sess, usess->pathname, app);
if (ret < 0) {
+ ret = LTTNG_ERR_UST_META_FAIL;
goto error_rcu_unlock;
}
/* Got all streams */
lttng_fd_put(LTTNG_FD_APPS, 2);
free(ustream);
+ ret = LTTNG_ERR_UST_STREAM_FAIL;
break;
}
ustream->handle = ustream->obj->handle;
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;
}
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:
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;
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;
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;
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;
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:
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:
# 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
/* 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;
}
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;
}
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");
}
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");
/* 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;
}
}
/* 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;
}
--- /dev/null
+/*
+ * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
+ *
+ * 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 <assert.h>
+
+#include <lttng/lttng-error.h>
+
+#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)];
+}
#include <errno.h>
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#ifndef _GNU_SOURCE
#error "lttng-tools error.h needs _GNU_SOURCE"
#endif
+#include <lttng/lttng-error.h>
+
/* Stringify the expansion of a define */
#define XSTR(d) STR(d)
#define STR(s) #s
} while(0);
#endif
+const char *error_get_str(int32_t code);
+
#endif /* _ERROR_H */
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) {
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) {
/* 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;
}
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;
}
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 {
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 {
* 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"
};
/*
*/
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)];
}
/*
/*
* 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 */
* 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 */
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) {
}
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;
}
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) {
}
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;
}
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;
}
}
/* Check error code if OK */
- if (llm.ret_code != LTTCOMM_OK) {
+ if (llm.ret_code != LTTNG_OK) {
ret = -llm.ret_code;
goto end;
}
*/
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)
{
/* 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;
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;
/* 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;
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 \
#include <bin/lttng-sessiond/session.h>
#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/common.h>
#include "utils.h"
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) {
return 0;
}
} else {
- if (ret == LTTCOMM_EXIST_SESS) {
+ if (ret == LTTNG_ERR_EXIST_SESS) {
printf("(session already exists) ");
}
return -1;
ret = session_destroy(session);
- if (ret == LTTCOMM_OK) {
+ if (ret == LTTNG_OK) {
/* Validate */
if (session == NULL) {
return 0;