X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=5429df4e2eacc9dbdc1c1b1186999046b3732309;hp=eced2b7165f1836098e415aad4768c772a581240;hb=ea5cbc00bc30274239a144a5ca614c4e1a57bc32;hpb=d8fbe2a9cc6ace367bfb5428df3e7649ac012f32 diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index eced2b716..5429df4e2 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -281,7 +281,7 @@ static void print_event_field(struct lttng_event_field *field) return; } MSG("%sfield: %s (%s)%s", indent8, field->field_name, - field_type(field), field->written ? "" : " [no write]"); + field_type(field), field->nowrite ? " [no write]" : ""); } /* @@ -294,6 +294,7 @@ static int list_ust_events(void) struct lttng_handle *handle; struct lttng_event *event_list; pid_t cur_pid = 0; + char *cmdline = NULL; memset(&domain, 0, sizeof(domain)); @@ -322,7 +323,9 @@ static int list_ust_events(void) for (i = 0; i < size; i++) { if (cur_pid != event_list[i].pid) { cur_pid = event_list[i].pid; - MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid)); + cmdline = get_cmdline_by_pid(cur_pid); + MSG("\nPID: %d - Name: %s", cur_pid, cmdline); + free(cmdline); } print_events(&event_list[i]); } @@ -349,6 +352,8 @@ static int list_ust_event_fields(void) struct lttng_handle *handle; struct lttng_event_field *event_field_list; pid_t cur_pid = 0; + char *cmdline = NULL; + struct lttng_event cur_event; memset(&domain, 0, sizeof(domain)); @@ -379,7 +384,9 @@ static int list_ust_event_fields(void) for (i = 0; i < size; i++) { if (cur_pid != event_field_list[i].event.pid) { cur_pid = event_field_list[i].event.pid; - MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid)); + cmdline = get_cmdline_by_pid(cur_pid); + MSG("\nPID: %d - Name: %s", cur_pid, cmdline); + free(cmdline); } if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) { print_events(&event_field_list[i].event); @@ -474,9 +481,7 @@ static int list_events(const char *channel_name) MSG(""); end: - if (events) { - free(events); - } + free(events); ret = CMD_SUCCESS; error: @@ -521,11 +526,17 @@ static int list_channels(const char *channel_name) count = lttng_list_channels(handle, &channels); if (count < 0) { - ret = count; + switch (-count) { + case LTTNG_ERR_KERN_CHAN_NOT_FOUND: + ret = CMD_SUCCESS; + WARN("No kernel channel"); + break; + default: + /* We had a real error */ + ret = count; + ERR("%s", lttng_strerror(ret)); + } goto error_channels; - } else if (count == 0) { - ERR("Channel %s not found", channel_name); - goto error; } if (channel_name == NULL) { @@ -674,8 +685,7 @@ error: */ int cmd_list(int argc, const char **argv) { - int opt, i, ret = CMD_SUCCESS; - int nb_domain; + int opt, ret = CMD_SUCCESS; const char *session_name; static poptContext pc; struct lttng_domain domain; @@ -739,6 +749,7 @@ int cmd_list(int argc, const char **argv) if (opt_kernel) { ret = list_kernel_events(); if (ret < 0) { + ret = CMD_ERROR; goto end; } } @@ -749,6 +760,7 @@ int cmd_list(int argc, const char **argv) ret = list_ust_events(); } if (ret < 0) { + ret = CMD_ERROR; goto end; } } @@ -772,6 +784,8 @@ int cmd_list(int argc, const char **argv) goto end; } } else { + int i, nb_domain; + /* We want all domain(s) */ nb_domain = lttng_list_domains(session_name, &domains); if (nb_domain < 0) { @@ -812,9 +826,7 @@ int cmd_list(int argc, const char **argv) } end: - if (domains) { - free(domains); - } + free(domains); if (handle) { lttng_destroy_handle(handle); }