acrn-kernel/include/trace/stages
Steven Rostedt (Google) 5ded8299b7 tracing: Error if a trace event has an array for a __field()
[ Upstream commit f82e7ca019 ]

A __field() in the TRACE_EVENT() macro is used to set up the fields of the
trace event data. It is for single storage units (word, char, int,
pointer, etc) and not for complex structures or arrays. Unfortunately,
there's nothing preventing the build from accepting:

    __field(int, arr[5]);

from building. It will turn into a array value. This use to work fine, as
the offset and size use to be determined by the macro using the field name,
but things have changed and the offset and size are now determined by the
type. So the above would only be size 4, and the next field will be
located 4 bytes from it (instead of 20).

The proper way to declare static arrays is to use the __array() macro.

Instead of __field(int, arr[5]) it should be __array(int, arr, 5).

Add some macro tricks to the building of a trace event from the
TRACE_EVENT() macro such that __field(int, arr[5]) will fail to build. A
comment by the failure will explain why the build failed.

Link: https://lore.kernel.org/lkml/20230306122549.236561-1-douglas.raillard@arm.com/
Link: https://lore.kernel.org/linux-trace-kernel/20230309221302.642e82d9@gandalf.local.home

Reported-by: Douglas RAILLARD <douglas.raillard@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-11 23:02:58 +09:00
..
init.h
stage1_struct_define.h tracing/events: Add __vstring() and __assign_vstr() helper macros 2022-07-15 17:42:34 -04:00
stage2_data_offsets.h tracing/events: Add __vstring() and __assign_vstr() helper macros 2022-07-15 17:42:34 -04:00
stage3_trace_output.h
stage4_event_fields.h tracing: Fix TASK_COMM_LEN in trace event format file 2023-02-14 19:11:54 +01:00
stage5_get_offsets.h tracing: Error if a trace event has an array for a __field() 2023-05-11 23:02:58 +09:00
stage6_event_callback.h tracing: Use a copy of the va_list for __assign_vstr() 2022-07-30 13:56:09 -04:00
stage7_class_define.h