lkml.org 
[lkml]   [2021]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [GIT PULL] tracing: Add __string_len() and __assign_str_len() helpers
On Wed, 14 Jul 2021 17:56:33 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> static inline notrace int trace_event_get_offsets_foo(
> struct trace_event_data_offsets_foo *__data_offsets, const char *foobar, int len)
> {
> int __data_size = 0;
> int __maybe_unused __item_length;
> struct trace_event_raw_foo __maybe_unused *entry;
>
> // The "(len)+1" will be used to calculate the __item_length below
>
> __item_length = (len + 1) * sizeof(char);
>
> // the dynamic fields (strings and such) are located after the static
> // fields in the trace event, and the offset is recorded in the bottom
> // 16 bits of a 32 bit word, and the size in the top 16 bits.
>
> __data_offsets->item = __data_size +
> offsetof(typeof(*entry), __data);
> __data_offsets->item |= __item_length << 16;

I missed a manual substitution of the macro. This should have been:

__data_offsets->str = __data_size +
offsetof(typeof(*entry), __data);
__data_offsets->str |= __item_length << 16;

As the macro creates the trace_event_data_offsets_foo structure (which
__data_offsets is declared as), which contains a field for every
__string/__string_len/__dynamic_array() in TP_STRUCT__entry.

The -">str" comes from the "str" in "__string_len(str, foobar, len)".

-- Steve


> __data_size += __item_length;
>
>
> // Each "__string_len()" or "__string()" in the TP_STRUCT__entry is inserted
> // into this macro created function. Thus, the above code is duplicated for
> // each field that uses __string(), __string_len() or __dynamic_array().
>
>
> return __data_size;
> }

\
 
 \ /
  Last update: 2021-07-15 00:04    [W:0.068 / U:0.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site