+ enum lttng_error_code ret_code = LTTNG_OK;
+ const struct process_attr_tracker *tracker;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (!session->kernel_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ tracker = kernel_get_process_attr_tracker(
+ session->kernel_session, process_attr);
+ break;
+ case LTTNG_DOMAIN_UST:
+ if (!session->ust_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ tracker = trace_ust_get_process_attr_tracker(
+ session->ust_session, process_attr);
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ goto end;
+ }
+ if (tracker) {
+ *policy = process_attr_tracker_get_tracking_policy(tracker);
+ } else {
+ ret_code = LTTNG_ERR_INVALID;
+ }
+end:
+ return ret_code;
+}
+
+enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy)
+{
+ enum lttng_error_code ret_code = LTTNG_OK;
+
+ switch (policy) {
+ case LTTNG_TRACKING_POLICY_INCLUDE_SET:
+ case LTTNG_TRACKING_POLICY_EXCLUDE_ALL:
+ case LTTNG_TRACKING_POLICY_INCLUDE_ALL:
+ break;
+ default:
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (!session->kernel_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = kernel_process_attr_tracker_set_tracking_policy(
+ session->kernel_session, process_attr, policy);
+ break;
+ case LTTNG_DOMAIN_UST:
+ if (!session->ust_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = trace_ust_process_attr_tracker_set_tracking_policy(
+ session->ust_session, process_attr, policy);
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ break;
+ }
+end:
+ return ret_code;
+}
+
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
+{
+ enum lttng_error_code ret_code = LTTNG_OK;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (!session->kernel_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = kernel_process_attr_tracker_inclusion_set_add_value(
+ session->kernel_session, process_attr, value);
+ break;
+ case LTTNG_DOMAIN_UST:
+ if (!session->ust_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = trace_ust_process_attr_tracker_inclusion_set_add_value(
+ session->ust_session, process_attr, value);
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ break;
+ }
+end:
+ return ret_code;
+}
+
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
+{
+ enum lttng_error_code ret_code = LTTNG_OK;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (!session->kernel_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = kernel_process_attr_tracker_inclusion_set_remove_value(
+ session->kernel_session, process_attr, value);
+ break;
+ case LTTNG_DOMAIN_UST:
+ if (!session->ust_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret_code = trace_ust_process_attr_tracker_inclusion_set_remove_value(
+ session->ust_session, process_attr, value);
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ break;
+ }
+end:
+ return ret_code;
+}
+
+enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ struct lttng_process_attr_values **values)
+{
+ enum lttng_error_code ret_code = LTTNG_OK;
+ const struct process_attr_tracker *tracker;
+ enum process_attr_tracker_status status;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ if (!session->kernel_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ tracker = kernel_get_process_attr_tracker(
+ session->kernel_session, process_attr);
+ break;
+ case LTTNG_DOMAIN_UST:
+ if (!session->ust_session) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+ tracker = trace_ust_get_process_attr_tracker(
+ session->ust_session, process_attr);
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ goto end;
+ }
+
+ if (!tracker) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ status = process_attr_tracker_get_inclusion_set(tracker, values);
+ switch (status) {
+ case PROCESS_ATTR_TRACKER_STATUS_OK:
+ ret_code = LTTNG_OK;
+ break;
+ case PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY:
+ ret_code = LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY;
+ break;
+ case PROCESS_ATTR_TRACKER_STATUS_ERROR:
+ ret_code = LTTNG_ERR_NOMEM;
+ break;
+ default:
+ ret_code = LTTNG_ERR_UNK;
+ break;
+ }
+
+end:
+ return ret_code;
+}
+
+/*
+ * Command LTTNG_DISABLE_EVENT processed by the client thread.
+ */
+int cmd_disable_event(struct ltt_session *session,
+ enum lttng_domain_type domain, const char *channel_name,
+ const struct lttng_event *event)
+{
+ int ret;
+ const char *event_name;
+
+ DBG("Disable event command for event \'%s\'", event->name);
+
+ event_name = event->name;
+
+ /* Error out on unhandled search criteria */
+ if (event->loglevel_type || event->loglevel != -1 || event->enabled
+ || event->pid || event->filter || event->exclusion) {
+ ret = LTTNG_ERR_UNK;
+ goto error;
+ }