From 49c336c1679295a31b92223dca05feccfe3e3464 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 9 Nov 2012 13:37:25 -0500 Subject: [PATCH] Support new lttng-ust error code Signed-off-by: David Goulet --- src/bin/lttng-sessiond/channel.c | 6 +-- src/bin/lttng-sessiond/event.c | 10 ++--- src/bin/lttng-sessiond/filter.c | 4 ++ src/bin/lttng-sessiond/lttng-ust-error.h | 56 ++++++++++++++++++++++++ src/bin/lttng-sessiond/ust-app.c | 10 ++--- src/bin/lttng-sessiond/ust-ctl.h | 2 + 6 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 src/bin/lttng-sessiond/lttng-ust-error.h diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index e2cdf563a..8b9adfba8 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -203,7 +203,7 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain, } if (ret < 0) { - if (ret != -EEXIST) { + if (ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_CHAN_ENABLE_FAIL; goto error; } else { @@ -284,7 +284,7 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, goto error_free_chan; } - if (ret < 0 && ret != -EEXIST) { + if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_CHAN_FAIL; goto error_free_chan; } @@ -341,7 +341,7 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain, goto error; } - if (ret < 0 && ret != -EEXIST) { + if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL; goto error; } diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 2173e414a..a2e6c37ef 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -343,7 +343,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, ret = ust_app_enable_event_pid(usess, uchan, uevent, events[i].pid); if (ret < 0) { - if (ret != -EEXIST) { + if (ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_ENABLE_FAIL; goto error; } @@ -362,7 +362,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain, ret = ust_app_enable_event_pid(usess, uchan, uevent, events[i].pid); if (ret < 0) { - if (ret == -EEXIST) { + if (ret == -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_EVENT_EXIST; goto error; } else { @@ -455,7 +455,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain, } if (ret < 0) { - if (ret == -EEXIST) { + if (ret == -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_EVENT_EXIST; goto end; } else { @@ -529,7 +529,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain, switch (domain) { case LTTNG_DOMAIN_UST: ret = ust_app_disable_event_glb(usess, uchan, uevent); - if (ret < 0 && ret != -EEXIST) { + if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_DISABLE_FAIL; goto error; } @@ -594,7 +594,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain, if (uevent != NULL && uevent->enabled == 1) { ret = ust_app_disable_event_pid(usess, uchan, uevent, events[i].pid); - if (ret < 0 && ret != -EEXIST) { + if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { ret = LTTNG_ERR_UST_DISABLE_FAIL; goto error; } diff --git a/src/bin/lttng-sessiond/filter.c b/src/bin/lttng-sessiond/filter.c index f0acffdc1..e88753305 100644 --- a/src/bin/lttng-sessiond/filter.c +++ b/src/bin/lttng-sessiond/filter.c @@ -155,17 +155,21 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, } end: + /* Must handle both local internal error and UST code. */ switch (ret) { case -EEXIST: + case -LTTNG_UST_ERR_EXIST: ret = LTTNG_ERR_FILTER_EXIST; break; case -ENOMEM: ret = LTTNG_ERR_FATAL; break; case -EINVAL: + case -LTTNG_UST_ERR_INVAL: ret = LTTNG_ERR_FILTER_INVAL; break; case -ENOSYS: + case -LTTNG_UST_ERR_NOSYS: ret = LTTNG_ERR_UNKNOWN_DOMAIN; break; default: diff --git a/src/bin/lttng-sessiond/lttng-ust-error.h b/src/bin/lttng-sessiond/lttng-ust-error.h new file mode 100644 index 000000000..d83ecb8c0 --- /dev/null +++ b/src/bin/lttng-sessiond/lttng-ust-error.h @@ -0,0 +1,56 @@ +#ifndef _LTTNG_UST_ERROR_H +#define _LTTNG_UST_ERROR_H + +/* + * Copyright (C) 2011 - David Goulet + * Julien Desfossez + * Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * 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 + */ + +/* + * This header is meant for liblttng and libust internal use ONLY. + * These declarations should NOT be considered stable API. + */ + +#include +#include + +#include "lttng-ust-abi.h" + +/* + * ustcomm error code. + */ +enum lttng_ust_error_code { + LTTNG_UST_OK = 0, /* Ok */ + LTTNG_UST_ERR = 1024, /* Unknown Error */ + LTTNG_UST_ERR_NOENT = 1025, /* No entry */ + LTTNG_UST_ERR_EXIST = 1026, /* Object exists */ + LTTNG_UST_ERR_INVAL = 1027, /* Invalid argument */ + LTTNG_UST_ERR_PERM = 1028, /* Permission denied */ + LTTNG_UST_ERR_NOSYS = 1029, /* Not implemented */ + + /* MUST be last element */ + LTTNG_UST_ERR_NR, /* Last element */ +}; + +/* + * Return a human-readable error message for an lttng-ust error code. + * code must be a positive value (or 0). + */ +extern const char *lttng_ust_strerror(int code); + +#endif /* _LTTNG_UST_ERROR_H */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index fc0d53787..2ebf79d28 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -734,10 +734,10 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess, * just created it. */ switch (ret) { - case -EPERM: + case -LTTNG_UST_ERR_PERM: /* Code flow problem */ assert(0); - case -EEXIST: + case -LTTNG_UST_ERR_EXIST: /* It's OK for our use case. */ ret = 0; break; @@ -1223,7 +1223,7 @@ static struct ust_app_channel *create_ust_app_channel( ret = create_ust_channel(app, ua_sess, ua_chan); if (ret < 0) { /* Not found previously means that it does not exist on the tracer */ - assert(ret != -EEXIST); + assert(ret != -LTTNG_UST_ERR_EXIST); goto error; } @@ -1274,7 +1274,7 @@ int create_ust_app_event(struct ust_app_session *ua_sess, ret = create_ust_event(app, ua_sess, ua_chan, ua_event); if (ret < 0) { /* Not found previously means that it does not exist on the tracer */ - assert(ret != -EEXIST); + assert(ret == -LTTNG_UST_ERR_EXIST); goto error; } @@ -2143,7 +2143,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess, ret = create_ust_app_event(ua_sess, ua_chan, uevent, app); if (ret < 0) { - if (ret != -EEXIST) { + if (ret != -LTTNG_UST_ERR_EXIST) { /* Possible value at this point: -ENOMEM. If so, we stop! */ break; } diff --git a/src/bin/lttng-sessiond/ust-ctl.h b/src/bin/lttng-sessiond/ust-ctl.h index fd0fc7ad0..f3494d6c3 100644 --- a/src/bin/lttng-sessiond/ust-ctl.h +++ b/src/bin/lttng-sessiond/ust-ctl.h @@ -33,9 +33,11 @@ #ifdef HAVE_LIBLTTNG_UST_CTL #include #include +#include #else #include "lttng-ust-ctl.h" #include "lttng-ust-abi.h" +#include "lttng-ust-error.h" #endif #endif /* _LTT_UST_CTL_H */ -- 2.34.1