+ handle_status = lttng_process_attr_tracker_handle_get_inclusion_set(
+ tracker_handle, &values);
+ ret = handle_process_attr_status(process_attr, handle_status);
+ if (ret != CMD_SUCCESS) {
+ goto end;
+ }
+
+ handle_status = lttng_process_attr_tracker_handle_get_tracking_policy(
+ tracker_handle, &policy);
+ ret = handle_process_attr_status(process_attr, handle_status);
+ if (ret != CMD_SUCCESS) {
+ goto end;
+ }
+
+ {
+ char *process_attr_name;
+ const int print_ret = asprintf(&process_attr_name, "%ss:",
+ get_capitalized_process_attr_str(process_attr));
+
+ if (print_ret == -1) {
+ ret = CMD_FATAL;
+ goto end;
+ }
+ _MSG(" %-22s", process_attr_name);
+ free(process_attr_name);
+ }
+ switch (policy) {
+ case LTTNG_TRACKING_POLICY_INCLUDE_SET:
+ break;
+ case LTTNG_TRACKING_POLICY_EXCLUDE_ALL:
+ if (the_writer) {
+ mi_output_empty_tracker(process_attr);
+ }
+ MSG("none");
+ ret = CMD_SUCCESS;
+ goto end;
+ case LTTNG_TRACKING_POLICY_INCLUDE_ALL:
+ MSG("all");
+ ret = CMD_SUCCESS;
+ goto end;
+ default:
+ ERR("Unknown tracking policy encoutered while listing the %s process attribute tracker of session `%s`",
+ lttng_process_attr_to_string(process_attr),
+ the_handle->session_name);
+ ret = CMD_FATAL;
+ goto end;
+ }
+
+ values_status = lttng_process_attr_values_get_count(values, &count);
+ if (values_status != LTTNG_PROCESS_ATTR_VALUES_STATUS_OK) {
+ ERR("Failed to get the count of values in the inclusion set of the %s process attribute tracker of session `%s`",
+ lttng_process_attr_to_string(process_attr),
+ the_handle->session_name);
+ ret = CMD_FATAL;
+ goto end;
+ }
+
+ if (count == 0) {
+ /* Functionally equivalent to the 'exclude all' policy. */
+ if (the_writer) {
+ mi_output_empty_tracker(process_attr);
+ }
+ MSG("none");
+ ret = CMD_SUCCESS;
+ goto end;
+ }
+
+ /* Mi tracker_id element */
+ if (the_writer) {
+ /* Open tracker_id and targets elements */
+ ret = mi_lttng_process_attribute_tracker_open(
+ the_writer, process_attr);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ const enum lttng_process_attr_value_type value_type =
+ lttng_process_attr_values_get_type_at_index(
+ values, i);
+ int64_t integral_value = INT64_MAX;
+ const char *name = "error";
+
+ if (i >= 1) {
+ _MSG(", ");
+ }
+ switch (value_type) {
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
+ {
+ pid_t pid;
+
+ values_status = lttng_process_attr_values_get_pid_at_index(
+ values, i, &pid);
+ integral_value = (int64_t) pid;
+ break;
+ }
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
+ {
+ uid_t uid;
+
+ values_status = lttng_process_attr_values_get_uid_at_index(
+ values, i, &uid);
+ integral_value = (int64_t) uid;
+ break;
+ }
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
+ {
+ gid_t gid;
+
+ values_status = lttng_process_attr_values_get_gid_at_index(
+ values, i, &gid);
+ integral_value = (int64_t) gid;
+ break;
+ }
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
+ values_status = lttng_process_attr_values_get_user_name_at_index(
+ values, i, &name);
+ break;
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME:
+ values_status = lttng_process_attr_values_get_group_name_at_index(
+ values, i, &name);
+ break;
+ default:
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ if (values_status != LTTNG_PROCESS_ATTR_VALUES_STATUS_OK) {
+ /*
+ * Not possible given the current liblttng-ctl
+ * implementation.
+ */
+ ERR("Unknown error occurred while fetching process attribute value in inclusion list");
+ ret = CMD_FATAL;
+ goto end;
+ }
+
+ if (is_value_type_name(value_type)) {
+ _MSG("`%s`", name);
+ } else {
+ _MSG("%" PRIi64, integral_value);
+ }
+
+ /* Mi */
+ if (the_writer) {
+ ret = is_value_type_name(value_type) ?
+ mi_lttng_string_process_attribute_value(
+ the_writer,
+ process_attr, name,
+ false) :
+ mi_lttng_integral_process_attribute_value(
+ the_writer,
+ process_attr,
+ integral_value, false);
+ if (ret) {
+ goto end;
+ }
+ }
+ }
+ MSG("");
+
+ /* Mi close tracker_id and targets */
+ if (the_writer) {
+ ret = mi_lttng_close_multi_element(the_writer, 2);
+ if (ret) {
+ goto end;
+ }
+ }
+end:
+ lttng_process_attr_tracker_handle_destroy(tracker_handle);
+ return ret;
+}
+
+/*
+ * List all trackers of a domain
+ */
+static int list_trackers(const struct lttng_domain *domain)
+{
+ int ret = 0;
+
+ MSG("Tracked process attributes");
+ /* Trackers listing */
+ if (lttng_opt_mi) {
+ ret = mi_lttng_trackers_open(the_writer);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ /* pid tracker */
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_PROCESS_ID);
+ if (ret) {
+ goto end;
+ }
+ /* vpid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ if (ret) {
+ goto end;
+ }
+ /* uid tracker */
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_USER_ID);
+ if (ret) {
+ goto end;
+ }
+ /* vuid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ if (ret) {
+ goto end;
+ }
+ /* gid tracker */
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_GROUP_ID);
+ if (ret) {
+ goto end;
+ }
+ /* vgid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ if (ret) {
+ goto end;
+ }
+ break;
+ case LTTNG_DOMAIN_UST:
+ /* vpid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ if (ret) {
+ goto end;
+ }
+ /* vuid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ if (ret) {
+ goto end;
+ }
+ /* vgid tracker */
+ ret = list_process_attr_tracker(
+ LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ if (ret) {
+ goto end;
+ }
+ break;
+ default:
+ break;
+ }
+ MSG();
+ if (lttng_opt_mi) {
+ /* Close trackers element */
+ ret = mi_lttng_writer_close_element(the_writer);
+ if (ret) {
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
+static enum cmd_error_code print_periodic_rotation_schedule(
+ const struct lttng_rotation_schedule *schedule)
+{
+ enum cmd_error_code ret;
+ enum lttng_rotation_status status;
+ uint64_t value;
+
+ status = lttng_rotation_schedule_periodic_get_period(schedule,
+ &value);
+ if (status != LTTNG_ROTATION_STATUS_OK) {
+ ERR("Failed to retrieve period parameter from periodic rotation schedule.");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ MSG(" timer period: %" PRIu64" %s", value, USEC_UNIT);
+ ret = CMD_SUCCESS;
+end:
+ return ret;
+}
+
+static enum cmd_error_code print_size_threshold_rotation_schedule(
+ const struct lttng_rotation_schedule *schedule)
+{
+ enum cmd_error_code ret;
+ enum lttng_rotation_status status;
+ uint64_t value;
+
+ status = lttng_rotation_schedule_size_threshold_get_threshold(schedule,
+ &value);
+ if (status != LTTNG_ROTATION_STATUS_OK) {
+ ERR("Failed to retrieve size parameter from size-based rotation schedule.");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ MSG(" size threshold: %" PRIu64" bytes", value);
+ ret = CMD_SUCCESS;
+end:
+ return ret;
+}
+
+static enum cmd_error_code print_rotation_schedule(
+ const struct lttng_rotation_schedule *schedule)
+{
+ enum cmd_error_code ret;
+
+ switch (lttng_rotation_schedule_get_type(schedule)) {
+ case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
+ ret = print_size_threshold_rotation_schedule(schedule);
+ break;
+ case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
+ ret = print_periodic_rotation_schedule(schedule);
+ break;
+ default:
+ ret = CMD_ERROR;
+ }
+ return ret;
+}
+
+/*
+ * List the automatic rotation settings.
+ */
+static enum cmd_error_code list_rotate_settings(const char *session_name)
+{
+ int ret;
+ enum cmd_error_code cmd_ret = CMD_SUCCESS;
+ unsigned int count, i;
+ struct lttng_rotation_schedules *schedules = NULL;
+ enum lttng_rotation_status status;
+
+ ret = lttng_session_list_rotation_schedules(session_name, &schedules);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to list session rotation schedules: %s", lttng_strerror(ret));
+ cmd_ret = CMD_ERROR;
+ goto end;
+ }
+
+ status = lttng_rotation_schedules_get_count(schedules, &count);
+ if (status != LTTNG_ROTATION_STATUS_OK) {
+ ERR("Failed to retrieve the number of session rotation schedules.");
+ cmd_ret = CMD_ERROR;
+ goto end;
+ }
+
+ if (count == 0) {
+ cmd_ret = CMD_SUCCESS;
+ goto end;
+ }
+
+ MSG("Automatic rotation schedules:");
+ if (lttng_opt_mi) {
+ ret = mi_lttng_writer_open_element(the_writer,
+ mi_lttng_element_rotation_schedules);
+ if (ret) {
+ cmd_ret = CMD_ERROR;
+ goto end;
+ }