xref: /openbmc/linux/include/trace/events/printk.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
295100358SJohannes Berg #undef TRACE_SYSTEM
395100358SJohannes Berg #define TRACE_SYSTEM printk
495100358SJohannes Berg 
595100358SJohannes Berg #if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
695100358SJohannes Berg #define _TRACE_PRINTK_H
795100358SJohannes Berg 
895100358SJohannes Berg #include <linux/tracepoint.h>
995100358SJohannes Berg 
1007c65f4dSzhangwei(Jovi) TRACE_EVENT(console,
1107c65f4dSzhangwei(Jovi) 	TP_PROTO(const char *text, size_t len),
1295100358SJohannes Berg 
1307c65f4dSzhangwei(Jovi) 	TP_ARGS(text, len),
1495100358SJohannes Berg 
1595100358SJohannes Berg 	TP_STRUCT__entry(
1607c65f4dSzhangwei(Jovi) 		__dynamic_array(char, msg, len + 1)
1795100358SJohannes Berg 	),
1895100358SJohannes Berg 
1995100358SJohannes Berg 	TP_fast_assign(
2078aebca2SDaniel Bristot de Oliveira 		/*
2178aebca2SDaniel Bristot de Oliveira 		 * Each trace entry is printed in a new line.
2278aebca2SDaniel Bristot de Oliveira 		 * If the msg finishes with '\n', cut it off
2378aebca2SDaniel Bristot de Oliveira 		 * to avoid blank lines in the trace.
2478aebca2SDaniel Bristot de Oliveira 		 */
2578aebca2SDaniel Bristot de Oliveira 		if ((len > 0) && (text[len-1] == '\n'))
2678aebca2SDaniel Bristot de Oliveira 			len -= 1;
2778aebca2SDaniel Bristot de Oliveira 
28752d596bSDaniel Bristot de Oliveira 		memcpy(__get_str(msg), text, len);
29752d596bSDaniel Bristot de Oliveira 		__get_str(msg)[len] = 0;
3095100358SJohannes Berg 	),
3195100358SJohannes Berg 
3295100358SJohannes Berg 	TP_printk("%s", __get_str(msg))
3395100358SJohannes Berg );
3495100358SJohannes Berg #endif /* _TRACE_PRINTK_H */
3595100358SJohannes Berg 
3695100358SJohannes Berg /* This part must be outside protection */
3795100358SJohannes Berg #include <trace/define_trace.h>
38