-/*
- * 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;
-
- DBG("Creating trace for pid %d", pid);
-
- trace = malloc(sizeof(struct ltt_ust_trace));
- if (trace == NULL) {
- perror("malloc");
- ret = -1;
- goto error;
- }
-
- /* Init */
- trace->pid = pid;
- trace->shmid = 0;
- /* NOTE: to be removed. Trace name will no longer be
- * required for LTTng userspace tracer. For now, we set it
- * to 'auto' for API compliance.
- */
- snprintf(trace->name, 5, "auto");
-
- /* Connect to app using ustctl API */
- sock = connect_app(pid);
- if (sock < 0) {
- ret = LTTCOMM_NO_TRACEABLE;
- goto error;
- }
-
- ret = ustctl_create_trace(sock, trace->name);
- 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);
- current_session->ust_trace_count++;
- }
-
-error:
- return ret;
-}
-
-/*
- * ust_start_trace
- *
- * Start a trace. This trace, identified by the pid, must be
- * in the current session ust_traces list.
- */
-static int ust_start_trace(pid_t pid)
-{
- int sock, ret;
- struct ltt_ust_trace *trace;
-
- DBG("Starting trace for pid %d", pid);
-
- trace = find_session_ust_trace_by_pid(current_session, pid);
- if (trace == NULL) {
- ret = LTTCOMM_NO_TRACE;
- goto error;
- }
-
- /* Connect to app using ustctl API */
- sock = connect_app(pid);
- if (sock < 0) {
- ret = LTTCOMM_NO_TRACEABLE;
- goto error;
- }
-
- ret = ustctl_start_trace(sock, "auto");
- if (ret < 0) {
- ret = LTTCOMM_START_FAIL;
- goto error;
- }
-
-error:
- return ret;
-}
-
-/*
- * ust_stop_trace
- *
- * Stop a trace. This trace, identified by the pid, must be
- * in the current session ust_traces list.
- */
-static int ust_stop_trace(pid_t pid)
-{
- int sock, ret;
- struct ltt_ust_trace *trace;
-
- DBG("Stopping trace for pid %d", pid);
-
- trace = find_session_ust_trace_by_pid(current_session, pid);
- if (trace == NULL) {
- ret = LTTCOMM_NO_TRACE;
- goto error;
- }
-
- /* Connect to app using ustctl API */
- sock = connect_app(pid);
- if (sock < 0) {
- ret = LTTCOMM_NO_TRACEABLE;
- goto error;
- }
-
- ret = ustctl_stop_trace(sock, trace->name);
- if (ret < 0) {
- ret = LTTCOMM_STOP_FAIL;
- goto error;
- }
-
-error:
- return ret;
-}
-