projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve error handling of lttng cli
[lttng-tools.git]
/
src
/
bin
/
lttng
/
commands
/
list.c
diff --git
a/src/bin/lttng/commands/list.c
b/src/bin/lttng/commands/list.c
index 743b79ff2431f826ec2d623fe1957c834bff0a0d..4def4e7a2ee3aa050599a661aeb162d5c2d179cb 100644
(file)
--- a/
src/bin/lttng/commands/list.c
+++ b/
src/bin/lttng/commands/list.c
@@
-70,7
+70,7
@@
static struct poptOption long_options[] = {
*/
static void usage(FILE *ofp)
{
*/
static void usage(FILE *ofp)
{
- fprintf(ofp, "usage: lttng list [
[-k] [-u] [-p PID] [SESSION [<options>]
]]\n");
+ fprintf(ofp, "usage: lttng list [
SESSION [<OPTIONS>
]]\n");
fprintf(ofp, "\n");
fprintf(ofp, "With no arguments, list available tracing session(s)\n");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
fprintf(ofp, "With no arguments, list available tracing session(s)\n");
fprintf(ofp, "\n");
@@
-179,8
+179,9
@@
static void print_events(struct lttng_event *event)
ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN,
" (%lld)", (long long) event->loglevel_value);
ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN,
" (%lld)", (long long) event->loglevel_value);
- if (ret < 0)
+ if (ret < 0)
{
ERR("snprintf error");
ERR("snprintf error");
+ }
}
MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6,
event->name,
}
MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6,
event->name,
@@
-215,11
+216,6
@@
static void print_events(struct lttng_event *event)
MSG("%s (type: noop)%s", indent6,
enabled_string(event->enabled));
break;
MSG("%s (type: noop)%s", indent6,
enabled_string(event->enabled));
break;
- case LTTNG_EVENT_TRACEPOINT_LOGLEVEL:
- MSG("%s%s (type: tracepoint loglevel)%s", indent6,
- event->name,
- enabled_string(event->enabled));
- break;
case LTTNG_EVENT_ALL:
/* We should never have "all" events in list. */
assert(0);
case LTTNG_EVENT_ALL:
/* We should never have "all" events in list. */
assert(0);
@@
-393,10
+389,10
@@
static int list_channels(const char *channel_name)
count = lttng_list_channels(handle, &channels);
if (count < 0) {
ret = count;
count = lttng_list_channels(handle, &channels);
if (count < 0) {
ret = count;
- goto error;
+ goto error
_channels
;
} else if (count == 0) {
} else if (count == 0) {
-
MSG("No channel found"
);
- goto e
nd
;
+
ERR("Channel %s not found", channel_name
);
+ goto e
rror
;
}
if (channel_name == NULL) {
}
if (channel_name == NULL) {
@@
-425,14
+421,16
@@
static int list_channels(const char *channel_name)
}
if (!chan_found && channel_name != NULL) {
}
if (!chan_found && channel_name != NULL) {
- MSG("Channel %s not found", channel_name);
+ ERR("Channel %s not found", channel_name);
+ goto error;
}
}
-end:
- free(channels);
ret = CMD_SUCCESS;
error:
ret = CMD_SUCCESS;
error:
+ free(channels);
+
+error_channels:
return ret;
}
return ret;
}
@@
-479,7
+477,7
@@
static int list_sessions(const char *session_name)
free(sessions);
if (!session_found && session_name != NULL) {
free(sessions);
if (!session_found && session_name != NULL) {
-
MSG
("Session %s not found", session_name);
+
ERR
("Session %s not found", session_name);
}
if (session_name == NULL) {
}
if (session_name == NULL) {
@@
-545,6
+543,7
@@
int cmd_list(int argc, const char **argv)
if (argc < 1) {
usage(stderr);
if (argc < 1) {
usage(stderr);
+ ret = CMD_ERROR;
goto end;
}
goto end;
}
@@
-554,14
+553,13
@@
int cmd_list(int argc, const char **argv)
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
- usage(std
err
);
+ usage(std
out
);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
break;
case OPT_LIST_OPTIONS:
list_cmd_options(stdout, long_options);
- ret = CMD_SUCCESS;
goto end;
default:
usage(stderr);
goto end;
default:
usage(stderr);
@@
-583,6
+581,7
@@
int cmd_list(int argc, const char **argv)
handle = lttng_create_handle(session_name, &domain);
if (handle == NULL) {
handle = lttng_create_handle(session_name, &domain);
if (handle == NULL) {
+ ret = CMD_FATAL;
goto end;
}
goto end;
}
@@
-590,18
+589,21
@@
int cmd_list(int argc, const char **argv)
if (!opt_kernel && !opt_userspace) {
ret = list_sessions(NULL);
if (ret < 0) {
if (!opt_kernel && !opt_userspace) {
ret = list_sessions(NULL);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
if (opt_kernel) {
ret = list_kernel_events();
if (ret < 0) {
goto end;
}
}
if (opt_kernel) {
ret = list_kernel_events();
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
if (opt_userspace) {
ret = list_ust_events();
if (ret < 0) {
goto end;
}
}
if (opt_userspace) {
ret = list_ust_events();
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
goto end;
}
}
@@
-609,12
+611,16
@@
int cmd_list(int argc, const char **argv)
/* List session attributes */
ret = list_sessions(session_name);
if (ret < 0) {
/* List session attributes */
ret = list_sessions(session_name);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
/* Domain listing */
if (opt_domain) {
ret = list_domains(session_name);
goto end;
}
/* Domain listing */
if (opt_domain) {
ret = list_domains(session_name);
+ if (ret < 0) {
+ ret = CMD_ERROR;
+ }
goto end;
}
goto end;
}
@@
-622,13
+628,14
@@
int cmd_list(int argc, const char **argv)
/* Channel listing */
ret = list_channels(opt_channel);
if (ret < 0) {
/* Channel listing */
ret = list_channels(opt_channel);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
} else {
/* We want all domain(s) */
nb_domain = lttng_list_domains(session_name, &domains);
if (nb_domain < 0) {
goto end;
}
} else {
/* We want all domain(s) */
nb_domain = lttng_list_domains(session_name, &domains);
if (nb_domain < 0) {
- ret =
nb_domain
;
+ ret =
CMD_ERROR
;
goto end;
}
goto end;
}
@@
-650,11
+657,13
@@
int cmd_list(int argc, const char **argv)
handle = lttng_create_handle(session_name, &domains[i]);
if (handle == NULL) {
handle = lttng_create_handle(session_name, &domains[i]);
if (handle == NULL) {
+ ret = CMD_FATAL;
goto end;
}
ret = list_channels(opt_channel);
if (ret < 0) {
goto end;
}
ret = list_channels(opt_channel);
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
goto end;
}
}
@@
-667,5
+676,6
@@
end:
}
lttng_destroy_handle(handle);
}
lttng_destroy_handle(handle);
+ poptFreeContext(pc);
return ret;
}
return ret;
}
This page took
0.026059 seconds
and
4
git commands to generate.