Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values

Perf has a problem that if sizeof() macros are used within TRACE_EVENT()
macro's they end up in userspace as "sizeof(kernel structure)" which
cannot properly be parsed. Add a macro which can forward this data
through the eval_map for userspace utilization.

Link: http://lkml.kernel.org/r/20170531215653.3240-10-jeremy.linton@arm.com

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Jeremy Linton and committed by
Steven Rostedt (VMware)
4f0dfd76 67ec0d85

+17
+1
include/linux/tracepoint.h
··· 88 88 #define PARAMS(args...) args 89 89 90 90 #define TRACE_DEFINE_ENUM(x) 91 + #define TRACE_DEFINE_SIZEOF(x) 91 92 92 93 #endif /* _LINUX_TRACEPOINT_H */ 93 94
+16
include/trace/trace_events.h
··· 46 46 __attribute__((section("_ftrace_eval_map"))) \ 47 47 *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a 48 48 49 + #undef TRACE_DEFINE_SIZEOF 50 + #define TRACE_DEFINE_SIZEOF(a) \ 51 + static struct trace_eval_map __used __initdata \ 52 + __##TRACE_SYSTEM##_##a = \ 53 + { \ 54 + .system = TRACE_SYSTEM_STRING, \ 55 + .eval_string = "sizeof(" #a ")", \ 56 + .eval_value = sizeof(a) \ 57 + }; \ 58 + static struct trace_eval_map __used \ 59 + __attribute__((section("_ftrace_eval_map"))) \ 60 + *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a 61 + 49 62 /* 50 63 * DECLARE_EVENT_CLASS can be used to add a generic function 51 64 * handlers for events. That is, if all events have the same ··· 170 157 171 158 #undef TRACE_DEFINE_ENUM 172 159 #define TRACE_DEFINE_ENUM(a) 160 + 161 + #undef TRACE_DEFINE_SIZEOF 162 + #define TRACE_DEFINE_SIZEOF(a) 173 163 174 164 #undef __field 175 165 #define __field(type, item)