X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=720d23439c99b855546617f503ad2fc609373b46;hp=56266db3ce429bb6074bf34af85391ce6e7b865e;hb=ce3d728cd9bfcc0f7d43e08275a92cf04e898662;hpb=d4a2a84a5533017c9d0aa9fe66e7677a6b36b521 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 56266db3c..720d23439 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -322,6 +322,42 @@ 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; +} + /* * copy_common_data * @@ -453,7 +489,10 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) { ret = ust_create_trace(lsm->pid); if (ret < 0) { - ret = LTTCOMM_CREATE_FAIL; + /* If -1 is returned from ust_create_trace, malloc + * failed so it's pretty much a fatal error. + */ + ret = LTTCOMM_FATAL; goto end; } @@ -481,6 +520,13 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) break; } + case UST_START_TRACE: + { + ret = ust_start_trace(lsm->pid); + + /* No auxiliary data so only send the llm struct. */ + goto end; + } case LTTNG_LIST_SESSIONS: { unsigned int session_count = get_session_count();