* lttng-events.h
*
* Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
- * Dual LGPL v2.1/GPL v2 license.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include <linux/uaccess.h>
#include <linux/debugfs.h>
#include "lttng.h"
#include "lttng-types.h"
#undef TP_fast_assign
#define TP_fast_assign(args...) args
+/*
+ * For state dump, check that "session" argument (mandatory) matches the
+ * session this event belongs to. Ensures that we write state dump data only
+ * into the started session, not into all sessions.
+ */
+#ifdef TP_SESSION_CHECK
+#define _TP_SESSION_CHECK(session, csession) (session == csession)
+#else /* TP_SESSION_CHECK */
+#define _TP_SESSION_CHECK(session, csession) 1
+#endif /* TP_SESSION_CHECK */
+
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
static void __event_probe__##_name(void *__data, _proto) \
struct __event_typemap__##_name __typemap; \
int __ret; \
\
- if (0) \
+ if (0) { \
(void) __dynamic_len_idx; /* don't warn if unused */ \
+ (void) __typemap; /* don't warn if unused */ \
+ } \
+ if (!_TP_SESSION_CHECK(session, __chan->session)) \
+ return; \
if (unlikely(!ACCESS_ONCE(__chan->session->active))) \
return; \
if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
size_t __event_len, __event_align; \
int __ret; \
\
+ if (!_TP_SESSION_CHECK(session, __chan->session)) \
+ return; \
if (unlikely(!ACCESS_ONCE(__chan->session->active))) \
return; \
if (unlikely(!ACCESS_ONCE(__chan->enabled))) \