+ req_header.command = LIST_TRACE_EVENTS;
+ req_header.size = 0;
+
+ result = ustcomm_send(app_fd, &req_header, NULL);
+ if (result != 1) {
+ ERR("error while requesting trace_event list");
+ return -1;
+ }
+
+ result = ustcomm_recv_alloc(app_fd, &res_header, &big_str);
+ if (result != 1) {
+ ERR("error while receiving markers list");
+ return -1;
+ }
+
+ close(app_fd);
+
+ tmp_tes = (struct trace_event_status *)
+ zmalloc(sizeof(struct trace_event_status) *
+ (ustcmd_count_nl(big_str) + 1));
+ if (tmp_tes == NULL) {
+ ERR("Failed to allocate TES array");
+ return -1;
+ }
+
+ /* Parse received reply string (format: "[name]"): */
+ while (big_str[i] != '\0') {
+ sscanf(big_str + i, "trace_event: %a[^\n]",
+ &tmp_tes[tes_ind].name);
+ while (big_str[i] != '\n') {
+ ++i; /* Go to next '\n' */
+ }
+ ++i; /* Skip current pointed '\n' */
+ ++tes_ind;
+ }
+ tmp_tes[tes_ind].name = NULL;
+
+ *tes = tmp_tes;
+
+ free(big_str);
+ return 0;
+}
+
+/**
+ * Set socket path
+ *
+ * @param sock_path Socket path
+ * @param pid Traced process ID
+ * @return 0 if successful, or error
+ */
+int ustcmd_set_sock_path(const char *sock_path, pid_t pid)
+{
+ int offset = 0;
+ struct ustcomm_header req_header, res_header;
+ struct ustcomm_sock_path sock_path_msg;
+
+ sock_path_msg.sock_path = ustcomm_print_data(sock_path_msg.data,
+ sizeof(sock_path_msg.data),
+ &offset,
+ sock_path);
+ if (sock_path_msg.sock_path == USTCOMM_POISON_PTR) {
+ return -1;
+ }
+
+ req_header.command = SET_SOCK_PATH;
+ req_header.size = COMPUTE_MSG_SIZE(&sock_path_msg, offset);
+
+ return do_cmd(pid, &req_header, (char *)&sock_path_msg,
+ &res_header, NULL);
+}
+
+/**
+ * Get socket path
+ *
+ * @param sock_path Pointer to where the socket path will be returned
+ * @param pid Traced process ID
+ * @return 0 if successful, or error
+ */
+int ustcmd_get_sock_path(char **sock_path, pid_t pid)
+{
+ int result;
+ struct ustcomm_header req_header, res_header;
+ struct ustcomm_sock_path *sock_path_msg;
+
+ req_header.command = GET_SOCK_PATH;
+ req_header.size = 0;
+
+ result = do_cmd(pid, &req_header, NULL, &res_header,
+ (char **)&sock_path_msg);
+ if (result < 0) {
+ return -1;
+ }
+
+ result = ustcomm_unpack_sock_path(sock_path_msg);
+ if (result < 0) {
+ return result;
+ }
+
+ *sock_path = strdup(sock_path_msg->sock_path);
+
+ free(sock_path_msg);