}
/*
- * Generate the filter bytecode from a give filter expression string. Put the
+ * Generate the filter bytecode from a given filter expression string. Put the
* newly allocated parser context in ctxp and populate the lsm object with the
* expression len.
*
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.
{
int ret;
struct lttcomm_session_msg lsm;
+ uint8_t *pending = NULL;
if (session_name == NULL) {
return -LTTNG_ERR_INVALID;
lttng_ctl_copy_string(lsm.session.name, session_name,
sizeof(lsm.session.name));
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
-
- /*
- * The lttng_ctl_ask_sessiond function negate the return code if it's not
- * LTTNG_OK so getting -1 means that the reply ret_code was 1 thus meaning
- * that the data is available. Yes it is hackish but for now this is the
- * only way.
- */
- if (ret == -1) {
- ret = 1;
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) &pending);
+ if (ret < 0) {
+ goto end;
+ } else if (ret != 1) {
+ /* Unexpected payload size */
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
}
+ ret = (int) *pending;
+end:
+ free(pending);
return ret;
}
struct lttcomm_session_msg lsm;
struct lttng_uri *uris = NULL;
- if (name == NULL) {
+ if (name == NULL || timer_interval == 0) {
return -LTTNG_ERR_INVALID;
}
return ret;
}
+/*
+ * List PIDs in the tracker.
+ *
+ * enabled is set to whether the PID tracker is enabled.
+ * pids is set to an allocated array of PIDs currently tracked. On
+ * success, pids must be freed by the caller.
+ * nr_pids is set to the number of entries contained by the pids array.
+ *
+ * Returns 0 on success, else a negative LTTng error code.
+ */
+int lttng_list_tracker_pids(struct lttng_handle *handle,
+ int *_enabled, int32_t **_pids, size_t *_nr_pids)
+{
+ int ret;
+ int enabled = 1;
+ struct lttcomm_session_msg lsm;
+ size_t nr_pids;
+ int32_t *pids;
+
+ if (handle == NULL) {
+ return -LTTNG_ERR_INVALID;
+ }
+
+ memset(&lsm, 0, sizeof(lsm));
+ lsm.cmd_type = LTTNG_LIST_TRACKER_PIDS;
+ lttng_ctl_copy_string(lsm.session.name, handle->session_name,
+ sizeof(lsm.session.name));
+ lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain);
+
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) &pids);
+ if (ret < 0) {
+ return ret;
+ }
+ nr_pids = ret / sizeof(int32_t);
+ if (nr_pids == 1 && pids[0] == -1) {
+ free(pids);
+ pids = NULL;
+ enabled = 0;
+ nr_pids = 0;
+ }
+ *_enabled = enabled;
+ *_pids = pids;
+ *_nr_pids = nr_pids;
+ return 0;
+}
+
/*
* lib constructor
*/