From: David Goulet Date: Mon, 2 May 2011 17:41:21 +0000 (-0400) Subject: Add trace C file called trace.c X-Git-Tag: v2.0-pre1~161 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=d4a2a84a5533017c9d0aa9fe66e7677a6b36b521 Add trace C file called trace.c This file contains every useful fct to manage and deal with lttng-tools' trace data structures. Add missing headers to session.h to resolve the compiling issues with trace.c. Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/Makefile.am b/ltt-sessiond/Makefile.am index 4f4669da5..d24a23aec 100644 --- a/ltt-sessiond/Makefile.am +++ b/ltt-sessiond/Makefile.am @@ -3,7 +3,7 @@ AM_CFLAGS = -fno-strict-aliasing bin_PROGRAMS = ltt-sessiond -ltt_sessiond_SOURCES = session.c traceable-app.c main.c +ltt_sessiond_SOURCES = session.c trace.c traceable-app.c main.c ltt_sessiond_LDADD = \ $(top_builddir)/liblttsessiondcomm/liblttsessiondcomm.la diff --git a/ltt-sessiond/session.h b/ltt-sessiond/session.h index 72183ef4b..6bc7c4799 100644 --- a/ltt-sessiond/session.h +++ b/ltt-sessiond/session.h @@ -19,6 +19,9 @@ #ifndef _LTT_SESSION_H #define _LTT_SESSION_H +#include +#include + /* Global session list */ struct ltt_session_list { struct cds_list_head head; diff --git a/ltt-sessiond/trace.c b/ltt-sessiond/trace.c new file mode 100644 index 000000000..7d9c40cc0 --- /dev/null +++ b/ltt-sessiond/trace.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 - David Goulet + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "lttngerr.h" +#include "trace.h" +#include "session.h" + +/* + * find_session_ust_trace_by_pid + * + * Iterate over the session ust_traces and + * return a pointer or NULL if not found. + */ +struct ltt_ust_trace *find_session_ust_trace_by_pid(struct ltt_session *session, pid_t pid) +{ + struct ltt_ust_trace *iter; + + cds_list_for_each_entry(iter, &session->ust_traces, list) { + if (iter->pid == pid) { + /* Found */ + return iter; + } + } + + return NULL; +} + diff --git a/ltt-sessiond/trace.h b/ltt-sessiond/trace.h index 9cbdaffd1..36b2f2270 100644 --- a/ltt-sessiond/trace.h +++ b/ltt-sessiond/trace.h @@ -19,6 +19,8 @@ #ifndef _LTT_TRACE_H #define _LTT_TRACE_H +#include "session.h" + /* LTTng trace representation */ struct ltt_lttng_trace { struct cds_list_head list; @@ -40,4 +42,6 @@ struct ltt_ust_marker { char *channel; }; +struct ltt_ust_trace *find_session_ust_trace_by_pid(struct ltt_session *session, pid_t pid); + #endif /* _LTT_TRACE_H */