[for-next][PATCH 11/25] tracing: Use enums instead of hard coded bitmasks for TRACE_ITER flags

From: Steven Rostedt
Date: Thu Oct 01 2015 - 07:59:24 EST


From: "Steven Rostedt (Red Hat)" <rostedt@xxxxxxxxxxx>

Using enums with FLAG_BIT and then defining a FLAG = (1 << FLAG_BIT), is a
bit more robust as we require that there are no bits out of order or skipped
to match the file names that represent the bits.

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace.h | 81 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 55 insertions(+), 26 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 19d5c411d4ec..31d8395c8dc5 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -886,33 +886,62 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
* NOTE: These bits must match the trace_options array in
* trace.c.
*/
+enum trace_iterator_bits {
+ TRACE_ITER_PRINT_PARENT_BIT = 0,
+ TRACE_ITER_SYM_OFFSET_BIT,
+ TRACE_ITER_SYM_ADDR_BIT,
+ TRACE_ITER_VERBOSE_BIT,
+ TRACE_ITER_RAW_BIT,
+ TRACE_ITER_HEX_BIT,
+ TRACE_ITER_BIN_BIT,
+ TRACE_ITER_BLOCK_BIT,
+ TRACE_ITER_STACKTRACE_BIT,
+ TRACE_ITER_PRINTK_BIT,
+ TRACE_ITER_BRANCH_BIT,
+ TRACE_ITER_ANNOTATE_BIT,
+ TRACE_ITER_USERSTACKTRACE_BIT,
+ TRACE_ITER_SYM_USEROBJ_BIT,
+ TRACE_ITER_PRINTK_MSGONLY_BIT,
+ TRACE_ITER_CONTEXT_INFO_BIT, /* Print pid/cpu/time */
+ TRACE_ITER_LATENCY_FMT_BIT,
+ TRACE_ITER_SLEEP_TIME_BIT,
+ TRACE_ITER_GRAPH_TIME_BIT,
+ TRACE_ITER_RECORD_CMD_BIT,
+ TRACE_ITER_OVERWRITE_BIT,
+ TRACE_ITER_STOP_ON_FREE_BIT,
+ TRACE_ITER_IRQ_INFO_BIT,
+ TRACE_ITER_MARKERS_BIT,
+ TRACE_ITER_FUNCTION_BIT,
+ TRACE_ITER_DISPLAY_GRAPH_BIT,
+};
+
enum trace_iterator_flags {
- TRACE_ITER_PRINT_PARENT = 0x01,
- TRACE_ITER_SYM_OFFSET = 0x02,
- TRACE_ITER_SYM_ADDR = 0x04,
- TRACE_ITER_VERBOSE = 0x08,
- TRACE_ITER_RAW = 0x10,
- TRACE_ITER_HEX = 0x20,
- TRACE_ITER_BIN = 0x40,
- TRACE_ITER_BLOCK = 0x80,
- TRACE_ITER_STACKTRACE = 0x100,
- TRACE_ITER_PRINTK = 0x200,
- TRACE_ITER_BRANCH = 0x400,
- TRACE_ITER_ANNOTATE = 0x800,
- TRACE_ITER_USERSTACKTRACE = 0x1000,
- TRACE_ITER_SYM_USEROBJ = 0x2000,
- TRACE_ITER_PRINTK_MSGONLY = 0x4000,
- TRACE_ITER_CONTEXT_INFO = 0x8000, /* Print pid/cpu/time */
- TRACE_ITER_LATENCY_FMT = 0x10000,
- TRACE_ITER_SLEEP_TIME = 0x20000,
- TRACE_ITER_GRAPH_TIME = 0x40000,
- TRACE_ITER_RECORD_CMD = 0x80000,
- TRACE_ITER_OVERWRITE = 0x100000,
- TRACE_ITER_STOP_ON_FREE = 0x200000,
- TRACE_ITER_IRQ_INFO = 0x400000,
- TRACE_ITER_MARKERS = 0x800000,
- TRACE_ITER_FUNCTION = 0x1000000,
- TRACE_ITER_DISPLAY_GRAPH = 0x2000000,
+ 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),
+ TRACE_ITER_RAW = (1 << TRACE_ITER_RAW_BIT),
+ TRACE_ITER_HEX = (1 << TRACE_ITER_HEX_BIT),
+ TRACE_ITER_BIN = (1 << TRACE_ITER_BIN_BIT),
+ TRACE_ITER_BLOCK = (1 << TRACE_ITER_BLOCK_BIT),
+ TRACE_ITER_STACKTRACE = (1 << TRACE_ITER_STACKTRACE_BIT),
+ TRACE_ITER_PRINTK = (1 << TRACE_ITER_PRINTK_BIT),
+ TRACE_ITER_BRANCH = (1 << TRACE_ITER_BRANCH_BIT),
+ TRACE_ITER_ANNOTATE = (1 << TRACE_ITER_ANNOTATE_BIT),
+ TRACE_ITER_USERSTACKTRACE = (1 << TRACE_ITER_USERSTACKTRACE_BIT),
+ TRACE_ITER_SYM_USEROBJ = (1 << TRACE_ITER_SYM_USEROBJ_BIT),
+ TRACE_ITER_PRINTK_MSGONLY = (1 << TRACE_ITER_PRINTK_MSGONLY_BIT),
+ TRACE_ITER_CONTEXT_INFO = (1 << TRACE_ITER_CONTEXT_INFO_BIT),
+ TRACE_ITER_LATENCY_FMT = (1 << TRACE_ITER_LATENCY_FMT_BIT),
+ TRACE_ITER_SLEEP_TIME = (1 << TRACE_ITER_SLEEP_TIME_BIT),
+ TRACE_ITER_GRAPH_TIME = (1 << TRACE_ITER_GRAPH_TIME_BIT),
+ TRACE_ITER_RECORD_CMD = (1 << TRACE_ITER_RECORD_CMD_BIT),
+ TRACE_ITER_OVERWRITE = (1 << TRACE_ITER_OVERWRITE_BIT),
+ TRACE_ITER_STOP_ON_FREE = (1 << TRACE_ITER_STOP_ON_FREE_BIT),
+ TRACE_ITER_IRQ_INFO = (1 << TRACE_ITER_IRQ_INFO_BIT),
+ TRACE_ITER_MARKERS = (1 << TRACE_ITER_MARKERS_BIT),
+ TRACE_ITER_FUNCTION = (1 << TRACE_ITER_FUNCTION_BIT),
+ TRACE_ITER_DISPLAY_GRAPH = (1 << TRACE_ITER_DISPLAY_GRAPH_BIT),
};

/*
--
2.5.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/