Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Steven Rostedt (Google) <rostedt@goodmis.org>

+5 -2
+5 -2
samples/trace_events/trace-events-sample.h
··· 303 303 __bitmask( cpus, num_possible_cpus() ) 304 304 __cpumask( cpum ) 305 305 __vstring( vstr, fmt, va ) 306 + __string_len( lstr, foo, bar / 2 < strlen(foo) ? bar / 2 : strlen(foo) ) 306 307 ), 307 308 308 309 TP_fast_assign( ··· 312 311 memcpy(__get_dynamic_array(list), lst, 313 312 __length_of(lst) * sizeof(int)); 314 313 __assign_str(str, string); 314 + __assign_str(lstr, foo); 315 315 __assign_vstr(vstr, fmt, va); 316 316 __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); 317 317 __assign_cpumask(cpum, cpumask_bits(mask)); 318 318 ), 319 319 320 - TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, 320 + TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, 321 321 322 322 /* 323 323 * Notice here the use of some helper functions. This includes: ··· 362 360 __print_array(__get_dynamic_array(list), 363 361 __get_dynamic_array_len(list) / sizeof(int), 364 362 sizeof(int)), 365 - __get_str(str), __get_bitmask(cpus), __get_cpumask(cpum), 363 + __get_str(str), __get_str(lstr), 364 + __get_bitmask(cpus), __get_cpumask(cpum), 366 365 __get_str(vstr)) 367 366 ); 368 367