Implement PID tracking for kernel tracing
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 4332881c6eb7a41f538189a3dd3dcc41aed0ae30..c2210f48aa484c94393003e9f5b782ddbc5770c4 100644 (file)
@@ -1280,6 +1280,62 @@ int lttng_disable_channel(struct lttng_handle *handle, const char *name)
        return lttng_ctl_ask_sessiond(&lsm, NULL);
 }
 
+/*
+ *  Add PID to session tracker.
+ *  Return 0 on success else a negative LTTng error code.
+ */
+int lttng_track_pid(struct lttng_handle *handle, int pid)
+{
+       struct lttcomm_session_msg lsm;
+
+       /*
+        * NULL arguments are forbidden. No default values.
+        */
+       if (handle == NULL) {
+               return -LTTNG_ERR_INVALID;
+       }
+
+       memset(&lsm, 0, sizeof(lsm));
+
+       lsm.cmd_type = LTTNG_TRACK_PID;
+       lsm.u.pid_tracker.pid = pid;
+
+       lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
+
+       lttng_ctl_copy_string(lsm.session.name, handle->session_name,
+                       sizeof(lsm.session.name));
+
+       return lttng_ctl_ask_sessiond(&lsm, NULL);
+}
+
+/*
+ *  Remove PID from session tracker.
+ *  Return 0 on success else a negative LTTng error code.
+ */
+int lttng_untrack_pid(struct lttng_handle *handle, int pid)
+{
+       struct lttcomm_session_msg lsm;
+
+       /*
+        * NULL arguments are forbidden. No default values.
+        */
+       if (handle == NULL) {
+               return -LTTNG_ERR_INVALID;
+       }
+
+       memset(&lsm, 0, sizeof(lsm));
+
+       lsm.cmd_type = LTTNG_UNTRACK_PID;
+       lsm.u.pid_tracker.pid = pid;
+
+       lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
+
+       lttng_ctl_copy_string(lsm.session.name, handle->session_name,
+                       sizeof(lsm.session.name));
+
+       return lttng_ctl_ask_sessiond(&lsm, NULL);
+}
+
 /*
  *  Lists all available tracepoints of domain.
  *  Sets the contents of the events array.
This page took 0.023382 seconds and 4 git commands to generate.