summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
abc9138)
Change lttcomm error code starting value from 1000 to 10. This way, bash
can return the exact error code since 255 is the maximum.
Fix multiple warning, error and message output.
Some return code could still be not "standardize" but for stable it's
ok. Fixes can come later on.
(close #105)
Signed-off-by: David Goulet <dgoulet@efficios.com>
13 files changed:
ret = LTTCOMM_KERN_CHAN_ENABLE_FAIL;
goto error;
}
ret = LTTCOMM_KERN_CHAN_ENABLE_FAIL;
goto error;
}
+ } else {
+ ret = LTTCOMM_KERN_CHAN_EXIST;
+ goto error;
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
+ ret = LTTCOMM_UST_CHAN_EXIST;
ret = LTTCOMM_KERN_ENABLE_FAIL;
goto end;
}
ret = LTTCOMM_KERN_ENABLE_FAIL;
goto end;
}
+ } else {
+ /* At this point, the event is considered enabled */
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ goto end;
ret = LTTCOMM_OK;
end:
return ret;
ret = LTTCOMM_OK;
end:
return ret;
#include <common/common.h>
#include <common/kernel-ctl/kernel-ctl.h>
#include <common/common.h>
#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/sessiond-comm/sessiond-comm.h>
#include "kernel.h"
#include "kern-modules.h"
#include "kernel.h"
#include "kern-modules.h"
int ret;
ret = kernctl_enable(event->fd);
int ret;
ret = kernctl_enable(event->fd);
- if (ret < 0 && errno != EEXIST) {
- PERROR("enable kernel event");
+ if (ret < 0) {
+ switch (errno) {
+ case EEXIST:
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ break;
+ default:
+ PERROR("enable kernel event");
+ break;
+ }
int ret;
ret = kernctl_disable(event->fd);
int ret;
ret = kernctl_disable(event->fd);
- if (ret < 0 && errno != EEXIST) {
- PERROR("disable kernel event");
+ if (ret < 0) {
+ switch (errno) {
+ case EEXIST:
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ break;
+ default:
+ PERROR("disable kernel event");
+ break;
+ }
#include "utils.h"
enum cmd_error_code {
#include "utils.h"
enum cmd_error_code {
CMD_ERROR,
CMD_UNDEFINED,
CMD_FATAL,
CMD_ERROR,
CMD_UNDEFINED,
CMD_FATAL,
#include "../command.h"
#include "../utils.h"
#include "../command.h"
#include "../utils.h"
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_output_path;
static char *opt_session_name;
static char *opt_output_path;
static char *opt_session_name;
ret = lttng_create_session(session_name, traces_path);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
ret = lttng_create_session(session_name, traces_path);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_EXIST_SESS:
+ WARN("Session %s already exists", session_name);
+ break;
+ }
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
static char *opt_session_name;
enum {
ret = lttng_destroy_session(session_name);
if (ret < 0) {
ret = lttng_destroy_session(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_SESS_NOT_FOUND:
+ WARN("Session name %s not found", session_name);
+ break;
+ default:
+ break;
+ }
+#include <src/common/sessiond-comm/sessiond-comm.h>
+
static char *opt_channels;
static int opt_kernel;
static char *opt_session_name;
static char *opt_channels;
static int opt_kernel;
static char *opt_session_name;
ret = lttng_enable_channel(handle, &chan);
if (ret < 0) {
ret = lttng_enable_channel(handle, &chan);
if (ret < 0) {
- ERR("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
+ switch (-ret) {
+ case LTTCOMM_KERN_CHAN_EXIST:
+ case LTTCOMM_UST_CHAN_EXIST:
+ WARN("Channel %s: %s (session %s", channel_name,
+ lttng_strerror(ret), session_name);
+ goto error;
+ default:
+ ERR("Channel %s: %s (session %s)", channel_name,
+ lttng_strerror(ret), session_name);
+ break;
+ }
warn = 1;
} else {
MSG("%s channel %s enabled for session %s",
warn = 1;
} else {
MSG("%s channel %s enabled for session %s",
#include <ctype.h>
#include "../command.h"
#include <ctype.h>
#include "../command.h"
+#include <src/common/sessiond-comm/sessiond-comm.h>
static char *opt_event_list;
static int opt_event_type;
static char *opt_event_list;
static int opt_event_type;
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
+ switch (-ret) {
+ case LTTCOMM_KERN_EVENT_EXIST:
+ WARN("Kernel events already enabled (channel %s, session %s)",
+ channel_name, session_name);
+ goto end;
+ default:
+ ERR("Event %s: %s (channel %s, session %s)", event_name,
+ lttng_strerror(ret), channel_name, session_name);
+ break;
+ }
}
switch (opt_event_type) {
}
switch (opt_event_type) {
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
- ERR("Event %s: %s (channel %s, session %s)", event_name,
- lttng_strerror(ret), channel_name, session_name);
+ /* Turn ret to positive value to handle the positive error code */
+ switch (-ret) {
+ case LTTCOMM_KERN_EVENT_EXIST:
+ WARN("Kernel event %s already enabled (channel %s, session %s)",
+ event_name, channel_name, session_name);
+ break;
+ default:
+ ERR("Event %s: %s (channel %s, session %s)", event_name,
+ lttng_strerror(ret), channel_name, session_name);
+ break;
+ }
warn = 1;
} else {
MSG("%s event %s created in channel %s",
warn = 1;
} else {
MSG("%s event %s created in channel %s",
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
static char *opt_session_name;
enum {
ret = lttng_start_tracing(session_name);
if (ret < 0) {
ret = lttng_start_tracing(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_TRACE_ALREADY_STARTED:
+ WARN("Tracing already started for session %s", session_name);
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ break;
+ }
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
static char *opt_session_name;
enum {
ret = lttng_stop_tracing(session_name);
if (ret < 0) {
ret = lttng_stop_tracing(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_TRACE_ALREADY_STOPPED:
+ WARN("Tracing already stopped for session %s", session_name);
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ break;
+ }
- ERR("%s", lttng_strerror(ret));
+ if (ret < 0) {
+ ret = -ret;
+ }
[ 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_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_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 error code.
*/
enum lttcomm_return_code {
* lttcomm error code.
*/
enum lttcomm_return_code {
- LTTCOMM_OK = 1000, /* Ok */
+ LTTCOMM_OK = 10, /* Ok */
LTTCOMM_ERR, /* Unknown Error */
LTTCOMM_UND, /* Undefine command */
LTTCOMM_NOT_IMPLEMENTED, /* Command not implemented */
LTTCOMM_ERR, /* Unknown Error */
LTTCOMM_UND, /* Undefine command */
LTTCOMM_NOT_IMPLEMENTED, /* Command not implemented */
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_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_FAIL, /* Kernel create channel failed */
LTTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */
LTTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */