X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=instrumentation%2Fevents%2Flttng-module%2Fprintk.h;h=b01ac59b22dcaf8a32b9a65020041f8ec6b2b0cd;hb=b78104db53f97c10add30016e365855a26f6e01e;hp=4c744f998f7115fd02813d887918bb558c96f242;hpb=b87700e318c27267890cbd6fb5e50b687279131b;p=lttng-modules.git diff --git a/instrumentation/events/lttng-module/printk.h b/instrumentation/events/lttng-module/printk.h index 4c744f99..b01ac59b 100644 --- a/instrumentation/events/lttng-module/printk.h +++ b/instrumentation/events/lttng-module/printk.h @@ -1,64 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #undef TRACE_SYSTEM #define TRACE_SYSTEM printk -#if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_PRINTK_H +#if !defined(LTTNG_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ) +#define LTTNG_TRACE_PRINTK_H -#include -#include +#include +#include -#define MSG_TRACE_MAX_LEN 2048 +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,10,0)) + +LTTNG_TRACEPOINT_EVENT_MAP(console, + + printk_console, + + TP_PROTO(const char *text, size_t len), + + TP_ARGS(text, len), + + TP_FIELDS( + ctf_sequence_text(char, msg, text, size_t, len) + ) +) + +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,5,0)) + +LTTNG_TRACEPOINT_EVENT_MAP(console, + + printk_console, -TRACE_EVENT_CONDITION(console, TP_PROTO(const char *log_buf, unsigned start, unsigned end, unsigned log_buf_len), TP_ARGS(log_buf, start, end, log_buf_len), - TP_CONDITION(start != end), - - TP_STRUCT__entry( - __dynamic_array_text(char, msg, - min_t(unsigned, end - start, MSG_TRACE_MAX_LEN) + 1) - ), - - TP_fast_assign( - tp_memcpy_dyn(msg, - ({ - char lmsg[MSG_TRACE_MAX_LEN + 1]; - - if ((end - start) > MSG_TRACE_MAX_LEN) - start = end - MSG_TRACE_MAX_LEN; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) - if ((start & (log_buf_len - 1)) > - (end & (log_buf_len - 1))) { - memcpy(lmsg, - log_buf + - (start & (log_buf_len - 1)), - log_buf_len - - (start & (log_buf_len - 1))); - memcpy(lmsg + log_buf_len - - (start & (log_buf_len - 1)), - log_buf, - end & (log_buf_len - 1)); - } else - memcpy(lmsg, - log_buf + - (start & (log_buf_len - 1)), - end - start); -#else - memcpy(lmsg, log_buf + start, end - start); -#endif - lmsg[end - start] = 0; - lmsg; - }) - ) - ), + TP_FIELDS( + ctf_sequence_text(char, msg, log_buf + start, + size_t, end - start) + ) +) - TP_printk("%s", __get_str(msg)) +#else /* (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,5,0)) */ + +LTTNG_TRACEPOINT_EVENT_MAP(console, + + printk_console, + + TP_PROTO(const char *log_buf, unsigned start, unsigned end, + unsigned log_buf_len), + + TP_ARGS(log_buf, start, end, log_buf_len), + + TP_FIELDS( + /* + * printk buffer is gathered from two segments on older kernels. + */ + ctf_sequence_text(char, msg1, + log_buf + (start & (log_buf_len - 1)), + size_t, (start & (log_buf_len - 1)) > (end & (log_buf_len - 1)) + ? log_buf_len - (start & (log_buf_len - 1)) + : end - start) + ctf_sequence_text(char, msg2, + log_buf, + size_t, (start & (log_buf_len - 1)) > (end & (log_buf_len - 1)) + ? end & (log_buf_len - 1) + : 0) + ) ) -#endif /* _TRACE_PRINTK_H */ + +#endif + +#endif /* LTTNG_TRACE_PRINTK_H */ /* This part must be outside protection */ -#include "../../../probes/define_trace.h" +#include