linux/kernel/trace
Steven Rostedt (Red Hat) a3418a364e tracing: Use TRACE_FLAGS macro to keep enums and strings matched
Use a cute little macro trick to keep the names of the trace flags file
guaranteed to match the corresponding masks.

The macro TRACE_FLAGS is defined as a serious of enum names followed by
the string name of the file that matches it. For example:

 #define TRACE_FLAGS						\
		C(PRINT_PARENT,		"print-parent"),	\
		C(SYM_OFFSET,		"sym-offset"),		\
		C(SYM_ADDR,		"sym-addr"),		\
		C(VERBOSE,		"verbose"),

Now we can define the following:

 #undef C
 #define C(a, b) TRACE_ITER_##a##_BIT
 enum trace_iterator_bits { TRACE_FLAGS };

The above creates:

 enum trace_iterator_bits {
	TRACE_ITER_PRINT_PARENT_BIT,
	TRACE_ITER_SYM_OFFSET_BIT,
	TRACE_ITER_SYM_ADDR_BIT,
	TRACE_ITER_VERBOSE_BIT,
 };

Then we can redefine C as:

 #undef C
 #define C(a, b) TRACE_ITER_##a = (1 << TRACE_ITER_##a##_BIT)
 enum trace_iterator_flags { TRACE_FLAGS };

Which creates:

 enum trace_iterator_flags {
	TRACE_ITER_PRINT_PARENT	= (1 << TRACE_ITER_PRINT_PARENT_BIT),
	TRACE_ITER_SYM_OFFSET	= (1 << TRACE_ITER_SYM_OFFSET_BIT),
	TRACE_ITER_SYM_ADDR	= (1 << TRACE_ITER_SYM_ADDR_BIT),
	TRACE_ITER_VERBOSE	= (1 << TRACE_ITER_VERBOSE_BIT),
 };

Then finally we can create the list of file names:

 #undef C
 #define C(a, b) b
 static const char *trace_options[] = {
	TRACE_FLAGS
	NULL
 };

Which creates:
 static const char *trace_options[] = {
	"print-parent",
	"sym-offset",
	"sym-addr",
	"verbose",
	NULL
 };

The importance of this is that the strings match the bit index.

	trace_options[TRACE_ITER_SYM_ADDR_BIT] == "sym-addr"

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2015-09-29 13:23:57 -04:00
..
blktrace.c tracing: Pass trace_array into trace_buffer_unlock_commit() 2015-09-25 17:38:44 -04:00
bpf_trace.c bpf: add support for %s specifier to bpf_trace_printk() 2015-08-28 16:27:27 -07:00
ftrace.c Mostly this is just clean ups and micro optimizations. 2015-09-08 14:04:14 -07:00
Kconfig tracing, perf: Implement BPF programs attached to uprobes 2015-08-06 15:29:14 -03:00
Makefile bpf: Fix the build on BPF_SYSCALL=y && !CONFIG_TRACING kernels, make it more configurable 2015-04-02 16:28:06 +02:00
power-traces.c PM / sleep: export suspend_resume trace event 2015-01-30 02:10:41 +01:00
ring_buffer_benchmark.c This patch series contains several clean ups and even a new trace clock 2015-06-26 14:02:43 -07:00
ring_buffer.c ring-buffer: Revert "ring-buffer: Get timestamp after event is allocated" 2015-09-03 08:57:12 -04:00
rpm-traces.c PM / Runtime: Introduce trace points for tracing rpm_* functions 2011-09-27 22:53:27 +02:00
trace_benchmark.c tracing: Only calculate stats of tracepoint benchmarks for 2^32 times 2014-06-06 00:41:38 -04:00
trace_benchmark.h tracing: Add tracepoint benchmark tracepoint 2014-05-29 22:49:54 -04:00
trace_branch.c tracing: Have branch tracer use recursive field of task struct 2015-07-08 11:53:45 -04:00
trace_clock.c tracing: Export tracing clock functions 2015-05-12 15:56:57 -04:00
trace_entries.h tracing: %pF is only for function pointers 2015-03-25 08:57:22 -04:00
trace_event_perf.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_events_filter_test.h tracing/filter: Add startup tests for events filter 2011-08-19 14:35:59 -04:00
trace_events_filter.c tracing: Allow triggers to filter for CPU ids and process names 2015-08-11 18:01:06 -04:00
trace_events_trigger.c tracing: Rename ftrace_raw_##call event structures to trace_event_raw_##call 2015-05-13 21:48:40 -04:00
trace_events.c tracing: Pass trace_array into trace_buffer_unlock_commit() 2015-09-25 17:38:44 -04:00
trace_export.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_functions_graph.c ftrace: Fix function_graph duration spacing with 7-digits 2015-07-20 22:30:52 -04:00
trace_functions.c tracing/trivial: Fix typos and make an int into a bool 2014-11-20 10:05:36 -05:00
trace_irqsoff.c tracing: Move "display-graph" option to main options 2015-09-29 12:56:40 -04:00
trace_kdb.c KGDB/KDB fixes and cleanups 2015-01-09 20:51:10 -08:00
trace_kprobe.c lib: introduce strncpy_from_unsafe() 2015-08-28 16:27:27 -07:00
trace_mmiotrace.c tracing: Pass trace_array into trace_buffer_unlock_commit() 2015-09-25 17:38:44 -04:00
trace_nop.c tracing: Remove unneeded includes of debugfs.h and fs.h 2015-01-22 11:19:48 -05:00
trace_output.c tracing: Turn seq_print_user_ip() into a static function 2015-09-28 10:16:12 -04:00
trace_output.h tracing: Turn seq_print_user_ip() into a static function 2015-09-28 10:16:12 -04:00
trace_printk.c tracing: Use IS_ERR() check for return value of tracing_init_dentry() 2015-01-22 11:19:49 -05:00
trace_probe.c trace: Don't use __weak in header files 2015-03-25 08:57:23 -04:00
trace_probe.h kernel/trace_probe: is_good_name can be boolean 2015-09-22 13:11:30 -04:00
trace_sched_switch.c sched: Introduce the 'trace_sched_waking' tracepoint 2015-08-03 12:21:22 +02:00
trace_sched_wakeup.c tracing: Move "display-graph" option to main options 2015-09-29 12:56:40 -04:00
trace_selftest_dynamic.c ftrace: Add self-tests for multiple function trace users 2011-05-18 19:24:51 -04:00
trace_selftest.c Seems that Peter Zijlstra added a new check that is making old 2014-10-12 07:28:55 -04:00
trace_seq.c tracing: use %*pb[l] to print bitmaps including cpumasks and nodemasks 2015-02-13 21:21:37 -08:00
trace_stack.c tracing: Clean up stack tracing and fix fentry updates 2015-07-20 22:30:50 -04:00
trace_stat.c tracing: Convert the tracing facility over to use tracefs 2015-02-03 12:48:41 -05:00
trace_stat.h
trace_syscalls.c tracing: Rename ftrace_trigger_soft_disabled() to trace_trigger_soft_disabled() 2015-05-13 15:25:39 -04:00
trace_uprobe.c tracing/uprobes: Do not print '0x (null)' when offset is 0 2015-08-26 10:43:01 -03:00
trace.c tracing: Use TRACE_FLAGS macro to keep enums and strings matched 2015-09-29 13:23:57 -04:00
trace.h tracing: Use TRACE_FLAGS macro to keep enums and strings matched 2015-09-29 13:23:57 -04:00