- case LTTNG_LIST_TRACKER_IDS:
- {
- struct lttcomm_tracker_command_header cmd_header;
- struct lttng_tracker_id *ids = NULL;
- ssize_t nr_ids, i;
- struct lttng_dynamic_buffer buf;
-
- nr_ids = cmd_list_tracker_ids(
- cmd_ctx->lsm->u.id_tracker.tracker_type,
- cmd_ctx->session, cmd_ctx->lsm->domain.type,
- &ids);
- if (nr_ids < 0) {
- /* Return value is a negative lttng_error_code. */
- ret = -nr_ids;
- goto error;
- }
-
- lttng_dynamic_buffer_init(&buf);
- for (i = 0; i < nr_ids; i++) {
- struct lttng_tracker_id *id = &ids[i];
- struct lttcomm_tracker_id_header id_hdr;
- size_t var_data_len = 0;
-
- memset(&id_hdr, 0, sizeof(id_hdr));
- id_hdr.type = id->type;
- switch (id->type) {
- case LTTNG_ID_ALL:
- break;
- case LTTNG_ID_VALUE:
- id_hdr.u.value = id->value;
- break;
- case LTTNG_ID_STRING:
- id_hdr.u.var_data_len = var_data_len =
- strlen(id->string) + 1;
- break;
- default:
- ret = LTTNG_ERR_INVALID;
- goto error;
- }
- ret = lttng_dynamic_buffer_append(
- &buf, &id_hdr, sizeof(id_hdr));
- if (ret) {
- ret = LTTNG_ERR_NOMEM;
- goto error;
- }
- ret = lttng_dynamic_buffer_append(
- &buf, id->string, var_data_len);
- if (ret) {
- ret = LTTNG_ERR_NOMEM;
- goto error;
- }
- free(id->string);
- }
-
- cmd_header.nb_tracker_id = nr_ids;
- ret = setup_lttng_msg(cmd_ctx, buf.data, buf.size, &cmd_header,
- sizeof(cmd_header));
- free(ids);
- lttng_dynamic_buffer_reset(&buf);
- if (ret < 0) {
- goto setup_error;
- }
-
- ret = LTTNG_OK;
- break;
- }