- case LTTNG_LIST_TRACKER_IDS:
- {
- struct lttcomm_tracker_command_header cmd_header;
- struct lttng_tracker_ids *ids = NULL;
- enum lttng_tracker_id_status status;
- unsigned int nr_ids, i;
- struct lttng_dynamic_buffer buf;
-
- ret = cmd_list_tracker_ids(
- cmd_ctx->lsm->u.id_tracker.tracker_type,
- cmd_ctx->session, cmd_ctx->lsm->domain.type,
- &ids);
- if (ret != LTTNG_OK) {
- goto error;
- }
-
- status = lttng_tracker_ids_get_count(ids, &nr_ids);
- if (status != LTTNG_TRACKER_ID_STATUS_OK) {
- ret = LTTNG_ERR_INVALID;
- goto error_list_tracker;
- }
-
- lttng_dynamic_buffer_init(&buf);
- for (i = 0; i < nr_ids; i++) {
- const struct lttng_tracker_id *id;
- struct lttcomm_tracker_id_header id_hdr;
- size_t var_data_len = 0;
- enum lttng_tracker_id_status status;
- const char *string;
- int value;
-
- id = lttng_tracker_ids_get_at_index(ids, i);
- if (!id) {
- ret = LTTNG_ERR_INVALID;
- goto error_list_tracker;
- }
-
- memset(&id_hdr, 0, sizeof(id_hdr));
- id_hdr.type = lttng_tracker_id_get_type(id);
- switch (id_hdr.type) {
- case LTTNG_ID_ALL:
- break;
- case LTTNG_ID_VALUE:
- status = lttng_tracker_id_get_value(id, &value);
- id_hdr.u.value = value;
- if (status != LTTNG_TRACKER_ID_STATUS_OK) {
- ret = LTTNG_ERR_INVALID;
- goto error_list_tracker;
- }
- break;
- case LTTNG_ID_STRING:
- status = lttng_tracker_id_get_string(
- id, &string);
- if (status != LTTNG_TRACKER_ID_STATUS_OK) {
- ret = LTTNG_ERR_INVALID;
- goto error_list_tracker;
- }
-
- id_hdr.u.var_data_len = var_data_len =
- strlen(string) + 1;
- break;
- default:
- ret = LTTNG_ERR_INVALID;
- goto error_list_tracker;
- }
- ret = lttng_dynamic_buffer_append(
- &buf, &id_hdr, sizeof(id_hdr));
- if (ret) {
- ret = LTTNG_ERR_NOMEM;
- goto error_list_tracker;
- }
- ret = lttng_dynamic_buffer_append(
- &buf, string, var_data_len);
- if (ret) {
- ret = LTTNG_ERR_NOMEM;
- goto error_list_tracker;
- }
- }
-
- cmd_header.nb_tracker_id = nr_ids;
- ret = setup_lttng_msg(cmd_ctx, buf.data, buf.size, &cmd_header,
- sizeof(cmd_header));
- error_list_tracker:
- lttng_tracker_ids_destroy(ids);
- lttng_dynamic_buffer_reset(&buf);
- if (ret < 0) {
- goto setup_error;
- }
-
- ret = LTTNG_OK;
- break;
- }