xref: /openbmc/linux/include/trace/events/printk.h (revision 78aebca2c955c1c5aeb48e12645e13fe3c3461f2)
195100358SJohannes Berg #undef TRACE_SYSTEM
295100358SJohannes Berg #define TRACE_SYSTEM printk
395100358SJohannes Berg 
495100358SJohannes Berg #if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
595100358SJohannes Berg #define _TRACE_PRINTK_H
695100358SJohannes Berg 
795100358SJohannes Berg #include <linux/tracepoint.h>
895100358SJohannes Berg 
907c65f4dSzhangwei(Jovi) TRACE_EVENT(console,
1007c65f4dSzhangwei(Jovi) 	TP_PROTO(const char *text, size_t len),
1195100358SJohannes Berg 
1207c65f4dSzhangwei(Jovi) 	TP_ARGS(text, len),
1395100358SJohannes Berg 
1495100358SJohannes Berg 	TP_STRUCT__entry(
1507c65f4dSzhangwei(Jovi) 		__dynamic_array(char, msg, len + 1)
1695100358SJohannes Berg 	),
1795100358SJohannes Berg 
1895100358SJohannes Berg 	TP_fast_assign(
19*78aebca2SDaniel Bristot de Oliveira 		/*
20*78aebca2SDaniel Bristot de Oliveira 		 * Each trace entry is printed in a new line.
21*78aebca2SDaniel Bristot de Oliveira 		 * If the msg finishes with '\n', cut it off
22*78aebca2SDaniel Bristot de Oliveira 		 * to avoid blank lines in the trace.
23*78aebca2SDaniel Bristot de Oliveira 		 */
24*78aebca2SDaniel Bristot de Oliveira 		if ((len > 0) && (text[len-1] == '\n'))
25*78aebca2SDaniel Bristot de Oliveira 			len -= 1;
26*78aebca2SDaniel Bristot de Oliveira 
27752d596bSDaniel Bristot de Oliveira 		memcpy(__get_str(msg), text, len);
28752d596bSDaniel Bristot de Oliveira 		__get_str(msg)[len] = 0;
2995100358SJohannes Berg 	),
3095100358SJohannes Berg 
3195100358SJohannes Berg 	TP_printk("%s", __get_str(msg))
3295100358SJohannes Berg );
3395100358SJohannes Berg #endif /* _TRACE_PRINTK_H */
3495100358SJohannes Berg 
3595100358SJohannes Berg /* This part must be outside protection */
3695100358SJohannes Berg #include <trace/define_trace.h>
37