Fix: add missing uaccess.h include (for ARM)
[lttng-modules.git] / probes / lttng-events.h
index d269490ec2a8ab9fb0c466f004b270bfa21d9250..05e17b9bd8e3e9ba3f32037583b2727f63eee551 100644 (file)
@@ -2,11 +2,23 @@
  * 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"
@@ -592,6 +604,17 @@ __assign_##dest##_2:                                                       \
 #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)                     \
@@ -605,8 +628,12 @@ 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)))                          \
@@ -638,6 +665,8 @@ static void __event_probe__##_name(void *__data)                          \
        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)))                          \
This page took 0.024354 seconds and 4 git commands to generate.