X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Ftrace-ust.c;h=a9aa1abceb8cf3779ec7e02ab4f96eb9dc7613f3;hp=957ac770b51eb9f9428ddbc3ea8648e49fad10ea;hb=0177d773712c6d6b11e395708ae2cc686d6917a4;hpb=ef805c1d5319ddce9777a7b78cbbaf595a7981e2 diff --git a/ltt-sessiond/trace-ust.c b/ltt-sessiond/trace-ust.c index 957ac770b..a9aa1abce 100644 --- a/ltt-sessiond/trace-ust.c +++ b/ltt-sessiond/trace-ust.c @@ -26,6 +26,24 @@ #include "trace-ust.h" +/* + * Return an UST session by traceable app PID. + */ +struct ltt_ust_session *trace_ust_get_session_by_pid(pid_t pid, + struct ltt_ust_session_list *session_list) +{ + struct ltt_ust_session *lus; + + cds_list_for_each_entry(lus, &session_list->head, list) { + if (lus->app->pid == pid) { + DBG("Found UST session by pid %d", pid); + return lus; + } + } + + return NULL; +} + /* * Find the channel name for the given ust session. */ @@ -80,8 +98,9 @@ error: * * Return pointer to structure or NULL. */ -struct ltt_ust_session *trace_ust_create_session(void) +struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid) { + int ret; struct ltt_ust_session *lus; /* Allocate a new ltt ust session */ @@ -97,9 +116,17 @@ struct ltt_ust_session *trace_ust_create_session(void) lus->uconsumer_fds_sent = 0; lus->path = NULL; lus->metadata = NULL; + lus->app = NULL; /* TODO: Search app by PID */ lus->channels.count = 0; CDS_INIT_LIST_HEAD(&lus->channels.head); + /* Set session path */ + ret = asprintf(&lus->path, "%s/ust_%d", path, pid); + if (ret < 0) { + perror("asprintf kernel traces path"); + goto error; + } + return lus; error: