Extract input/output arguments from accept and connect syscalls
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 24 Jul 2014 16:47:46 +0000 (12:47 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 26 Sep 2014 16:09:59 +0000 (12:09 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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

index 46308af33794faf9f2465a81402b79dec2d4ad9e..efdfc37c991527473108eae9237cc9d1c52d4c61 100644 (file)
@@ -1,5 +1,131 @@
 #ifndef CREATE_SYSCALL_TABLE
 
+#define OVERRIDE_64_connect
+SC_LTTNG_TRACE_EVENT(connect,
+       TP_PROTO(sc_exit(long ret,) int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(sc_exit(ret,) fd, uservaddr, addrlen),
+       TP_locvar(
+               __typeof__(uservaddr->sa_family) sa_family;
+               uint16_t dport;
+               uint32_t v4addr;
+               uint16_t v6addr[8];
+               int v4addr_len, v6addr_len;
+       ),
+       TP_code(
+               sc_in(
+                       memset(tp_locvar, 0, sizeof(*tp_locvar));
+                       if (addrlen < sizeof(struct sockaddr))
+                               goto skip_code;
+                       (void) get_user(tp_locvar->sa_family, &uservaddr->sa_family);
+                       switch (tp_locvar->sa_family) {
+                       case AF_INET:
+                               if (addrlen < sizeof(struct sockaddr_in))
+                                       goto skip_code;
+                               (void) get_user(tp_locvar->dport, &((struct sockaddr_in *) uservaddr)->sin_port);
+                               (void) get_user(tp_locvar->v4addr, &((struct sockaddr_in *) uservaddr)->sin_addr.s_addr);
+                               tp_locvar->v4addr_len = 4;
+                               break;
+                       case AF_INET6:
+                               if (addrlen < sizeof(struct sockaddr_in6))
+                                       goto skip_code;
+                               (void) get_user(tp_locvar->dport, &((struct sockaddr_in6 *) uservaddr)->sin6_port);
+                               (void) copy_from_user(tp_locvar->v6addr,
+                                               &((struct sockaddr_in6 *) uservaddr)->sin6_addr.in6_u.u6_addr8,
+                                               sizeof(tp_locvar->v6addr));
+                               tp_locvar->v6addr_len = 8;
+                               break;
+                       }
+               skip_code:
+               )
+       ),
+       TP_STRUCT__entry(
+               sc_exit(__field(long, ret))
+               sc_in(__field(int, fd))
+               sc_in(__field_hex(struct sockaddr *, uservaddr))
+               sc_in(__field_hex(int, addrlen))
+               sc_in(__field(int, family))
+               sc_in(__field_network(uint16_t, dport))
+               sc_in(__dynamic_array_network(uint8_t, v4addr, tp_locvar->v4addr_len))
+               sc_in(__dynamic_array_network_hex(uint16_t, v6addr, tp_locvar->v6addr_len))
+       ),
+       TP_fast_assign(
+               sc_exit(tp_assign(ret, ret))
+               sc_in(tp_assign(fd, fd))
+               sc_in(tp_assign(uservaddr, uservaddr))
+               sc_in(tp_assign(addrlen, addrlen))
+               sc_in(tp_assign(family, tp_locvar->sa_family))
+               sc_in(tp_assign(dport, tp_locvar->dport))
+               sc_in(tp_memcpy_dyn(v4addr, &tp_locvar->v4addr))
+               sc_in(tp_memcpy_dyn(v6addr, &tp_locvar->v6addr))
+       ),
+       TP_printk()
+)
+
+#define OVERRIDE_64_accept
+SC_LTTNG_TRACE_EVENT(accept,
+       TP_PROTO(sc_exit(long ret,) int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(sc_exit(ret,) fd, upeer_sockaddr, upeer_addrlen),
+       TP_locvar(
+               __typeof__(upeer_sockaddr->sa_family) sa_family;
+               uint16_t sport;
+               uint32_t v4addr;
+               uint16_t v6addr[8];
+               int v4addr_len, v6addr_len;
+               int uaddr_len;
+       ),
+       TP_code(
+               sc_inout(
+                       memset(tp_locvar, 0, sizeof(*tp_locvar));
+                       (void) get_user(tp_locvar->uaddr_len, upeer_addrlen);
+               )
+               sc_out(
+                       if (tp_locvar->uaddr_len < sizeof(struct sockaddr))
+                               goto skip_code;
+                       (void) get_user(tp_locvar->sa_family, &upeer_sockaddr->sa_family);
+                       switch (tp_locvar->sa_family) {
+                       case AF_INET:
+                               if (tp_locvar->uaddr_len < sizeof(struct sockaddr_in))
+                                       goto skip_code;
+                               (void) get_user(tp_locvar->sport, &((struct sockaddr_in *) upeer_sockaddr)->sin_port);
+                               (void) get_user(tp_locvar->v4addr, &((struct sockaddr_in *) upeer_sockaddr)->sin_addr.s_addr);
+                               tp_locvar->v4addr_len = 4;
+                               break;
+                       case AF_INET6:
+                               if (tp_locvar->uaddr_len < sizeof(struct sockaddr_in6))
+                                       goto skip_code;
+                               (void) get_user(tp_locvar->sport, &((struct sockaddr_in6 *) upeer_sockaddr)->sin6_port);
+                               (void) copy_from_user(tp_locvar->v6addr,
+                                               &((struct sockaddr_in6 *) upeer_sockaddr)->sin6_addr.in6_u.u6_addr8,
+                                               sizeof(tp_locvar->v6addr));
+                               tp_locvar->v6addr_len = 8;
+                               break;
+                       }
+               skip_code:
+               )
+       ),
+       TP_STRUCT__entry(
+               sc_exit(__field(long, ret))
+               sc_in(__field(int, fd))
+               sc_in(__field_hex(struct sockaddr *, upeer_sockaddr))
+               sc_inout(__field(int, upeer_addrlen))
+               sc_out(__field(int, family))
+               sc_out(__field_network(uint16_t, sport))
+               sc_out(__dynamic_array_network(uint8_t, v4addr, tp_locvar->v4addr_len))
+               sc_out(__dynamic_array_network_hex(uint16_t, v6addr, tp_locvar->v6addr_len))
+       ),
+       TP_fast_assign(
+               sc_exit(tp_assign(ret, ret))
+               sc_in(tp_assign(fd, fd))
+               sc_in(tp_assign(upeer_sockaddr, upeer_sockaddr))
+               sc_inout(tp_assign(upeer_addrlen, tp_locvar->uaddr_len))
+               sc_out(tp_assign(family, tp_locvar->sa_family))
+               sc_out(tp_assign(sport, tp_locvar->sport))
+               sc_out(tp_memcpy_dyn(v4addr, &tp_locvar->v4addr))
+               sc_out(tp_memcpy_dyn(v6addr, &tp_locvar->v6addr))
+       ),
+       TP_printk()
+)
+
 #else  /* CREATE_SYSCALL_TABLE */
 
 #define OVERRIDE_TABLE_64_clone
index 7d86a72aaaae4dd5010eff8b9fe81bfdb8c62d54..1840caf57d6de50270e3bbac3e9d414c1b372410 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/compat.h>
 #include <linux/err.h>
 #include <linux/bitmap.h>
+#include <linux/in.h>
+#include <linux/in6.h>
 #include <asm/ptrace.h>
 #include <asm/syscall.h>
 
@@ -109,6 +111,10 @@ struct mmap_arg_struct;
 #define SC_TRACE_EVENT(_name, _proto, _args, _struct, _assign, _printk)        \
        TRACE_EVENT(syscall_enter_##_name, PARAMS(_proto), PARAMS(_args),\
                PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
+#define SC_LTTNG_TRACE_EVENT(_name, _proto, _args, _locvar, _code, _struct, _assign, _printk) \
+       LTTNG_TRACE_EVENT(syscall_enter_##_name, PARAMS(_proto), PARAMS(_args),\
+               PARAMS(_locvar), PARAMS(_code),\
+               PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
 #define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk)        \
        DECLARE_EVENT_CLASS_NOARGS(syscall_enter_##_name, PARAMS(_struct), PARAMS(_assign),\
                PARAMS(_printk))
@@ -125,6 +131,7 @@ struct mmap_arg_struct;
 #include "instrumentation/syscalls/headers/syscalls_pointers.h"
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACE_EVENT
 #undef SC_TRACE_EVENT
 #undef SC_DECLARE_EVENT_CLASS_NOARGS
 #undef SC_DEFINE_EVENT_NOARGS
@@ -139,6 +146,10 @@ struct mmap_arg_struct;
        TRACE_EVENT(compat_syscall_enter_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_struct), PARAMS(_assign),                       \
                PARAMS(_printk))
+#define SC_LTTNG_TRACE_EVENT(_name, _proto, _args, _locvar, _code, _struct, _assign, _printk) \
+       LTTNG_TRACE_EVENT(compat_syscall_enter_##_name, PARAMS(_proto), PARAMS(_args),\
+               PARAMS(_locvar), PARAMS(_code),\
+               PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
 #define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk) \
        DECLARE_EVENT_CLASS_NOARGS(compat_syscall_enter_##_name, PARAMS(_struct), \
                PARAMS(_assign), PARAMS(_printk))
@@ -155,6 +166,7 @@ struct mmap_arg_struct;
 #include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACE_EVENT
 #undef SC_TRACE_EVENT
 #undef SC_DECLARE_EVENT_CLASS_NOARGS
 #undef SC_DEFINE_EVENT_NOARGS
@@ -180,6 +192,10 @@ struct mmap_arg_struct;
 #define SC_TRACE_EVENT(_name, _proto, _args, _struct, _assign, _printk)        \
        TRACE_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args),\
                PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
+#define SC_LTTNG_TRACE_EVENT(_name, _proto, _args, _locvar, _code, _struct, _assign, _printk) \
+       LTTNG_TRACE_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args),\
+               PARAMS(_locvar), PARAMS(_code),\
+               PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
 #define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk) \
        DECLARE_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_struct), \
                PARAMS(_assign), PARAMS(_printk))
@@ -196,6 +212,7 @@ struct mmap_arg_struct;
 #include "instrumentation/syscalls/headers/syscalls_pointers.h"
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACE_EVENT
 #undef SC_TRACE_EVENT
 #undef SC_DECLARE_EVENT_CLASS_NOARGS
 #undef SC_DEFINE_EVENT_NOARGS
@@ -209,6 +226,10 @@ struct mmap_arg_struct;
 #define SC_TRACE_EVENT(_name, _proto, _args, _struct, _assign, _printk)        \
        TRACE_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
+#define SC_LTTNG_TRACE_EVENT(_name, _proto, _args, _locvar, _code, _struct, _assign, _printk) \
+       LTTNG_TRACE_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args),\
+               PARAMS(_locvar), PARAMS(_code),\
+               PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
 #define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk) \
        DECLARE_EVENT_CLASS_NOARGS(compat_syscall_exit_##_name, PARAMS(_struct), \
                PARAMS(_assign), PARAMS(_printk))
@@ -225,6 +246,7 @@ struct mmap_arg_struct;
 #include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACE_EVENT
 #undef SC_TRACE_EVENT
 #undef SC_DECLARE_EVENT_CLASS_NOARGS
 #undef SC_DEFINE_EVENT_NOARGS
index ed5233af06ba02cbaecd40643d946977d989fde6..6e7dae32c0c7c4c2f455fa27585797228fa172a2 100644 (file)
@@ -92,6 +92,9 @@
                PARAMS(assign),                                         \
                PARAMS(print))
 
+#undef LTTNG_TRACE_EVENT
+#define LTTNG_TRACE_EVENT(name, proto, args, _locvar, _code, tstruct, assign, print)
+
 #undef TRACE_EVENT_FN
 #define TRACE_EVENT_FN(name, proto, args, tstruct,             \
                assign, print, reg, unreg)
 #undef DEFINE_EVENT_CONDITION_MAP
 #undef TRACE_HEADER_MULTI_READ
 
+#undef LTTNG_TRACE_EVENT
+#define LTTNG_TRACE_EVENT(name, proto, args, _locvar, _code, tstruct, assign, print)
+
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE
 # undef TRACE_INCLUDE_FILE
index b601e8d8d971ba2165909c429e9eae63f92e00b8..be400fa16a0efa3778215c7a6fdbf84461900ccb 100644 (file)
 #undef TP_ARGS
 #define TP_ARGS(args...)
 
+#undef TP_locvar
+#define TP_locvar(...)
+
+#undef TP_code
+#define TP_code(...)
+
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...)
 
 #undef TP_printk
 #define TP_printk(args...)
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print)
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print)
 
 #undef DEFINE_EVENT_MAP
 #define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args)
index ba9563b15cf94ac093511f7de1eb90f5624f75b8..62ed63610df45820fb2f0f4aad269bf8840cecc0 100644 (file)
                             PARAMS(print))                             \
        DEFINE_EVENT_MAP_NOARGS(map, name, map)
 
+#undef LTTNG_TRACE_EVENT
+#define LTTNG_TRACE_EVENT(name, proto, args, _locvar, _code, tstruct, assign, print) \
+       LTTNG_DECLARE_EVENT_CLASS(name,                                 \
+                            PARAMS(proto),                             \
+                            PARAMS(args),                              \
+                            PARAMS(_locvar),                           \
+                            PARAMS(_code),                             \
+                            PARAMS(tstruct),                           \
+                            PARAMS(assign),                            \
+                            PARAMS(print))                             \
+       DEFINE_EVENT_MAP(name, name, name, PARAMS(proto), PARAMS(args))
+
 #undef DEFINE_EVENT_PRINT_MAP
 #define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print)        \
        DEFINE_EVENT_MAP(template, name, map, PARAMS(proto), PARAMS(args))
                PARAMS(assign),                                         \
                PARAMS(print))
 
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+       LTTNG_DECLARE_EVENT_CLASS(_name, PARAMS(_proto), PARAMS(_args), , , \
+               PARAMS(_tstruct), PARAMS(_assign), PARAMS(_print))
+
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)   \
+       LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, , , PARAMS(_tstruct),   \
+               PARAMS(_assign), PARAMS(_print))
+
+
 /*
  * Stage 1 of the trace events.
  *
@@ -256,6 +279,14 @@ void trace_##_name(void *__data);
 #define __dynamic_array_hex(_type, _item, _length)             \
        __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
 
+#undef __dynamic_array_network_hex
+#define __dynamic_array_network_hex(_type, _item, _length)             \
+       __dynamic_array_enc_ext(_type, _item, _length, __BIG_ENDIAN, 16, none)
+
+#undef __dynamic_array_network
+#define __dynamic_array_network(_type, _item, _length)         \
+       __dynamic_array_enc_ext(_type, _item, _length, __BIG_ENDIAN, 10, none)
+
 #undef __dynamic_array_text_2
 #define __dynamic_array_text_2(_type, _item, _length1, _length2)       \
        __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, __BYTE_ORDER, 10, UTF8)
@@ -278,15 +309,15 @@ void trace_##_name(void *__data);
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args /* Only one used in this phase */
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \
        static const struct lttng_event_field __event_fields___##_name[] = { \
                _tstruct                                                     \
        };
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
-       DECLARE_EVENT_CLASS_NOARGS(_name, PARAMS(_tstruct), PARAMS(_assign), \
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \
+       LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, PARAMS(_tstruct), PARAMS(_assign), \
                        PARAMS(_print))
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
@@ -302,12 +333,12 @@ void trace_##_name(void *__data);
 #undef TP_PROTO
 #define TP_PROTO(args...) args
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \
 static void __event_probe__##_name(void *__data, _proto);
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \
 static void __event_probe__##_name(void *__data);
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
@@ -413,7 +444,7 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
 
 #undef __dynamic_array_enc_ext
 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
-       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32));   \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32)); \
        __event_len += sizeof(u32);                                            \
        __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
        __dynamic_len[__dynamic_len_idx] = (_length);                          \
@@ -422,7 +453,7 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
 
 #undef __dynamic_array_enc_ext_2
 #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\
-       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32));   \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32)); \
        __event_len += sizeof(u32);                                            \
        __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
        __dynamic_len[__dynamic_len_idx] = (_length1);                         \
@@ -451,23 +482,30 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
-static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \
+#undef TP_locvar
+#define TP_locvar(...) __VA_ARGS__
+
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print)  \
+static inline size_t __event_get_size__##_name(size_t *__dynamic_len,        \
+               void *__tp_locvar, _proto)                                    \
 {                                                                            \
        size_t __event_len = 0;                                               \
        unsigned int __dynamic_len_idx __attribute__((unused)) = 0;           \
+       struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar;  \
                                                                              \
        _tstruct                                                              \
        return __event_len;                                                   \
 }
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
-static inline size_t __event_get_size__##_name(size_t *__dynamic_len)        \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print)  \
+static inline size_t __event_get_size__##_name(size_t *__dynamic_len,        \
+               void *__tp_locvar)                                            \
 {                                                                            \
        size_t __event_len = 0;                                               \
        unsigned int __dynamic_len_idx __attribute__((unused)) = 0;           \
+       struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar;  \
                                                                              \
        _tstruct                                                              \
        return __event_len;                                                   \
@@ -495,7 +533,7 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len)             \
 
 #undef __dynamic_array_enc_ext
 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
-       __event_align = max_t(size_t, __event_align, lttng_alignof(u32));         \
+       __event_align = max_t(size_t, __event_align, lttng_alignof(u32)); \
        __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
 
 #undef __dynamic_array_enc_ext_2
@@ -514,27 +552,33 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len)           \
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
-static inline size_t __event_get_align__##_name(_proto)                              \
+#undef TP_locvar
+#define TP_locvar(...) __VA_ARGS__
+
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print)  \
+static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
 {                                                                            \
        size_t __event_align = 1;                                             \
+       struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar;  \
+                                                                             \
        _tstruct                                                              \
        return __event_align;                                                 \
 }
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
-static inline size_t __event_get_align__##_name(void)                        \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print)  \
+static inline size_t __event_get_align__##_name(void *__tp_locvar)           \
 {                                                                            \
        size_t __event_align = 1;                                             \
+       struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar;  \
+                                                                             \
        _tstruct                                                              \
        return __event_align;                                                 \
 }
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-
 /*
  * Stage 8 of the trace events.
  *
@@ -571,15 +615,15 @@ static inline size_t __event_get_align__##_name(void)                           \
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print)  \
 struct __event_typemap__##_name {                                            \
        _tstruct                                                              \
 };
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
-       DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print)  \
+       LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print)
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
@@ -758,6 +802,12 @@ __assign_##dest:                                                   \
 #undef TP_fast_assign
 #define TP_fast_assign(args...) args
 
+#undef TP_locvar
+#define TP_locvar(...) __VA_ARGS__
+
+#undef TP_code
+#define TP_code(...)   __VA_ARGS__
+
 /*
  * For state dump, check that "session" argument (mandatory) matches the
  * session this event belongs to. Ensures that we write state dump data only
@@ -774,10 +824,11 @@ __assign_##dest:                                                  \
  * __dynamic_array_enc_ext_2() and tp_memcpy_dyn_2(), which are the
  * worse case, needing 2 entries per field.
  */
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+#undef LTTNG_DECLARE_EVENT_CLASS
+#define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \
 static void __event_probe__##_name(void *__data, _proto)                     \
 {                                                                            \
+       struct probe_local_vars { _locvar };                                  \
        struct lttng_event *__event = __data;                                 \
        struct lttng_channel *__chan = __event->chan;                         \
        struct lib_ring_buffer_ctx __ctx;                                     \
@@ -786,6 +837,9 @@ static void __event_probe__##_name(void *__data, _proto)                  \
        size_t __dynamic_len[2 * ARRAY_SIZE(__event_fields___##_name)] __attribute__((unused)); \
        struct __event_typemap__##_name __typemap __attribute__((unused));    \
        int __ret;                                                            \
+       struct probe_local_vars __tp_locvar;                                  \
+       struct probe_local_vars *tp_locvar __attribute__((unused)) =          \
+                       &__tp_locvar;                                         \
                                                                              \
        if (!_TP_SESSION_CHECK(session, __chan->session))                     \
                return;                                                       \
@@ -795,8 +849,10 @@ static void __event_probe__##_name(void *__data, _proto)                 \
                return;                                                       \
        if (unlikely(!ACCESS_ONCE(__event->enabled)))                         \
                return;                                                       \
-       __event_len = __event_get_size__##_name(__dynamic_len, _args);        \
-       __event_align = __event_get_align__##_name(_args);                    \
+       _code                                                                 \
+       __event_len = __event_get_size__##_name(__dynamic_len, tp_locvar,     \
+                               _args);                                       \
+       __event_align = __event_get_align__##_name(tp_locvar, _args);         \
        lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len,  \
                                 __event_align, -1);                          \
        __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
@@ -810,10 +866,11 @@ static void __event_probe__##_name(void *__data, _proto)                \
        _assign                                                               \
 }
 
-#undef DECLARE_EVENT_CLASS_NOARGS
-#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+#undef LTTNG_DECLARE_EVENT_CLASS_NOARGS
+#define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \
 static void __event_probe__##_name(void *__data)                             \
 {                                                                            \
+       struct probe_local_vars { _locvar };                                  \
        struct lttng_event *__event = __data;                                 \
        struct lttng_channel *__chan = __event->chan;                         \
        struct lib_ring_buffer_ctx __ctx;                                     \
@@ -822,6 +879,9 @@ static void __event_probe__##_name(void *__data)                          \
        size_t __dynamic_len[2 * ARRAY_SIZE(__event_fields___##_name)] __attribute__((unused)); \
        struct __event_typemap__##_name __typemap __attribute__((unused));    \
        int __ret;                                                            \
+       struct probe_local_vars __tp_locvar;                                  \
+       struct probe_local_vars *tp_locvar __attribute__((unused)) =          \
+                       &__tp_locvar;                                         \
                                                                              \
        if (!_TP_SESSION_CHECK(session, __chan->session))                     \
                return;                                                       \
@@ -831,8 +891,9 @@ static void __event_probe__##_name(void *__data)                          \
                return;                                                       \
        if (unlikely(!ACCESS_ONCE(__event->enabled)))                         \
                return;                                                       \
-       __event_len = __event_get_size__##_name(__dynamic_len);               \
-       __event_align = __event_get_align__##_name();                         \
+       _code                                                                 \
+       __event_len = __event_get_size__##_name(__dynamic_len, tp_locvar);    \
+       __event_align = __event_get_align__##_name(tp_locvar);                \
        lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len,  \
                                 __event_align, -1);                          \
        __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
This page took 0.045536 seconds and 4 git commands to generate.