Implement PID tracker content listing
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 546da2e53d69cc84280ec0b9ca0aec7556962b80..4c1609fd20366f95438b240504e1ab20ca8229b5 100644 (file)
@@ -926,6 +926,8 @@ error:
 
 /*
  * Command LTTNG_TRACK_PID processed by the client thread.
+ *
+ * Called with session lock held.
  */
 int cmd_track_pid(struct ltt_session *session, int domain, int pid)
 {
@@ -949,6 +951,17 @@ int cmd_track_pid(struct ltt_session *session, int domain, int pid)
                break;
        }
        case LTTNG_DOMAIN_UST:
+       {
+               struct ltt_ust_session *usess;
+
+               usess = session->ust_session;
+
+               ret = trace_ust_track_pid(usess, pid);
+               if (ret != LTTNG_OK) {
+                       goto error;
+               }
+               break;
+       }
        default:
                ret = LTTNG_ERR_UNKNOWN_DOMAIN;
                goto error;
@@ -963,6 +976,8 @@ error:
 
 /*
  * Command LTTNG_UNTRACK_PID processed by the client thread.
+ *
+ * Called with session lock held.
  */
 int cmd_untrack_pid(struct ltt_session *session, int domain, int pid)
 {
@@ -986,6 +1001,17 @@ int cmd_untrack_pid(struct ltt_session *session, int domain, int pid)
                break;
        }
        case LTTNG_DOMAIN_UST:
+       {
+               struct ltt_ust_session *usess;
+
+               usess = session->ust_session;
+
+               ret = trace_ust_untrack_pid(usess, pid);
+               if (ret != LTTNG_OK) {
+                       goto error;
+               }
+               break;
+       }
        default:
                ret = LTTNG_ERR_UNKNOWN_DOMAIN;
                goto error;
@@ -1923,8 +1949,61 @@ ssize_t cmd_list_syscalls(struct lttng_event **events)
        return syscall_table_list(events);
 }
 
+/*
+ * Command LTTNG_LIST_TRACKER_PIDS processed by the client thread.
+ *
+ * Called with session lock held.
+ */
+ssize_t cmd_list_tracker_pids(struct ltt_session *session,
+               int domain, int32_t **pids)
+{
+       int ret;
+       ssize_t nr_pids = 0;
+
+       switch (domain) {
+       case LTTNG_DOMAIN_KERNEL:
+       {
+               struct ltt_kernel_session *ksess;
+
+               ksess = session->kernel_session;
+               nr_pids = kernel_list_tracker_pids(ksess, pids);
+               if (nr_pids < 0) {
+                       ret = LTTNG_ERR_KERN_LIST_FAIL;
+                       goto error;
+               }
+               break;
+       }
+       case LTTNG_DOMAIN_UST:
+       {
+               struct ltt_ust_session *usess;
+
+               usess = session->ust_session;
+               nr_pids = trace_ust_list_tracker_pids(usess, pids);
+               if (nr_pids < 0) {
+                       ret = LTTNG_ERR_UST_LIST_FAIL;
+                       goto error;
+               }
+               break;
+       }
+       case LTTNG_DOMAIN_LOG4J:
+       case LTTNG_DOMAIN_JUL:
+       case LTTNG_DOMAIN_PYTHON:
+       default:
+               ret = LTTNG_ERR_UND;
+               goto error;
+       }
+
+       return nr_pids;
+
+error:
+       /* Return negative value to differentiate return code */
+       return -ret;
+}
+
 /*
  * Command LTTNG_START_TRACE processed by the client thread.
+ *
+ * Called with session mutex held.
  */
 int cmd_start_trace(struct ltt_session *session)
 {
@@ -2285,6 +2364,8 @@ error:
 
 /*
  * Command LTTNG_DESTROY_SESSION processed by the client thread.
+ *
+ * Called with session lock held.
  */
 int cmd_destroy_session(struct ltt_session *session, int wpipe)
 {
This page took 0.025182 seconds and 4 git commands to generate.