From: Mathieu Desnoyers Date: Thu, 24 Jul 2014 16:47:46 +0000 (-0400) Subject: Extract input/output arguments from accept and connect syscalls X-Git-Tag: v2.6.0-rc1~42 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7ca580f8aca4f8c2b9e0066ad52ebfc226b3d645;p=lttng-modules.git Extract input/output arguments from accept and connect syscalls Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h index 46308af3..efdfc37c 100644 --- a/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h +++ b/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h @@ -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 diff --git a/lttng-syscalls.c b/lttng-syscalls.c index 7d86a72a..1840caf5 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -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 diff --git a/probes/define_trace.h b/probes/define_trace.h index ed5233af..6e7dae32 100644 --- a/probes/define_trace.h +++ b/probes/define_trace.h @@ -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) @@ -154,6 +157,9 @@ #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 diff --git a/probes/lttng-events-reset.h b/probes/lttng-events-reset.h index b601e8d8..be400fa1 100644 --- a/probes/lttng-events-reset.h +++ b/probes/lttng-events-reset.h @@ -65,6 +65,12 @@ #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...) @@ -83,11 +89,11 @@ #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) diff --git a/probes/lttng-events.h b/probes/lttng-events.h index ba9563b1..62ed6361 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -54,6 +54,18 @@ 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)) @@ -130,6 +142,17 @@ 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); \