X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=a8ed999899d89fa83da56e8dc84fd9a00fbf73a4;hp=f69d34db99aab59b115cf3c6cdf9b77f2a3a9252;hb=6223570f28ad0fa3264905079cdefae5ee93c947;hpb=6c1c0768320135c6936c371b09731851b508c023 diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index f69d34db9..a8ed99989 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -129,14 +129,14 @@ static char *get_cmdline_by_pid(pid_t pid) } /* Caller must free() *cmdline */ - cmdline = malloc(PATH_MAX); + cmdline = zmalloc(PATH_MAX); if (!cmdline) { - perror("malloc cmdline"); + PERROR("malloc cmdline"); goto end; } ret = fread(cmdline, 1, PATH_MAX, fp); if (ret < 0) { - perror("fread proc list"); + PERROR("fread proc list"); } end: @@ -1246,6 +1246,36 @@ error_channels: return ret; } +/* + * List tracker PID(s) of session and domain. + */ +static int list_tracker_pids(void) +{ + int enabled, ret; + int *pids = NULL; + size_t nr_pids; + + ret = lttng_list_tracker_pids(handle, + &enabled, &pids, &nr_pids); + if (ret) { + return ret; + } + if (enabled) { + int i; + _MSG("PID tracker: ["); + + for (i = 0; i < nr_pids; i++) { + if (i) { + _MSG(","); + } + _MSG(" %d", pids[i]); + } + _MSG(" ]\n\n"); + } + free(pids); + return 0; +} + /* * Machine interface * Find the session with session_name as name @@ -1667,6 +1697,11 @@ int cmd_list(int argc, const char **argv) } + ret = list_tracker_pids(); + if (ret) { + goto end; + } + ret = list_channels(opt_channel); if (ret) { goto end; @@ -1754,6 +1789,18 @@ int cmd_list(int argc, const char **argv) continue; } + switch (domains[i].type) { + case LTTNG_DOMAIN_KERNEL: + case LTTNG_DOMAIN_UST: + ret = list_tracker_pids(); + if (ret) { + goto end; + } + break; + default: + break; + } + ret = list_channels(opt_channel); if (ret) { goto end;