-/*
- * find_app_by_pid
- *
- * Iterate over the traceable apps list.
- * On success, return 1, else return 0
- */
-static int find_app_by_pid(pid_t pid)
-{
- struct ltt_traceable_app *iter;
-
- pthread_mutex_lock(<t_traceable_app_list_mutex);
- cds_list_for_each_entry(iter, <t_traceable_app_list.head, list) {
- if (iter->pid == pid) {
- pthread_mutex_unlock(<t_traceable_app_list_mutex);
- /* Found */
- return 1;
- }
- }
- pthread_mutex_unlock(<t_traceable_app_list_mutex);
-
- return 0;
-}
-
-/*
- * ust_create_trace
- *
- * Create an userspace trace using pid.
- * This trace is then appended to the current session
- * ust trace list.
- */
-static int ust_create_trace(pid_t pid)
-{
- int sock, ret;
- struct ltt_ust_trace *trace;
-
- trace = malloc(sizeof(struct ltt_ust_trace));
- if (trace == NULL) {
- perror("malloc");
- ret = -1;
- goto error;
- }
-
- /* Init */
- trace->pid = pid;
- trace->shmid = 0;
-
- /* Connect to app using ustctl API */
- sock = connect_app(pid);
- if (sock < 0) {
- ret = LTTCOMM_NO_TRACEABLE;
- goto error;
- }
-
- ret = ustctl_create_trace(sock, "auto");
- if (ret < 0) {
- ret = LTTCOMM_CREATE_FAIL;
- goto error;
- }
-
- /* Check if current session is valid */
- if (current_session) {
- cds_list_add(&trace->list, ¤t_session->ust_traces);
- }
-
-error:
- return ret;
-}
-
-/*
- * get_list_apps
- *
- * List traceable user-space application and fill an
- * array of pids.
- */
-static void get_list_apps(pid_t *pids)
-{
- int i = 0;
- struct ltt_traceable_app *iter;
-
- /* Protected by a mutex here because the threads manage_client
- * and manage_apps can access this list.
- */
- pthread_mutex_lock(<t_traceable_app_list_mutex);
- cds_list_for_each_entry(iter, <t_traceable_app_list.head, list) {
- pids[i] = iter->pid;
- i++;
- }
- pthread_mutex_unlock(<t_traceable_app_list_mutex);
-}
-