Tracepoint event: add "TP_code_post()"
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Oct 2015 14:02:37 +0000 (10:02 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 21 Oct 2015 19:40:34 +0000 (15:40 -0400)
Useful for probes that need to perform teardown after serialization,
e.g. allocate temporary memory in TP_code_pre() and free it in
TP_code_post(). Be careful to only use memory allocation from contexts
allowing it.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/arch/x86/kvm/trace.h
instrumentation/events/lttng-module/block.h
instrumentation/events/lttng-module/compaction.h
instrumentation/events/lttng-module/sched.h
instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h
lttng-syscalls.c
probes/define_trace.h
probes/lttng-events-reset.h
probes/lttng-events.h
probes/lttng-tracepoint-event.h

index 32c4743e7efae7a58ee60055b5cda3770bda2796..c36626715884b0a9b492862980e1c8c4fa4c6a3b 100644 (file)
@@ -122,7 +122,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(kvm_exit,
                u64 info1, info2;
        ),
 
-       TP_code(
+       TP_code_pre(
                kvm_x86_ops->get_exit_info(vcpu, &tp_locvar->info1,
                                &tp_locvar->info2);
        ),
@@ -133,7 +133,9 @@ LTTNG_TRACEPOINT_EVENT_CODE(kvm_exit,
                ctf_integer(u32, isa, isa)
                ctf_integer(u64, info1, tp_locvar->info1)
                ctf_integer(u64, info2, tp_locvar->info2)
-       )
+       ),
+
+       TP_code_post()
 )
 
 /*
index 3505df08223e5a1f8742e44d7c2b91f84a2e38bd..1a2ba6b47d8adafcef714fc92634d9648e702f27 100644 (file)
@@ -135,7 +135,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
                size_t cmd_len;
        ),
 
-       TP_code(
+       TP_code_pre(
                if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
                        tp_locvar->sector = 0;
                        tp_locvar->nr_sector = 0;
@@ -159,7 +159,9 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
                        rq->cmd_flags, blk_rq_bytes(rq))
                ctf_sequence_hex(unsigned char, cmd,
                        tp_locvar->cmd, size_t, tp_locvar->cmd_len)
-       )
+       ),
+
+       TP_code_post()
 )
 
 /**
@@ -227,7 +229,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete,
                size_t cmd_len;
        ),
 
-       TP_code(
+       TP_code_pre(
                if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
                        tp_locvar->cmd = rq->cmd;
                        tp_locvar->cmd_len = rq->cmd_len;
@@ -247,7 +249,9 @@ LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete,
                        rq->cmd_flags, nr_bytes)
                ctf_sequence_hex(unsigned char, cmd,
                        tp_locvar->cmd, size_t, tp_locvar->cmd_len)
-       )
+       ),
+
+       TP_code_post()
 )
 
 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
@@ -286,7 +290,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq,
                size_t cmd_len;
        ),
 
-       TP_code(
+       TP_code_pre(
                if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
                        tp_locvar->sector = 0;
                        tp_locvar->nr_sector = 0;
@@ -314,7 +318,9 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq,
                ctf_sequence_hex(unsigned char, cmd,
                        tp_locvar->cmd, size_t, tp_locvar->cmd_len)
                ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
-       )
+       ),
+
+       TP_code_post()
 )
 
 /**
index 2c2584672831eff20367531995ada6528667d989..771da7dbcb3b2825601a5e89d7bebe4aea283240 100644 (file)
@@ -114,7 +114,7 @@ LTTNG_TRACEPOINT_EVENT_CODE_MAP(mm_compaction_migratepages,
                unsigned long nr_failed;
        ),
 
-       TP_code(
+       TP_code_pre(
                tp_locvar->nr_failed = 0;
 
                {
@@ -131,7 +131,9 @@ LTTNG_TRACEPOINT_EVENT_CODE_MAP(mm_compaction_migratepages,
        TP_FIELDS(
                ctf_integer(unsigned long, nr_migrated, nr_all - tp_locvar->nr_failed)
                ctf_integer(unsigned long, nr_failed, tp_locvar->nr_failed)
-       )
+       ),
+
+       TP_code_post()
 )
 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
 LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages,
index 2efff161949556a294e72085ed2e5e7ed0ca6a60..dc30398826546c87cf3b4000d921bd6cdd42014f 100644 (file)
@@ -349,7 +349,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
                unsigned int ns_level;
        ),
 
-       TP_code(
+       TP_code_pre(
                if (child) {
                        struct pid *child_pid;
                        unsigned int i;
@@ -403,7 +403,9 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
                                child_ns_inum;
                        }))
 #endif
-       )
+       ),
+
+       TP_code_post()
 )
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
index 702cfb5d710b835896f86ffc5482d998896e69b8..837991a6a1667c127715c6affb14c5f1dc569f67 100644 (file)
@@ -11,7 +11,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(connect,
                uint16_t v6addr[8];
                unsigned int v4addr_len, v6addr_len;
        ),
-       TP_code(
+       TP_code_pre(
                sc_in(
                        memset(tp_locvar, 0, sizeof(*tp_locvar));
                        if (addrlen < sizeof(struct sockaddr))
@@ -48,7 +48,8 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(connect,
                sc_in(ctf_integer_network(uint16_t, dport, tp_locvar->dport))
                sc_in(ctf_sequence_network(uint8_t, v4addr, &tp_locvar->v4addr, unsigned int, tp_locvar->v4addr_len))
                sc_in(ctf_sequence_network(uint16_t, v6addr, &tp_locvar->v6addr, unsigned int, tp_locvar->v6addr_len))
-       )
+       ),
+       TP_code_post()
 )
 
 #define OVERRIDE_64_accept
@@ -63,7 +64,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(accept,
                int v4addr_len, v6addr_len;
                int uaddr_len;
        ),
-       TP_code(
+       TP_code_pre(
                sc_inout(
                        memset(tp_locvar, 0, sizeof(*tp_locvar));
                        (void) get_user(tp_locvar->uaddr_len, upeer_addrlen);
@@ -103,7 +104,8 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(accept,
                sc_out(ctf_integer_network(uint16_t, sport, tp_locvar->sport))
                sc_in(ctf_sequence_network(uint8_t, v4addr, &tp_locvar->v4addr, unsigned int, tp_locvar->v4addr_len))
                sc_in(ctf_sequence_network(uint16_t, v6addr, &tp_locvar->v6addr, unsigned int, tp_locvar->v6addr_len))
-       )
+       ),
+       TP_code_post()
 )
 
 #define OVERRIDE_64_pipe
index 5fa66660b5f2532d715e80d90fb7c8feb6ec08ca..806485f0753712a544f068ddfb5033b68fc9c8bb 100644 (file)
@@ -118,10 +118,10 @@ struct file_handle;
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CODE(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code),                                 \
-               PARAMS(_fields))
+               PARAMS(_locvar), PARAMS(_code_pre),                             \
+               PARAMS(_fields), PARAMS(_code_post))
 #define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
        LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_entry_##_name, PARAMS(_fields))
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
@@ -150,9 +150,9 @@ struct file_handle;
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code), PARAMS(_fields))
+               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
 #define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
        LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_entry_##_name, PARAMS(_fields))
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
@@ -194,9 +194,9 @@ struct file_handle;
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CODE(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code), PARAMS(_fields))
+               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
 #define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
        LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_fields))
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
@@ -226,9 +226,9 @@ struct file_handle;
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
-               PARAMS(_locvar), PARAMS(_code), PARAMS(_fields))
+               PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
 #define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
        LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_exit_##_name, PARAMS(_fields))
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
index 4b67f5f8392c535f9571435f4069b147cf5b00d4..98bd9f8ba21c445f1e0b6b533ca5cdbf3b463026 100644 (file)
 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields)
 
 #undef LTTNG_TRACEPOINT_EVENT_CODE
-#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code, fields)
+#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post)
 
 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
-#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code, fields)
+#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post)
 
 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args)
index 1bc77820c20e73b11ebde2a379879c47be1af024..8262d83eb238572e3b30f593c87cac933f676b4c 100644 (file)
 /* Reset macros used within LTTNG_TRACEPOINT_EVENT to "nothing" */
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields)
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post)
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields)
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post)
 
 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args)
 #undef TP_locvar
 #define TP_locvar(...)
 
-#undef TP_code
-#define TP_code(...)
+#undef TP_code_pre
+#define TP_code_pre(...)
+
+#undef TP_code_post
+#define TP_code_post(...)
 
 #undef TP_FIELDS
 #define TP_FIELDS(args...)
index 35d6f790a7df7dbdb6188f87acd01d84a3408166..0e3b713b46498f1e3272f4647f5bfb324040b7c1 100644 (file)
        LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
 
 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
-#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code, fields) \
+#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map,                          \
                             PARAMS(proto),                             \
                             PARAMS(args),                              \
                             PARAMS(_locvar),                           \
-                            PARAMS(_code),                             \
-                            PARAMS(fields))                            \
+                            PARAMS(_code_pre),                         \
+                            PARAMS(fields),                            \
+                            PARAMS(_code_post))                        \
        LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
 
 #undef LTTNG_TRACEPOINT_EVENT_CODE
-#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code, fields) \
+#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
        LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name,                     \
                             PARAMS(proto),                             \
                             PARAMS(args),                              \
                             PARAMS(_locvar),                           \
-                            PARAMS(_code),                             \
-                            PARAMS(fields))
+                            PARAMS(_code_pre),                         \
+                            PARAMS(fields),                            \
+                            PARAMS(_code_post))
 
 /*
  * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
 #undef LTTNG_TRACEPOINT_EVENT_CLASS
 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
-               PARAMS(_fields))
+               PARAMS(_fields))
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields))
+       LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields))
 
 
 /*
@@ -165,11 +167,11 @@ void __event_template_proto___##_template(_proto);
 void __event_template_proto___##_template(void);
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 void __event_template_proto___##_name(_proto);
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 void __event_template_proto___##_name(void);
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
@@ -302,14 +304,14 @@ void __event_template_proto___##_name(void);
 #define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
        static const struct lttng_event_field __event_fields___##_name[] = { \
                _fields                                                      \
        };
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
-       LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, PARAMS(_fields))
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+       LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
@@ -326,11 +328,11 @@ void __event_template_proto___##_name(void);
 #define TP_PROTO(...)  __VA_ARGS__
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 static void __event_probe__##_name(void *__data, _proto);
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 static void __event_probe__##_name(void *__data);
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
@@ -399,7 +401,7 @@ static void __event_probe__##_name(void *__data);
 #define TP_locvar(...) __VA_ARGS__
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 static inline size_t __event_get_size__##_name(size_t *__dynamic_len,        \
                void *__tp_locvar, _proto)                                    \
 {                                                                            \
@@ -412,7 +414,7 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len,             \
 }
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 static inline size_t __event_get_size__##_name(size_t *__dynamic_len,        \
                void *__tp_locvar)                                            \
 {                                                                            \
@@ -575,7 +577,7 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len,             \
 #define TP_locvar(...) __VA_ARGS__
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 static inline                                                                \
 void __event_prepare_filter_stack__##_name(char *__stack_data,               \
                void *__tp_locvar)                                            \
@@ -586,7 +588,7 @@ void __event_prepare_filter_stack__##_name(char *__stack_data,                    \
 }
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 static inline                                                                \
 void __event_prepare_filter_stack__##_name(char *__stack_data,               \
                void *__tp_locvar, _proto)                                    \
@@ -646,7 +648,7 @@ void __event_prepare_filter_stack__##_name(char *__stack_data,                    \
 #define TP_locvar(...) __VA_ARGS__
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto)    \
 {                                                                            \
        size_t __event_align = 1;                                             \
@@ -657,7 +659,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto)    \
 }
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 static inline size_t __event_get_align__##_name(void *__tp_locvar)           \
 {                                                                            \
        size_t __event_align = 1;                                             \
@@ -871,8 +873,11 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)       \
 #undef TP_locvar
 #define TP_locvar(...) __VA_ARGS__
 
-#undef TP_code
-#define TP_code(...)   __VA_ARGS__
+#undef TP_code_pre
+#define TP_code_pre(...)       __VA_ARGS__
+
+#undef TP_code_post
+#define TP_code_post(...)      __VA_ARGS__
 
 /*
  * For state dump, check that "session" argument (mandatory) matches the
@@ -893,7 +898,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)        \
  * Perform UNION (||) of filter runtime list.
  */
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
 static void __event_probe__##_name(void *__data, _proto)                     \
 {                                                                            \
        struct probe_local_vars { _locvar };                                  \
@@ -924,7 +929,7 @@ static void __event_probe__##_name(void *__data, _proto)                  \
        __lpf = lttng_rcu_dereference(__session->pid_tracker);                \
        if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid)))  \
                return;                                                       \
-       _code                                                                 \
+       _code_pre                                                             \
        if (unlikely(!list_empty(&__event->bytecode_runtime_head))) {         \
                struct lttng_bytecode_runtime *bc_runtime;                    \
                int __filter_record = __event->has_enablers_without_bytecode; \
@@ -937,7 +942,7 @@ static void __event_probe__##_name(void *__data, _proto)                  \
                                __filter_record = 1;                          \
                }                                                             \
                if (likely(!__filter_record))                                 \
-                       return;                                               \
+                       goto __post;                                          \
        }                                                                     \
        __event_len = __event_get_size__##_name(__stackvar.__dynamic_len,     \
                                tp_locvar, _args);                            \
@@ -946,13 +951,16 @@ static void __event_probe__##_name(void *__data, _proto)                \
                                 __event_align, -1);                          \
        __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
        if (__ret < 0)                                                        \
-               return;                                                       \
+               goto __post;                                                  \
        _fields                                                               \
        __chan->ops->event_commit(&__ctx);                                    \
+__post:                                                                              \
+       _code_post                                                            \
+       return;                                                               \
 }
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields) \
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
 static void __event_probe__##_name(void *__data)                             \
 {                                                                            \
        struct probe_local_vars { _locvar };                                  \
@@ -983,7 +991,7 @@ static void __event_probe__##_name(void *__data)                          \
        __lpf = lttng_rcu_dereference(__session->pid_tracker);                \
        if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid)))  \
                return;                                                       \
-       _code                                                                 \
+       _code_pre                                                             \
        if (unlikely(!list_empty(&__event->bytecode_runtime_head))) {         \
                struct lttng_bytecode_runtime *bc_runtime;                    \
                int __filter_record = __event->has_enablers_without_bytecode; \
@@ -996,7 +1004,7 @@ static void __event_probe__##_name(void *__data)                         \
                                __filter_record = 1;                          \
                }                                                             \
                if (likely(!__filter_record))                                 \
-                       return;                                               \
+                       goto __post;                                          \
        }                                                                     \
        __event_len = __event_get_size__##_name(__stackvar.__dynamic_len, tp_locvar); \
        __event_align = __event_get_align__##_name(tp_locvar);                \
@@ -1004,9 +1012,12 @@ static void __event_probe__##_name(void *__data)                       \
                                 __event_align, -1);                          \
        __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
        if (__ret < 0)                                                        \
-               return;                                                       \
+               goto __post;                                                  \
        _fields                                                               \
        __chan->ops->event_commit(&__ctx);                                    \
+__post:                                                                              \
+       _code_post                                                            \
+       return;                                                               \
 }
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
index 39c0f3714aecc621be2c2d30670e2a52df403ade..fc3417cd7fc8d12254688aefb2f6ce86db6f1288 100644 (file)
@@ -37,9 +37,9 @@
 
 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
-#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code, fields) \
+#define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
-#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code, fields) \
+#define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
@@ -47,8 +47,8 @@
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE_NOARGS(name))
 
 #define LTTNG_TRACEPOINT_EVENT_CLASS(name, proto, args, fields)
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code, _fields)
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code, _fields)
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post)
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post)
 
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
        _LTTNG_INSTRUMENTATION(DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)))
This page took 0.037936 seconds and 4 git commands to generate.