UI: Only show tracker PID state when enabled
[lttng-tools.git] / src / bin / lttng / commands / list.c
index 12499ee408f1e545b3afbe727f2b0c3659a23082..a8ed999899d89fa83da56e8dc84fd9a00fbf73a4 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <inttypes.h>
 #include <popt.h>
 #include <stdio.h>
@@ -128,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:
@@ -1245,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
@@ -1666,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;
@@ -1753,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;
This page took 0.02507 seconds and 4 git commands to generate.