Use -EIO as tsc value for nmi error (and drop event)
[lttng-modules.git] / probes / lttng-events.h
index ee7e5d9694fdd6790c152f5ab54f3d9ea95582a2..a739bbc8e20dce85b35fdaa3476ab0f591bc220e 100644 (file)
@@ -1,21 +1,11 @@
-#include <lttng.h>
-#include <lttng-types.h>
 #include <linux/debugfs.h>
-#include <linux/ringbuffer/frontend_types.h>
+#include "lttng.h"
+#include "lttng-types.h"
+#include "../wrapper/vmalloc.h"        /* for wrapper_vmalloc_sync_all() */
+#include "../wrapper/ringbuffer/frontend_types.h"
 #include "../ltt-events.h"
 #include "../ltt-tracer-core.h"
 
-struct lttng_event_field {
-       const char *name;
-       const struct lttng_type type;
-};
-
-struct lttng_event_desc {
-       const struct lttng_event_field *fields;
-       const char *name;
-       unsigned int nr_fields;
-};
-
 /*
  * Macro declarations used for all stages.
  */
@@ -51,6 +41,28 @@ struct lttng_event_desc {
        TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
                PARAMS(tstruct), PARAMS(assign), PARAMS(print))         \
 
+/*
+ * Stage 0.1 of the trace events.
+ *
+ * Create dummy trace calls for each events, verifying that the LTTng module
+ * TRACE_EVENT headers match the kernel arguments. Will be optimized out by the
+ * compiler.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef TP_ARGS
+#define TP_ARGS(args...) args
+
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(_template, _name, _proto, _args)                  \
+void trace_##_name(_proto);
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
 /*
  * Stage 1 of the trace events.
  *
@@ -115,6 +127,23 @@ struct lttng_event_desc {
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
+/*
+ * Stage 1.1 of the trace events.
+ *
+ * Create probe callback prototypes.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+static void __event_probe__##_name(void *__data, _proto);
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
 /*
  * Stage 2 of the trace events.
  *
@@ -130,6 +159,7 @@ struct lttng_event_desc {
                {                                                              \
                        .fields = __event_fields___##_template,                \
                        .name = #_name,                                        \
+                       .probe_callback = (void *) &__event_probe__##_template,\
                        .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
                },
 
@@ -143,6 +173,25 @@ static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #undef TP_ID1
 #undef TP_ID
 
+
+/*
+ * Stage 2.1 of the trace events.
+ *
+ * Create a toplevel descriptor for the whole probe.
+ */
+
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+
+/* non-const because list head will be modified when registered. */
+static struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
+       .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
+       .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
+};
+
+#undef TP_ID1
+#undef TP_ID
+
 /*
  * Stage 3 of the trace events.
  *
@@ -514,6 +563,8 @@ static void __event_probe__##_name(void *__data, _proto)                  \
                                                                              \
        if (0)                                                                \
                (void) __dynamic_len_idx;       /* don't warn if unused */    \
+       if (!ACCESS_ONCE(__chan->session->active))                            \
+               return;                                                       \
        __event_len = __event_get_size__##_name(__dynamic_len, _args);        \
        __event_align = __event_get_align__##_name(_args);                    \
        lib_ring_buffer_ctx_init(&ctx, __chan->chan, NULL, __event_len,       \
@@ -531,7 +582,6 @@ static void __event_probe__##_name(void *__data, _proto)                  \
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-
 /*
  * Stage 8 of the trace events.
  *
@@ -547,32 +597,23 @@ static void __event_probe__##_name(void *__data, _proto)                \
 #define module_exit_eval1(_token, _system)     module_exit(_token##_system)
 #define module_exit_eval(_token, _system)      module_exit_eval1(_token, _system)
 
-#undef DEFINE_EVENT
-#define DEFINE_EVENT(_template, _name, _proto, _args)                         \
-       ret = ltt_probe_register(#_name, (void *) __event_probe__##_template); \
-       WARN_ON_ONCE(ret);
-
 static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
 {
-       int ret = 0;
+       int ret;
 
+       wrapper_vmalloc_sync_all();
        ret = TP_ID(__lttng_types_init__, TRACE_SYSTEM)();
        if (ret)
                return ret;
-#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
-       return ret;
+       return ltt_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
 }
 
 module_init_eval(__lttng_events_init__, TRACE_SYSTEM);
 
-#undef DEFINE_EVENT
-#define DEFINE_EVENT(_template, _name, _proto, _args)                         \
-       ltt_probe_unregister(#_name);
-
 static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void)
 {
-#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
        TP_ID(__lttng_types_exit__, TRACE_SYSTEM)();
+       ltt_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM));
 }
 
 module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM);
This page took 0.026033 seconds and 4 git commands to generate.