X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=4a53968740bd789aa8216bfda39029396c346b72;hb=aa5de748c1150c17624abce3cc74839fea3234f6;hp=c0bd30f2245a1a3597e9e9699d500d925ea0a249;hpb=b69133401acc92e8b947c81e365872ebab0c9aa8;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index c0bd30f22..4a5396874 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -196,11 +196,10 @@ static void print_events(struct lttng_event *event) switch (event->type) { case LTTNG_EVENT_TRACEPOINT: { - MSG("%s%s%s%s%d%s (type: tracepoint)%s", indent6, + MSG("%s%s%s%s%s (type: tracepoint)%s", indent6, event->name, loglevel_string_pre(event->loglevel), loglevel_string(event->loglevel), - event->loglevel, loglevel_string_post(event->loglevel), enabled_string(event->enabled)); break; @@ -247,6 +246,8 @@ static int list_ust_events(void) struct lttng_event *event_list; pid_t cur_pid = 0; + memset(&domain, 0, sizeof(domain)); + DBG("Getting UST tracing events"); domain.type = LTTNG_DOMAIN_UST; @@ -259,6 +260,7 @@ static int list_ust_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list UST events"); + lttng_destroy_handle(handle); return size; } @@ -279,10 +281,12 @@ static int list_ust_events(void) MSG(""); free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; } @@ -296,6 +300,8 @@ static int list_kernel_events(void) struct lttng_handle *handle; struct lttng_event *event_list; + memset(&domain, 0, sizeof(domain)); + DBG("Getting kernel tracing events"); domain.type = LTTNG_DOMAIN_KERNEL; @@ -308,6 +314,7 @@ static int list_kernel_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list kernel events"); + lttng_destroy_handle(handle); return size; } @@ -321,9 +328,11 @@ static int list_kernel_events(void) free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; } @@ -557,6 +566,8 @@ int cmd_list(int argc, const char **argv) struct lttng_domain domain; struct lttng_domain *domains = NULL; + memset(&domain, 0, sizeof(domain)); + if (argc < 1) { usage(stderr); ret = CMD_ERROR; @@ -595,10 +606,12 @@ int cmd_list(int argc, const char **argv) domain.type = LTTNG_DOMAIN_UST; } - handle = lttng_create_handle(session_name, &domain); - if (handle == NULL) { - ret = CMD_FATAL; - goto end; + if (opt_kernel || opt_userspace) { + handle = lttng_create_handle(session_name, &domain); + if (handle == NULL) { + ret = CMD_FATAL; + goto end; + } } if (session_name == NULL) { @@ -661,7 +674,9 @@ int cmd_list(int argc, const char **argv) } /* Clean handle before creating a new one */ - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } handle = lttng_create_handle(session_name, &domains[i]); if (handle == NULL) { @@ -681,7 +696,9 @@ end: if (domains) { free(domains); } - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } poptFreeContext(pc); return ret;