tracing: Add __string_len() example

There's no example code that uses __string_len(), and since the sample
code is used for testing the event logic, add a use case.

Link: https://lore.kernel.org/linux-trace-kernel/20240223152827.5f9f78e2@gandalf.local.home

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent c759e609
...@@ -303,6 +303,7 @@ TRACE_EVENT(foo_bar, ...@@ -303,6 +303,7 @@ TRACE_EVENT(foo_bar,
__bitmask( cpus, num_possible_cpus() ) __bitmask( cpus, num_possible_cpus() )
__cpumask( cpum ) __cpumask( cpum )
__vstring( vstr, fmt, va ) __vstring( vstr, fmt, va )
__string_len( lstr, foo, bar / 2 < strlen(foo) ? bar / 2 : strlen(foo) )
), ),
TP_fast_assign( TP_fast_assign(
...@@ -311,12 +312,13 @@ TRACE_EVENT(foo_bar, ...@@ -311,12 +312,13 @@ TRACE_EVENT(foo_bar,
memcpy(__get_dynamic_array(list), lst, memcpy(__get_dynamic_array(list), lst,
__length_of(lst) * sizeof(int)); __length_of(lst) * sizeof(int));
__assign_str(str, string); __assign_str(str, string);
__assign_str(lstr, foo);
__assign_vstr(vstr, fmt, va); __assign_vstr(vstr, fmt, va);
__assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus());
__assign_cpumask(cpum, cpumask_bits(mask)); __assign_cpumask(cpum, cpumask_bits(mask));
), ),
TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar,
/* /*
* Notice here the use of some helper functions. This includes: * Notice here the use of some helper functions. This includes:
...@@ -360,7 +362,8 @@ TRACE_EVENT(foo_bar, ...@@ -360,7 +362,8 @@ TRACE_EVENT(foo_bar,
__print_array(__get_dynamic_array(list), __print_array(__get_dynamic_array(list),
__get_dynamic_array_len(list) / sizeof(int), __get_dynamic_array_len(list) / sizeof(int),
sizeof(int)), sizeof(int)),
__get_str(str), __get_bitmask(cpus), __get_cpumask(cpum), __get_str(str), __get_str(lstr),
__get_bitmask(cpus), __get_cpumask(cpum),
__get_str(vstr)) __get_str(vstr))
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment